-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
126 lines (111 loc) · 3.91 KB
/
index.html
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
<!DOCTYPE html>
<!-- jquery cdn -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- jquery ui cdn -->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<!-- bootstrap4 cdn (jsはjqueryよりあとに読み込む)-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>純烈の順列</title>
<meta name="description" content="純烈の順列" />
<meta name="author" content="Jiro Shimaya" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
</head>
<body>
<div class="container">
<div class="setting"></div>
<div class="main"></div>
<div class='btn-area'></div>
<div class="supplement-area">
<br><br><br><br>
<div>写真拝借元:<a href="http://junretsu-official.com/profile.php">http://junretsu-official.com/profile.php</a></div>
<div>--------</div>
<div>更新履歴</div>
<div>2020/04/26 Webページ公開</div>
</div>
</div>
</body>
<script>
const shuffle = ([...array]) => {
for (let i = array.length - 1; i >= 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
const isSmartPhone = () => {
if (navigator.userAgent.match(/iPhone|Android.+Mobile/)) {
return true;
} else {
return false;
}
}
//ダブルタップ無効
let lastTouch = 0;
document.addEventListener('touchend', event => {
const now = window.performance.now();
if (now - lastTouch <= 500) {
event.preventDefault();
BtnArea.btnClick();
}
lastTouch = now;
}, true);
</script>
<script>
const area = $('.main');
let members = ["sakai.jpg","gogami.jpg","shirakawa.jpg","odai.jpg"]
const pict_dir = isSmartPhone() ? 'pict_light/': 'pict/'
const display = () => {
area.html('');
let randomized = shuffle(members);
for(let v of randomized){
area.append("<img width='25%' src='"+pict_dir+v+"'>");
}
BtnArea.addCount(randomized);
}
const BtnArea = (()=>{
const area = $('.btn-area');
const btn = $('<button>次の順列を表示</button>');
btn.addClass('btn btn-secondary');
area.append(btn);
btn.click(()=>{
display();
});
let displayed_junretsu = []
let goal_result = [];
let button_count = 0;
let start_time = null;
area.append('<span> 登場した順列:</span>');
const count_area = $('<span>0</span>');
area.append(count_area);
area.append('<span>種類</span>');
const addCount = junretsu => {
if(start_time === null)start_time = Date.now();
button_count += 1;
j_str = JSON.stringify(junretsu);
if(displayed_junretsu.includes(j_str) == false){
displayed_junretsu.push(j_str);
count_area.html(displayed_junretsu.length);
}
if(displayed_junretsu.length == 24){
const msec = (Date.now()-start_time)/1000;
alert("おめでとうございます。あなたは"+button_count+"回ボタンを押し、"+String(msec)+"秒かけてすべての順列を登場させました");
goal_result.push([msec,button_count]);
displayed_junretsu = []
start_time = null;
button_count = 0;
}
}
return {
addCount: addCount,
btnClick: ()=>btn.click(),
}
})();
display();
</script>