1// Avoid `console` errors in browsers that lack a console. 2(function() { 3 var method; 4 var noop = function () {}; 5 var methods = [ 6 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 7 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 8 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 9 'timeStamp', 'trace', 'warn' 10 ]; 11 var length = methods.length; 12 var console = (window.console = window.console || {}); 13 14 while (length--) { 15 method = methods[length]; 16 // Only stub undefined methods. 17 if (!console[method]) { 18 console[method] = noop; 19 } 20 } 21}()); 22 23// Place any jQuery/helper plugins in here. 24function checkContentHeight(target){ 25 var stageHeight=$( window ).height(); 26 var newHeight = (stageHeight/2)-(target.height()/2); 27 return newHeight; 28} 29 30function checkContentWidth(target){ 31 var stageWidth=$( window ).width(); 32 var newWidth = (stageWidth/2)-(target.width()/2); 33 return newWidth; 34} 35 36function getDeviceVer() { 37 var ua = navigator.userAgent; 38 var uaindex; 39 40 // determine OS 41 if ( ua.match(/(iPad|iPhone|iPod touch)/) ){ 42 userOS = 'iOS'; 43 uaindex = ua.indexOf( 'OS ' ); 44 }else if ( ua.match(/Android/) ){ 45 userOS = 'Android'; 46 uaindex = ua.indexOf( 'Android ' ); 47 }else{ 48 userOS = 'unknown'; 49 } 50 51 // determine version 52 if ( userOS === 'iOS' && uaindex > -1 ){ 53 userOSver = ua.substr( uaindex + 3, 3 ).replace( '_', '.' ); 54 }else if ( userOS === 'Android' && uaindex > -1 ){ 55 userOSver = ua.substr( uaindex + 8, 3 ); 56 }else{ 57 userOSver = 'unknown'; 58 } 59 return Number(userOSver) 60} 61 62function shuffle(array) { 63 var currentIndex = array.length 64 , temporaryValue 65 , randomIndex 66 ; 67 68 // While there remain elements to shuffle... 69 while (0 !== currentIndex) { 70 // Pick a remaining element... 71 randomIndex = Math.floor(Math.random() * currentIndex); 72 currentIndex -= 1; 73 74 // And swap it with the current element. 75 temporaryValue = array[currentIndex]; 76 array[currentIndex] = array[randomIndex]; 77 array[randomIndex] = temporaryValue; 78 } 79 80 return array; 81} 82 83function unique(list) { 84 var result = []; 85 $.each(list, function(i, e) { 86 if ($.inArray(e, result) == -1) result.push(e); 87 }); 88 return result; 89} 90 91function randomBoolean(){ 92 return Math.random() < 0.5; 93} 94 95function sortOnObject(array, object) { 96 array.sort(function(a, b){ 97 var a1= a[object], b1= b[object]; 98 if(a1== b1) return 0; 99 return a1> b1? 1: -1; 100 }); 101 102 return array; 103} 104 105function countDecimalDigits(number){ 106 var char_array = number.toString().split(""); 107 var not_decimal = char_array.lastIndexOf("."); 108 return (not_decimal<0)?0:char_array.length - not_decimal; 109} 110 111 112function getCenterPosition(startX, startY, endX, endY) { 113 var position = {x:0, y:0}; 114 position.x=(startX+endX)/2; 115 position.y=(startY+endY)/2; 116 117 return position; 118} 119 120Array.prototype.swap = function (x,y) { 121 var b = this[x]; 122 this[x] = this[y]; 123 this[y] = b; 124 return this; 125} 126 127Array.prototype.insert = function ( index, item ) { 128 this.splice( index, 0, item ); 129};
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.