Skip to content

Commit 471ae07

Browse files
author
Jerome Simeon
committed
Add chat form ; Fixed size to board so window can be resized ; Add board coordinates
1 parent fd75721 commit 471ae07

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

chessground/base.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ piece.ghost {
8686
opacity: 0.3;
8787
}
8888
.cg-board-wrap coords {
89-
position: absolute;
89+
font-weight: bold;
90+
position: absolute;
9091
display: flex;
9192
pointer-events: none;
92-
opacity: 0.8;
93-
font-size: 9px;
93+
opacity: 1;
94+
font-size: 12px;
9495
}
9596
.cg-board-wrap coords.ranks {
9697
right: -15px;

index.html

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@
1414
<body>
1515

1616
<div id="container">
17-
<div id="board" class="chessground blue merida"></div>
17+
<div id="board" style="width: 400px" class="chessground blue merida"></div>
18+
<p>
19+
<br/>
20+
<form>
21+
<fieldset>
22+
<legend>chessbot</legend>
23+
<textarea id = "chessbot"
24+
rows = "1"
25+
cols = "80" /></textarea>
26+
</fieldset>
1827
</div>
1928

2029
<script>
@@ -24,7 +33,7 @@
2433
}
2534

2635
let ground = Chessground(document.getElementById("board"), {
27-
coordinates: false,
36+
coordinates: true,
2837
movable: {
2938
free: true,
3039
color: "both"
@@ -58,7 +67,25 @@
5867

5968
setInterval(() => {
6069
konsole.log(getMask())
61-
}, 1000)
70+
}, 250)
71+
72+
// Send a chat text
73+
function getUtteranceMsg(utterance) {
74+
let s = "TEXT ";
75+
s = s + utterance;
76+
return s;
77+
}
78+
function sendBot() {
79+
var utterance = document.getElementById("chessbot").value;
80+
// Clear
81+
konsole.log(getUtteranceMsg(utterance))
82+
}
83+
document.getElementById("chessbot").addEventListener("keydown", function(e){
84+
if(e.keyCode == 13){sendBot(); clearBot();}
85+
});
86+
function clearBot() {
87+
document.getElementById("chessbot").value = "";
88+
}
6289
</script>
6390
</body>
6491
</html>

style.css

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
* {
22
margin: 0;
3-
padding: 0;
3+
padding: 10;
44
}
55

66
html {
@@ -16,15 +16,14 @@ body {
1616
}
1717

1818
#container {
19-
width: 100%;
20-
height: 100%;
21-
display: flex;
22-
flex-direction: column;
19+
display:table;
20+
height:800px;
21+
width:100%;
2322
justify-content: center;
2423
}
2524

2625
#board {
2726
margin: auto;
28-
width: 90vmin;
29-
height: 90vmin;
27+
width: 400px;
28+
height: 400px;
3029
}

0 commit comments

Comments
 (0)