PageSourceSearch

https://gospring.ai/assets/js/embed.js

js gospring.ai collected 2026-10-03 19:25:58 UTC 24,048 bytes, 567 lines download raw bytes

1// let crQuizUrl = null;
2// let width = 450;
3// let height = 650;
4// let useAmp = false;
5// let type = 'st';
6// let delay = 0;
7// let crMode = 'q';
8
9function standardEmbed(propObj) {
10    var iFrame = document.createElement('iFrame');
11    iFrame.classList.add('curiosity');
12    iFrame.style.minWidth = '300px';
13    iFrame.style.width = '100%';
14    iFrame.style.maxWidth = propObj.width ? (propObj.width + "px"):'450px';
15    iFrame.style.height = getHeight(null, propObj) + 'px';
16    iFrame.style.border = '1px solid lightgray';
17    iFrame.style.background = '#ffffff';
18    iFrame.style.borderRadius = '4px';
19    iFrame.style.marginTop =  '10px';
20    iFrame.style.marginBottom = '10px';
21    iFrame.src = propObj.crQuizUrl;
22    return iFrame;
23}
24
25
26function standardAmpEmbed(propObj){
27    var url = propObj.crQuizUrl;
28    let nodeamp = document.createElement('amp-iframe');
29    nodeamp.setAttribute('layout', 'responsive');
30    nodeamp.setAttribute("sandbox", "allow-scripts allow-same-origin allow-top-navigation");
31    nodeamp.setAttribute("frameborder", "0");
32    nodeamp.setAttribute('src', url);
33    nodeamp.setAttribute("width", propObj.width + "px");
34    nodeamp.setAttribute("height", propObj.height + "px");
35    nodeamp.style.background = '#fff';
36    nodeamp.style.border = '1px solid lightgray';
37    let ampImg = document.createElement('amp-img');
38    ampImg.setAttribute('layout', 'fill');
39    ampImg.setAttribute('placeholder', 'fill');
40    nodeamp.appendChild(ampImg);
41    return nodeamp;
42}
43
44
45function ampCode() {
46    var node1, node2, node3, node4;
47    node1 = document.createElement("script");
48    node1.src = "https://cdn.ampproject.org/v0.js";
49    node1.type = "text/javascript";
50    node1.async = true;
51    document.getElementsByTagName("head")[0].appendChild(node1);
52    node2 = document.createElement("script");
53    node2.setAttribute("custom-element", "amp-iframe");
54    node2.src = "https://cdn.ampproject.org/v0/amp-iframe-0.1.js";
55    node2.type = "text/javascript";
56    node2.async = true;
57    document.getElementsByTagName("head")[0].appendChild(node2);
58    node3 = document.createElement("script");
59    node3.setAttribute("custom-element", "amp-ibind");
60    node3.src = "https://cdn.ampproject.org/v0/amp-bind-0.1.js";
61    node3.type = "text/javascript";
62    node3.async = true;
63    document.getElementsByTagName("head")[0].appendChild(node3);
64    node4 = document.createElement("meta");
65    node4.name = "viewport";
66    node4.content = "width=device-width,minimum-scale=1,initial-scale=1";
67    document.getElementsByTagName("head")[0].appendChild(node4);
68}
69
70
71function fullPageEmbed(propObj) {
72    var url = propObj.crQuizUrl;
73    var overlay, popup, iframe, close;
74    function onMediaChange(x) {
75        popup.style.cssText =
76            "position: absolute;top: 0;left: 0;font-size: 50px;color: black;transform: translate(0%,0%);-ms-transform: translate(0%,0%);background:white;min-width:100vw;min-height:100vh;";
77        iframe.style.cssText = "min-width:100vw;min-height:100vh;border:none;";
78        close.style.cssText =
79            "width:35px;height:35px;background-color:lightgray;border:none;position:fixed;top:5px;right:10px";
80    }
81    function onClose() {
82        document.body.removeChild(overlay);
83    }
84    function dots42(n) {
85        overlay = document.createElement("div");
86        overlay.style.cssText =
87            "position: fixed;display: block;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(0,0,0,0.5);z-index: 2;";
88        popup = document.createElement("div");
89        iframe = document.createElement("iframe");
90        iframe.src = url;
91        close = document.createElement("button");
92        close.addEventListener("click", onClose);
93        var icon = document.createElement("mat-icon");
94        icon.innerHTML = "x";
95        close.appendChild(icon);
96        popup.appendChild(iframe);
97        // popup.appendChild(close);
98        overlay.appendChild(popup);
99        document.body.appendChild(overlay);
100    }
101    dots42();
102    var mediaChange = window.matchMedia("(max-width:" + propObj.width + ")");
103    onMediaChange(mediaChange);
104    mediaChange.addListener(onMediaChange);
105}
106
107function fullPageAmpEmbed(propObj) {
108    var url = propObj.crQuizUrl;
109    var width = '499px';
110    var overlay, popup, nodeamp, close;
111    function onMediaChange(x) {
112        popup.style.cssText = 'position: absolute;top: 0;left: 0;font-size: 50px;color: black;transform: translate(0%,0%);-ms-transform: translate(0%,0%);background:white;min-width:100vw;min-height:100vh;';
113        nodeamp.style.cssText = 'min-width:100vw;min-height:100vh;border:none;';
114        close.style.cssText = 'width:35px;height:35px;background-color:lightgray;border:none;position:fixed;top:5px;right:10px';
115    } function onClose() {
116        document.body.removeChild(overlay);
117    }
118    function dots42(n) {
119        overlay = document.createElement('div');
120        overlay.style.cssText = 'position: fixed;display: block;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(0,0,0,0.5);z-index: 2;';
121        let ampDiv = document.createElement('div');
122        ampDiv.style.minHeight = '600px';
123        ampDiv.style.width = "40%";
124        popup = document.createElement('div');
125        nodeamp = document.createElement('amp-iframe');
126        nodeamp.setAttribute('layout', 'responsive');
127        nodeamp.setAttribute("sandbox", "allow-scripts allow-same-origin allow-top-navigation");
128        nodeamp.setAttribute("frameborder", "0");
129        nodeamp.setAttribute('src', url);
130        nodeamp.setAttribute("width", '100%');
131        nodeamp.setAttribute("height", "100%");
132        let ampImg = document.createElement('amp-img');
133        ampImg.setAttribute('layout', 'fill');
134        ampImg.setAttribute('placeholder', 'fill');
135        close = document.createElement('button');
136        close.addEventListener('click', onClose);
137        var icon = document.createElement('mat-icon');
138        icon.innerHTML = 'x';
139        close.appendChild(icon);
140        nodeamp.appendChild(ampImg);
141        popup.appendChild(nodeamp);
142        popup.appendChild(close);
143        ampDiv.appendChild(popup);
144        overlay.appendChild(ampDiv);
145        document.body.appendChild(overlay);
146    }
147    dots42();
148    var mediaChange = window.matchMedia('(max-width:' + width + ')');
149    onMediaChange(mediaChange);
150    mediaChange.addListener(onMediaChange);
151}
152
153function sideTabEmbed(propObj) {
154    var url = propObj.crQuizUrl;
155    var overlay, iframe, close, flag = false, overlayBack, iframeContainer;
156    var resizewidth, resizeheight;
157    if(propObj.crMode == 'p')
158        propObj.height = 570
159    
160    function openNav() {
161        flag = true;
162        // iframe.style.display = 'block';
163        document.getElementById('cr-embed-nav').style.display = 'block';
164        overlayBack = document.createElement('div');
165        overlayBack.setAttribute('id', 'cr-overlay-back');
166        overlayBack.style.cssText = 'background-color: rgba(0,0,0,.2); position: fixed; height: 150%; width: 100%; top: 0; left: 0; z-index: 500;';
167        document.body.appendChild(overlayBack);
168        iframeContainer.appendChild(iframe)
169    }
170    function closeNav() {
171        flag = false;
172        document.getElementById('cr-embed-nav').style.display = 'none';
173        let backoverlay = document.getElementById('cr-overlay-back');
174        if (backoverlay) {
175            backoverlay.remove();
176        }
177        let iframe = document.getElementById('cr-side-embed-iframe');
178        if (iframe) {
179            iframe.remove();
180        }
181    }
182    function toggleNav() {
183        if (!flag) openNav(); else closeNav();
184    }
185    function dots42(n) {
186        let available = true;
187        while(available) {
188            let element = document.getElementById('cr-embed-nav')
189            if (element) {
190                element.remove()
191            } else {
192                available = false;
193            }
194        }
195        let availablebtn = true;
196        while(availablebtn) {
197            let element = document.getElementById('cr-embed-button')
198            if (element) {
199                element.remove()
200            } else {
201                availablebtn = false;
202            }
203        }
204        var screenSize = document.documentElement.clientWidth;
205        overlay = document.createElement('div');
206        overlay.setAttribute('id', 'cr-embed-nav');
207        slideBtn = document.createElement('button');
208        slideBtn.setAttribute('id', 'cr-embed-button');
209        slideBtn.innerHTML = "Quiz";
210        slideBtn.style.cssText = 'z-index: 100; display: block; width: 100px; height: 28px; position: fixed; right: 3px; bottom: 40vh; margin-right: -39px; padding-top: 2px; color: #000; background-color: #fcd813; border: 1px solid #fcd813; transform: translateZ(0) rotate(-90deg); font-family: MetricWeb,sans-serif; font-size: 16px; line-height: 20px; font-weight: 600; cursor: pointer;';
211        slideBtn.addEventListener('click', toggleNav);
212        close = document.createElement('button');
213        var icon = document.createElement('mat-icon');
214        icon.innerHTML = 'x';
215        close.style.cssText = 'width:30px;height:30px;position:absolute;top:0;right:0;background-color:white;color:black;border:none;padding-right: 12px;cursor:pointer;';
216        close.addEventListener('click', closeNav);
217        close.appendChild(icon);
218        iframeContainer = document.createElement('div')
219        iframeContainer.setAttribute('id', 'cr-embed-iframe-container');
220        iframe = document.createElement('iframe');
221        iframe.setAttribute('id', 'cr-side-embed-iframe');
222        iframe.style.cssText = 'position: relative; border: none; display:block; max-width:90vw; max-height:90vh';
223        iframe.src = url;
224        iframe.height = propObj.height + 'px';
225        iframe.width = propObj.width + 'px';
226        iframe.style.background = '#fff';
227        // iframeContainer.appendChild(iframe);
228        overlay.appendChild(iframeContainer);
229        overlay.appendChild(close);
230        document.body.appendChild(overlay);
231        document.body.appendChild(slideBtn);
232    }
233    dots42();
234    overlay.style.cssText = 'display:none; position: fixed; right: 42px; bottom: 10vh; width: auto; height: auto; max-height: calc(100vh - 15vh); left: inherit !important; margin-left: inherit !important; margin-top: inherit !important; top: inherit !important; box-shadow: 0 1px 4px rgb(77 72 69 / 15%), 0 8px 14px rgb(77 72 69 / 20%); box-sizing: border-box; opacity: 1; transition: opacity .3s ease-in-out; z-index:2000';
235}
236
237function sideTabAmpEmbed(propObj) {
238    var url = propObj.crQuizUrl;
239    var ampDiv, overlay, nodeamp, close, flag = false;
240    var resizewidth;
241    function onClose() {
242        document.getElementById("cr-embed-nav").remove();
243    }
244    function openNav() {
245        flag = true;
246        document.getElementById("cr-embed-nav").style.width = "auto";
247        overlay.appendChild(nodeamp);
248        // nodeamp.style.display = "block";
249    }
250    function closeNav() {
251        flag = false;
252        // nodeamp.style.display = "none";
253        overlay.removeChild(nodeamp);
254    }
255    function toggleNav() {
256        if (!flag) openNav();
257        else closeNav();
258    }
259    function dots42(n) {
260        var screenSize = document.documentElement.clientWidth;
261        ampDiv = document.createElement('div');
262        ampDiv.style.minHeight = '600px';
263        ampDiv.style.width = "40%";
264        // ampDiv.style.cssText = "position: absolute; top: 218px;right: 0;min-height:600px;width: 40%;float: right;margin-right:-8px;overflow-x: hidden;overflow-y: hidden;";
265        overlay = document.createElement("div");
266        overlay.setAttribute("id", "cr-embed-nav");
267        overlay.style.cssText = " position: absolute;display: inline-flex;top: 218px;right: 0;min-height:100px;max-width: 100%;float: right;margin-right:-8px;overflow-x: hidden;overflow-y: hidden;";
268        slideBtn = document.createElement("button");
269        slideBtn.style.cssText = "position:relative; top:29px;width: 30px;border: 2px solid black; height: 50px;margin-right:-30px;background-color: black;border-bottom-left-radius: 10px;";
270        slideBtn.addEventListener("click", toggleNav);
271        close = document.createElement("button");
272        var icon = document.createElement("mat-icon");
273        icon.innerHTML = "x";
274        close.style.cssText = "width:30px;height:30px;position:relative;background-color:black;color:white;border-top-left-radius: 10px;border:none;padding-right: 12px;";
275        close.addEventListener("click", onClose);
276        close.appendChild(icon);
277        nodeamp = document.createElement('amp-iframe');
278        nodeamp.setAttribute('layout', 'responsive');
279        nodeamp.setAttribute("sandbox", "allow-scripts allow-same-origin allow-top-navigation");
280        nodeamp.setAttribute("frameborder", "0");
281        nodeamp.setAttribute('src', url);
282        nodeamp.setAttribute("width", width + "px");
283        nodeamp.setAttribute("height", height + "px");
284        let ampImg = document.createElement('amp-img');
285        ampImg.setAttribute('layout', 'fill');
286        ampImg.setAttribute('placeholder', 'fill');
287        nodeamp.style.cssText = " position: relative;width: " + width + "px;height:" + height + "px;";
288        overlay.appendChild(slideBtn);
289        overlay.appendChild(close);
290        nodeamp.style.background = '#fff';
291        nodeamp.style.border = '1px solid lightgray';
292        nodeamp.appendChild(ampImg);
293        // overlay.appendChild(nodeamp);
294        ampDiv.appendChild(overlay);
295        document.body.appendChild(ampDiv);
296    }
297    dots42();
298}
299
300function popUpEmbed(propObj) {
301    var url = propObj.crQuizUrl;
302    var overlay, popup, iframe, close, top, left;
303
304    function onClose() {
305        document.body.removeChild(overlay);
306        window.removeEventListener('resize', addWindowSizeChangeEvent)
307    }
308    function dots42(n) {
309        let available = true;
310        while(available) {
311            let element = document.getElementById('cr-embed-pue')
312            if (element) {
313                element.remove()
314            } else {
315                available = false;
316            }
317        }
318        overlay = document.createElement("div");
319        overlay.setAttribute('id', 'cr-embed-pue');
320        overlay.style.cssText = "position: fixed;display: block;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(0,0,0,0.5);z-index: 2;";
321        popup = document.createElement("div");
322        iframe = document.createElement("iframe");
323        iframe.setAttribute('id', 'cr-pue-iframe');
324        iframe.src = url;
325        iframe.style.minWidth = '300px';
326        iframe.style.width = '100%';
327        iframe.style.maxWidth = '450px';
328        iframe.style.height = getHeight(null, propObj) + 'px';
329        iframe.style.border = 'none';
330        close = document.createElement("div");
331        close.addEventListener("click", onClose);
332        close.textContent = 'X'
333        popup.appendChild(iframe);
334        popup.appendChild(close);
335        overlay.appendChild(popup);
336        document.body.appendChild(overlay);
337    }
338    dots42();
339    popup.style.cssText = "position: absolute; font-size: 50px; color: black; background: white; top: 50%; left: 50%; transform: translate(-50%, -50%);min-width: 300px; width: inherit; max-width: 450px; border: 5px solid #e5c829;"
340    close.style.cssText = "width: 28px; height: 24px; background-color: #fff; position: fixed; top: 5px; right: 5px; font-size: 20px; text-align: center; border-radius: 20px; border: 2px solid #465667; padding-top: 4px; color: #465667;"
341}
342
343function popUpAmpEmbed(propObj) {
344    var url = propObj.crQuizUrl;
345    var overlay, popup, iframe, close, top, left;
346    
347    function onClose() {
348        document.body.removeChild(overlay);
349    }
350    function dots42(n) {
351        overlay = document.createElement("div");
352        overlay.style.cssText = "position: fixed;display: block;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(0,0,0,0.5);z-index: 2;";
353        popup = document.createElement("div");
354        iframe = document.createElement('amp-iframe');
355        iframe.setAttribute('layout', 'responsive');
356        iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-top-navigation");
357        iframe.setAttribute("frameborder", "0");
358        
359        let ampImg = document.createElement('amp-img');
360        ampImg.setAttribute('layout', 'fill');
361        ampImg.setAttribute('placeholder', 'fill');
362        iframe.appendChild(ampImg);
363        
364        iframe.setAttribute('src', url);
365        iframe.setAttribute("height", propObj.height + "px");
366        iframe.setAttribute("width", propObj.width + "px");
367        iframe.style.height = propObj.height + 'px';
368        iframe.style.width = propObj.width + 'px';
369        iframe.style.maxHeight = 100 + 'vh'
370        close = document.createElement("button");
371        close.addEventListener("click", onClose);
372        var icon = document.createElement("mat-icon");
373        icon.innerHTML = "x";
374        close.appendChild(icon);
375        popup.appendChild(iframe);
376        popup.appendChild(close);
377        overlay.appendChild(popup);
378        document.body.appendChild(overlay);
379    }
380    dots42();
381    popup.style.cssText = "position: absolute;font-size: 50px;color: black;background:white;margin: auto;left: 0;right: 0;width:" + width +'px' +";height:" + height +'px' + ";top: 0px; bottom:0px; max-height:100vh;";
382    close.style.cssText = "width:30px;height:30px;background-color:lightgray;border:none;position:absolute;top:5px;right:5px";
383}
384
385function getPropObj(href) {
386    let propObj = {
387        crQuizUrl: null,
388        width: 450,
389        height: 650,
390        useAmp: false,
391        type: 'st',
392        delay: 0,
393        crMode: 'q'
394    }
395    let embedValues = null;
396    let splits = href.split('?');
397    // crQuizUrl = splits[0];
398    embedValues = splits[1];
399    propObj.crQuizUrl = href;
400    if(splits[0].split('/')[4] == 'p'){
401        propObj.crMode = 'p'
402    }
403    embedValues = embedValues.split('&');
404    embedValues.forEach(keyVal => {
405        let sptKeyVal = keyVal.split('=');
406        if (sptKeyVal && sptKeyVal.length == 2) {
407            propObj = setProperties(sptKeyVal[0], sptKeyVal[1], propObj)
408        }
409    });
410    return propObj;
411}
412
413function createEmbed(embedDiv, propObj) {
414    try {
415        if (embedDiv && propObj.crQuizUrl) {
416            if (propObj.useAmp) {
417                ampCode();
418            }
419            setTimeout(() => {
420                if (propObj.type == 'fpe') {
421                    if (propObj.useAmp) fullPageAmpEmbed(propObj); else fullPageEmbed(propObj);
422                } else if (propObj.type == 'ste') {
423                    if (propObj.useAmp) sideTabAmpEmbed(propObj); else sideTabEmbed(propObj);
424                } else if (propObj.type == 'pue') {
425                    if (propObj.useAmp) popUpAmpEmbed(propObj); else  popUpEmbed(propObj);
426                } else {
427                    if (propObj.useAmp) {
428                        var container = standardAmpEmbed(propObj);
429                        embedDiv.appendChild(container);
430                    } else {
431                        var container = standardEmbed(propObj);
432                        embedDiv.appendChild(container);
433                    }
434                }
435                setTimeout(() => {
436                    addWindowSizeChangeEvent()
437                }, 100);
438                window.removeEventListener('resize', addWindowSizeChangeEvent)
439                window.addEventListener('resize', addWindowSizeChangeEvent)
440            }, propObj.delay);
441        } else {
442            throw 'Unable to find crQuizurl and embed optoins';
443        }
444    } catch(e) {
445        console.log('Error on cr-embed.')
446    }
447}
448
449function checkAndCreateDivForEmbed() {
450    try {
451        let propObjs = [];
452        let embedDivs = document.getElementsByClassName('curiosityroad-embed');
453        if (!(embedDivs && embedDivs.length)) {
454            return;
455        }
456        for(let embedDiv of embedDivs) {
457            if (embedDiv && embedDiv.tagName == 'BLOCKQUOTE') {
458                let aTag = embedDiv.getElementsByTagName('a')
459                if (aTag && aTag.length && aTag[0].href) {
460                    // Delete link after fatching values
461                    let href = aTag[0].href;
462                    aTag[0].remove();
463                    let propObj = getPropObj(href);
464                    propObjs.push(propObj);
465
466                    // create embed
467                    var d = document.createElement('div');
468                    d.classList.add('curiosityroad-embed');
469                    d.innerHTML = embedDivs[0].innerHTML;
470                    d.style.width = 'inherit';
471                    createEmbed(d, propObj);
472                    embedDiv.parentNode.replaceChild(d, embedDiv);
473                }
474            }
475        }
476    } catch(e) {
477        console.log('Error on cr-embed.')
478    }
479}
480
481function addWindowSizeChangeEvent() {
482    try {
483        if (propObj != undefined && propObj.type == 'se') {
484            let element = document.getElementById('cr-embed-std')
485            if (element) {
486                let height = getHeight(element.clientWidth)
487                element.style.height = height + 'px';
488            }
489        } else if (propObj != undefined && propObj.type == 'pue') {
490            let element = document.getElementById('cr-pue-iframe')
491            if (element) {
492                let height = getHeight(element.clientWidth)
493                element.style.height = height + 'px';
494            }
495        }
496    }catch(e) {
497        // console.log(e)
498    }
499}
500
501function getHeight(elemWidth=null, propObj={}) {
502    let width = window.innerWidth;
503    if(propObj.height)
504        return propObj.height
505    if(propObj && propObj.crMode == 'p'){
506        return 570;
507    }
508    if (elemWidth) {
509        width = elemWidth;
510    }
511    if (width <= 450 && width >= 300) {
512        let ht = 500;
513        ht = parseInt(width * 1.44)
514        return ht;
515    } else if (width < 300) {
516        return 500;
517    } else{
518        return 650;
519    }
520}
521// function createDiv(){
522//     shareDiv = document.createElement("div");
523//     shareDiv.setAttribute('id', 'shareUrl');
524//     shareDiv.setAttribute('visibility','hidden');
525//     embedShareUrl = window.location.href
526//     shareDiv.innerHTML = embedShareUrl
527//     document.body.appendChild(shareDiv)
528// }
529
530function setProperties(key, val, propObj) {
531    key = key.trim();
532    val = val.trim();
533    if (key == 'h')
534        propObj.height = parseInt(val);
535    else if (key == 'w')
536        propObj.width = parseInt(val);
537    else if (key == 'dly')
538        propObj.delay = parseInt(val) * 1000;
539    else if (key == 'amp') {
540        propObj.useAmp = val;
541        if (propObj.useAmp == 'true') {
542            propObj.useAmp = true;
543        } else {
544            propObj.useAmp = false;
545        }
546    } else if (key == 'tp') {
547        propObj.type = val;
548    }
549    return propObj;
550}
551
552
553document.onload = (function () {
554    let elementFind = false;
555    for (let idx = 1; idx < 20; idx = idx+3) {
556        setTimeout(() => {
557            if (!elementFind) {
558                // let crUrl = document.getElementById('cr-url')
559                let embeds = document.getElementsByClassName('curiosityroad-embed');
560                if (embeds && embeds.length) {
561                    elementFind = true;
562                    checkAndCreateDivForEmbed();
563                }
564            }
565        }, idx * 1000);
566    }
567})();

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.