christopher commited on
Commit
4af4cb2
·
1 Parent(s): 9b0851e

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +46 -0
index.html ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link rel="stylesheet" href="/static/chessboard-1.0.0.min.css">
5
+ <style>
6
+ body { font-family: Arial; max-width: 800px; margin: 50px auto; }
7
+ #board { width: 400px; margin: 20px 0; }
8
+ button { padding: 10px 20px; margin: 5px; cursor: pointer; }
9
+ #fen, #result { background: #f0f0f0; padding: 10px; margin: 10px 0; font-family: monospace; }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>Chess Position Search</h1>
14
+ <div id="board"></div>
15
+ <button onclick="board.start()">Reset</button>
16
+ <button onclick="board.clear()">Clear</button>
17
+ <button onclick="search()">Search</button>
18
+ <div id="fen"></div>
19
+ <div id="result"></div>
20
+
21
+ <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
22
+ <script src="/static/chessboard-1.0.0.min.js"></script>
23
+ <script>
24
+ var board = Chessboard('board', {
25
+ draggable: true,
26
+ dropOffBoard: 'trash',
27
+ sparePieces: true,
28
+ position: 'start',
29
+ pieceTheme: '/static/img/chesspieces/wikipedia/{piece}.png',
30
+ onChange: () => document.getElementById('fen').textContent = 'FEN: ' + board.fen()
31
+ });
32
+
33
+ function search() {
34
+ fetch('/search', {
35
+ method: 'POST',
36
+ headers: {'Content-Type': 'application/json'},
37
+ body: JSON.stringify({fen: board.fen()})
38
+ })
39
+ .then(r => r.json())
40
+ .then(d => document.getElementById('result').textContent = JSON.stringify(d, null, 2));
41
+ }
42
+
43
+ document.getElementById('fen').textContent = 'FEN: ' + board.fen();
44
+ </script>
45
+ </body>
46
+ </html>