-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (52 loc) · 1.72 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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lights out</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
background-color: #222;
color: #eee;
font-family: Arial, Helvetica, sans-serif;
}
p {
padding: 8px 8px 2px 8px;
}
button {
width: 44px;
height: 44px;
}
</style>
<script async src="lightsout.js"></script>
<script async defer src="solver.js"></script>
</head>
<body>
<p>Mach es einfarbig!</p>
<p><button id="incr">+</button><button id="decr">−</button></p>
<lightsout-game data-width="5" data-height="5" data-states="2"></lightsout-game>
<script>
const game = document.querySelector('lightsout-game');
const incrButton = document.querySelector('#incr');
incrButton.addEventListener('click', () => {
const w = parseInt(game.getAttribute('data-width'));
game.setAttribute('data-width', w + 1);
const h = parseInt(game.getAttribute('data-height'));
game.setAttribute('data-height', h + 1);
});
const decrButton = document.querySelector('#decr');
decrButton.addEventListener('click', () => {
const w = parseInt(game.getAttribute('data-width'));
game.setAttribute('data-width', Math.max(5, w - 1));
const h = parseInt(game.getAttribute('data-height'));
game.setAttribute('data-height', Math.max(5, h - 1));
});
</script>
</body>
</html>