-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
117 lines (113 loc) · 4.18 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<meta name="Description" content=""/>
<link rel="shortcut icon" href=""/>
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--
<link href="css/style.css" rel="stylesheet"/>
-->
<style>
@media screen and (min-width: 1200px) {
:root {
--size: 1.2;
}
}
@media screen and (min-width: 1400px) {
:root {
--size: 1.4;
}
}
.terminal span[style*="width"] span,
.cmd span[style*="width"] span {
width: inherit;
}
</style>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png"/>
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png"/>
<link rel="manifest" href="site.webmanifest"/>
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5"/>
<meta name="msapplication-TileColor" content="#000000"/>
<meta name="theme-color" content="#ffffff"/>
<link href="https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@devel/css/jquery.terminal.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/chess.js/chess.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/jcubic/static/js/wcwidth.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-polyfills/keyboard.js"></script>
<script src="https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@devel/js/jquery.terminal.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/figlet/lib/figlet.js"></script>
<script src="game.js"></script>
<script src="formatters.js"></script>
<script>
// TODO: Webpack + host font files (add to webpack using font-loader)
var term;
var game;
figlet.defaults({fontPath: 'https://unpkg.com/figlet@1.4.0/fonts/'});
figlet.preloadFonts(["Slant"], ready);
var term;
var copyright = '<nop>Copyright (C) </nop><a href="https://jcubic.pl">Jakub T. Jankiewicz</a> <nop>version 0.1.0</nop>';
function ready() {
$(function() {
var chess_index;
game = new Game();
term = $('body').terminal({
move: function(str) {
game._chess.move(str);
term.update(chess_index, game);
}
}, {
prompt: function() {
return `${game._chess.turn() === 'b' ? 'black' : 'white'}> `;
},
//echoCommand: false,
greetings: false,
onInit: function() {
this.echo(() => [
render('Terminal Chess', 'Slant'),
copyright,
''
].join('\n'));
},
checkArity: false,
renderHandler: function(obj, options) {
if (!(obj instanceof Game)) {
return obj;
}
if (options.update) {
this.update(options.line, obj.render(), {
finalize: function(div) {
div.css('--size', 2);
}
});
} else {
this.echo(obj.render(), {
finalize: function(div) {
div.css('--size', 2);
}
});
}
return false;
}
});
term.echo(game);
chess_index = term.last_index();
});
}
function render(text, font) {
return figlet.textSync(text, {
font: font || 'Standard',
width: !term ? 80 : term.cols(),
whitespaceBreak: true
});
}
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
</body>
</html>