-
Notifications
You must be signed in to change notification settings - Fork 1
/
js.js
82 lines (71 loc) · 3.38 KB
/
js.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
function NewScramble(z0) {
var MoveNames = ["R", "R2", "R'", "F", "F2", "F'", "L", "L2", "L'", "B", "B2", "B'", "U", "U2", "U'", "D", "D2", "D'"];
var MoveNamesWCA;
if ("White" == "Yellow") {
MoveNamesWCA = ["R", "R2", "R'", "F", "F2", "F'", "L", "L2", "L'", "B", "B2", "B'", "U", "U2", "U'", "D", "D2", "D'"];
} else {
MoveNamesWCA = ["R", "R2", "R'", "B", "B2", "B'", "L", "L2", "L'", "F", "F2", "F'", "D", "D2", "D'", "U", "U2", "U'"];
}
var Level = document.getElementById("Level").value;
var RandomScramble = Scrambles[Level - 1][Math.floor(Math.random() * 1000)];
var TextScramble = "";
var TextScrambleWithSpaces = "";
document.getElementById("Output").innerHTML = "";
for (var A = 0; A < RandomScramble.length; A++) {
TextScramble += MoveNames[RandomScramble[A].charCodeAt(0) - 'A'.charCodeAt(0)];
if (A > 0) {
TextScrambleWithSpaces += " ";
}
TextScrambleWithSpaces += MoveNamesWCA[RandomScramble[A].charCodeAt(0) - 'A'.charCodeAt(0)];
}
if ("0" != "0") {
var OutputString = '';
OutputString = OutputString + '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="5" BGCOLOR="#000000">';
var TextScrambleArray = TextScrambleWithSpaces.split(" ");
for (var A = 0; A < TextScrambleArray.length + 2; A++) {
if (A % '0'.value == 0) {
OutputString = OutputString + '<TR>';
}
if (A == 0) {
OutputString = OutputString + '<TD WIDTH="124" BGCOLOR="#FFFFFF"><CENTER><IMAGE HEIGHT="124" SRC="//icon.png';
if ("White" == "Yellow") {
OutputString = OutputString + 'y24x-24';
} else {
OutputString = OutputString + 'y-24x-204';
}
OutputString = OutputString + '&alg=">';
} else if (A == TextScrambleArray.length + 1) {
OutputString = OutputString + '<TD WIDTH="124" BGCOLOR="#FFFFFF"><CENTER><IMAGE HEIGHT="124" SRC="//icon.png';
if ("White" == "Yellow") {
OutputString = OutputString + 'y24x-24';
} else {
OutputString = OutputString + 'y-24x-204';
}
OutputString = OutputString + '&alg=' + TextScramble + '">';
} else {
OutputString = OutputString + '<TD WIDTH="124" BGCOLOR="#FFFFFF"><CENTER>';
var Move = TextScrambleArray[A - 1].substring(0, 1);
var MoveVariant = TextScrambleArray[A - 1].substring(1, 2);
if (MoveVariant == "'") {
MoveVariant = 'i';
}
if (MoveVariant == '2') {
OutputString = OutputString + '<IMAGE SRC="../Images/' + Move + '.png">';
OutputString = OutputString + '<IMAGE SRC="../Images/' + Move + '.png">';
} else {
OutputString = OutputString + '<IMAGE SRC="../Images/' + Move + MoveVariant + '.png">';
}
}
}
Output(OutputString);
}
Output(TextScrambleWithSpaces + "<BR>");
}
var Output = function(z0) {
document.getElementById("Output").innerHTML = document.getElementById("Output").innerHTML + z0;
}
window.addEventListener("keypress", function onEvent(event) {
if (event.key === " ") {
NewScramble();
}
});