PageSourceSearch

https://www.epsc-dps2019.eu/co_common.js

js epsc-dps2019.eu collected 2026-10-03 23:38:32 UTC 11,811 bytes, 428 lines download raw bytes

1function co_in_array(a, value)
2{
3    for(var i = 0, l = a.length; i < l; i++) if(a[i] == value) return true;
4    return false;
5}
6
7function co_elementHasClass(element, className)
8{
9    if(element.className == undefined || element.className.match == undefined)
10        return false;
11
12    return element.className && ( element.className==className || element.className.match( new RegExp( "\\b"+className+"\\b" )) );
13}
14
15//
16// expects same domain origin !!
17//
18function co_modify_css_class(classname,element,new_value)
19{
20    var cssrules_key;
21
22    for (var styleIndex = 0, l1=document.styleSheets.length; styleIndex < l1; styleIndex++)
23    {
24        if (document.styleSheets[styleIndex]['rules'])
25        {
26            cssrules_key = 'rules';
27        }
28        else if (document.styleSheets[styleIndex]['cssRules'])
29        {
30            cssrules_key = 'cssRules';
31        }
32        else
33        {
34            return false;
35        }
36
37        for (var ruleIndex = 0, l2=document.styleSheets[styleIndex][cssrules_key].length; ruleIndex < l2; ruleIndex++)
38        {
39            if (document.styleSheets[styleIndex][cssrules_key][ruleIndex].selectorText == classname && document.styleSheets[styleIndex][cssrules_key][ruleIndex].style[element])
40            {
41                document.styleSheets[styleIndex][cssrules_key][ruleIndex].style[element] = new_value;
42                return true;
43            }
44        }
45
46        if(document.styleSheets[styleIndex].insertRule)
47        {
48            document.styleSheets[styleIndex].insertRule(classname+' { '+element+': '+new_value+'; }',document.styleSheets[styleIndex][cssrules_key].length);
49        }
50        else if (document.styleSheets[styleIndex].addRule)
51        {
52            document.styleSheets[styleIndex].addRule(classname,element+': '+new_value+';');
53        }
54        else
55        {
56            return false;
57        }
58
59        return true;
60    }
61}
62
63function co_hide_tablerow(node)
64{
65    if(typeof node == "string")
66    {
67        if(!_get(node)) return false;
68        node = _get(node);
69    }
70    else if (typeof node == "undefined")
71    {
72        return false
73    }
74    node.style.display="none";
75
76    return true;
77}
78
79function co_show_tablerow(node)
80{
81    if(typeof node == "string")
82    {
83        if(!_get(node)) return false;
84        node = _get(node);
85    }
86    else if (typeof node == "undefined")
87    {
88        return false
89    }
90
91    var isMSie = /*@cc_on!@*/false;
92    if(isMSie)
93    {
94        node.style.display="block";
95    }
96    else
97    {
98        node.style.display="table-row";
99    }
100
101    return true;
102}
103
104function co_getElementsByClassName(className, parentElement)
105{
106    var elements = new Array ();
107    var parent = ( typeof parentElement == 'object' ) ? parentElement : window.document;
108
109    if(!parent)
110    {
111        return elements;
112    }
113
114    var children = parent.getElementsByTagName( "*" );
115
116    for ( var i = 0; i < children.length; i++ )
117    {
118        if ( co_elementHasClass(children[i], className) )
119        {
120            elements[elements.length] = children[i];
121        }
122    }
123    return elements;
124}
125
126function findPos(obj)
127{
128    var curleft = curtop = 0;
129    if (obj.offsetParent) {
130        curleft = obj.offsetLeft
131        curtop = obj.offsetTop
132        while (obj = obj.offsetParent) {
133            curleft += obj.offsetLeft
134            curtop += obj.offsetTop
135        }
136    }
137    return [curleft,curtop];
138}
139
140function addEvent(obj, evType, fn)
141{
142    if(typeof fn == "undefined")
143    {
144        return false;
145    }
146    if (obj.addEventListener){
147        obj.addEventListener(evType, fn, true);
148        return true;
149    } else if (obj.attachEvent){
150        var r = obj.attachEvent("on"+evType, fn, true);
151        return r;
152    } else {
153        return false;
154    }
155}
156
157function removeEvent(obj, evType, fn)
158{
159    if(typeof fn == "undefined")
160    {
161        return false;
162    }
163
164    if (obj.removeEventListener){
165        obj.removeEventListener(evType, fn, true);
166        return true;
167    } else if (obj.detachEvent){
168        var r = obj.detachEvent("on"+evType, fn, true);
169        return r;
170    } else {
171        return false;
172    }
173}
174
175//
176// getPageSize()
177// Returns array with page width, height and window width, height
178// Core code from - quirksmode.org
179// Edit for Firefox by pHaez
180// grabbed from http://www.huddletogether.com/projects/lightbox/lightbox.js
181//
182function getPageSize(){
183
184    var xScroll, yScroll;
185
186    if (window.innerHeight && window.scrollMaxY) {
187        xScroll = document.body.scrollWidth;
188        yScroll = window.innerHeight + window.scrollMaxY;
189    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
190        xScroll = document.body.scrollWidth;
191        yScroll = document.body.scrollHeight;
192    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
193        xScroll = document.body.offsetWidth;
194        yScroll = document.body.offsetHeight;
195    }
196
197    var windowWidth, windowHeight;
198    if (self.innerHeight) {	// all except Explorer
199        windowWidth = self.innerWidth;
200        windowHeight = self.innerHeight;
201    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
202        windowWidth = document.documentElement.clientWidth;
203        windowHeight = document.documentElement.clientHeight;
204    } else if (document.body) { // other Explorers
205        windowWidth = document.body.clientWidth;
206        windowHeight = document.body.clientHeight;
207    }
208
209    // for small pages with total height less then height of the viewport
210    if(yScroll < windowHeight){
211        pageHeight = windowHeight;
212    } else {
213        pageHeight = yScroll;
214    }
215
216    // for small pages with total width less then width of the viewport
217    if(xScroll < windowWidth){
218        pageWidth = windowWidth;
219    } else {
220        pageWidth = xScroll;
221    }
222
223
224    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
225    return arrayPageSize;
226}
227//
228// co_getPageScroll()
229// Returns array with x,y page scroll values.
230// Core code from - quirksmode.org
231// grabbed from http://www.huddletogether.com/projects/lightbox/lightbox.js
232//
233function co_getPageScroll(){
234
235    var yScroll;
236
237    if (self.pageYOffset) {
238        yScroll = self.pageYOffset;
239    } else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
240        yScroll = document.documentElement.scrollTop;
241    } else if (document.body) {// all other Explorers
242        yScroll = document.body.scrollTop;
243    }
244
245    arrayPageScroll = new Array('',yScroll)
246    return arrayPageScroll;
247}
248
249function co_get_viewport_size()
250{
251    var viewportwidth;
252    var viewportheight;
253
254    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
255
256    if (typeof window.innerWidth != 'undefined')
257    {
258        viewportwidth = window.innerWidth,
259            viewportheight = window.innerHeight
260    }
261
262// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
263
264    else if (typeof document.documentElement != 'undefined'
265        && typeof document.documentElement.clientWidth !=
266        'undefined' && document.documentElement.clientWidth != 0)
267    {
268        viewportwidth = document.documentElement.clientWidth,
269            viewportheight = document.documentElement.clientHeight
270    }
271
272    // older versions of IE
273
274    else
275    {
276        viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
277            viewportheight = document.getElementsByTagName('body')[0].clientHeight
278    }
279
280    viewportSize = new Array(viewportwidth,viewportheight  )
281    return viewportSize ;
282
283}
284
285function getStyle(el,styleProp)
286{
287    if(typeof el != "object" )
288    {
289        if(document.getElementById(el))
290        {
291            var obj = document.getElementById(el);
292        }
293        else
294        {
295            return false;
296        }
297    }
298    else
299    {
300        var obj = el;
301    }
302
303    var ret = false;
304
305
306    // Handle "float" property as a special case
307    if (styleProp=="float")
308    {
309        ret = getStyle(obj,"cssFloat");
310        if (ret==null)
311        {
312            ret = getStyle(obj,"styleFloat");
313        }
314
315        return ret;
316    }
317
318    if(obj.style && obj.style[toCamelCase(styleProp)])
319    {
320        ret = obj.style[toCamelCase(styleProp)];
321    }
322    else if (obj.currentStyle && obj.currentStyle[toCamelCase(styleProp)])
323        ret = obj.currentStyle[toCamelCase(styleProp)];
324    else if (window.getComputedStyle)
325        ret = document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
326
327    return ret;
328}
329
330/** toCamelCase(input)
331 * Converts string input to a camel cased version of itself.
332 * For example:
333 * toCamelCase("z-index"); // returns zIndex
334 * toCamelCase("border-bottom-style"); // returns borderBottomStyle.
335 */
336function toCamelCase(s) {
337    for(var exp = toCamelCase.exp;
338        exp.test(s); s = s.replace(exp, RegExp.$1.toUpperCase()) );
339    return s;
340}
341toCamelCase.exp = /-([a-z])/;
342
343
344
345
346
347
348window.onload_actions = new Array();
349
350function add_onload_action(evalstring)
351{
352    window.onload_actions.push(evalstring);
353}
354
355function onload_action()
356{
357    for(i=0; i<window.onload_actions.length; i++)
358    {
359        try
360        {
361            eval(window.onload_actions[i]);
362        }
363        catch(e)
364        {
365            alert('onload action "'+window.onload_actions[i]+'" failed:'+e);
366        }
367    }
368}
369
370
371function _get(node)
372{
373    return document.getElementById(node);
374}
375
376function alertForDesktopRedirection() {
377    var viewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
378    if (viewPortWidth < 1025) {
379        var message = document.querySelector('body').getAttribute('data-non-mobile-optimized-message');
380        var nonMobileOptimizedElements = document.querySelectorAll('[data-non-mobile-optimized]');
381
382        if (!message) {
383            message = 'You are leaving the mobile-optimized environment. To proceed, please use an appropriate device.';
384        }
385
386        if (nonMobileOptimizedElements && nonMobileOptimizedElements.length > 0) {
387            for (var i = 0; i < nonMobileOptimizedElements.length; i++) {
388                nonMobileOptimizedElements[i].addEventListener("click", function (e) {
389                    console.log("Calling non-mobile-message");
390                    if (window.confirm(message)) {
391                        return true;
392                    } else {
393                        e.preventDefault();
394                        return false;
395                    }
396                });
397            }
398        }
399    }
400}
401
402
403function detectAnchor(){
404    var anchorValue = window.location.hash.substr(1);
405    var anchorElement = document.getElementById(anchorValue);
406
407    if(anchorElement){
408        if(anchorElement.offsetParent === null){
409            showInvisibleParent(anchorElement);
410        }
411    }
412}
413
414function showInvisibleParent(element){
415    var parentElement = element.parentElement;
416
417    if(parentElement && parentElement.offsetParent === null){
418            parentElement.style.display = 'block';
419            parentElement.style.visibility = 'visible';
420        if(parentElement.offsetParent === null){
421            showInvisibleParent(parentElement);
422        }
423    }
424}
425
426add_onload_action("alertForDesktopRedirection()");
427add_onload_action("detectAnchor()");
428addEvent(window, "load", onload_action);

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.