/
gui.html
262 lines (252 loc) · 11.2 KB
/
gui.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="client/semantic-build/semantic.css">
<script>window.$ = window.jQuery = require('./client/jquery-3.1.1.min.js');</script>
<script src="client/semantic-build/semantic.js"></script>
<title>Quidditch overlay</title>
<style>
h2, .centered {
text-align: center;
}
div.spaced {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-content: center;
align-items: baseline;
}
.ui.form .inline.field > :last-child {
margin-left: 12px;
}
</style>
</head>
<body>
<div class="ui vertical container segments">
<div class="ui horizontal segments">
<div class="ui raised segment">
<h2>Team A</h2>
<div class="container">
<div class="ui fluid form">
<div class="ui inline field">
<div class="ui right pointing label">
Team name
</div>
<input id="team-a-name" type="text">
</div>
<div class="ui inline field">
<div class="ui right pointing label">
Team color
</div>
<select id="team-a-color">
<option value="red">red</option>
<option value="orange">orange</option>
<option value="yellow">yellow</option>
<option value="olive">olive</option>
<option value="green">green</option>
<option value="teal">teal</option>
<option value="blue">blue</option>
<option value="violet">violet</option>
<option value="purple">purple</option>
<option value="pink">pink</option>
<option value="brown">brown</option>
<option value="grey">grey</option>
<option value="black">black</option>
</select>
</div>
</div>
</div>
</div>
<div class="ui raised segment">
<h2>Team B</h2>
<div class="container">
<div class="ui fluid form">
<div class="ui inline field">
<div class="ui right pointing label">
Team name
</div>
<input id="team-b-name" type="text">
</div>
<div class="ui inline field">
<div class="ui right pointing label">
Team color
</div>
<select id="team-b-color">
<option value="red">red</option>
<option value="orange">orange</option>
<option value="yellow">yellow</option>
<option value="olive">olive</option>
<option value="green">green</option>
<option value="teal">teal</option>
<option value="blue">blue</option>
<option value="violet">violet</option>
<option value="purple">purple</option>
<option value="pink">pink</option>
<option value="brown">brown</option>
<option value="grey">grey</option>
<option value="black">black</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="ui center aligned segment">
<button id="update-info-btn" class="ui button">Update team info</button>
</div>
<div class="ui center aligned segment">
<h2>Score</h2>
</div>
<div class="ui horizontal segments">
<div class="ui raised center aligned segment">
<div class="ui fluid form">
<div class="ui inline field">
<button id="team-a-plus" class="ui button">+</button>
<input id="team-a-score" class="centered" type="text" value="0" disabled>
<button id="team-a-minus" class="ui button">-</button>
</div>
</div>
<div class="ui fluid form">
<div class="ui inline field">
<button id="team-a-catch" class="ui button">Catch</button>
<input id="team-a-snitches" class="centered" type="text" style="width: 70px" value="" disabled>
</div>
</div>
</div>
<div class="ui raised center aligned segment">
<div class="ui fluid form">
<div class="ui inline field">
<button id="team-b-plus" class="ui button">+</button>
<input id="team-b-score" class="centered" type="text" value="0" disabled>
<button id="team-b-minus" class="ui button">-</button>
</div>
</div>
<div class="ui fluid form">
<div class="ui inline field">
<button id="team-b-catch" class="ui button">Catch</button>
<input id="team-b-snitches" class="centered" type="text" style="width: 70px" value="" disabled>
</div>
</div>
</div>
</div>
<div class="ui center aligned segment">
<h2 id="game-time">00:00.00</h2>
<button id="game-time-btn" class="ui button">Start/Stop</button>
<button id="game-time-reset-btn" class="ui button">Reset</button>
</div>
<div class="ui center aligned segment">
<button id="period-1" class="ui button">Regulation time</button>
<button id="period-2" class="ui button">Overtime</button>
<button id="period-3" class="ui button">Second overtime</button>
</div>
</div>
<script>
const { ipcRenderer, remote } = require( "electron" );
var Stopwatch = require('timer-stopwatch');
var data = {
teamAname: "Team A",
teamAcolor: "green",
teamAscore: 0,
teamAsnitches: [],
teamBname: "Team B",
teamBcolor: "blue",
teamBscore: 0,
teamBsnitches: [],
period: 1,
gameTime: 0
}
var stopwatch = new Stopwatch();
stopwatch.onTime(timeChanged);
function timeChanged(time) {
let ms = time.ms;
let seconds = Math.floor(ms / 1000);
let minutes = Math.floor(seconds / 60);
seconds = seconds % 60;
ms = Math.floor((ms % 1000) / 10);
$('#game-time')[0].innerText = (''+minutes).padStart(2, '0') + ":" + (''+seconds).padStart(2, '0') + "." + (''+ms).padStart(2,'0');
data.gameTime = seconds + 60 * minutes;
updateClient(true);
}
function updateClient(send) {
ipcRenderer.send("setVar", JSON.stringify({variable: "data", value: data}));
if(send) ipcRenderer.send("updateClient");
}
function fillData() {
$('#team-a-name')[0].value = data.teamAname;
$('#team-a-color')[0].value = data.teamAcolor;
$('#team-b-name')[0].value = data.teamBname;
$('#team-b-color')[0].value = data.teamBcolor;
}
function getData() {
data.teamAname = $('#team-a-name')[0].value;
data.teamAcolor = $('#team-a-color')[0].value;
data.teamBname = $('#team-b-name')[0].value;
data.teamBcolor = $('#team-b-color')[0].value;
}
$(document).ready(function() {
fillData();
$('#game-time-btn')[0].onclick = () => stopwatch.startstop();
$('#game-time-reset-btn')[0].onclick = () => stopwatch.reset();
$('#update-info-btn')[0].onclick = () => { getData(); updateClient(true); }
$('#period-1')[0].onclick = () => { data.period = 1; updateClient(true); }
$('#period-2')[0].onclick = () => { data.period = 2; updateClient(true); }
$('#period-3')[0].onclick = () => { data.period = 3; updateClient(true); }
$('#team-a-plus')[0].onclick = () => {
let score = new Number($('#team-a-score')[0].value);
score += 10;
data.teamAscore = score;
$('#team-a-score')[0].value = score;
updateClient(true);
}
$('#team-a-minus')[0].onclick = () => {
let score = new Number($('#team-a-score')[0].value);
score -= 10;
if (score < 0) score = 0;
data.teamAscore = score;
$('#team-a-score')[0].value = score;
updateClient(true);
}
$('#team-b-plus')[0].onclick = () => {
let score = new Number($('#team-b-score')[0].value);
score += 10;
data.teamBscore = score;
$('#team-b-score')[0].value = score;
updateClient(true);
}
$('#team-b-minus')[0].onclick = () => {
let score = new Number($('#team-b-score')[0].value);
score -= 10;
if (score < 0) score = 0;
data.teamBscore = score;
$('#team-b-score')[0].value = score;
updateClient(true);
}
$('#team-a-catch')[0].onclick = () => {
let score = new Number($('#team-a-score')[0].value);
score += 30;
data.teamAscore = score;
data.teamAsnitches.push(true);
data.teamBsnitches.push(false);
$('#team-a-score')[0].value = score;
$('#team-a-snitches')[0].value += "*";
$('#team-b-snitches')[0].value += "°";
updateClient(true);
}
$('#team-b-catch')[0].onclick = () => {
let score = new Number($('#team-b-score')[0].value);
score += 30;
data.teamBscore = score;
data.teamBsnitches.push(true);
data.teamAsnitches.push(false);
$('#team-b-score')[0].value = score;
$('#team-b-snitches')[0].value += "*";
$('#team-a-snitches')[0].value += "°";
updateClient(true);
}
updateClient(false);
});
</script>
</body>
</html>