-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (31 loc) · 860 Bytes
/
Copy pathscript.js
File metadata and controls
34 lines (31 loc) · 860 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
34
var select = document.getElementById('level'),
slider = document.getElementById('slider'),
levels = [
function (x) { return x },
function (x) { return x + 1 },
function (x) { return 11 - x }
]
for (var i = 0, l = levels.length; i < l; ++i) {
var option = document.createElement('option')
option.setAttribute('value', i)
option.appendChild(document.createTextNode(i))
select.appendChild(option)
}
select.addEventListener('change', function () {
slider.value = 0
})
slider.addEventListener('change', function () {
slider.value = levels[select.value](+slider.value)
if (+slider.value === 10) {
[8, 9, 7, 10, 8, 9, 7, 10].reduce(function (p, c) {
return p.then(function () {
return new Promise(function (resolve) {
setTimeout(function () {
slider.value = c
resolve()
}, 250)
})
})
}, Promise.resolve())
}
})