diff options
| author | john.j.camilleri <john.j.camilleri@chalmers.se> | 2012-11-27 10:09:40 +0000 |
|---|---|---|
| committer | john.j.camilleri <john.j.camilleri@chalmers.se> | 2012-11-27 10:09:40 +0000 |
| commit | b3c1177f9ed5a3eaff378671fa119be1c605498e (patch) | |
| tree | 6c32e5fc86fd45b91a934b8d0fc6da2cf236ab8a /src/www/js/support.js | |
| parent | def375e58808ea431ef0d786ae0abb9de0a67155 (diff) | |
Syntax editor: improvements and fixes with grammar manager
Diffstat (limited to 'src/www/js/support.js')
| -rw-r--r-- | src/www/js/support.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/www/js/support.js b/src/www/js/support.js index eefda3f8b..47753e768 100644 --- a/src/www/js/support.js +++ b/src/www/js/support.js @@ -22,12 +22,21 @@ if(!Array.isArray) { // Create a clone of an array // http://davidwalsh.name/javascript-clone-array -// Note that iterating over an array with for...in will include "clone" as a key! -// if(!Array.clone) { -// Array.prototype.clone = function() { -// return this.slice(0); -// }; -// } +if(!Array.clone) { + Array.clone = function(arg) { + return arg.slice(0); + }; +} + +// Array Remove - By John Resig (MIT Licensed) +// http://ejohn.org/blog/javascript-array-remove/if(!Array.remove) { +if(!Array.remove) { + Array.remove = function(arg, from, to) { + var rest = arg.slice((to || from) + 1 || arg.length); + arg.length = from < 0 ? arg.length + from : from; + return arg.push.apply(arg, rest); + }; +} /* --- JSONP ---------------------------------------------------------------- */ |
