-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddTeam.js
More file actions
37 lines (26 loc) · 880 Bytes
/
addTeam.js
File metadata and controls
37 lines (26 loc) · 880 Bytes
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
let localTeam = JSON.parse(localStorage.getItem("teamArray"));
let localPlayers = JSON.parse(localStorage.getItem("playerArray"));
$("#addteamform").submit(function (e) {
e.preventDefault();
let inp_val = $("#inp1").val();
let shortName = '';
for(let i=0;i<inp_val.length;i++){
if(i == 0){
shortName += inp_val[i++].toUpperCase();
continue;
}else if(inp_val[i] == ' '){
shortName += inp_val[++i].toUpperCase();
i++;
}
}
let addData = {
"id": localTeam.length,
"teamFullName":$("#inp1").val() ,
"sName": shortName,
"teamIcon": $("#inp3").val(),
"WonCount": $("#inp4").val(),
}
localTeam.push(addData);
localStorage.setItem("teamArray", JSON.stringify(localTeam));
location.href = `./teams.html?name=${addData.sName}`;
})