-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomLibrarySequenceGenerator.js
88 lines (77 loc) · 1.86 KB
/
RandomLibrarySequenceGenerator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function __basicloop( a, b, fn, c = 0 )
{
var i;
for (
i = a;
i < b;
i++ )
fn( i, c );
}
function __rnsg__convert( m )
{
switch ( m )
{
case 0: return __rnsg__binary(); break;
case 1: return __rnsg__integer(); break;
}
return 0;
}
function __rnsg__binary()
{
return Math.round( Math.random() );
}
function __rnsg__integer()
{
var __r0 = document.getElementById( "rnsg__integer__r0" ).value;
var __r1 = document.getElementById( "rnsg__integer__r1" ).value;
return __rnsg__integer__ranged( __r0, __r1 );
}
function __rnsg__integer__ranged( __r0, __r1 )
{
var r = Math.random();
var d = __r1 - __r0;
var m = r * d;
var k = __r0 + m;
return Math.round( k );
}
function __rnsg__click__button()
{
var seq = new Array();
var a = 0;
var b = Number( document.getElementById( "rnsg__amount" ).value );
var m = Number( document.getElementById( "rnsg__mode" ).value );
var c = Number( document.getElementById( "rnsg__codex" ).value );
var w = Number( document.getElementById( "rnsg__words" ).value );
__basicloop( a, b, loc__create );
function loc__create( i )
{
var p = __rnsg__integer__ranged( 0, w - 1 );
var __vars = {
place : p
};
__basicloop( 0, w, loc__sector, __vars );
}
function loc__sector( i, __vars )
{
var x = 0;
if ( i == __vars.place )
x = c;
else
x = __rnsg__convert( m );
seq.push( x );
}
var rnsg__string = seq.join( ", " );
var elem = document.getElementById( "rnsg__content" );
elem.innerHTML = rnsg__string;
}
function __rnsg__click__amount( e )
{
e.target.value = '';
}
function __rnsg__click__fn( m )
{
return function () {
document.getElementById( "rnsg__mode" ).value = m;
document.getElementById( "rnsg__button" ).click();
}
}