-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (29 loc) · 781 Bytes
/
script.js
File metadata and controls
33 lines (29 loc) · 781 Bytes
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
/**
* Created by Simon on 22/02/2006.
* scripts test
*/
var size = 3;
var myCube = new Cube(size);
var varname = 'myCube'
var myIds = Cube.ids('my-cube', 'my-moves', 'my-nshuf', 'my-txtmov');
myCube.refresh(myIds.cube, myIds.moves);
document.getElementById('my-ctrl').innerHTML = Cube.movesCtrlHTML(varname, myIds) + Cube.playCtrlHTML(varname, myIds);
var moveKeys = {
66: "B",
70: "F",
82: "R",
76: "L",
68: "D",
85: "U"
}
document.addEventListener('keydown', function(e) {
var key = moveKeys[e.keyCode];
if (key != undefined) {
if (e.shiftKey)
key += e.ctrlKey ? "2" : "'";
else if (e.ctrlKey)
return false;
myCube.move(key).refresh('my-cube', 'my-moves');
}
return false;
}, false);