-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.html
145 lines (130 loc) · 5.77 KB
/
settings.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
<head>
<style>
#lnpdir {
display: flex;
justify-content: space-between;
max-width: 300px;
margin-bottom: 10px;
}
#nhdir {
display: flex;
justify-content: space-between;
max-width: 300px;
margin-bottom: 10px;
}
</style>
<script src="index.js"></script>
<script>
window.onload = function() {
var colorPickers = [
{
id: "Main Background Color",
key: "main-bg-color"
},
{
id: "Main Text Color",
key: "main-font-color",
},
{
id: "Selected Number Background Color",
key: 'select-tab-color'
},
{
id: 'Selected Number Text Color',
key: 'select-tab-text-color'
},
{
id: "Default Number Background Color",
key: 'unselect-tab-color'
},
{
id: 'Default Number Text Color',
key: 'unselect-tab-text-color'
}
];
if( localStorage.getItem('last-number-on') === "true" ){
document.getElementById('last-number-enabled').checked = true;
}
else
{
document.getElementById('last-number-enabled').checked = false;
}
if( localStorage.getItem('number-history-on') === "true" ){
document.getElementById('history-enabled').checked = true;
}
else
{
document.getElementById('history-enabled').checked = false;
}
for (var i = 0; i < colorPickers.length; i++) {
var colorPickerLabel = document.createElement('label');
colorPickerLabel.setAttribute('for', colorPickers[i].key);
colorPickerLabel.textContent = colorPickers[i].id;
var colorPicker = document.createElement('input');
colorPicker.setAttribute('type', 'color');
colorPicker.setAttribute('id', colorPickers[i].key);
colorPicker.setAttribute('name', colorPickers[i].key);
colorPicker.setAttribute('value', localStorage.getItem(colorPickers[i].key));
//console.log('Creating picker for:', colorPickers[i].key);
//console.log('Value:', localStorage.getItem(colorPickers[i].key));
// Create a new row
var newRow = document.createElement('div');
newRow.classList.add('row', 'color-picker-row'); // Add 'color-picker-row' class
newRow.style.display = 'flex'; // Set this div to be a flex container
newRow.style.maxWidth = '300px'; // Set the max width of the row
newRow.style.marginBottom = '10px';
newRow.style.justifyContent = 'space-between'; // Push the label to the left and the color picker to the right
// Append label and color picker to the new row
newRow.appendChild(colorPickerLabel);
newRow.appendChild(colorPicker);
// Append the new row to the container
var container = document.getElementsByClassName('container')[0];
container.appendChild(newRow);
}
document.getElementById('applyButton').addEventListener('click', function() {
var lastDirection = document.getElementById('last-direction').value;
localStorage.setItem('last-number-dir', lastDirection);
var lastDirection = document.getElementById('history-direction').value;
localStorage.setItem('number-history-dir', lastDirection);
var lastEnabled = document.getElementById('last-number-enabled').checked;
localStorage.setItem('last-number-on', lastEnabled);
var lastEnabled = document.getElementById('history-enabled').checked;
localStorage.setItem('number-history-on', lastEnabled);
var colorPickers = document.getElementsByTagName('input');
for (var i = 0; i < colorPickers.length; i++) {
console.log('Setting', colorPickers[i].id, 'to', colorPickers[i].value);
localStorage.setItem(colorPickers[i].id, colorPickers[i].value);
}
window.location.href = 'index.html';
});
document.getElementById('resetButton').addEventListener('click', function() {
setDefaultSettings(true)
window.location.href = 'index.html';
});
}
</script>
</head>
<body>
<div class="container">
<h1>Settings</h1>
<p>Change your settings here.</p>
<div class="row" id="lnpdir">
<input type="checkbox" id="last-number-enabled" checked="true">
<label for="last-direction">Last Number Played Location:</label>
<select id="last-direction">
<option value="top">Top</option>
<option value="bottom">Bottom</option>
</select>
</div>
<div class="row" id="nhdir">
<input type="checkbox" id="history-enabled" checked="true">
<label for="history-direction">Number History Location:</label>
<select id="history-direction">
<option value="right">Right</option>
<option value="left">Left</option>
</select>
</div>
</div>
<button id="applyButton">Apply</button>
<button id="resetButton">Reset To Default</button>
</body>