1/* 2 * ubNJ 3 * 2015/12/21 {^æÌñ\¦ðsíÈ¢ 4 */ 5/* 6 * Return the classList property of e, if it has one. 7 * Otherwise, return an object that simulates the DOMTokenList API for e. 8 * The returned object has contains(), add(), remove(), toggle() and toString() 9 * methods for testing and altering the set of classes of the element e. 10 * If the classList property is natively supported, the returned object is 11 * array-like and has length and array index properties. The simulated 12 * DOMTokenList is not array-like, but has a toArray() method that returns 13 * a true-array snapshot of the element's class names. 14 */ 15 16function classList(e) { 17 if (e.classList) return e.classList; // Return e.classList if it exists 18 else return new CSSClassList(e); // Otherwise try to fake it 19} 20 21// CSSClassList is a JavaScript class that simulates DOMTokenList 22function CSSClassList(e) { this.e = e; } 23 24// Return true if e.className contains the class c, false otherwise 25CSSClassList.prototype.contains = function(c) { 26 // Check that c is a valid class name 27 if (c.length === 0 || c.indexOf(" ") != -1) 28 throw new Error("Invalid class name: '" + c + "'"); 29 // Check common cases first 30 var classes = this.e.className; 31 if (!classes) return false; // e has no classes at all 32 if (classes === c) return true; // e has one class that matches exactly 33 34 // Otherwise, use a RegExp to search for c as a word by itself 35 // \b in a regular expression requires a match at a word boundary. 36 return classes.search("\\b" + c + "\\b") != -1; 37}; 38 39// Add c to the e.className if it is not already present 40CSSClassList.prototype.add = function(c) { 41 if (this.contains(c)) return; // Do nothing if already present 42 var classes = this.e.className; 43 if (classes && classes[classes.length-1] != " ") 44 c = " " + c; // Add a space if we need one 45 this.e.className += c; // Add c to the className 46}; 47 48// Remove all occurrences of c from e.className 49CSSClassList.prototype.remove = function(c) { 50 // Make sure c is a valid class name 51 if (c.length === 0 || c.indexOf(" ") != -1) 52 throw new Error("Invalid class name: '" + c + "'"); 53 // Remove all occurances of c as a word, plus any trailing space 54 var pattern = new RegExp("\\b" + c + "\\b\\s*", "g"); 55 this.e.className = this.e.className.replace(pattern, ""); 56}; 57 58// Add c to e.className if it is not already present and return true. 59// Otherwise, remove all occurrences of c from e.className and return false. 60CSSClassList.prototype.toggle = function(c) { 61 if (this.contains(c)) { // If e.className contains c 62 this.remove(c); // then remove it. 63 return false; 64 } 65 else { // Otherwise: 66 this.add(c); // add it. 67 return true; 68 } 69}; 70 71// Return e.className itself 72CSSClassList.prototype.toString = function() { return this.e.className; }; 73 74// Return of the names in e.className 75CSSClassList.prototype.toArray = function() { 76 return this.e.className.match(/\b\w+\b/g) || []; 77}; 78function do_onoff(hdr, item) 79{ 80 var e = document.getElementById(hdr); 81 var e2 = document.getElementById(item); 82 if (e2.style.display == 'none') { 83 e2.style.display = ''; 84 classList(e).remove('close'); 85 classList(e).add('open'); 86 } else { 87 e2.style.display = 'none'; 88 classList(e).remove('open'); 89 classList(e).add('close'); 90 } 91} 92function open_close(hdr, item) 93{ 94 var e = document.getElementById(hdr); 95 var e2 = document.getElementById(item); 96 e.addEventListener("click", function() { do_onoff(hdr, item); }, false); 97 98 classList(e).remove('open'); 99 classList(e).add('close'); 100 if (classList(e).contains('open')) { 101// e.style.display = ''; 102 e2.style.display = ''; 103 } 104 if (classList(e).contains('close')) { 105// e.style.display = ''; 106 e2.style.display = 'none'; 107 } 108 109} 110function OCisSmartPhone() 111{ 112 return ( 113 (navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) || 114 navigator.userAgent.indexOf('iPod') > 0 || 115 navigator.userAgent.indexOf('Android') > 0); 116} 117function OCdisplayWidth() 118{ 119 return window.parent.screen.width; 120} 121function OCwindowWidth() 122{ 123 if (window.screen.width < window.innerWidth) { 124 return window.screen.width; 125 } 126 return window.innerWidth; 127}
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.