Skip to content
Snippets Groups Projects
Commit 91e74711 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'patch-3' into 'pregmod-master'

Add random JS functions

See merge request pregmodfan/fc-pregmod!1225
parents 1a582e88 328c6eef
No related branches found
No related tags found
No related merge requests found
...@@ -400,6 +400,26 @@ window.numberWithCommas = function(x) { ...@@ -400,6 +400,26 @@ window.numberWithCommas = function(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
} }
window.jsRandom = function(min,max) {
return Math.floor(Math.random()*(max-min+1)+min);
}
window.jsRandomMany = function (arr, count) {
var result = [];
var _tmp = arr.slice();
for (var i = 0; i < count; i++) {
var index = Math.ceil(Math.random() * 10) % _tmp.length;
result.push(_tmp.splice(index, 1)[0]);
}
return result;
}
window.jsEither = function(choices) {
var index = Math.floor(Math.random() * choices.length);
return choices[index];
}
/* /*
Make everything waiting for this execute. Usage: Make everything waiting for this execute. Usage:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment