diff --git a/luciexpress/Gruntfile.js b/luciexpress/Gruntfile.js index f4f687eaa..a9c6f0ca4 100644 --- a/luciexpress/Gruntfile.js +++ b/luciexpress/Gruntfile.js @@ -119,6 +119,7 @@ module.exports = function(grunt){ "htdocs/lib/js/angular-checklist-model.js" ]; var appfiles = [ + "htdocs/js/compat.js", "htdocs/js/rpc.js", "htdocs/js/uci.js", "htdocs/js/juci.js", diff --git a/luciexpress/htdocs/js/app.js b/luciexpress/htdocs/js/app.js index 6f60036d8..426f3d79e 100644 --- a/luciexpress/htdocs/js/app.js +++ b/luciexpress/htdocs/js/app.js @@ -17,30 +17,6 @@ require.config({ }); -Object.assign = Object.assign || function (target, source) { - function ToObject(val) { - if (val == null) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); - } - - var from; - var keys; - var to = ToObject(target); - - for (var s = 1; s < arguments.length; s++) { - from = arguments[s]; - keys = Object.keys(Object(from)); - - for (var i = 0; i < keys.length; i++) { - to[keys[i]] = from[keys[i]]; - } - } - - return to; -}; JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $urlRouterProvider, $controllerProvider, $templateCacheProvider, $provide) { console.log("CONF"); diff --git a/luciexpress/htdocs/js/compat.js b/luciexpress/htdocs/js/compat.js new file mode 100644 index 000000000..7d85979c3 --- /dev/null +++ b/luciexpress/htdocs/js/compat.js @@ -0,0 +1,53 @@ +//! Author: Martin K. Schröder + +// Browser compatibility code + +if(!Object.prototype.assign){ + Object.prototype.assign = function (target, source) { + function ToObject(val) { + if (val == null) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); + } + + var from; + var keys; + var to = ToObject(target); + + for (var s = 1; s < arguments.length; s++) { + from = arguments[s]; + keys = Object.keys(Object(from)); + + for (var i = 0; i < keys.length; i++) { + to[keys[i]] = from[keys[i]]; + } + } + + return to; + }; +} + +if (!Array.prototype.find) { + Array.prototype.find = function(predicate) { + if (this == null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + }; +}