forked from AshleyF/briefcubing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
435 lines (417 loc) · 25.3 KB
/
Copy pathindex.html
File metadata and controls
435 lines (417 loc) · 25.3 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<!DOCTYPE html>
<html lang="en">
<head>
<title>Brief Cubing</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-75630988-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-75630988-2');
</script>
<meta charset="UTF-8">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery/jquery.mobile-1.4.5.min.css" />
<link rel="stylesheet" href="theme-classic.css" />
<link rel="stylesheet" href="spectrum/spectrum.css" />
<link rel="stylesheet" href="styles.css" />
<script src="jquery/jquery-1.11.1.min.js"></script>
<script src="jquery/jquery.mobile-1.4.5.min.js"></script>
<script src="cube.js"></script>
<script src="display.js"></script>
<script src="lzstring.js"></script>
<script src="btcube.js"></script>
<script src="settings.js"></script>
<script src="algs.js"></script>
<script src="localization.js"></script>
<script src="ui.js"></script>
<script src="nosleep.min.js"></script>
<script src="spectrum/spectrum.js"></script>
<script>
var nosleep = new NoSleep();
function allowSleep(allow) {
if (allow || Settings.values.allowSleep) {
nosleep.disable();
} else {
nosleep.enable();
}
}
$(window).resize(setMainHeightToFit);
function setMainHeightToFit() {
var screenHeight = $.mobile.getScreenHeight();
var header = $(".ui-header").hasClass("ui-header-fixed") ? $(".ui-header").outerHeight() - 1 : $(".ui-header").outerHeight();
var footer = $(".ui-footer").hasClass("ui-footer-fixed") ? $(".ui-footer").outerHeight() - 1 : $(".ui-footer").outerHeight();
var contentHeight = $(".ui-content").outerHeight() - $(".ui-content").height();
var content = screenHeight - header - footer - contentHeight;
$(".ui-content").height(content);
}
$(document).on("pagecreate", "#main", function() {
buildAlgOptions();
$("#colorSchemeU").spectrum({
showButtons: false,
containerClassName: "spectrum-container",
replacerClassName: "spectrum-replacer",
change: function(c) { setColorScheme("colorSchemeU", c.toHexString()); } });
$("#colorSchemeD").spectrum({
showButtons: false,
containerClassName: "spectrum-container",
replacerClassName: "spectrum-replacer",
change: function(c) { setColorScheme("colorSchemeD", c.toHexString()); } });
$("#colorSchemeL").spectrum({
showButtons: false,
containerClassName: "spectrum-container",
replacerClassName: "spectrum-replacer",
change: function(c) { setColorScheme("colorSchemeL", c.toHexString()); } });
$("#colorSchemeR").spectrum({
showButtons: false,
containerClassName: "spectrum-container",
replacerClassName: "spectrum-replacer",
change: function(c) { setColorScheme("colorSchemeR", c.toHexString()); } });
$("#colorSchemeF").spectrum({
showButtons: false,
containerClassName: "spectrum-container",
replacerClassName: "spectrum-replacer",
change: function(c) { setColorScheme("colorSchemeF", c.toHexString()); } });
$("#colorSchemeB").spectrum({
showButtons: false,
containerClassName: "spectrum-container",
replacerClassName: "spectrum-replacer",
change: function(c) { setColorScheme("colorSchemeB", c.toHexString()); } });
});
$(document).on("pagebeforeshow", "#main", function(event) {
localize();
setMainHeightToFit();
if (!BtCube.connected()) Ui.showConnectButton();
Ui.next();
$("#cube").bind("click", Ui.adjustAUF);
});
$(document).on("panelbeforeopen", "#options", function() {
settingsToUi();
});
var colors = ["yellow", "white", "blue", "green", "red", "orange"];
function settingsToUi() {
algIndex = 0;
$("#auf").prop('value', Settings.values.randomAuf ? "on" : "off").slider('refresh');
$("#order").prop('value', Settings.values.randomOrder ? "on" : "off").slider('refresh');
$("#simple").prop('value', Settings.values.simpleDiagram ? "on" : "off").slider('refresh');
$("#llHide").prop('value', Settings.values.llHide).selectmenu("refresh");
for (var c in Settings.values.upColors) {
$('#' + c).prop('checked', Settings.values.upColors[c]).checkboxradio('refresh');
}
for (var i = 0; i < colors.length; i++) {
$('#' + colors[i] + "Swatch").css("backgroundColor", Display.faceToCssColor("UDLRFB"[i]));
}
for (var a in Settings.values.algs) {
var id = Settings.values.algs[a];
$('#' + id).prop('checked', true).checkboxradio('refresh');
}
var htm = "";
for (var l in Localization.langs) {
var lang = Localization.langs[l];
var chosen = Settings.values.lang || "en";
htm += '<option id="lang_' + l + '" value="' + l + '"' + (chosen == l ? ' selected="selected"' : '') + '>' + Localization.getString("lang_" + l) + '</option>';
}
var timeout = Settings.values.timeout;
$("#timeout").prop('value', timeout).slider('refresh');
$("#allowSleep").prop('value', Settings.values.allowSleep ? "on" : "off").slider('refresh');
document.getElementById("timeout_value").innerText = timeout == 10.5 ? '∞' : timeout;
document.getElementById("language").innerHTML = htm;
$("#language").selectmenu("refresh");
$("#colorSchemeU").spectrum("set", Display.faceToCssColor("U"));
$("#colorSchemeD").spectrum("set", Display.faceToCssColor("D"));
$("#colorSchemeL").spectrum("set", Display.faceToCssColor("L"));
$("#colorSchemeR").spectrum("set", Display.faceToCssColor("R"));
$("#colorSchemeF").spectrum("set", Display.faceToCssColor("F"));
$("#colorSchemeB").spectrum("set", Display.faceToCssColor("B"));
settingsUpdate(); // consistency checks
}
function settingsUpdate() {
Settings.values.randomAuf = document.getElementById("auf").value == "on";
Settings.values.randomOrder = document.getElementById("order").value == "on";
Settings.values.simpleDiagram = document.getElementById("simple").value == "on";
Settings.values.llHide = $("#llHide option:selected").val();
var upcols = Settings.values.upColors;
for (var c in colors) {
var col = colors[c];
upcols[col] = document.getElementById(col).checked;
}
if (!upcols.yellow && !upcols.white && !upcols.red && !upcols.orange && !upcols.green && !upcols.blue) {
$("#yellow").prop('checked', true).checkboxradio('refresh'); // default
upcols.yellow = true;
}
Settings.values.algs = [];
for (var s in Algs.sets) {
var set = Algs.sets[s];
var some = false;
var all = true;
for (var a in set.algs) {
var id = s + '_' + set.algs[a].id;
var cb = document.getElementById(id);
if (cb && cb.checked) {
some = true;
Settings.values.algs.push(id);
} else {
all = false;
}
}
$('#' + s).prop('checked', all).checkboxradio('refresh');
document.getElementById(s + "_title").style.color = (some ? "#6ad" : "white");
}
Settings.values.timeout = document.getElementById("timeout").value;
document.getElementById("timeout_value").innerText = Settings.values.timeout == 10.5 ? '∞' : Settings.values.timeout;
Settings.values.allowSleep = document.getElementById("allowSleep").value == "on";
Settings.values.lang = $("#language option:selected").val();
Settings.save();
Ui.next();
}
function localize() {
$("#drills").text(Localization.getString("briefDrills"));
for (var l in Localization.langs) {
$("#lang_" + l).text(Localization.getString("lang_" + l));
}
for (var s in Algs.sets) {
$("#all_" + s).text(Localization.getString("allCases").replace("[ALG]", Algs.sets[s].name));
$("#info_" + s).text(Localization.getString("moreInfo"));
}
$("#auf_label").text(Localization.getString("randomAuf"));
$("#auf").next("div").children("span:nth-child(1)").text(Localization.getString("on"));
$("#auf").next("div").children("span:nth-child(2)").text(Localization.getString("off"));
$("#order_label").text(Localization.getString("randomOrder"));
$("#order").next("div").children("span:nth-child(1)").text(Localization.getString("on"));
$("#order").next("div").children("span:nth-child(2)").text(Localization.getString("off"));
$("#simple_label").text(Localization.getString("simplifiedDiagram"));
$("#hide_label").text(Localization.getString("llHide"));
$("#hide_none").text(Localization.getString("llHideNone"));
$("#hide_back").text(Localization.getString("llHideBack"));
$("#hide_back_left").text(Localization.getString("llHideBackLeft"));
$("#hide_back_right").text(Localization.getString("llHideBackRight"));
$("#llHide").selectmenu("refresh");
$("#simple").next("div").children("span:nth-child(1)").text(Localization.getString("on"));
$("#simple").next("div").children("span:nth-child(2)").text(Localization.getString("off"));
$("#timeout_label").text(Localization.getString("timeout"));
$("#allowSleep_label").text(Localization.getString("allowSleep"));
$("#allowSleep").next("div").children("span:nth-child(1)").text(Localization.getString("on"));
$("#allowSleep").next("div").children("span:nth-child(2)").text(Localization.getString("off"));
$("#upColors_label").html(Localization.getString("upColors") + ' <a href="#colorScheme" data-rel="popup" style="font-size: small; float: right">' + Localization.getString("customScheme") + '</a>');
$("#customSchemeReset").text(Localization.getString("customSchemeReset"));
$("#feedback").text(Localization.getString("feedback"));
$("#btCubeConnect").text(Localization.getString("btCubeConnect"));
$("#btCubeDisconnect").text(Localization.getString("btCubeDisconnect"));
$("#btCubeBuy").text(Localization.getString("btCubeBuy"));
$("#retry").text(Localization.getString("retry"));
$("#next").text(Localization.getString("next"));
$("#visualcube").html(Localization.getString("diagramCredit").replace("[LINK]", '<a href="http://cube.crider.co.uk/visualcube.php" target="_blank">VisualCube</a>'));
}
function localizationUpdate() {
Settings.values.lang = $("#language option:selected").val();
localize();
settingsUpdate();
}
function settingsAllCasesUpdate(name) {
var all = document.getElementById(name).checked;
var set = Algs.sets[name];
for (var a in set.algs) {
$('#' + name + '_' + set.algs[a].id).prop('checked', all).checkboxradio('refresh');
}
settingsUpdate();
}
function upColorToRot() {
var upcols = Settings.values.upColors;
if (upcols.yellow) return "";
if (upcols.white) return "x2";
if (upcols.red) return "x";
if (upcols.orange) return "x'";
if (upcols.green) return "z'";
if (upcols.blue) return "z";
}
var lastRot = undefined;
function buildAlgOptions() {
var rot = upColorToRot();
if (rot == lastRot) return;
lastRot = rot;
var htm = "";
for (var s in Algs.sets) {
var set = Algs.sets[s];
htm += '<div id="cmllFieldset" data-role="collapsible"><h3><span id="' + s + '_title">' + set.name + '</span></h3>';
htm += '<input id="' + s + '" type="checkbox" onchange="settingsAllCasesUpdate(\'' + s + '\')" data-mini="true" /><label id="all_' + s + '" for="' + s + '">' + Localization.getString("allCases").replace("[ALG]", set.name) + '</label>';
htm += '<fieldset data-role="controlgroup" data-type="horizontal">';
for (var a in set.algs) {
var alg = set.algs[a];
var id = s + '_' + alg.id;
var auf = Settings.values.algAufPrefs[id] || "";
var diag = Display.diagramAlg(rot, auf, alg, "5.1em");
htm += '<input id="' + id + '" type="checkbox" onchange="settingsUpdate()" data-mini="true" /><label for="' + id + '"><span id="diag_' + id + '">' + diag + '</span></label>';
}
htm += '</fieldset>';
htm += '<a id="info_' + s + '" target="_blank" href="' + set.source + '">' + Localization.getString("moreInfo") + '</a>';
htm += '</div>';
}
document.getElementById("algs").innerHTML = htm;
$("#options").trigger("create");
}
function updateAlgColors() {
var rot = upColorToRot();
for (var s in Algs.sets) {
var set = Algs.sets[s];
for (var a in set.algs) {
var alg = set.algs[a];
var algId = s + '_' + alg.id;
var id = "diag_" + algId;
var auf = Settings.values.algAufPrefs[algId] || "";
var diag = Display.diagramAlg(rot, auf, alg, "5.1em");
document.getElementById(id).innerHTML = diag;
}
}
}
function setColorScheme(id, color) {
Settings.values[id] = color;
settingsToUi();
updateAlgColors();
}
function resetColorScheme() {
Settings.values.colorSchemeU = "#EF0";
Settings.values.colorSchemeD = "#FFF";
Settings.values.colorSchemeL = "#08F";
Settings.values.colorSchemeR = "#0C0";
Settings.values.colorSchemeF = "#F10";
Settings.values.colorSchemeB = "#F90";
settingsToUi();
updateAlgColors();
}
</script>
</head>
<body>
<div id="main" data-role="page">
<div data-role="header" style="height:40px">
<a href="#options" style="padding: 3px 6px 0 6px; margin: 2px; border: 0">
<img src="hamburger.svg" width="22px" height="22px" />
</a>
<h1><img src="logo_transparent.png" width="22px" height="22px" style="vertical-align: middle; margin-top: -7px" /> <span id="drills"></span></h1>
</div>
<div id="diagram" role="main" class="ui-content" style="margin-left: -16px">
<div id="btCube" style="margin-top: -30px; margin-bottom: -20px">
<button id="btCubeConnect" onclick="Ui.btCubeConnect()" class="ui-btn ui-mini"></button>
<a id="btCubeBuy" target="_blank" href="https://amzn.to/2DVcCnV" style="padding-left: 20px"></a>
</div>
<h1 id="status" style="text-align: center; width: 100%; overflow: hidden; margin-bottom: 80px" style="display: none"></h1>
<div id="cube" style="text-align: center; margin-top: -80px;"></div>
<div id="message" style="text-align: center; margin-top: -3em"></div>
</div>
<div data-role="footer" data-position="fixed" style="height:52px">
<button id="retry" onclick="Ui.retry()" class="ui-btn-left ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-left ui-icon-refresh"></button>
<button id="next" onclick="Ui.next()" class="ui-btn-right ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-right ui-icon-carat-r"></button>
</div>
<div id="options" data-role="panel" data-display="overlay">
<div id="btCubeDisconnectSection" style="display:none">
<button id="btCubeDisconnect" onclick="allowSleep(true); Ui.btCubeDisconnect()" class="ui-btn ui-mini" data-mini="true"></button>
<hr />
</div>
<fieldset id="upColors" data-role="controlgroup" data-type="horizontal">
<legend id="upColors_label"></legend>
<input id="yellow" type="checkbox" value="yellow" onchange="settingsUpdate(); updateAlgColors()" data-mini="true" /><label for="yellow"><span id="yellowSwatch" class="swatch"></span></label>
<input id="white" type="checkbox" value="white" onchange="settingsUpdate(); updateAlgColors()" data-mini="true" /><label for="white"><span id="whiteSwatch" class="swatch"></span></label>
<input id="red" type="checkbox" value="red" onchange="settingsUpdate(); updateAlgColors()" data-mini="true" /><label for="red"><span id="redSwatch" class="swatch"></span></label>
<input id="orange" type="checkbox" value="orange" onchange="settingsUpdate(); updateAlgColors()" data-mini="true" /><label for="orange"><span id="orangeSwatch" class="swatch"></span></label>
<input id="green" type="checkbox" value="green" onchange="settingsUpdate(); updateAlgColors()" data-mini="true" /><label for="green"><span id="greenSwatch" class="swatch"></span></label>
<input id="blue" type="checkbox" value="blue" onchange="settingsUpdate(); updateAlgColors()" data-mini="true" /><label for="blue"><span id="blueSwatch" class="swatch"></span></label>
</fieldset>
<div id="algs" data-role="collapsibleset" data-mini="true"></div>
<label id="auf_label" for="auf"></label>
<select id="auf" data-role="slider" data-mini="true" onchange="settingsUpdate()">
<option value="off"></option>
<option value="on"></option>
</select>
<label id="order_label" for="order"></label>
<select id="order" data-role="slider" data-mini="true" onchange="settingsUpdate()">
<option value="off"></option>
<option value="on"></option>
</select>
<label id="simple_label" for="simple"></label>
<select id="simple" data-role="slider" data-mini="true" onchange="settingsUpdate()">
<option value="off"></option>
<option value="on"></option>
</select>
<label id="hide_label" for="llHide"></label>
<select name="llHide" id="llHide" onchange="settingsUpdate()">
<option id="hide_none" value="show_all" selected="selected"></option>
<option id="hide_back" value="hide_back"></option>
<option id="hide_back_left" value="hide_back_left"></option>
<option id="hide_back_right" value="hide_back_right"></option>
</select>
<label id="timeout_label" for="timeout"></label>
<span style="font-weight: bold; padding: 0.5em; float: left" id="timeout_value">10</span>
<input style="display: none" type="range" name="timeout" id="timeout" min="0.5" max="10.5" step=".5" value="3" data-highlight="true" onchange="settingsUpdate()">
<label id="allowSleep_label" for="allowSleep"></label>
<select id="allowSleep" data-role="slider" data-mini="true" onchange="settingsUpdate()">
<option value="off"></option>
<option value="on"></option>
</select>
<div class="ui-field-contain">
<select name="language" id="language" data-mini="true" onchange="localizationUpdate()">
</select>
</div>
<a id="feedback" href="mailto:feedback@briefcubing.com?Subject=Feedback%20%28v0.1.6%29%0A"></a>
<p style="font-size: xx-small; text-align: right">v0.1.6 © <a href="https://github.com/AshleyF/briefcubing" target="_blank">Ashley Nathan Feniello</a> </p>
<p id="visualcube" style="font-size: xx-small; text-align: right"></p>
</div>
<div id="colorScheme" data-role="popup" data-transition="pop">
<div style="padding: 1em">
<table>
<tr>
<td></td>
<td>
<input id="colorSchemeU" type="text" class="spectrum" />
</td>
<td></td>
</tr>
<tr>
<td>
<input id="colorSchemeL" type="text" class="spectrum" />
</td>
<td>
<input id="colorSchemeF" type="text" class="spectrum" />
</td>
<td>
<input id="colorSchemeR" type="text" class="spectrum" />
</td>
</tr>
<tr>
<td></td>
<td>
<input id="colorSchemeD" type="text" class="spectrum" />
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input id="colorSchemeB" type="text" class="spectrum" />
</td>
<td></td>
</tr>
</table>
<br />
<a id="customSchemeReset" href="javascript:resetColorScheme()" style="font-size: small"></a>
</div>
</div>
<div id="bluetooth-help" data-role="popup" data-transition="pop">
<div style="padding: 1em">
<h1 id="btError"></h1>
<p id="btSupport"></p>
<ul>
<li id="btAndroid"></li>
<li id="btIOS"></li>
<li id="btMacOS"></li>
<li id="btLinux"></li>
<li id="btWindows"></li>
</ul>
<a id="btInfo" target="_blank" href="https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md#chrome"></a>
</div>
</div>
<div id="popup" data-role="popup" data-transition="pop" style="padding: 1em; margin-top: 1.9em; margin-left: 0.5em"></div>
</div>
</body>
</html>