-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
81 lines (70 loc) · 2.97 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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="assets/chessground.css" async>
<link rel="stylesheet" href="assets/theme.css" async>
<link rel="stylesheet" href="assets/examples.css">
<link rel="icon" type="image/png" href="assets/omnipotron.png" />
<title>Omnip-o-tron</title>
<meta name="Description" content="Be ready for any move" />
</head>
<body>
<h2><a href="https://github.com/tailuge/omnip-o-tron">Omnip-o-tron</a></h2>
<div class="tagline">
Be ready for any move - thanks to <a href="https://github.com/ornicar/chessground">lichess</a> and <a href="https://github.com/niklasf/stockfish.js/">stockfish</a>
</div>
<div class="inputs">
FEN:
<input type="text" id="fen" name="fen" value="8/8/8/8/8/8/2p1N2K/2k5 b - - 0 1" onkeydown="pressEnter(event)" />
Search depth :
<input type="text" name="depth" id="depth" value="14" style="width: 20px;" onkeydown="onPressEnter(event,perturb)"/>
<input type="submit" id="Search" value="Begin" onclick="search()">
</div>
<pre class="inputs" id="log"></pre>
<div id="chessground-examples"></div>
<script src="dist/main.js"></script>
<script>
/* global bundle */
var boards = new bundle.Boards(elt('chessground-examples'));
var sf = loadStockfish();
var stockfishQueue = new bundle.StockfishQueue(sf, (x)=>{console.log(x)}, elt('depth').value)
var params = bundle.parse(window.location.href);
if (params.fen) {
elt('fen').value = params.fen;
search();
}
function search() {
var fen = elt('fen').value;
var puzzles = bundle.puzzlesFrom(fen, stockfishQueue);
status("There are " + (puzzles.length - 1) + " continuations from this position - find the best replies!");
boards.setPuzzles([]);
boards.setPuzzles(puzzles);
updateUrlWithState();
}
function pressEnter(event) {
(event.keyCode == 13) && elt('Search').click();
}
function status(x) {
elt("log").innerHTML = x;
console.log(x);
}
function elt(e) {
return document.getElementById(e);
}
function updateUrlWithState() {
if (history.pushState) {
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + "?" +
bundle.build({ fen: elt('fen').value});
window.history.pushState({
path: newurl
}, '', newurl);
}
}
function loadStockfish() {
var wasmSupported = typeof WebAssembly === 'object' && WebAssembly.validate(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
console.log("wasmSupported:" + wasmSupported);
return new Worker(wasmSupported ? 'vendor/stockfish.wasm.js' : 'vendor/stockfish.js');
}
</script>
</body>
</html>