-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (35 loc) · 1.02 KB
/
app.js
File metadata and controls
41 lines (35 loc) · 1.02 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
window.addEventListener("load", function() {
init();
});
var osName = ["Mac OS", "Windows", "Linux", "UNIX", "*BSD"];
var osIndex = 0;
var rouletteInterval;
function ssButtonAction(ssButton){
if(ssButton.textContent == 'スタート'){
rouletteInterval = setInterval(roulette, 100);
ssButton.textContent = 'ストップ';
} else if(ssButton.textContent == 'ストップ'){
ssButton.textContent = '判定中';
clearInterval(rouletteInterval);
var sleepTime = 150;
for(var i = 0; i < 20; i++){
rouletteInterval = setTimeout(roulette, sleepTime);
sleepTime = sleepTime + 100 * i;
}
setTimeout(setStart, sleepTime);
}
}
function setStart(){
document.getElementById("ssButton").textContent = 'スタート';
}
function roulette(){
document.getElementById("OS").textContent = osName[osIndex];
osIndex++;
osIndex %= osName.length;
}
function init(){
var ssButton = document.getElementById("ssButton");
ssButton.onclick = function(){
ssButtonAction(ssButton);
};
}