-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscriptJsCreateFight.html
More file actions
98 lines (95 loc) · 4.94 KB
/
scriptJsCreateFight.html
File metadata and controls
98 lines (95 loc) · 4.94 KB
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
<script>
function displayNameAndCategory(node){
const selectElementA = document.getElementById('selectA');
const arrFighterA = selectElementA.value.split(',');
const selectElementB = document.getElementById('selectB');
const arrFighterB = selectElementB.value.split(',');
const optionEltWinnerA = document.getElementById('winnerA');
optionEltWinnerA.value = arrFighterA[0];
optionEltWinnerA.innerHTML = arrFighterA[0];
const optionEltWinnerB = document.getElementById('winnerB');
optionEltWinnerB.value = arrFighterB[0];
optionEltWinnerB.innerHTML = arrFighterB[0];
if (node.id === 'selectA-div'){
google.script.run.withSuccessHandler(object => {
console.log(document.getElementById('paragraphA'));
if (document.getElementById('paragraphA') !== null)
node.removeChild(document.getElementById('paragraphA'));
let display = '<strong>Nom: </strong><em>'+ object.person +' </em> <strong> Category: </strong><em>'+ object.category +' </em> <strong>Gender: </strong><em>'+ object.gender +' </em>';
const paragraph = document.createElement('p');
paragraph.id = 'paragraphA';
paragraph.innerHTML = display;
node.appendChild(paragraph);
}).getNameAndCategory(arrFighterA[1], arrFighterA[2]);
}else{
google.script.run.withSuccessHandler(object => {
if (document.getElementById('paragraphB') !== null)
node.removeChild(document.getElementById('paragraphB'));
let display = '<strong>Nom: </strong><em>'+ object.person +' </em> <strong> Category: </strong><em>'+ object.category +' </em> <strong>Gender: </strong><em>'+ object.gender +' </em>';
const paragraph = document.createElement('p');
paragraph.id = 'paragraphB';
paragraph.innerHTML = display;
node.appendChild(paragraph);
}).getNameAndCategory(arrFighterB[1], arrFighterB[2]);
}
}
function validateFields(input){
const regExStr = /^\d+[:]\d+$/;
if (input.fighterA.value === input.fighterB.value){
const divName = document.getElementById('selectB-div');
const div = document.createElement('div');
div.className = "warning";
div.innerHTML = "Attention!! Les identifiants des deux combattants doivent être différents.";
divName.appendChild(div);
setTimeout(()=>{
div.parentNode.removeChild(div);
}, 2000);
}else if (input.duration.value.length === 0 || !regExStr.test(input.duration.value)){
const divName = document.getElementById('duration');
const div = document.createElement('div');
div.className = "warning";
div.innerHTML = "Champs Durée: Veuillez entrez la durée du combat au format nombre:nombre!";
divName.appendChild(div);
setTimeout(()=>{
div.parentNode.removeChild(div);
}, 4000);
}else if (input.ipponFighterA.value.length === 0 || isNaN(parseInt(input.ipponFighterA.value))){
const divTown = document.getElementById('ipponFighterA');
const div = document.createElement('div');
div.className = "warning";
div.innerHTML = "Champs Ippon Combattant 1: Veuillez entrer un nombre!";
divTown.appendChild(div);
setTimeout(()=>{
div.parentNode.removeChild(div);
}, 2000);
}else if (input.ipponFighterB.value.length === 0 || isNaN(parseInt(input.ipponFighterB.value))){
const divTown = document.getElementById('ipponFighterB');
const div = document.createElement('div');
div.className = "warning";
div.innerHTML = "Champs Ippon Combattant 2: Veuillez entrer un nombre!";
divTown.appendChild(div);
setTimeout(()=>{
div.parentNode.removeChild(div);
}, 2000);
}else if (input.wazaFighterA.value.length === 0 || isNaN(parseInt(input.wazaFighterA.value))){
const divTown = document.getElementById('wazaFighterA');
const div = document.createElement('div');
div.className = "warning";
div.innerHTML = "Champs Waza Combattant 1: Veuillez entrer un nombre!";
divTown.appendChild(div);
setTimeout(()=>{
div.parentNode.removeChild(div);
}, 2000);
}else if (input.wazaFighterB.value.length === 0 || isNaN(parseInt(input.wazaFighterB.value))){
const divTown = document.getElementById('wazaFighterB');
const div = document.createElement('div');
div.className = "warning";
div.innerHTML = "Champs Waza Combattant 2: Veuillez entrer un nombre!";
divTown.appendChild(div);
setTimeout(()=>{
div.parentNode.removeChild(div);
}, 2000);
}else
google.script.run.createFight(input);
}
</script>