1//FWDRLUtils 2(function (window){ 3 4 var FWDRLUtils = function(){}; 5 6 FWDRLUtils.dumy = document.createElement("div"); 7 8 //###################################// 9 /* String */ 10 //###################################// 11 FWDRLUtils.trim = function(str){ 12 return str.replace(/\s/gi, ""); 13 }; 14 15 FWDRLUtils.splitAndTrim = function(str, trim_bl){ 16 var array = str.split(","); 17 var length = array.length; 18 for(var i=0; i<length; i++){ 19 if(trim_bl) array[i] = FWDRLUtils.trim(array[i]); 20 }; 21 return array; 22 }; 23 24 //#############################################// 25 //Array // 26 //#############################################// 27 FWDRLUtils.indexOfArray = function(array, prop){ 28 var length = array.length; 29 for(var i=0; i<length; i++){ 30 if(array[i] === prop) return i; 31 }; 32 return -1; 33 }; 34 35 FWDRLUtils.randomizeArray = function(aArray) { 36 var randomizedArray = []; 37 var copyArray = aArray.concat(); 38 39 var length = copyArray.length; 40 for(var i=0; i< length; i++) { 41 var index = Math.floor(Math.random() * copyArray.length); 42 randomizedArray.push(copyArray[index]); 43 copyArray.splice(index,1); 44 } 45 return randomizedArray; 46 }; 47 48 49 //#############################################// 50 /*DOM manipulation */ 51 //#############################################// 52 FWDRLUtils.prt = function (e, n){ 53 if(n === undefined) n = 1; 54 while(n-- && e) e = e.parentNode; 55 if(!e || e.nodeType !== 1) return null; 56 return e; 57 }; 58 59 FWDRLUtils.sibling = function(e, n){ 60 while (e && n !== 0){ 61 if(n > 0){ 62 if(e.nextElementSibling){ 63 e = e.nextElementSibling; 64 }else{ 65 for(var e = e.nextSibling; e && e.nodeType !== 1; e = e.nextSibling); 66 } 67 n--; 68 }else{ 69 if(e.previousElementSibling){ 70 e = e.previousElementSibling; 71 }else{ 72 for(var e = e.previousSibling; e && e.nodeType !== 1; e = e.previousSibling); 73 } 74 n++; 75 } 76 } 77 return e; 78 }; 79 80 FWDRLUtils.getChildAt = function (e, n){ 81 var kids = FWDRLUtils.getChildren(e); 82 if(n < 0) n += kids.length; 83 if(n < 0) return null; 84 return kids[n]; 85 }; 86 87 FWDRLUtils.getChildById = function(id){ 88 return document.getElementById(id) || undefined; 89 }; 90 91 FWDRLUtils.getChildren = function(e, allNodesTypes){ 92 var kids = []; 93 for(var c = e.firstChild; c != null; c = c.nextSibling){ 94 if(allNodesTypes){ 95 kids.push(c); 96 }else if(c.nodeType === 1){ 97 kids.push(c); 98 } 99 } 100 return kids; 101 }; 102 103 FWDRLUtils.getChildrenFromAttribute = function(e, attr, allNodesTypes){ 104 var kids = []; 105 for(var c = e.firstChild; c != null; c = c.nextSibling){ 106 if(allNodesTypes && FWDRLUtils.hasAttribute(c, attr)){ 107 kids.push(c); 108 }else if(c.nodeType === 1 && FWDRLUtils.hasAttribute(c, attr)){ 109 kids.push(c); 110 } 111 } 112 return kids.length == 0 ? undefined : kids; 113 }; 114 115 FWDRLUtils.getChildFromNodeListFromAttribute = function(e, attr, allNodesTypes){ 116 for(var c = e.firstChild; c != null; c = c.nextSibling){ 117 if(allNodesTypes && FWDRLUtils.hasAttribute(c, attr)){ 118 return c; 119 }else if(c.nodeType === 1 && FWDRLUtils.hasAttribute(c, attr)){ 120 return c; 121 } 122 } 123 return undefined; 124 }; 125 126 FWDRLUtils.getAttributeValue = function(e, attr){ 127 if(!FWDRLUtils.hasAttribute(e, attr)) return undefined; 128 return e.getAttribute(attr); 129 }; 130 131 FWDRLUtils.hasAttribute = function(e, attr){ 132 if(e.hasAttribute){ 133 return e.hasAttribute(attr); 134 }else { 135 var test = e.getAttribute(attr); 136 return test ? true : false; 137 } 138 }; 139 140 FWDRLUtils.insertNodeAt = function(prt, child, n){ 141 var children = FWDRLUtils.children(prt); 142 if(n < 0 || n > children.length){ 143 throw new Error("invalid index!"); 144 }else { 145 prt.insertBefore(child, children[n]); 146 }; 147 }; 148 149 FWDRLUtils.hasCanvas = function(){ 150 return Boolean(document.createElement("canvas")); 151 }; 152 153 //###################################// 154 /* DOM geometry */ 155 //##################################// 156 FWDRLUtils.hitTest = function(target, x, y){ 157 var hit = false; 158 if(!target) throw Error("Hit test target is null!"); 159 var rect = target.getBoundingClientRect(); 160 161 if(x >= rect.left && x <= rect.left +(rect.right - rect.left) && y >= rect.top && y <= rect.top + (rect.bottom - rect.top)) return true; 162 return false;
163 }; 164 165 FWDRLUtils.getScrollOffsets = function(){ 166 //all browsers 167 if(window.pageXOffset != null) return{x:window.pageXOffset, y:window.pageYOffset}; 168 169 //ie7/ie8 170 if(document.compatMode == "CSS1Compat"){ 171 return({x:document.documentElement.scrollLeft, y:document.documentElement.scrollTop}); 172 } 173 }; 174 175 FWDRLUtils.getViewportSize = function(){ 176 if(FWDRLUtils.hasPointerEvent && navigator.msMaxTouchPoints > 1){ 177 return {w:document.documentElement.clientWidth || window.innerWidth, h:document.documentElement.clientHeight || window.innerHeight}; 178 } 179 180 if(FWDRLUtils.isMbl) return {w:window.innerWidth, h:window.innerHeight}; 181 return {w:document.documentElement.clientWidth || window.innerWidth, h:document.documentElement.clientHeight || window.innerHeight}; 182 }; 183 184 FWDRLUtils.getViewportMouseCoordinates = function(e){ 185 var offsets = FWDRLUtils.getScrollOffsets(); 186 187 if(e.touches){ 188 return{ 189 screenX:e.touches[0] == undefined ? e.touches.pageX - offsets.x :e.touches[0].pageX - offsets.x, 190 screenY:e.touches[0] == undefined ? e.touches.pageY - offsets.y :e.touches[0].pageY - offsets.y 191 }; 192 } 193 194 return{ 195 screenX: e.clientX == undefined ? e.pageX - offsets.x : e.clientX, 196 screenY: e.clientY == undefined ? e.pageY - offsets.y : e.clientY 197 }; 198 }; 199 200 201 //###################################// 202 /* Browsers test */ 203 //##################################// 204 FWDRLUtils.hasPointerEvent = (function(){ 205 return Boolean(window.navigator.msPointerEnabled) || Boolean(window.navigator.pointerEnabled); 206 }()); 207 208 FWDRLUtils.isMbl = (function (){ 209 if((FWDRLUtils.hasPointerEvent && navigator.msMaxTouchPoints > 1) || (FWDRLUtils.hasPointerEvent && navigator.maxTouchPoints > 1)) return true; 210 var agents = ['android', 'webos', 'iphone', 'ipad', 'blackberry', 'kfsowi']; 211 for(i in agents) { 212 if(String(navigator.userAgent).toLowerCase().indexOf(String(agents[i]).toLowerCase()) != -1) { 213 return true; 214 } 215 } 216 if(navigator.platform.toLowerCase() === 'macintel' && navigator.maxTouchPoints > 1 && !window.MSStream) return true; 217 return false; 218 }()); 219 220 FWDRLUtils.isAndroid = (function(){ 221 return (navigator.userAgent.toLowerCase().indexOf("android".toLowerCase()) != -1); 222 }()); 223 224 FWDRLUtils.isChrome = (function(){ 225 return navigator.userAgent.toLowerCase().indexOf('chrome') != -1; 226 }()); 227 228 FWDRLUtils.isSafari = (function(){ 229 return navigator.userAgent.toLowerCase().indexOf('safari') != -1 && navigator.userAgent.toLowerCase().indexOf('chrome') == -1; 230 }()); 231 232 FWDRLUtils.isOpera = (function(){ 233 return navigator.userAgent.toLowerCase().indexOf('opera') != -1 && navigator.userAgent.toLowerCase().indexOf('chrome') == -1; 234 }()); 235 236 FWDRLUtils.isFirefox = (function(){ 237 return navigator.userAgent.toLowerCase().indexOf('firefox') != -1; 238 }()); 239 240 FWDRLUtils.isIE = (function(){ 241 var isIE = Boolean(navigator.userAgent.toLowerCase().indexOf('msie') != -1) || Boolean(navigator.userAgent.toLowerCase().indexOf('edge') != -1); 242 return Boolean(isIE || document.documentElement.msRequestFullscreen); 243 }()); 244 245 FWDRLUtils.isIE11 = (function(){ 246 return Boolean(!FWDRLUtils.isIE && document.documentElement.msRequestFullscreen); 247 }()); 248 249 FWDRLUtils.isIEAndLessThen9 = (function(){ 250 return navigator.userAgent.toLowerCase().indexOf("msie 7") != -1 || navigator.userAgent.toLowerCase().indexOf("msie 8") != -1; 251 }()); 252 253 FWDRLUtils.isIEAndLessThen10 = (function(){ 254 return navigator.userAgent.toLowerCase().indexOf("msie 7") != -1 255 || navigator.userAgent.toLowerCase().indexOf("msie 8") != -1 256 || navigator.userAgent.toLowerCase().indexOf("msie 9") != -1; 257 }()); 258 259 FWDRLUtils.isIE7 = (function(){ 260 return navigator.userAgent.toLowerCase().indexOf("msie 7") != -1; 261 }()); 262 263 FWDRLUtils.isIOS = (function(){ 264 return navigator.userAgent.match(/(iPad|iPhone|iPod)/g); 265 }()); 266 267 FWDRLUtils.isIphone = (function(){ 268 return navigator.userAgent.match(/(iPhone|iPod)/g); 269 }()); 270 271 FWDRLUtils.isApple = (function(){ 272 return navigator.appVersion.toLowerCase().indexOf('mac') != -1; 273 }()); 274 275 FWDRLUtils.isLocal = (function(){ 276 return location.href.indexOf('file:') != -1; 277 }()); 278 279 FWDRLUtils.hasFullScreen = (function(){ 280 return FWDRLUtils.dumy.requestFullScreen || FWDRLUtils.dumy.mozRequestFullScreen || FWDRLUtils.dumy.webkitRequestFullScreen || FWDRLUtils.dumy.msieRequestFullScreen; 281 }()); 282 283 function get3d(){ 284 var properties = ['transform', 'msTransform', 'WebkitTransform', 'MozTransform', 'OTransform', 'KhtmlTransform']; 285 var p; 286 var position; 287 while (p = properties.shift()) { 288 if (typeof FWDRLUtils.dumy.style[p] !== 'undefined') { 289 FWDRLUtils.dumy.style.position = "absolute"; 290 position = FWDRLUtils.dumy.getBoundingClientRect().left; 291 FWDRLUtils.dumy.style[p] = 'translate3d(500px, 0px, 0px)'; 292 position = Math.abs(FWDRLUtils.dumy.getBoundingClientRect().left - position); 293 294 if(position > 100 && position < 900){ 295 try{document.documentElement.removeChild(FWDRLUtils.dumy);}catch(e){} 296 return true; 297 } 298 } 299 } 300 try{document.documentElement.removeChild(FWDRLUtils.dumy);}catch(e){} 301 return false;
302 }; 303 304 function get2d(){ 305 var properties = ['transform', 'msTransform', 'WebkitTransform', 'MozTransform', 'OTransform', 'KhtmlTransform']; 306 var p; 307 while (p = properties.shift()) { 308 if (typeof FWDRLUtils.dumy.style[p] !== 'undefined') { 309 return true; 310 } 311 } 312 try{document.documentElement.removeChild(FWDRLUtils.dumy);}catch(e){} 313 return false; 314 }; 315 316 //###############################################// 317 /* various utils */ 318 //###############################################// 319 FWDRLUtils.onReady = function(callbalk){ 320 if (document.addEventListener) { 321 document.addEventListener( "DOMContentLoaded", function(){ 322 callbalk(); 323 }); 324 }else{ 325 document.onreadystatechange = function () { 326 if (document.readyState == "complete") callbalk(); 327 }; 328 } 329 }; 330 331 FWDRLUtils.checkIfHasTransforms = function(){ 332 if(FWDRLUtils.isReadyMethodCalled_bl) return; 333 document.documentElement.appendChild(FWDRLUtils.dumy); 334 FWDRLUtils.hasTransform3d = get3d(); 335 FWDRLUtils.hasTransform2d = get2d(); 336 FWDRLUtils.isReadyMethodCalled_bl = true; 337 }; 338 339 FWDRLUtils.disableElementSelection = function(e){ 340 try{e.style.userSelect = "none";}catch(e){}; 341 try{e.style.MozUserSelect = "none";}catch(e){}; 342 try{e.style.webkitUserSelect = "none";}catch(e){}; 343 try{e.style.khtmlUserSelect = "none";}catch(e){}; 344 try{e.style.oUserSelect = "none";}catch(e){}; 345 try{e.style.msUserSelect = "none";}catch(e){}; 346 try{e.msUserSelect = "none";}catch(e){}; 347 e.onselectstart = function(){return false;}; 348 }; 349 350 FWDRLUtils.getSearchArgs = function(){ 351 var args = {}; 352 var query = location.href.substr(location.href.indexOf("?") + 1); 353 354 var pairs = query.split("&"); 355 356 for(var i=0; i< pairs.length; i++){ 357 var pos = pairs[i].indexOf("="); 358 var name = pairs[i].substring(0,pos); 359 var value = pairs[i].substring(pos + 1); 360 value = decodeURIComponent(value); 361 args[name] = value; 362 } 363 return args; 364 }; 365 366 FWDRLUtils.getHashArgs = function(string){ 367 var args = {}; 368 var query = string.substr(string.indexOf("#") + 1) || location.hash.substring(1); 369 var pairs = query.split("&"); 370 for(var i=0; i< pairs.length; i++){ 371 var pos = pairs[i].indexOf("="); 372 var name = pairs[i].substring(0,pos); 373 var value = pairs[i].substring(pos + 1); 374 value = decodeURIComponent(value); 375 args[name] = value; 376 } 377 return args; 378 }; 379 380 381 FWDRLUtils.isReadyMethodCalled_bl = false; 382 383 window.FWDRLUtils = FWDRLUtils; 384}(window)); 385
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.