forked from prathmesh-ka-github/Chessable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwo-player.html
93 lines (89 loc) · 3.75 KB
/
two-player.html
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
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="./Assets/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chessable - 2 Player</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="styles/two-player.css">
</head>
<body onload="setlocalstorage()">
<img class="bg-img" src="./Assets/chessable-bg-light.png" alt="background-img">
<a href="index.html">
<div class="logo-sm">
<img src="Assets/Chessable-logo-dark.png" alt="Chessable logo">
</div>
</a>
<div class="container">
<img src="Assets/2kings.png" alt="Two-players">
<div class="two-p-txt">2-Player Chess</div>
<input id="black-player" class="name" type="text" placeholder="Enter player name">
<input id="white-player" class="name" type="text" placeholder="Enter player name">
<div class="sub-container">
<div class="clk-div">
<button onclick="fivemin()" id="b_5min" class="clk-btn">5 mins</button>
<button onclick="tenmin()" id="b_10min" class="clk-btn">10 mins</button>
</div>
<div class="clk-ply-div">
<button onclick="fifteenmin()" id="b_15min" class="clk-btn">15 mins</button>
<a href="2-game.html">
<button class="ply-btn-sm">Play!</button>
</a>
</div>
</div>
</div>
<script>
var blackName = "Black Player";
var whiteName = "White Player";
var playtime = 10;
function setlocalstorage(){
localStorage.setItem("timevalue", playtime);
localStorage.setItem("blackname", blackName);
localStorage.setItem("whitename", whiteName);
}
function savedefaults(){
if (blackName == "") {
blackName = "Black Player";
}
if (whiteName == "") {
whiteName = "White Player";
}
}
// UI Javascript
function fivemin() {
console.log('Time set to 5 mins');
playtime = 5;
blackName = document.getElementById("black-player").value
whiteName = document.getElementById("white-player").value
savedefaults();
setlocalstorage();
document.getElementById("b_5min").style.backgroundColor = "#7FA650"
document.getElementById("b_10min").style.backgroundColor = "#4F4844"
document.getElementById("b_15min").style.backgroundColor = "#4F4844"
}
function tenmin() {
console.log('Time set to 10 mins');
playtime = 10;
blackName = document.getElementById("black-player").value
whiteName = document.getElementById("white-player").value
savedefaults();
setlocalstorage();
document.getElementById("b_10min").style.backgroundColor = "#7FA650"
document.getElementById("b_5min").style.backgroundColor = "#4F4844"
document.getElementById("b_15min").style.backgroundColor = "#4F4844"
}
function fifteenmin() {
console.log('Time set to 15 mins');
playtime = 15;
blackName = document.getElementById("black-player").value
whiteName = document.getElementById("white-player").value
savedefaults();
setlocalstorage();
document.getElementById("b_5min").style.backgroundColor = "#4F4844"
document.getElementById("b_10min").style.backgroundColor = "#4F4844"
document.getElementById("b_15min").style.backgroundColor = "#7FA650"
}
</script>
</body>
</html>