From b3c1177f9ed5a3eaff378671fa119be1c605498e Mon Sep 17 00:00:00 2001 From: "john.j.camilleri" Date: Tue, 27 Nov 2012 10:09:40 +0000 Subject: Syntax editor: improvements and fixes with grammar manager --- src/www/js/support.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/www/js/support.js') 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 ---------------------------------------------------------------- */ -- cgit v1.2.3