Skip to content

Commit aa59627

Browse files
committed
Run code through prettier
1 parent 5a835c2 commit aa59627

File tree

7 files changed

+464
-323
lines changed

7 files changed

+464
-323
lines changed

bg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function bgResize() {
3232
if (shift < 0) shift = 0;
3333
bgCanvas.style.top = -shift + 'px';
3434
bgCanvas.style.left = 0;
35-
} else {
35+
} else {
3636
bgCanvas.style.width = 'auto';
3737
bgCanvas.style.height = window.innerHeight + 'px';
3838
var width = bgCanvas.offsetWidth;

hold.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ function Hold() {
44
Hold.prototype.draw = function() {
55
clear(holdCtx);
66
if (this.piece === 0 || this.piece === 3) {
7-
draw(pieces[this.piece].tetro, pieces[this.piece].x - 3,
8-
2 + pieces[this.piece].y, holdCtx);
7+
draw(
8+
pieces[this.piece].tetro,
9+
pieces[this.piece].x - 3,
10+
2 + pieces[this.piece].y,
11+
holdCtx,
12+
);
913
} else {
10-
draw(pieces[this.piece].tetro, pieces[this.piece].x - 2.5,
11-
2 + pieces[this.piece].y, holdCtx);
14+
draw(
15+
pieces[this.piece].tetro,
16+
pieces[this.piece].x - 2.5,
17+
2 + pieces[this.piece].y,
18+
holdCtx,
19+
);
1220
}
13-
}
21+
};
1422
var hold = new Hold();

menu.js

Lines changed: 126 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,102 @@ var arrowReleased = true;
44
var arrowDelay = 0;
55

66
var key = {
7-
8: 'Backspace', 9: 'Tab', 13: 'Enter', 16: 'Shift',
8-
17: 'Ctrl', 18: 'Alt', 19: 'Pause', 20: 'Caps Lock',
9-
27: 'Esc', 32: 'Space', 33: 'PgUp', 34: 'PgDn',
10-
35: 'End', 36: 'Home', 37: '←', 38: '↑',
11-
39: '→', 40: '↓', 45: 'Insert', 46: 'Delete',
12-
48: '0', 49: '1', 50: '2', 51: '3',
13-
52: '4', 53: '5', 54: '6', 55: '7',
14-
56: '8', 57: '9', 59: ';', 61: '=',
15-
65: 'A', 66: 'B', 67: 'C', 68: 'D',
16-
69: 'E', 70: 'F', 71: 'G', 72: 'H',
17-
73: 'I', 74: 'J', 75: 'K', 76: 'L',
18-
77: 'M', 78: 'N', 79: 'O', 80: 'P',
19-
81: 'Q', 82: 'R', 83: 'S', 84: 'T',
20-
85: 'U', 86: 'V', 87: 'W', 88: 'X',
21-
89: 'Y', 90: 'Z', 96: '0kpad', 97: '1kpad',
22-
98: '2kpad', 99: '3kpad', 100: '4kpad', 101: '5kpad',
23-
102: '6kpad', 103: '7kpad', 104: '8kpad', 105: '9kpad',
24-
106: '*', 107: '+', 109: '-', 110: '.',
25-
111: '/', 112: 'F1', 113: 'F2', 114: 'F3',
26-
115: 'F4', 116: 'F5', 117: 'F6', 118: 'F7',
27-
119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11',
28-
123: 'F12', 173: '-', 187: '=', 188: ',',
29-
190: '.', 191: '/', 192: '`', 219: '[',
30-
220: '\\', 221: ']', 222: "'"
31-
}
7+
8: 'Backspace',
8+
9: 'Tab',
9+
13: 'Enter',
10+
16: 'Shift',
11+
17: 'Ctrl',
12+
18: 'Alt',
13+
19: 'Pause',
14+
20: 'Caps Lock',
15+
27: 'Esc',
16+
32: 'Space',
17+
33: 'PgUp',
18+
34: 'PgDn',
19+
35: 'End',
20+
36: 'Home',
21+
37: '←',
22+
38: '↑',
23+
39: '→',
24+
40: '↓',
25+
45: 'Insert',
26+
46: 'Delete',
27+
48: '0',
28+
49: '1',
29+
50: '2',
30+
51: '3',
31+
52: '4',
32+
53: '5',
33+
54: '6',
34+
55: '7',
35+
56: '8',
36+
57: '9',
37+
59: ';',
38+
61: '=',
39+
65: 'A',
40+
66: 'B',
41+
67: 'C',
42+
68: 'D',
43+
69: 'E',
44+
70: 'F',
45+
71: 'G',
46+
72: 'H',
47+
73: 'I',
48+
74: 'J',
49+
75: 'K',
50+
76: 'L',
51+
77: 'M',
52+
78: 'N',
53+
79: 'O',
54+
80: 'P',
55+
81: 'Q',
56+
82: 'R',
57+
83: 'S',
58+
84: 'T',
59+
85: 'U',
60+
86: 'V',
61+
87: 'W',
62+
88: 'X',
63+
89: 'Y',
64+
90: 'Z',
65+
96: '0kpad',
66+
97: '1kpad',
67+
98: '2kpad',
68+
99: '3kpad',
69+
100: '4kpad',
70+
101: '5kpad',
71+
102: '6kpad',
72+
103: '7kpad',
73+
104: '8kpad',
74+
105: '9kpad',
75+
106: '*',
76+
107: '+',
77+
109: '-',
78+
110: '.',
79+
111: '/',
80+
112: 'F1',
81+
113: 'F2',
82+
114: 'F3',
83+
115: 'F4',
84+
116: 'F5',
85+
117: 'F6',
86+
118: 'F7',
87+
119: 'F8',
88+
120: 'F9',
89+
121: 'F10',
90+
122: 'F11',
91+
123: 'F12',
92+
173: '-',
93+
187: '=',
94+
188: ',',
95+
190: '.',
96+
191: '/',
97+
192: '`',
98+
219: '[',
99+
220: '\\',
100+
221: ']',
101+
222: "'",
102+
};
32103

33104
/**
34105
* Show and hide menus.
@@ -38,8 +109,7 @@ function menu(menuIndex) {
38109
for (var i = 0, len = menus.length; i < len; i++) {
39110
menus[i].classList.remove('on');
40111
}
41-
if (menuIndex !== void 0)
42-
menus[menuIndex].classList.add('on');
112+
if (menuIndex !== void 0) menus[menuIndex].classList.add('on');
43113
}
44114

45115
/**
@@ -63,37 +133,41 @@ for (var i = 0, len = controlCells.length; i < len; i++) {
63133
tempKey = binds[this.id];
64134
this.innerHTML = 'Press key';
65135
currCell = this;
66-
}
136+
};
67137
}
68138
// Listen for key input if a control has been clicked on.
69-
addEventListener('keyup', function(e) {
70-
// if click outside of cell or press esc clear currCell
71-
// reset binds button.
72-
if (currCell) {
73-
// Checks if key already in use, and unbinds it.
74-
for (var i in binds) {
75-
if (e.keyCode === binds[i]) {
76-
binds[i] = void 0;
77-
document.getElementById(i).innerHTML = binds[i];
139+
addEventListener(
140+
'keyup',
141+
function(e) {
142+
// if click outside of cell or press esc clear currCell
143+
// reset binds button.
144+
if (currCell) {
145+
// Checks if key already in use, and unbinds it.
146+
for (var i in binds) {
147+
if (e.keyCode === binds[i]) {
148+
binds[i] = void 0;
149+
document.getElementById(i).innerHTML = binds[i];
150+
}
78151
}
152+
// Binds the key and saves the data.
153+
binds[currCell.id] = e.keyCode;
154+
currCell.innerHTML = key[e.keyCode];
155+
localStorage.setItem('binds', JSON.stringify(binds));
156+
currCell = 0;
79157
}
80-
// Binds the key and saves the data.
81-
binds[currCell.id] = e.keyCode;
82-
currCell.innerHTML = key[e.keyCode];
83-
localStorage.setItem('binds', JSON.stringify(binds));
84-
currCell = 0;
85-
}
86-
}, false);
158+
},
159+
false,
160+
);
87161

88162
/**
89163
* Settings Menu
90164
*/
91165
function settingsLoop() {
92166
if (arrowReleased || arrowDelay >= 6) {
93167
if (settingsArrow)
94-
settings[s] = (settings[s] === 0) ? setting[s].length - 1 : settings[s] - 1;
168+
settings[s] = settings[s] === 0 ? setting[s].length - 1 : settings[s] - 1;
95169
else
96-
settings[s] = (settings[s] === setting[s].length - 1) ? 0 : settings[s] + 1;
170+
settings[s] = settings[s] === setting[s].length - 1 ? 0 : settings[s] + 1;
97171
saveSetting(s);
98172
arrowReleased = false;
99173
} else {
@@ -105,10 +179,10 @@ var s;
105179
var settingsArrow;
106180
// TODO DRY this.
107181
function arrowRelease() {
108-
resize();
109-
arrowReleased = true;
110-
arrowDelay = 0;
111-
clearTimeout(setLoop)
182+
resize();
183+
arrowReleased = true;
184+
arrowDelay = 0;
185+
clearTimeout(setLoop);
112186
}
113187
function left() {
114188
settingsArrow = 1;
@@ -131,9 +205,8 @@ function right() {
131205
function saveSetting(s) {
132206
localStorage['version'] = version;
133207

134-
document.getElementById(s)
135-
.getElementsByTagName('span')[0]
136-
.innerHTML = setting[s][settings[s]];
208+
document.getElementById(s).getElementsByTagName('span')[0].innerHTML =
209+
setting[s][settings[s]];
137210

138211
localStorage['settings'] = JSON.stringify(settings);
139212
}

0 commit comments

Comments
 (0)