質問編集履歴
6
HTMLの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -254,6 +254,100 @@
|
|
254
254
|
|
255
255
|
})();
|
256
256
|
|
257
|
+
|
258
|
+
|
259
|
+
```HTML
|
260
|
+
|
261
|
+
コード
|
262
|
+
|
263
|
+
```ここに言語を入力
|
264
|
+
|
265
|
+
<!DOCTYPE html>
|
266
|
+
|
267
|
+
<html lang="ja">
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<head>
|
272
|
+
|
273
|
+
<meta charset="utf-8">
|
274
|
+
|
275
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
276
|
+
|
277
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
278
|
+
|
279
|
+
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
280
|
+
|
281
|
+
<title>Party Bingo!</title>
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
<!-- Bootstrap -->
|
286
|
+
|
287
|
+
<link href="asset/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet">
|
288
|
+
|
289
|
+
<link rel="stylesheet" href="asset/partybingo.css">
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
294
|
+
|
295
|
+
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
296
|
+
|
297
|
+
<!--[if lt IE 9]>
|
298
|
+
|
299
|
+
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
300
|
+
|
301
|
+
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
302
|
+
|
303
|
+
<![endif]-->
|
304
|
+
|
305
|
+
</head>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
<body>
|
310
|
+
|
311
|
+
<p>
|
312
|
+
|
313
|
+
<span id="pingo-number">00</span></p>
|
314
|
+
|
315
|
+
<div id="buttons">
|
316
|
+
|
317
|
+
<button id="start-button" class="btn btn-lg btn-default">Start</button>
|
318
|
+
|
319
|
+
<button id="reset-button" class="btn btn-lg btn-default">Reset</button>
|
320
|
+
|
321
|
+
</div>
|
322
|
+
|
323
|
+
<h3>Histories</h3>
|
324
|
+
|
325
|
+
<div id="histories" class="row histories"></div>
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
334
|
+
|
335
|
+
<script src="asset/jquery-1.11.3.min.js "></script>
|
336
|
+
|
337
|
+
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
338
|
+
|
339
|
+
<script src="asset/bootstrap-3.3.5-dist/js/bootstrap.min.js "></script>
|
340
|
+
|
341
|
+
<script src="asset/partybingo.js "></script>
|
342
|
+
|
343
|
+
</body>
|
344
|
+
|
345
|
+
</html>
|
346
|
+
|
347
|
+
```
|
348
|
+
|
349
|
+
|
350
|
+
|
257
351
|
|
258
352
|
|
259
353
|
```githubで取得したビンゴマシンのコードを改良して数字をすべて引ききったらalertを行うコードを作成しています。現在ビンゴの結果として排出されていない数がなくなった場合にalertさせようと考えているのですが全ての数字を引ききってもalertされません。条件をどのようにしたらalertされるようになりますか。
|
5
タイトル、質問文の訂正インデントの整形
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
javascript
|
1
|
+
javascriptビンゴマシン排出されていない数値の数の取得
|
test
CHANGED
@@ -4,508 +4,256 @@
|
|
4
4
|
|
5
5
|
(function(){
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
7
|
+
var pingoNumber = $('#pingo-number');
|
8
|
+
|
9
|
+
var startButton = $('#start-button');
|
10
|
+
|
11
|
+
var resetButton = $('#reset-button');
|
12
|
+
|
13
|
+
var historiesDiv = $('#histories');
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
// init histories
|
18
|
+
|
19
|
+
var toBingoString = function(n){
|
20
|
+
|
21
|
+
if(n > 9) {
|
22
|
+
|
23
|
+
return n.toString(10);
|
24
|
+
|
25
|
+
} else if (n < 0) {
|
26
|
+
|
27
|
+
return '00';
|
28
|
+
|
29
|
+
} else {
|
30
|
+
|
31
|
+
return '0' + n.toString(10);
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
};
|
36
|
+
|
37
|
+
var addHistory = function(n) {
|
38
|
+
|
39
|
+
historiesDiv.append('<div class="col-md-1"><p class="history-number">' + toBingoString(n) + '</p></div>');
|
40
|
+
|
41
|
+
};
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
// init number list and storage
|
46
|
+
|
47
|
+
var numberListAll = [];
|
48
|
+
|
49
|
+
var maxNumber = 75;
|
50
|
+
|
51
|
+
for(var num = 1; num <= maxNumber; num++) {
|
52
|
+
|
53
|
+
numberListAll.push(num);
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
var storage = localStorage;
|
60
|
+
|
61
|
+
var listKey = 'partybingo.numberlist';
|
62
|
+
|
63
|
+
var removedKey = 'partybingo.removedlist';
|
64
|
+
|
65
|
+
var setNumberList = function(a) {
|
66
|
+
|
67
|
+
storage.setItem(listKey, JSON.stringify(a));
|
68
|
+
|
69
|
+
};
|
70
|
+
|
71
|
+
var getNumberList = function() {
|
72
|
+
|
73
|
+
return JSON.parse(storage.getItem(listKey));
|
74
|
+
|
75
|
+
};
|
76
|
+
|
77
|
+
var setRemovedList = function(a) {
|
78
|
+
|
79
|
+
storage.setItem(removedKey, JSON.stringify(a));
|
80
|
+
|
81
|
+
};
|
82
|
+
|
83
|
+
var getRemovedList = function() {
|
84
|
+
|
85
|
+
return JSON.parse(storage.getItem(removedKey));
|
86
|
+
|
87
|
+
};
|
88
|
+
|
89
|
+
var resetLists = function() {
|
90
|
+
|
91
|
+
setNumberList(numberListAll.concat());
|
92
|
+
|
93
|
+
setRemovedList([]);
|
94
|
+
|
95
|
+
};
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
// create initial list or loadHistory
|
100
|
+
|
101
|
+
var loadedNumberList = getNumberList();
|
102
|
+
|
103
|
+
var loadedRemovedList = getRemovedList();
|
104
|
+
|
105
|
+
if(loadedNumberList && loadedRemovedList) {
|
106
|
+
|
107
|
+
for (var i = 0; i < loadedRemovedList.length; i++) {
|
108
|
+
|
109
|
+
addHistory(loadedRemovedList[i]);
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
} else {
|
114
|
+
|
115
|
+
resetLists();
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
// create util method
|
122
|
+
|
123
|
+
var getNumberRamdom = function(){
|
124
|
+
|
125
|
+
var numberList = getNumberList();
|
126
|
+
|
127
|
+
var i = Math.floor(Math.random() * numberList.length);
|
128
|
+
|
129
|
+
return numberList[i];
|
130
|
+
|
131
|
+
};
|
132
|
+
|
133
|
+
var removeNumberRamdom = function(){
|
134
|
+
|
135
|
+
var numberList = getNumberList();
|
136
|
+
|
137
|
+
if(numberList.length === 0) {
|
138
|
+
|
139
|
+
return -1;
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
var i = Math.floor(Math.random() * numberList.length);
|
144
|
+
|
145
|
+
var removed = numberList[i];
|
146
|
+
|
147
|
+
numberList.splice(i, 1);
|
148
|
+
|
149
|
+
setNumberList(numberList);
|
150
|
+
|
151
|
+
var removedList = getRemovedList();
|
152
|
+
|
153
|
+
removedList.push(removed);
|
154
|
+
|
155
|
+
setRemovedList(removedList);
|
156
|
+
|
157
|
+
return removed;
|
158
|
+
|
159
|
+
};
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
// init start button
|
164
|
+
|
165
|
+
var isStarted = false;
|
166
|
+
|
167
|
+
function rourletto() {
|
168
|
+
|
169
|
+
if(isStarted) {
|
170
|
+
|
171
|
+
pingoNumber.text(toBingoString(getNumberRamdom()));
|
172
|
+
|
173
|
+
setTimeout(rourletto, 60);
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
var stop = function(time) {
|
180
|
+
|
181
|
+
isStarted = false;
|
182
|
+
|
183
|
+
startButton.text('Start');
|
184
|
+
|
185
|
+
var n = removeNumberRamdom();
|
186
|
+
|
187
|
+
pingoNumber.text(toBingoString(n));
|
188
|
+
|
189
|
+
addHistory(n);
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
};
|
194
|
+
|
195
|
+
var start = function(){
|
196
|
+
|
197
|
+
isStarted = true;
|
198
|
+
|
199
|
+
startButton.text('Stop');
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
rourletto();
|
204
|
+
|
205
|
+
};
|
206
|
+
|
207
|
+
var startClicked = function(e){
|
208
|
+
|
209
|
+
if(isStarted) {
|
210
|
+
|
211
|
+
stop(null);
|
212
|
+
|
213
|
+
} else {
|
214
|
+
|
215
|
+
start();
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
};
|
220
|
+
|
221
|
+
startButton.click(startClicked); // button
|
222
|
+
|
223
|
+
startButton.focus();
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
// init reset button
|
228
|
+
|
229
|
+
var resetClicked = function() {
|
230
|
+
|
231
|
+
if (confirm('リセットしてもよろしいですか?')) {
|
232
|
+
|
233
|
+
resetLists();
|
234
|
+
|
235
|
+
pingoNumber.text('00');
|
236
|
+
|
237
|
+
historiesDiv.empty();
|
238
|
+
|
239
|
+
startButton.focus();
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
};
|
244
|
+
|
245
|
+
resetButton.click(resetClicked);
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
if (loadedNumberList.length=0) {
|
250
|
+
|
251
|
+
alert("")
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
})();
|
24
256
|
|
25
257
|
|
26
258
|
|
27
|
-
|
28
|
-
|
29
|
-
// init histories
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
var toBingoString = function(n){
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if(n > 9) {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
return n.toString(10);
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
} else if (n < 0) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
return '00';
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
} else {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
return '0' + n.toString(10);
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
};
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
var addHistory = function(n) {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
historiesDiv.append('<div class="col-md-1"><p class="history-number">' + toBingoString(n) + '</p></div>');
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
};
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
// init number list and storage
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
var numberListAll = [];
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
var maxNumber = 75;
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
for(var num = 1; num <= maxNumber; num++) {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
numberListAll.push(num);
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
var storage = localStorage;
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
var listKey = 'partybingo.numberlist';
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
var removedKey = 'partybingo.removedlist';
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
var setNumberList = function(a) {
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
storage.setItem(listKey, JSON.stringify(a));
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
};
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
var getNumberList = function() {
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
return JSON.parse(storage.getItem(listKey));
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
};
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
var setRemovedList = function(a) {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
storage.setItem(removedKey, JSON.stringify(a));
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
};
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
var getRemovedList = function() {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
return JSON.parse(storage.getItem(removedKey));
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
};
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
var resetLists = function() {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
setNumberList(numberListAll.concat());
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
setRemovedList([]);
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
};
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
// create initial list or loadHistory
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
var loadedNumberList = getNumberList();
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
var loadedRemovedList = getRemovedList();
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
if(loadedNumberList && loadedRemovedList) {
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
for (var i = 0; i < loadedRemovedList.length; i++) {
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
addHistory(loadedRemovedList[i]);
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
} else {
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
resetLists();
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
// create util method
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
var getNumberRamdom = function(){
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
var numberList = getNumberList();
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
var i = Math.floor(Math.random() * numberList.length);
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
return numberList[i];
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
};
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
var removeNumberRamdom = function(){
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
var numberList = getNumberList();
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
if(numberList.length === 0) {
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
return -1;
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
var i = Math.floor(Math.random() * numberList.length);
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
var removed = numberList[i];
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
numberList.splice(i, 1);
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
setNumberList(numberList);
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
var removedList = getRemovedList();
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
removedList.push(removed);
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
setRemovedList(removedList);
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
return removed;
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
};
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
// init start button
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
var isStarted = false;
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
function rourletto() {
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
if(isStarted) {
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
pingoNumber.text(toBingoString(getNumberRamdom()));
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
setTimeout(rourletto, 60);
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
}
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
var stop = function(time) {
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
isStarted = false;
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
startButton.text('Start');
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
var n = removeNumberRamdom();
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
pingoNumber.text(toBingoString(n));
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
addHistory(n);
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
};
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
var start = function(){
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
isStarted = true;
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
startButton.text('Stop');
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
rourletto();
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
};
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
var startClicked = function(e){
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
if(isStarted) {
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
stop(null);
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
} else {
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
start();
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
}
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
};
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
startButton.click(startClicked); // button
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
startButton.focus();
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
// init reset button
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
var resetClicked = function() {
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
if (confirm('リセットしてもよろしいですか?')) {
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
resetLists();
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
pingoNumber.text('00');
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
historiesDiv.empty();
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
drumAudio.pause();
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
startButton.focus();
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
}
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
};
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
resetButton.click(resetClicked);
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
})();
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
```
|
259
|
+
```githubで取得したビンゴマシンのコードを改良して数字をすべて引ききったらalertを行うコードを作成しています。現在ビンゴの結果として排出されていない数がなくなった場合にalertさせようと考えているのですが全ての数字を引ききってもalertされません。条件をどのようにしたらalertされるようになりますか。
|
4
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
3
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
2
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,511 @@
|
|
1
|
+
```javascript
|
2
|
+
|
3
|
+
コード
|
4
|
+
|
5
|
+
(function(){
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
var pingoNumber = $('#pingo-number');
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
var startButton = $('#start-button');
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
var resetButton = $('#reset-button');
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
var historiesDiv = $('#histories');
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
// init histories
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
var toBingoString = function(n){
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
if(n > 9) {
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
return n.toString(10);
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
} else if (n < 0) {
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
return '00';
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
} else {
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
return '0' + n.toString(10);
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
};
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
var addHistory = function(n) {
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
historiesDiv.append('<div class="col-md-1"><p class="history-number">' + toBingoString(n) + '</p></div>');
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
};
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
// init number list and storage
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
var numberListAll = [];
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
var maxNumber = 75;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
for(var num = 1; num <= maxNumber; num++) {
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
numberListAll.push(num);
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
var storage = localStorage;
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
var listKey = 'partybingo.numberlist';
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
var removedKey = 'partybingo.removedlist';
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
var setNumberList = function(a) {
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
storage.setItem(listKey, JSON.stringify(a));
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
var getNumberList = function() {
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
return JSON.parse(storage.getItem(listKey));
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
};
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
var setRemovedList = function(a) {
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
storage.setItem(removedKey, JSON.stringify(a));
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
};
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
var getRemovedList = function() {
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
return JSON.parse(storage.getItem(removedKey));
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
};
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
var resetLists = function() {
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
setNumberList(numberListAll.concat());
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
setRemovedList([]);
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
};
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
// create initial list or loadHistory
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
var loadedNumberList = getNumberList();
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
var loadedRemovedList = getRemovedList();
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
if(loadedNumberList && loadedRemovedList) {
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
for (var i = 0; i < loadedRemovedList.length; i++) {
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
addHistory(loadedRemovedList[i]);
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
} else {
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
resetLists();
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
// create util method
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
var getNumberRamdom = function(){
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
var numberList = getNumberList();
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
var i = Math.floor(Math.random() * numberList.length);
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
return numberList[i];
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
};
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
var removeNumberRamdom = function(){
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
var numberList = getNumberList();
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
if(numberList.length === 0) {
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
return -1;
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
var i = Math.floor(Math.random() * numberList.length);
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
var removed = numberList[i];
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
numberList.splice(i, 1);
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
setNumberList(numberList);
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
var removedList = getRemovedList();
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
removedList.push(removed);
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
setRemovedList(removedList);
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
return removed;
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
};
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
// init start button
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
var isStarted = false;
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
function rourletto() {
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
if(isStarted) {
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
pingoNumber.text(toBingoString(getNumberRamdom()));
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
setTimeout(rourletto, 60);
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
var stop = function(time) {
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
isStarted = false;
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
startButton.text('Start');
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
var n = removeNumberRamdom();
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
pingoNumber.text(toBingoString(n));
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
addHistory(n);
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
};
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
var start = function(){
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
isStarted = true;
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
startButton.text('Stop');
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
rourletto();
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
};
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
var startClicked = function(e){
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
if(isStarted) {
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
stop(null);
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
} else {
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
start();
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
};
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
startButton.click(startClicked); // button
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
startButton.focus();
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
// init reset button
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
var resetClicked = function() {
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
if (confirm('リセットしてもよろしいですか?')) {
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
resetLists();
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
pingoNumber.text('00');
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
historiesDiv.empty();
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
drumAudio.pause();
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
startButton.focus();
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
};
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
resetButton.click(resetClicked);
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
})();
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
1
|
-
現在githubで取得したビンゴマシンのコードを改良して数字をすべて引ききったらalertを行うコードを作成していますが、うまくいきません
|
511
|
+
```現在githubで取得したビンゴマシンのコードを改良して数字をすべて引ききったらalertを行うコードを作成していますが、うまくいきません
|