31 lines
930 B
JavaScript
Raw Normal View History

2020-02-12 17:01:08 +01:00
console.log("Chargement...");
function init() {
console.log("Initialisation...");
2020-02-12 17:25:20 +01:00
var div = document.querySelectorAll(".case");
2020-02-12 17:01:08 +01:00
for (var i = 0; i < div.length; i++) {
div[i].addEventListener("click", selection);
}
}
function selection(event) {
2020-02-12 17:25:20 +01:00
var maCase = event.currentTarget;
var vide = document.body.querySelector(".case.vide");
2020-02-19 16:14:31 +01:00
if ((maCase.offsetTop == vide.offsetTop && Math.abs(maCase.offsetLeft - vide.offsetLeft) == 102) ||
(maCase.offsetLeft == vide.offsetLeft && Math.abs(maCase.offsetTop - vide.offsetTop) == 102)) {
console.log("ok");
2020-02-12 18:36:12 +01:00
maCase.className = "case vide";
2020-02-19 16:14:31 +01:00
var buff = maCase.innerHTML;
maCase.innerHTML = "";
2020-02-12 18:36:12 +01:00
vide.className = "case";
2020-02-19 16:14:31 +01:00
vide.innerHTML = buff;
2020-02-12 18:36:12 +01:00
}
console.log(event.currentTarget.className + " : " + event.currentTarget.innerText);
var e = event.target;
}