Otaku-Projects /
AngularJS-CRUD-PHP
| 1 | /*! shim.js (C) 2013-present SheetJS -- http://sheetjs.com */ |
||
| 2 | /* ES3/5 Compatibility shims and other utilities for older browsers. */ |
||
| 3 | |||
| 4 | // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys |
||
| 5 | if(!Object.keys) Object.keys = (function() { |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Loading history...
|
|||
| 6 | var hasOwnProperty = Object.prototype.hasOwnProperty, |
||
| 7 | hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'), |
||
| 8 | dontEnums = [ |
||
| 9 | 'toString', |
||
| 10 | 'toLocaleString', |
||
| 11 | 'valueOf', |
||
| 12 | 'hasOwnProperty', |
||
| 13 | 'isPrototypeOf', |
||
| 14 | 'propertyIsEnumerable', |
||
| 15 | 'constructor' |
||
| 16 | ], |
||
| 17 | dontEnumsLength = dontEnums.length; |
||
| 18 | |||
| 19 | return function(obj) { |
||
| 20 | if(typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object'); |
||
| 21 | |||
| 22 | var result = []; |
||
| 23 | |||
| 24 | for(var prop in obj) if(hasOwnProperty.call(obj, prop)) result.push(prop); |
||
|
0 ignored issues
–
show
A for in loop automatically includes the property of any prototype object, consider checking the key using
hasOwnProperty.
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: var someObject;
for (var key in someObject) {
if ( ! someObject.hasOwnProperty(key)) {
continue; // Skip keys from the prototype.
}
doSomethingWith(key);
}
Loading history...
|
|||
| 25 | |||
| 26 | if(hasDontEnumBug) |
||
| 27 | for(var i=0; i < dontEnumsLength; ++i) |
||
| 28 | if(hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]); |
||
| 29 | return result; |
||
| 30 | }; |
||
| 31 | })(); |
||
| 32 | |||
| 33 | if(!String.prototype.trim) String.prototype.trim = function() { |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
|
|||
| 34 | var s = this.replace(/^\s+/, ''); |
||
| 35 | for(var i = s.length - 1; i >=0 ; --i) if(!s.charAt(i).match(/^\s/)) return s.slice(0,i+1); |
||
| 36 | return ""; |
||
| 37 | }; |
||
| 38 | |||
| 39 | if(!Array.prototype.forEach) Array.prototype.forEach = function(cb) { |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
|
|||
| 40 | var len = (this.length>>>0), self = (arguments[1]||void 0); |
||
|
0 ignored issues
–
show
|
|||
| 41 | for(var i=0; i<len; ++i) if(i in this) self ? cb.call(self, this[i], i, this) : cb(this[i], i, this); |
||
| 42 | }; |
||
| 43 | |||
| 44 | if(!Array.prototype.map) Array.prototype.map = function(cb) { |
||
| 45 | var len = (this.length>>>0), self = (arguments[1]||void 0), A = new Array(len); |
||
|
0 ignored issues
–
show
|
|||
| 46 | for(var i=0; i<len; ++i) if(i in this) A[i] = self ? cb.call(self, this[i], i, this) : cb(this[i], i, this); |
||
| 47 | return A; |
||
| 48 | }; |
||
| 49 | |||
| 50 | if(!Array.prototype.indexOf) Array.prototype.indexOf = function(needle) { |
||
| 51 | var len = (this.length>>>0), i = ((arguments[1]|0)||0); |
||
| 52 | for(i<0 && (i+=len)<0 && (i=0); i<len; ++i) if(this[i] === needle) return i; |
||
| 53 | return -1; |
||
| 54 | }; |
||
| 55 | |||
| 56 | if(!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(needle) { |
||
| 57 | var len = (this.length>>>0), i = len - 1; |
||
| 58 | for(; i>=0; --i) if(this[i] === needle) return i; |
||
| 59 | return -1; |
||
| 60 | }; |
||
| 61 | |||
| 62 | if(!Array.isArray) Array.isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }; |
||
| 63 | |||
| 64 | if(!Date.prototype.toISOString) Date.prototype.toISOString = (function() { |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
|
|||
| 65 | function p(n,i) { return ('0000000' + n).slice(-(i||2)); } |
||
| 66 | |||
| 67 | return function _toISOString() { |
||
| 68 | var y = this.getUTCFullYear(), yr = ""; |
||
| 69 | if(y>9999) yr = '+' + p( y, 6); |
||
| 70 | else if(y<0) yr = '-' + p(-y, 6); |
||
| 71 | else yr = p( y, 4); |
||
| 72 | |||
| 73 | return [ |
||
| 74 | yr, p(this.getUTCMonth()+1), p(this.getUTCDate()) |
||
| 75 | ].join('-') + 'T' + [ |
||
| 76 | p(this.getUTCHours()), p(this.getUTCMinutes()), p(this.getUTCSeconds()) |
||
| 77 | ].join(':') + '.' + p(this.getUTCMilliseconds(),3) + 'Z'; |
||
| 78 | }; |
||
| 79 | }()); |
||
| 80 | |||
| 81 | if(typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) ArrayBuffer.prototype.slice = function(start, end) { |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
|
|||
| 82 | if(start == null) start = 0; |
||
| 83 | if(start < 0) { start += this.byteLength; if(start < 0) start = 0; } |
||
| 84 | if(start >= this.byteLength) return new Uint8Array(0); |
||
| 85 | if(end == null) end = this.byteLength; |
||
| 86 | if(end < 0) { end += this.byteLength; if(end < 0) end = 0; } |
||
| 87 | if(end > this.byteLength) end = this.byteLength; |
||
| 88 | if(start > end) return new Uint8Array(0); |
||
| 89 | var out = new ArrayBuffer(end - start); |
||
| 90 | var view = new Uint8Array(out); |
||
| 91 | var data = new Uint8Array(this, start, end - start) |
||
| 92 | /* IE10 should have Uint8Array#set */ |
||
| 93 | if(view.set) view.set(data); else while(start <= --end) view[end - start] = data[end]; |
||
| 94 | return out; |
||
| 95 | }; |
||
| 96 | if(typeof Uint8Array !== 'undefined' && !Uint8Array.prototype.slice) Uint8Array.prototype.slice = function(start, end) { |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
|
|||
| 97 | if(start == null) start = 0; |
||
| 98 | if(start < 0) { start += this.length; if(start < 0) start = 0; } |
||
| 99 | if(start >= this.length) return new Uint8Array(0); |
||
| 100 | if(end == null) end = this.length; |
||
| 101 | if(end < 0) { end += this.length; if(end < 0) end = 0; } |
||
| 102 | if(end > this.length) end = this.length; |
||
| 103 | if(start > end) return new Uint8Array(0); |
||
| 104 | var out = new Uint8Array(end - start); |
||
| 105 | while(start <= --end) out[end - start] = this[end]; |
||
| 106 | return out; |
||
| 107 | }; |
||
| 108 | |||
| 109 | // VBScript + ActiveX fallback for IE5+ |
||
| 110 | var IE_SaveFile = (function() { try { |
||
| 111 | if(typeof IE_SaveFile_Impl == "undefined") document.write([ |
||
| 112 | '<script type="text/vbscript" language="vbscript">', |
||
| 113 | 'IE_GetProfileAndPath_Key = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\"', |
||
| 114 | 'Function IE_GetProfileAndPath(key): Set wshell = CreateObject("WScript.Shell"): IE_GetProfileAndPath = wshell.RegRead(IE_GetProfileAndPath_Key & key): IE_GetProfileAndPath = wshell.ExpandEnvironmentStrings("%USERPROFILE%") & "!" & IE_GetProfileAndPath: End Function', |
||
| 115 | 'Function IE_SaveFile_Impl(FileName, payload): Dim data, plen, i, bit: data = CStr(payload): plen = Len(data): Set fso = CreateObject("Scripting.FileSystemObject"): fso.CreateTextFile FileName, True: Set f = fso.GetFile(FileName): Set stream = f.OpenAsTextStream(2, 0): For i = 1 To plen Step 3: bit = Mid(data, i, 2): stream.write Chr(CLng("&h" & bit)): Next: stream.Close: IE_SaveFile_Impl = True: End Function', |
||
| 116 | '|/script>'.replace("|","<") |
||
| 117 | ].join("\r\n")); |
||
| 118 | if(typeof IE_SaveFile_Impl == "undefined") return void 0; |
||
|
0 ignored issues
–
show
|
|||
| 119 | var IE_GetPath = (function() { |
||
| 120 | var DDP1 = ""; |
||
| 121 | try { DDP1 = IE_GetProfileAndPath("{374DE290-123F-4565-9164-39C4925E467B}"); } catch(e) { try { DDP1 = IE_GetProfileAndPath("Personal"); } catch(e) { try { DDP1 = IE_GetProfileAndPath("Desktop"); } catch(e) { throw e; }}} |
||
| 122 | var o = DDP1.split("!"); |
||
| 123 | DDP = o[1].replace("%USERPROFILE%", o[0]); |
||
|
0 ignored issues
–
show
|
|||
| 124 | return function(path) { return DDP + "\\" + path; }; |
||
| 125 | })(); |
||
| 126 | function fix_data(data) { |
||
|
0 ignored issues
–
show
|
|||
| 127 | var out = []; |
||
| 128 | var T = typeof data == "string"; |
||
| 129 | for(var i = 0; i < data.length; ++i) out.push(("00"+(T ? data.charCodeAt(i) : data[i]).toString(16)).slice(-2)); |
||
| 130 | var o = out.join("|"); |
||
| 131 | return o; |
||
| 132 | } |
||
| 133 | return function(data, filename) { return IE_SaveFile_Impl(IE_GetPath(filename), fix_data(data)); }; |
||
| 134 | } catch(e) { return void 0; }})(); |
||
|
0 ignored issues
–
show
|
|||
| 135 | var IE_LoadFile = (function() { try { |
||
| 136 | if(typeof IE_LoadFile_Impl == "undefined") document.write([ |
||
| 137 | '<script type="text/vbscript" language="vbscript">', |
||
| 138 | 'Function IE_LoadFile_Impl(FileName): Dim out(), plen, i, cc: Set fso = CreateObject("Scripting.FileSystemObject"): Set f = fso.GetFile(FileName): Set stream = f.OpenAsTextStream(1, 0): plen = f.Size: ReDim out(plen): For i = 1 To plen Step 1: cc = Hex(Asc(stream.read(1))): If Len(cc) < 2 Then: cc = "0" & cc: End If: out(i) = cc: Next: IE_LoadFile_Impl = Join(out,""): End Function', |
||
| 139 | '|/script>'.replace("|","<") |
||
| 140 | ].join("\r\n")); |
||
| 141 | if(typeof IE_LoadFile_Impl == "undefined") return void 0; |
||
|
0 ignored issues
–
show
|
|||
| 142 | function fix_data(data) { |
||
|
0 ignored issues
–
show
|
|||
| 143 | var out = []; |
||
| 144 | for(var i = 0; i < data.length; i+=2) out.push(String.fromCharCode(parseInt(data.slice(i, i+2), 16))); |
||
| 145 | var o = out.join(""); |
||
| 146 | return o; |
||
| 147 | } |
||
| 148 | return function(filename) { return fix_data(IE_LoadFile_Impl(filename)); }; |
||
| 149 | } catch(e) { return void 0; }})(); |
||
|
0 ignored issues
–
show
|
|||
| 150 | |||
| 151 | // getComputedStyle polyfill from https://gist.github.com/8HNHoFtE/5891086 |
||
| 152 | if(typeof window !== 'undefined' && typeof window.getComputedStyle !== 'function') { |
||
| 153 | window.getComputedStyle = function(e,t){return this.el=e,this.getPropertyValue=function(t){var n=/(\-([a-z]){1})/g;return t=="float"&&(t="styleFloat"),n.test(t)&&(t=t.replace(n,function(){return arguments[2].toUpperCase()})),e.currentStyle[t]?e.currentStyle[t]:null},this} |
||
|
0 ignored issues
–
show
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. Loading history...
|
|||
| 154 | } |
||
| 155 |