Randomize 'ordered list' initial state in forms

pull/1/head
yflory 4 years ago
parent f46a820ad8
commit ed28b5ec7b

@ -9,6 +9,15 @@
return Array.prototype.slice.call(A, start, end);
};
Util.shuffleArray = function (a) {
for (var i = a.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
};
Util.bake = function (f, args) {
if (typeof(args) === 'undefined') { args = []; }
if (!Array.isArray(args)) { args = [args]; }

@ -1471,6 +1471,7 @@ define([
var map = {};
var invMap = {};
var sorted = false;
Util.shuffleArray(opts.values);
var els = opts.values.map(function (data, i) {
var uid = Util.uid();
map[uid] = data;

Loading…
Cancel
Save