1var $en = { 2 3 createDiv: function(cssClass, innerHTML) { 4 return this.createElement("div", cssClass, innerHTML); 5 }, 6 7 createElement: function(type, cssClass, innerHTML) { 8 let el = document.createElement(type); 9 if (cssClass != null) { 10 if (typeof cssClass === "string") { 11 el.classList.add(cssClass); 12 } else if (Array.isArray(cssClass)) { 13 for (let x = 0; x < cssClass.length; x++) { 14 if (cssClass[x] != null) { 15 el.classList.add(cssClass[x]); 16 } 17 } 18 } 19 } 20 if (innerHTML != null) { 21 el.innerHTML = innerHTML; 22 } 23 return el; 24 }, 25 26 ajax: function(xhrdata) { 27 let xhr = new XMLHttpRequest(); 28 try { 29 xhr.timeout = xhrdata.timeout; 30 } catch (e) { 31 } 32 xhr.addEventListener("load", function(event) { 33 if (xhr.status == 200) { 34 if (xhrdata.callback != null) { 35 xhrdata.callback(xhr.responseText); 36 } 37 } else { 38 if (xhrdata.onbadstatus != null) { 39 xhrdata.onbadstatus(xhr); 40 } 41 } 42 }); 43 44 45 if (xhrdata.ontimeout != null) { 46 xhr.addEventListener("timeout", function(event) { xhrdata.ontimeout(event); }); 47 } else { 48 if (xhrdata.onerror != null) { 49 xhr.addEventListener("timeout", function(event) { xhrdata.onerror(event); }); 50 } 51 } 52 53 if (xhrdata.onerror != null) { 54 xhr.addEventListener("error", function(event) { 55 xhrdata.onerror(event); 56 }); 57 } 58 59 if (xhrdata.uploadPanel != null) { 60 let eventTypes = ["loadstart", "progress", "abort", "error", "load", "timeout", "loadend"]; 61 xhrdata.uploadPanel.bindHttpRequest(xhr); 62 for (let x = 0; x < eventTypes.length; x++) { 63 xhr.upload.addEventListener(eventTypes[x], function(e) { xhrdata.uploadPanel.eventHandler(e); } ); 64 } 65 } 66 67 xhr.open("POST", xhrdata.url); 68 if (xhrdata.file != null) { 69 xhr.timeout = 0; 70 xhr.setRequestHeader('X-Requested-With','XMLHttpRequest'); 71 xhr.enctype = "multipart/form-data"; 72 let formData = new FormData(); 73 for (let f = 0; f < xhrdata.file.length; f++) { 74 formData.append("fileToUpload_" + f, xhrdata.file[f]); 75 } 76 for (let [key, value] of xhrdata.params.entries()) { 77 formData.append(key, value); 78 } 79 xhr.send(formData); 80 } else { 81 xhr.timeout = Math.max(2000, xhr.timeout); 82 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 83 xhr.send(this.getEncodedURI(xhrdata.params)); 84 } 85 }, 86 87 getEncodedURI: function(params) { 88 let encodedData = []; 89 let encodedURI = ""; 90 for ( let [key, value] of params.entries() ) { 91 encodedData.push( encodeURIComponent(key) + "=" + encodeURIComponent(value) ); 92 } 93 return encodedData.join("&").replace( /%20/g, "+" ); 94 }, 95 96 isInsideOf: function(parent, child) { 97 let p = child.parentNode; 98 while (p != null) { 99 if (p == parent) { 100 return true; 101 } 102 p = p.parentNode; 103 } 104 return false; 105 }, 106 107 getParentByClassName: function(className, el) { 108 do { 109 if (el.classList && el.classList.contains(className)) { 110 return el; 111 } 112 el = el.parentNode; 113 } while (el); 114 return null; 115 }, 116 117 getCookie: function (name) { 118 return document.cookie.split('; ').reduce((r, v) => { 119 const parts = v.split('=') 120 return parts[0] === name ? decodeURIComponent(parts[1]) : r 121 }, ''); 122 }, 123 124 setCookie: function (name, value, days = 30, path = '/') { 125 const expires = new Date(Date.now() + days * 864e5).toUTCString(); 126 document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + expires + '; path=' + path; 127 }, 128 129 deleteCookie: function (name, path = '/') { 130 this.setCookie(name, '', -1, path); 131 }, 132 133 isPageEditorEnabled: function () { 134 return !!(typeof window._encms !== 'undefined' && typeof window._encms.pageEditor !== 'undefined' 135 && window._encms.editMode && window._encms.pageEditor.activeBlock); 136 }, 137 138 camelize: (text) => { 139 return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase(); 140 }, 141 142 isHover: (e) => { 143 if (e != null) { 144 return e.parentElement.querySelector(':hover') === e; 145 } 146 return false;
147 }, 148 149 getComputedStyle: function (el, attr, isNum = true) { 150 let elemAttr = window.getComputedStyle(el).getPropertyValue(attr); 151 return isNum ? parseFloat(elemAttr.replace("px", "")) : elemAttr; 152 }, 153 154 getOS: function() { 155 let os = "unknown"; 156 let navApp = navigator.userAgent.toLowerCase(); 157 158 switch (true) { 159 case (navApp.indexOf("win") !== -1): 160 os = "win"; 161 break; 162 case /ipad|iphone/.test(navApp) && !window.MSStream: 163 os = "iphone"; 164 break; 165 case (navApp.indexOf("mac") !== -1): 166 os = "mac"; 167 break; 168 case /android/i.test(navApp): 169 os = "android"; 170 break; 171 case (navApp.indexOf("linux") !== -1): 172 os = "lin"; 173 break; 174 case (navApp.indexOf("x11") !== -1): 175 os = "unix"; 176 break; 177 } 178 return os; 179 }, 180 181 isMobile: function() { 182 let os = this.getOS(); 183 return os !== 'win' && os !== 'mac' && os !== 'lin' && os !== 'unix'; 184 }, 185 186 getBrowser: function() { 187 let isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; 188 if (isOpera) { 189 return "opera"; 190 } 191 192 let isFirefox = typeof InstallTrigger !== 'undefined'; 193 if (isFirefox) { 194 return "firefox"; 195 } 196 197 let isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification)); 198 if (isSafari) { 199 return "safari"; 200 } 201 202 let isIE = (navigator.userAgent.indexOf("MSIE") !== -1) || (!!document.documentMode === true); 203 if (isIE) { 204 return "ie"; 205 } 206 207 let isEdge = navigator.userAgent.indexOf("Edg") !== -1; 208 if (isEdge) { 209 return "edge"; 210 } 211 212 let isChrome = !!window.chrome && navigator.userAgent.indexOf("Chrome") != -1; 213 if (isChrome) { 214 return "chrome"; 215 } 216 217 let isEdgeChromium = isChrome && (navigator.userAgent.indexOf("Edg") != -1); 218 if (isEdgeChromium) { 219 return "edge"; 220 } 221 222 return undefined; 223 } 224 225};
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.