From 26240d288750ddb096f5c2b28ec63f716d98237b Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Thu, 25 Jul 2013 01:50:16 +0200 Subject: [PATCH] Do not add shuffle to array prototype --- js/h5p.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 876c975..b795f6b 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -284,17 +284,17 @@ H5P.cssLoaded = function (path) { // We have several situations where we want to shuffle an array, extend array // to do so. -Array.prototype.shuffle = function() { - var i = this.length, j, tempi, tempj; +H5P.shuffleArray = function(array) { + var i = array.length, j, tempi, tempj; if ( i === 0 ) return false; while ( --i ) { j = Math.floor( Math.random() * ( i + 1 ) ); - tempi = this[i]; - tempj = this[j]; - this[i] = tempj; - this[j] = tempi; + tempi = array[i]; + tempj = array[j]; + array[i] = tempj; + array[j] = tempi; } - return this; + return array; }; // Add indexOf to browsers that lack them. (IEs)