-
Notifications
You must be signed in to change notification settings - Fork 0
/
windowmanager.js
83 lines (72 loc) · 2.33 KB
/
windowmanager.js
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
function play()
{
if (tab.length != 0)
{
document.getElementById("set").style.display="none";
document.getElementById("interface").style.display="inline";
document.getElementById("flash").style.display="none";
game = tab
updatedGame = [...game]
difficulty = /ia/g.test(document.URL) ? document.getElementById("difficulte").value : undefined;
createGame(tab);
}
else {
alert("Impossible de créer la terrain de Jeu.");
}
}
function param()
{
document.getElementById("set").style.display="inline";
document.getElementById("interface").style.display="none";
document.getElementById("flash").style.display="none";
}
let tab=[];
function removeRow(mouseEvent) {
//console.log(tab);
tab.splice(mouseEvent.target.parentElement.parentElement.firstChild.value-1,1);
mouseEvent.target.parentElement.parentElement.remove();
//console.log(tab);
}
function reset()
{
document.getElementById("columnNumber").value=5;
document.getElementById("difficulte").value="facile";
tab=[];
const body = document.getElementById("tablebody")
body.innerHTML='';
}
function displaygrid(){
const body = document.getElementById("tablebody")
body.innerHTML='';
tab.forEach( (element, index) => {
if(element){
const newRow = document.createElement("TR");
const lineCell = document.createElement("TD");
lineCell.innerText=index+1;
const columnCell = document.createElement("TD");
columnCell.innerText=element;
const removeCell = document.createElement("TD");
const removeButton = document.createElement("BUTTON");
removeButton.innerText = "remove";
removeButton.addEventListener("click", removeRow);
removeCell.appendChild(removeButton);
newRow.appendChild(lineCell);
newRow.appendChild(columnCell);
newRow.appendChild(removeCell);
body.appendChild(newRow);
}
});
}
function addRow(){
const n=document.getElementById("columnNumber").value;
if (n <=10 && n >=0){
tab.push(n);
displaygrid();
}
else {alert("Valeur non comprise entre 0 et 10! C'est la loi dsl")}
}
function getArray(array){
for(i of tab){
array.push(i);
}
}