-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumgen.js
49 lines (43 loc) · 1014 Bytes
/
numgen.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
function numgen() {
var startnum = document.getElementById("startnum");
var endnum = document.getElementById("endnum");
var output = document.getElementById("output");
var zeros = window.zeros;
s = parseInt(startnum.value);
e = parseInt(endnum.value);
z = parseInt(zeros.value);
output.value = "";
f = fseparator();
for (i=s; i<=e; i++) {
n = padding(i, z);
output.value = output.value + n + f;
}
}
function padding(n, p) {
len = n.toString().length;
zer = 0;
if (len < p) {
zer = p - len;
}
zstr = repeater("0", zer) + n;
return zstr;
}
function repeater(x, n) {
o = "";
for (q = 0; q < n; q++) {
o += x;
}
return o;
}
function toggle_options() {
options = document.getElementById("options_div");
if (options.style.display != "none") {
options.style.display = "none";
} else {
options.style.display = "";
}
}
function fseparator() {
fieldsep = window.fieldsep;
return fieldsep.value.replace(/\\n/g, '\n').replace(/\\t/g, '\t')
}