Initial attempt and commit
This commit is contained in:
commit
9120e1dc5f
5 changed files with 146 additions and 0 deletions
32
js/app.js
Normal file
32
js/app.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import Chessboard from "./chessboard.js";
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded",async function ready(){
|
||||
var boardEl = document.getElementById("board");
|
||||
var clearHighlightsBtn = document.getElementById("clear-highlights-btn");
|
||||
|
||||
Chessboard.draw(boardEl);
|
||||
|
||||
boardEl.addEventListener("click",onClickTile,false);
|
||||
clearHighlightsBtn.addEventListener("click",clearHighlights,false);
|
||||
|
||||
|
||||
// ********************************
|
||||
|
||||
function onClickTile(evt) {
|
||||
var clickedEl = evt.target;
|
||||
|
||||
// clicked on a board tile?
|
||||
if (clickedEl.matches("#board > div > div")) {
|
||||
Chessboard.highlight(clickedEl);
|
||||
}
|
||||
else {
|
||||
clearHighlights();
|
||||
}
|
||||
}
|
||||
|
||||
function clearHighlights() {
|
||||
Chessboard.highlight();
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue