Do not add shuffle to array prototype
parent
9a4f57fa7d
commit
26240d2887
14
js/h5p.js
14
js/h5p.js
|
@ -284,17 +284,17 @@ H5P.cssLoaded = function (path) {
|
||||||
|
|
||||||
// We have several situations where we want to shuffle an array, extend array
|
// We have several situations where we want to shuffle an array, extend array
|
||||||
// to do so.
|
// to do so.
|
||||||
Array.prototype.shuffle = function() {
|
H5P.shuffleArray = function(array) {
|
||||||
var i = this.length, j, tempi, tempj;
|
var i = array.length, j, tempi, tempj;
|
||||||
if ( i === 0 ) return false;
|
if ( i === 0 ) return false;
|
||||||
while ( --i ) {
|
while ( --i ) {
|
||||||
j = Math.floor( Math.random() * ( i + 1 ) );
|
j = Math.floor( Math.random() * ( i + 1 ) );
|
||||||
tempi = this[i];
|
tempi = array[i];
|
||||||
tempj = this[j];
|
tempj = array[j];
|
||||||
this[i] = tempj;
|
array[i] = tempj;
|
||||||
this[j] = tempi;
|
array[j] = tempi;
|
||||||
}
|
}
|
||||||
return this;
|
return array;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add indexOf to browsers that lack them. (IEs)
|
// Add indexOf to browsers that lack them. (IEs)
|
||||||
|
|
Loading…
Reference in New Issue