JSFiddle - React, Tailwind, and code Playground
by nderscore
HTML
<input id="seed" type="text" />
<input id="seedbtn" type="submit" value="Set Seed" />
<br />
<textarea id="output"></textarea>
<br />
<input id="rand" type="submit" value="Generate Random" />
<input id="clear" type="submit" value="Clear" />
CSS
textarea { width: 230px; height: 200px; }
JavaScript
NotSoRandom = (function(){
var seed = +new Date(),
i = 0;
return {
seed: function(s){
var c = 0;
if(!s) s = +new Date();
seed = [].reduce.call(s + '', function(a, b){
return (a + b.charCodeAt()) ^ c++;
});
i = 0;
},
rand: function(){
return Math.abs(Math.cos(seed ^ ++i));
}
};
})();
var _ = document.getElementById.bind(document);
_('seedbtn').onclick = function(){
NotSoRandom.seed(_('seed').value);
};
_('rand').onclick = function(){
_('output').value += NotSoRandom.rand() + '\n';
};
_('clear').onclick = function(){
_('output').value = '';
};