-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayground.html
99 lines (92 loc) · 2.62 KB
/
playground.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./lib/stack-chess.css">
<script src="./lib/stack-chess.js"></script>
<title>Stack Chess</title>
</head>
<body>
<div class="board">
<div class="flip"></div>
<div class="undo"></div>
<div class="reset"></div>
</div>
<div class="sweep-box">Drag your piece here to <i>sweep</i> it!</div>
</body>
<script type="module">
const game = new StackChess;
game.setDiv(
document.querySelector(".board"),
document.querySelector(".sweep-box")
);
game.reset();
document.querySelector(".flip").addEventListener("click", () => game.flip());
document.querySelector(".undo").addEventListener("click", () => game.undo());
document.querySelector(".reset").addEventListener("click", () => game.reset());
/*let hisR = localStorage.getItem("chess_history");
let pieceR = localStorage.getItem("chess_pieces");
if (hisR) {
game.history = JSON.parse(hisR);
game.pieces = JSON.parse(pieceR);
for (let i = 0; i < 64; i++) {
const p = game.pieces[i];
for (const piece of p) {
game.__renderPut(i % 8, Math.floor(i / 8), piece.type);
}
}
} else game.reset();
setInterval(() => {
return;
localStorage.setItem("chess_history", JSON.stringify(game.history));
localStorage.setItem("chess_pieces", JSON.stringify(game.pieces));
}, 1000);*/
window.game = game;
</script>
<style>
body {
font-family: system-ui, sans-serif;
background: #2a2626;
overflow: hidden;
color: white;
}
.flip, .reset, .undo {
position: absolute;
left: 0;
top: -40px;
width: 32px;
height: 32px;
background-size: 100% 100%;
cursor: pointer;
}
.flip {
background-image: url("./assets/flip.png");
}
.reset {
left: 85px;
background-image: url("./assets/reset.png");
}
.undo {
left: 40px;
background-image: url("./assets/undo.png");
}
.flip:hover, .reset:hover, .undo:hover {
scale: 1.1;
}
.sweep-box {
position: absolute;
bottom: 20px;
left: 20px;
padding: 1%;
background: #b2afaf;
border-radius: 10px;
}
.sweep-box:hover {
background: #739552;
cursor: pointer;
}
</style>
</html>