-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav-buttons.js
83 lines (71 loc) · 2.96 KB
/
nav-buttons.js
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
import { isPaused } from './game.js';
// import { updateSetting } from './DBStorage.js';
export let darkMode = true;
export let sound = true;//false
export let music = true;//true
// main container
const gameContainer = document.getElementsByClassName('game-container')[0]; // reference to the first element of the collection
// status display // right
const statusDisplay = document.getElementsByClassName('status-display')[0]; // reference to the first element of the collection
const cell = document.querySelectorAll('.status-display table tr td:last-of-type');
// canvas
// const canvas = document.getElementsByTagName('canvas')[0];
const canvas = document.getElementById('gameCanvas');
// buttons
const buttons = document.querySelectorAll('.button-display button');
const buttonDarkMode = document.getElementById('btn-dark-mode');
const buttonSoundMode = document.getElementById('btn-sound-mode');
const buttonMusicMode = document.getElementById('btn-music-mode');
const buttonDifficultMode = document.getElementById('btn-difficult-mode');
const buttonStart = document.getElementById('btn-start');
export const buttonPause = document.getElementById('btn-pause');
const buttonNewGame = document.getElementById('btn-new-game');
const buttonExitGame = document.getElementById('btn-exit-game');
export function toggleDark() {
darkMode = !darkMode;
// savesetting in IndexedDB
// updateSetting('toggleDark', darkMode);
// main container
gameContainer.style.backgroundColor = darkMode ?
'var(--main-background-color-dark-mode)' :
'var(--main-background-color-light-mode)'
// status display // right
statusDisplay.style.color = darkMode ?
'var(--text-color-dark-mode)' :
'var(--text-color-light-mode)'
cell.forEach(c => {
c.style.backgroundColor = darkMode ?
'var(--cell-background-color-dark-mode)' :
'var(--cell-background-color-light-mode)';
});
// canvas
canvas.style.backgroundColor = darkMode ?
'var(--canvas-background-color-dark-mode)' :
'var(--canvas-background-color-light-mode)';
canvas.style.borderColor= darkMode ?
'var(--canvas-border-color-dark-mode)' :
'var(--canvas-border-color-light-mode)';
// buttons
buttonDarkMode.innerText = darkMode ?
'light mode' :
'dark mode';
buttons.forEach(b => {
b.style.backgroundColor = darkMode ?
'var(--button-background-color-dark-mode)' :
'var(--button-background-color-light-mode)';
b.style.color = darkMode ?
'var(--button-text-color-dark-mode)' :
'var(--button-text-color-light-mode)';
});
}
export function toggleSound() {
sound = !sound;
buttonSoundMode.innerText = sound ? 'sound on' : 'sound off';
};
export function toggleMusic() {
music = !music;
buttonMusicMode.innerText = music ? 'music on' : 'music off';
}
export function togglePause() {
buttonPause.innerText = isPaused ? 'pause on' : 'pause off';
}