-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
81 lines (72 loc) · 3.16 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>yard</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="yard.css">
<script src="yard.js"></script>
</head>
<body>
<script type="module">
import "https://unpkg.com/preact";
import "https://unpkg.com/prop-types/prop-types.min.js";
import {html, Component, render} from "https://unpkg.com/htm/preact/standalone.module.js";
// Меняем цвет выбранного шара или ВСЕХ шаров, если ничего не выбрано
function setHue() {
let R = Number(document.getElementById("colorR").value);
let G = Number(document.getElementById("colorG").value);
let B = Number(document.getElementById("colorB").value);
console.log(currentId, ":", R, G, B);
balls
.filter(a => currentId == null || a.id === currentId)
.map(a => [a.colorR, a.colorG, a.colorB] = [R, G, B]);
document.getElementById("colorBox").style.background = "rgb(" + R + "," + G + "," + B + ")";
}
class App extends Component {
open() {
document.getElementById("colorR").value = currentId == null ? 128 : balls[currentId].colorR;
document.getElementById("colorG").value = currentId == null ? 128 : balls[currentId].colorG;
document.getElementById("colorB").value = currentId == null ? 128 : balls[currentId].colorB;
document.querySelector("dialog").showModal();
setHue();
}
close() {
document.querySelector("dialog").close();
isModal = false;
currentId = null;
}
range() {
setHue();
}
render({page}, {todos = []}, {id = currentId}) {
return html`
<button id="actionColor" onClick=${() => this.open()}>Изменить цвет</button>
<dialog onCancel={preventDefault}>
<h2 id="colorBox">Выберите цвет</h2>
<label>R</label>
<input id="colorR" type="range" min="128" max="255" onChange=${() => this.range()}/>
<label>G</label>
<input id="colorG" type="range" min="128" max="255" onChange=${() => this.range()}/>
<label>B</label>
<input id="colorB" type="range" min="128" max="255" onChange=${() => this.range()}/>
<button type="button" onClick=${() => this.close()}>Закрыть</button>
</dialog>
`;
}
}
render(html`
<${App} page="All"/>
`, document.body);
</script>
<button></button>
<button id="actionRandom">Случайный расклад</button>
<button id="actionStop">Обнулить скорости</button>
<button id="actionPause">Пауза</button>
<label>Итерация</label>
<input type="text" id="generation" disabled>
<label>Время итерации, мс</label>
<input type="text" id="time" disabled>
<canvas id="canvas"></canvas>
</body>
</html>