-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
71 lines (50 loc) · 1.95 KB
/
app.js
File metadata and controls
71 lines (50 loc) · 1.95 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
/*** APP JS is the CONTROLLER
*
* CLOCK is the model, calculating logics
*
* VIEW is view, rendering visuals
*
* CONTROLLER connects model and view
* It controls the following
* * capture clock button clicks and process time stop, start and switch turns
* * capture volume button clicks and process audio on/off
* * capture play/pause button clicks and process game state
* * capture clock settings and update timers, timing methods and increments
*
*/
// MAIN --------------------------------
// add click event listeners
const CLOCK = new Clock();
const VIEW = new View();
const CONTROLLER = new Controller(CLOCK, VIEW);
$(document).ready(() => {
// add event listeners
$(CLOCK_1_SELECTOR).on('click', clock_1_clicked);
$(CLOCK_2_SELECTOR).on('click', clock_2_clicked);
$(PLAY_PAUSE_SELECTOR).on('click', () => CONTROLLER.play_pause_clicked());
$(VOLUME_SELECTOR).on('click', () => CONTROLLER.volume_clicked());
$(SETTINGS_SELECTOR).on('click', () => CONTROLLER.settings_clicked());
$(COVER_BACKDROP).on('click', () => CONTROLLER.hide_pop_up_interface());
$(BTN_UPDATE_TIMERS).on('click', () => {
CONTROLLER.update_timers();
CONTROLLER.hide_pop_up_interface();
});
$(BTN_RESET_DEFAULT).on('click', () => {
CONTROLLER.reset_default_clock_settings();
});
$(BTN_CLOSE_POP_UP).on('click', () => CONTROLLER.hide_pop_up_interface());
// --- --- --- ---
$(BTN_TOGGLE_SECOND_TIMER).on('change', () => CONTROLLER.toggle_2nd_timer());
CONTROLLER.reset_default_clock_settings();
CLOCK.reset()
VIEW.update_display_game_reset();
});
// ---------------------------------
// EVENT LISTENER functions -------- ------------
// ---------- ---------------
const clock_1_clicked = () => {
CONTROLLER.clock_btn_clicked(CLOCK_2_SELECTOR, CLOCK_1_SELECTOR);
}
const clock_2_clicked = () => {
CONTROLLER.clock_btn_clicked(CLOCK_1_SELECTOR, CLOCK_2_SELECTOR);
}