1(function (window) { 2 var tgbEmbed = window.tgbEmbed; 3 if (!tgbEmbed) { 4 tgbEmbed = { 5 domain: window.tagboardDomain || "https://embed.tagboard.com", 6 modalFrm: null, 7 frames: [], 8 9 con: { 10 log: function (s) { console.log(s); }, 11 warn: function (s) { console.warn ? console.warn(s) : console.log(s); }, 12 error: function (s) { console.error ? console.error(s) : console.log(s); } 13 }, 14 15 insertIFrame: function _insertIFrame(div, embedId, preview, nostats) { 16 var ifrm = document.createElement("IFRAME"), 17 frameID = tgbEmbed.frames.length + 1, 18 frameURL = tgbEmbed.domain + "/" + embedId; 19 20 if (preview) { 21 frameURL += '/preview'; 22 } 23 24 if (nostats) { 25 var prefix = '?'; 26 frameURL += prefix + 'nostats=true'; 27 } 28 29 frameURL += "#id=" + frameID; 30 31 ifrm.setAttribute("src", frameURL); 32 ifrm.setAttribute("onload", "tgbEmbed.frameLoaded(" + frameID + ")"); 33 ifrm.setAttribute("class", "tagboard-iframe"); 34 ifrm.setAttribute("tgb-frame-id", frameID); 35 ifrm.name = "tagboard"; 36 ifrm.setAttribute("style", "border:0; width:100%; height:100%"); 37 ifrm.setAttribute("title", "Tagboard Embed"); 38 ifrm.setAttribute("scrolling", "no"); 39 40 div.appendChild(ifrm); 41 return ifrm; 42 }, 43 44 frameLoaded: function _frameLoaded(frame_id) { 45 if (tgbEmbed.modalFrm) { 46 tgbEmbed.modalFrm.contentWindow.postMessage('tgbPingFrames', tgbEmbed.domain); 47 } 48 49 tgbEmbed.execForFrames(function (ifrm) { 50 ifrm.contentWindow.postMessage('location:' + JSON.stringify(window.location), tgbEmbed.domain); 51 ifrm.contentWindow.postMessage('height?', tgbEmbed.domain); 52 }, frame_id); 53 }, 54 55 execForFrames: function _execForFrame(func, frame_id) { 56 tgbEmbed.frames.some(function (ifrm) { 57 var match = ifrm.getAttribute('tgb-frame-id') == frame_id; 58 if (!frame_id || match) { 59 func(ifrm); 60 return frame_id ? true : false; 61 } 62 return false; 63 }); 64 }, 65 66 createModalIframe: function _createModalIframe() { 67 if (document.getElementsByName('tagboard-modal').length) { return; } 68 69 var ifrm = document.createElement("iframe"), 70 style = document.createElement('style'), 71 css = '.tgb-noscroll { overflow: hidden; }'; 72 73 ifrm.setAttribute("src", tgbEmbed.domain + "/embed-modal"); 74 ifrm.setAttribute("class", "tagboard-modal"); 75 ifrm.name = "tagboard-modal"; 76 ifrm.setAttribute("style", "border:0!important; position:fixed!important; top:0!important; left:0!important; width:100%!important; height:100%!important; z-index:999999!important; display:none; visibility:hidden;"); 77 ifrm.setAttribute("scrolling", "no"); 78 ifrm.setAttribute("title", "Tagboard Post Details"); 79 80 style.type = 'text/css'; 81 style.appendChild(document.createTextNode(css)); 82 83 document.getElementsByTagName('head')[0].appendChild(style); 84 document.getElementsByTagName("body")[0].appendChild(ifrm); 85 tgbEmbed.modalFrm = ifrm; 86 }, 87 88 setFrameHeight: function _setFrameHeight(height, frame_id) { 89 tgbEmbed.execForFrames(function (ifrm) { 90 var prev = parseInt(ifrm.style.height, 10), 91 newHeight = height; 92 93 ifrm.style.height = newHeight + "px"; 94 }, frame_id); 95 }, 96 97 handleFrameMessage: function _handleFrameMessage(e) { 98 var body, iframe; 99 100 if (e.origin == tgbEmbed.domain) { 101 var dataObj = {}; 102 e.data.split('&').forEach(function (e) { 103 var d = e.split(':'); 104 dataObj[d[0]] = d.length > 1 ? d[1] : d[0]; 105 }); 106 107 if (dataObj.height) { 108 tgbEmbed.setFrameHeight(parseInt(dataObj.height), dataObj.frame_id); 109 } 110 111 if (e.data === "needsModalFrame" && !tgbEmbed.modalFrm) { 112 tgbEmbed.createModalIframe(); 113 } 114 115 if (e.data === "tgbShowModalIframe") { 116 body = document.getElementsByTagName("body")[0], 117 iframe = document.getElementsByClassName('tagboard-modal')[0]; 118 119 iframe.style.display = 'block'; 120 iframe.style.visibility = 'visible'; 121 body.classList.add('tgb-noscroll'); 122 } 123 124 if (e.data === "tgbHideModalIframe") { 125 body = document.getElementsByTagName("body")[0], 126 iframe = document.getElementsByClassName('tagboard-modal')[0]; 127 128 iframe.style.display = 'none'; 129 iframe.style.visibility = 'hidden'; 130 body.classList.remove('tgb-noscroll'); 131 } 132 133 if (e.data.indexOf('tgbRemoveIframe') === 0) { 134 var id = e.data.substr(e.data.indexOf(':') + 1), 135 element = document.querySelector("iframe[tgb-frame-id='" + id + "']"); 136 element.parentNode.removeChild(element); 137 } 138 } 139 }, 140 141 initializeFrames: function _initializeFrames() { 142 var elems = document.getElementsByClassName('tagboard-embed'); 143 for (var i = 0; i < elems.length; ++i) { 144 var div = elems[i], 145 eid = div.getAttribute('tgb-embed-id'), 146 noStats = div.getAttribute('tgb-no-stats') == 'true', 147 previewMode = div.getAttribute('tgb-preview-mode') == 'true'; 148 149 if ((div.nodeName === 'DIV') && eid && !div.getAttribute('tgb-built-iframe')) { 150 tgbEmbed.frames.push(tgbEmbed.insertIFrame(div, eid, previewMode, noStats)); 151 div.setAttribute('tgb-built-iframe', "1"); 152 } 153 } 154 } 155 }; 156 157 window.tgbEmbed = tgbEmbed; 158 159 window.addEventListener('message', tgbEmbed.handleFrameMessage, false); 160 } 161 162 window.tgbEmbed.initializeFrames(); 163 164})(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.