-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSidebar.html
More file actions
265 lines (226 loc) · 6.86 KB
/
Copy pathSidebar.html
File metadata and controls
265 lines (226 loc) · 6.86 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
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
263
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #1e1e2f, #121221);
color: #e0e0e0;
margin: 0;
padding: 25px 20px 30px;
width: 270px;
box-sizing: border-box;
user-select: none;
}
h2 {
text-align: center;
margin-bottom: 25px;
color: #00bcd4;
text-shadow: 0 0 10px #00bcd4aa;
font-weight: 700;
letter-spacing: 1.2px;
}
label {
display: block;
margin-bottom: 10px;
font-weight: 600;
font-size: 14px;
color: #80deea;
cursor: pointer;
}
select, input[type="text"], input[type="checkbox"] {
margin-bottom: 22px;
width: 100%;
padding: 10px 14px;
border-radius: 8px;
border: none;
font-size: 14px;
background-color: #2c2c3e;
color: #e0e0e0;
box-shadow:
inset 2px 2px 6px #151522,
inset -2px -2px 6px #44445a;
transition: background-color 0.3s ease, box-shadow 0.3s ease;
cursor: pointer;
outline-offset: 2px;
}
input[type="checkbox"] {
width: auto;
vertical-align: middle;
margin-right: 10px;
cursor: pointer;
box-shadow: none;
background: none;
padding: 0;
}
input[type="checkbox"]:hover, select:hover, input[type="text"]:hover {
background-color: #3a3a54;
box-shadow:
inset 3px 3px 8px #1c1c30,
inset -3px -3px 8px #55556f;
}
button {
width: 100%;
padding: 14px 0;
background: linear-gradient(45deg, #00bcd4, #00838f);
border: none;
border-radius: 10px;
color: white;
font-weight: 700;
font-size: 17px;
cursor: pointer;
box-shadow:
0 5px 15px rgba(0, 188, 212, 0.7),
0 8px 30px rgba(0, 131, 143, 0.6);
transition:
box-shadow 0.3s ease,
background 0.3s ease;
user-select: none;
letter-spacing: 0.8px;
margin-bottom: 18px;
}
button:hover:not(:disabled) {
background: linear-gradient(45deg, #00e5ff, #006064);
box-shadow:
0 8px 20px rgba(0, 229, 255, 0.85),
0 12px 40px rgba(0, 96, 100, 0.8);
}
button:disabled {
opacity: 0.45;
cursor: not-allowed;
box-shadow: none;
}
#status {
font-size: 14px;
color: #00e676;
text-align: center;
min-height: 24px;
margin-top: 12px;
font-weight: 600;
user-select: text;
letter-spacing: 0.5px;
}
#currentSheet {
font-size: 13px;
color: #bbbbbb;
text-align: center;
margin-top: 8px;
font-style: italic;
user-select: text;
}
</style>
</head>
<body>
<h2>Filter Sports Sheet</h2>
<label for="sportSelect">Select Sport:</label>
<select id="sportSelect">
<option value="FB">Football</option>
<option value="BSB">Baseball</option>
<option value="MBB">Men's Basketball</option>
<option value="WBB">Women's Basketball</option>
<option value="SFB">Softball</option>
<option value="SOC">Soccer</option>
<option value="TRK">Track</option>
</select>
<label for="applyRange">Apply Filter to Sheet Indexes (e.g., 0-3,5,10-12):</label>
<input type="text" id="applyRange" placeholder="e.g. 0-3,5,10-12" />
<label>
<input type="checkbox" id="hideNACheckbox" />
Hide Opponent "N/A"
</label>
<label for="chunkSize">Sheets per batch (chunk size):</label>
<input type="number" id="chunkSize" min="1" max="20" value="10" />
<button id="applyBtn">Apply Filter</button>
<button id="clearBtn">Clear Filters</button>
<div id="status"></div>
<div id="currentSheet"></div>
<script>
const applyBtn = document.getElementById('applyBtn');
const clearBtn = document.getElementById('clearBtn');
const statusDiv = document.getElementById('status');
const sheetDiv = document.getElementById('currentSheet');
function disableControls(disabled) {
applyBtn.disabled = disabled;
clearBtn.disabled = disabled;
document.getElementById('sportSelect').disabled = disabled;
document.getElementById('applyRange').disabled = disabled;
document.getElementById('hideNACheckbox').disabled = disabled;
document.getElementById('chunkSize').disabled = disabled;
}
// Helper to parse range string into array of sheet indexes (0-based)
function parseRangeToArray(rangeStr) {
const result = new Set();
if (!rangeStr) return [];
const parts = rangeStr.split(',').map(p => p.trim());
parts.forEach(part => {
if (part.includes('-')) {
const [start, end] = part.split('-').map(n => parseInt(n.trim(), 10));
if (!isNaN(start) && !isNaN(end)) {
for (let i = start; i <= end; i++) result.add(i);
}
} else {
const num = parseInt(part, 10);
if (!isNaN(num)) result.add(num);
}
});
return [...result].sort((a,b) => a-b);
}
function runFilterInChunks(selectedSport, hideNA, sheetIndexes, chunkSize) {
let currentChunk = 0;
const totalChunks = Math.ceil(sheetIndexes.length / chunkSize);
function runNextChunk() {
if (currentChunk >= totalChunks) {
statusDiv.textContent = 'Filter applied successfully!';
sheetDiv.textContent = '';
disableControls(false);
return;
}
const chunk = sheetIndexes.slice(currentChunk * chunkSize, (currentChunk + 1) * chunkSize);
const chunkRangeStr = chunk.map(i => i).join(',');
statusDiv.textContent = `Applying filter batch ${currentChunk + 1} of ${totalChunks}...`;
sheetDiv.textContent = `Processing sheets: ${chunkRangeStr}`;
google.script.run
.withSuccessHandler(() => {
currentChunk++;
runNextChunk();
})
.withFailureHandler(err => {
statusDiv.textContent = 'Error: ' + err.message;
disableControls(false);
})
.filterAllSheets(selectedSport, hideNA, chunkRangeStr);
}
disableControls(true);
runNextChunk();
}
applyBtn.addEventListener('click', () => {
const selectedSport = document.getElementById('sportSelect').value;
const hideNA = document.getElementById('hideNACheckbox').checked;
const applyRangeStr = document.getElementById('applyRange').value;
const chunkSize = parseInt(document.getElementById('chunkSize').value, 10) || 10;
const sheetIndexes = parseRangeToArray(applyRangeStr);
if (sheetIndexes.length === 0) {
statusDiv.textContent = 'Please specify at least one sheet index.';
return;
}
runFilterInChunks(selectedSport, hideNA, sheetIndexes, chunkSize);
});
clearBtn.addEventListener('click', () => {
statusDiv.textContent = 'Clearing filters...';
sheetDiv.textContent = '';
disableControls(true);
google.script.run
.withSuccessHandler(() => {
statusDiv.textContent = 'Filters cleared!';
disableControls(false);
})
.withFailureHandler(err => {
statusDiv.textContent = 'Error: ' + err.message;
disableControls(false);
})
.clearFiltersFromAllSheets();
});
</script>
</body>
</html>