-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-53-Timezone-Overlap-Finder.html
More file actions
516 lines (427 loc) · 19.4 KB
/
tool-53-Timezone-Overlap-Finder.html
File metadata and controls
516 lines (427 loc) · 19.4 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 53 - Timezone Overlap Finder - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<style>
.split-view {
display: grid;
grid-template-columns: 1fr;
gap: 1.5rem;
margin-bottom: 2rem;
margin-top: 1rem;
}
@media (min-width: 900px) {
.split-view { grid-template-columns: 350px 1fr; }
}
.controls-panel {
background: rgba(0,0,0,0.4);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
}
.input-group label {
display: block;
color: var(--text-secondary);
font-weight: bold;
margin-bottom: 0.5rem;
}
input[type="text"], input[type="number"], select {
width: 100%;
background: var(--bg-main);
color: var(--text-primary);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 0.8rem;
font-family: inherit;
}
.team-member {
background: rgba(255,255,255,0.05);
border: 1px solid rgba(255,255,255,0.1);
padding: 1rem;
border-radius: var(--radius-sm);
display: flex;
flex-direction: column;
gap: 0.5rem;
position: relative;
}
.btn-remove {
position: absolute;
top: 0.5rem; right: 0.5rem;
background: none;
border: none;
color: #ff5555;
cursor: pointer;
font-weight: bold;
}
.grid-container {
overflow-x: auto;
border-radius: var(--radius-sm);
border: 1px solid var(--border-color);
background: rgba(0,0,0,0.2);
}
table {
width: 100%;
border-collapse: collapse;
font-family: var(--font-mono);
font-size: 0.85rem;
}
th, td {
text-align: center;
border: 1px solid var(--border-color);
min-width: 40px;
padding: 0.5rem;
}
th {
background: rgba(255,255,255,0.05);
color: var(--text-secondary);
position: sticky;
top: 0;
z-index: 10;
}
th:first-child {
left: 0;
z-index: 20;
background: var(--bg-main);
width: 120px;
text-align: left;
padding-left: 1rem;
}
td:first-child {
position: sticky;
left: 0;
background: var(--bg-main);
font-weight: bold;
text-align: left;
padding-left: 1rem;
z-index: 5;
}
.hour-overlap-0 { background: #1a1a24; color: #444; } /* Outside hours */
.hour-overlap-1 { background: #253325; color: #666; } /* Some working */
.hour-overlap-max { background: #2ea043; color: white; font-weight: bold; } /* Ideal */
.time-header { font-size: 0.75rem; writing-mode: vertical-lr; transform: rotate(180deg); height: 60px; }
.suggestion-box {
background: rgba(86, 182, 194, 0.1);
border: 1px solid rgba(86, 182, 194, 0.3);
padding: 1rem;
border-radius: var(--radius-sm);
margin-top: 1rem;
color: #56b6c2;
}
</style>
</head>
<body class="theme-dark">
<!-- Background Canvas -->
<div class="tool-canvas-container" id="canvas-container"></div>
<main class="main-content">
<div class="container" style="max-width: 1400px;">
<div class="tool-header">
<div>
<a href="index.html" class="back-link">← Back to Toolbox</a>
<h1>53. Timezone Overlap Finder</h1>
</div>
<div>
<select id="theme-select" aria-label="Select Theme">
<option value="dark">Dark Theme</option>
<option value="light">Light Theme</option>
<option value="solarized">Solarized</option>
<option value="neon">Neon Glow</option>
<option value="highcontrast">High Contrast</option>
</select>
</div>
</div>
<div class="glass-panel">
<div class="split-view">
<!-- Controls -->
<div class="controls-panel">
<div style="display:flex; justify-content:space-between; align-items:center;">
<h3 style="margin:0; color:var(--text-primary);">Team Members</h3>
<button class="btn btn-sm btn-primary" id="btn-add">➕ Add</button>
</div>
<div id="members-list" style="display:flex; flex-direction:column; gap:1rem; max-height:400px; overflow-y:auto; padding-right:0.5rem;">
<!-- Injected -->
</div>
<hr style="border-color: rgba(255,255,255,0.1); margin: 0.5rem 0;">
<div>
<label style="color:var(--text-secondary); font-weight:bold; display:block; margin-bottom:0.5rem;">Working Hours</label>
<div style="display:flex; gap:0.5rem; align-items:center;">
<input type="number" id="work-start" value="9" min="0" max="23">
<span style="color:var(--text-secondary);">to</span>
<input type="number" id="work-end" value="17" min="0" max="23">
</div>
</div>
<div class="suggestion-box" id="suggestions">
Optimal meeting times will appear here.
</div>
</div>
<!-- Visual Grid -->
<div class="grid-container">
<table id="overlap-table">
<!-- Injected -->
</table>
</div>
</div>
</div>
</div>
</main>
<footer class="global-footer">
<div class="container">
Made with ❤️ by <a href="https://github.com/Aliriyaj007" target="_blank">Aliriyaj007</a>
</div>
</footer>
<script src="assets/core.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.43/moment-timezone-with-data.min.js"></script>
<script>
const membersList = document.getElementById('members-list');
const overlapTable = document.getElementById('overlap-table');
const workStart = document.getElementById('work-start');
const workEnd = document.getElementById('work-end');
const suggestionsBox = document.getElementById('suggestions');
const allTimezones = moment.tz.names();
let members = [
{ name: 'Alice (SF)', tz: 'America/Los_Angeles' },
{ name: 'Bob (London)', tz: 'Europe/London' },
{ name: 'Charlie (Tokyo)', tz: 'Asia/Tokyo' }
];
function createTimezoneOptions(selected) {
let html = '';
// Group typical regions
const popular = ['UTC', 'America/New_York', 'America/Los_Angeles', 'Europe/London', 'Europe/Paris', 'Asia/Tokyo', 'Asia/Kolkata', 'Australia/Sydney'];
html += `<optgroup label="Popular">`;
popular.forEach(tz => {
html += `<option value="${tz}" ${tz===selected ? 'selected' : ''}>${tz.replace('_',' ')}</option>`;
});
html += `</optgroup><optgroup label="All">`;
allTimezones.forEach(tz => {
if(!popular.includes(tz)) {
html += `<option value="${tz}" ${tz===selected ? 'selected' : ''}>${tz}</option>`;
}
});
html += `</optgroup>`;
return html;
}
function renderMembers() {
membersList.innerHTML = '';
members.forEach((m, idx) => {
const div = document.createElement('div');
div.className = 'team-member';
div.innerHTML = `
<button class="btn-remove" data-idx="${idx}">×</button>
<input type="text" placeholder="Name" value="${m.name}" data-target="name" data-idx="${idx}">
<select data-target="tz" data-idx="${idx}">
${createTimezoneOptions(m.tz)}
</select>
`;
membersList.appendChild(div);
});
document.querySelectorAll('.team-member input, .team-member select').forEach(inp => {
inp.addEventListener('input', (e) => {
const idx = e.target.dataset.idx;
const target = e.target.dataset.target;
members[idx][target] = e.target.value;
renderGrid();
});
});
document.querySelectorAll('.btn-remove').forEach(btn => {
btn.addEventListener('click', (e) => {
const idx = e.target.dataset.idx;
members.splice(idx, 1);
renderMembers();
renderGrid();
});
});
}
document.getElementById('btn-add').addEventListener('click', () => {
members.push({ name: 'New Member', tz: 'UTC' });
renderMembers();
renderGrid();
});
[workStart, workEnd].forEach(el => el.addEventListener('input', renderGrid));
function renderGrid() {
if(members.length === 0) {
overlapTable.innerHTML = '<tr><td>No team members added.</td></tr>';
suggestionsBox.innerHTML = 'Add members to find overlap.';
window.update3DGlobe([]); // clear 3D
return;
}
const startHour = parseInt(workStart.value);
const endHour = parseInt(workEnd.value);
// Base UTC timeline (24 hours) for "today"
const baseMoment = moment.utc().startOf('day');
let html = `<thead><tr><th>UTC Time</th>`;
for(let h=0; h<24; h++) {
html += `<th class="time-header">${h.toString().padStart(2,'0')}:00</th>`;
}
html += `</tr></thead><tbody>`;
// Calculate overlap scores per hour (index 0-23 UTC)
let overlapScores = new Array(24).fill(0);
let memberHours = []; // store for 3D and rendering
members.forEach((m, mIdx) => {
// Determine local time offset
let mHtml = `<tr><td>${m.name}<br><small style="color:var(--text-secondary)">${m.tz.split('/').pop().replace('_',' ')}</small></td>`;
let localHours = [];
for(let h=0; h<24; h++) {
const utcTime = baseMoment.clone().add(h, 'hours');
const localTime = utcTime.tz(m.tz);
const localHour = localTime.hour();
localHours.push(localHour);
const isWorkHour = (localHour >= startHour && localHour < endHour);
if(isWorkHour) overlapScores[h]++;
mHtml += `<td class="${isWorkHour ? 'hour-overlap-max' : 'hour-overlap-0'}">${localHour}</td>`;
}
memberHours.push({ tz: m.tz, hours: localHours });
mHtml += `</tr>`;
html += mHtml;
});
// Summary row
html += `<tr><td><strong>Overlap Score</strong></td>`;
let maxScore = Math.max(...overlapScores);
let optimalHoursUTC = [];
for(let h=0; h<24; h++) {
const score = overlapScores[h];
let cssClass = 'hour-overlap-0';
if(score > 0 && score < members.length) cssClass = 'hour-overlap-1';
if(score === members.length && members.length > 0) cssClass = 'hour-overlap-max';
html += `<td class="${cssClass}">${score}/${members.length}</td>`;
if(score === members.length && members.length > 0) {
optimalHoursUTC.push(h);
}
}
html += `</tr></tbody>`;
overlapTable.innerHTML = html;
// Update suggestions
if(optimalHoursUTC.length > 0) {
let sugs = optimalHoursUTC.map(h => `${h.toString().padStart(2,'0')}:00 UTC`).join(', ');
suggestionsBox.innerHTML = `<strong>★ Optimal Times Found:</strong><br>${sugs}<br><br><small style="color:var(--text-secondary)">These times fall within everyone's working hours.</small>`;
} else {
suggestionsBox.innerHTML = `<span style="color:#ffaa00;">No perfect overlap found where everyone is within working hours.</span><br><br><small style="color:var(--text-secondary)">Consider alternating painful meeting times across the team.</small>`;
}
// Trigger 3D Globe Update with TZ coordinates
if(window.update3DGlobe) {
window.update3DGlobe(members);
}
}
// Init UI
renderMembers();
renderGrid();
// 3D Visualization: A 3D globe with markers for each team member
let scene, camera, renderer, globeGroup;
let markers = [];
function init3D() {
const container = document.getElementById('canvas-container');
if(!container || !window.THREE) return;
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 0, 15);
camera.lookAt(0, 0, 0);
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.4);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
dirLight.position.set(5, 5, 5);
scene.add(dirLight);
globeGroup = new THREE.Group();
scene.add(globeGroup);
// Shift scene left
scene.position.x = 3.5;
// Earth Base (Wireframe for a cyber look)
const globeGeo = new THREE.SphereGeometry(3.5, 32, 32);
const globeMat = new THREE.MeshPhongMaterial({
color: 0x112233,
emissive: 0x051122,
wireframe: true,
transparent: true,
opacity: 0.4
});
const globe = new THREE.Mesh(globeGeo, globeMat);
globeGroup.add(globe);
// Inner solid sphere to hide back lines
const innerGeo = new THREE.SphereGeometry(3.4, 32, 32);
const innerMat = new THREE.MeshPhongMaterial({ color: 0x0a0c10 });
const inner = new THREE.Mesh(innerGeo, innerMat);
globeGroup.add(inner);
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
}
// Very rough TZ to Longitude mapping for visual effect
const tzToCoords = (tzName) => {
// Rough mapping based on typical regions
let lon = 0; let lat = 0;
if(tzName.includes('America/Los_Angeles')) { lon = -118; lat = 34; }
else if(tzName.includes('America/New_York')) { lon = -74; lat = 40; }
else if(tzName.includes('Europe/London')) { lon = 0; lat = 51; }
else if(tzName.includes('Europe/Paris')) { lon = 2; lat = 48; }
else if(tzName.includes('Asia/Tokyo')) { lon = 139; lat = 35; }
else if(tzName.includes('Asia/Kolkata')) { lon = 77; lat = 28; }
else if(tzName.includes('Australia/Sydney')) { lon = 151; lat = -33; }
else {
// Extract generic offset from moment to guess longitude
const offset = moment.tz(tzName).utcOffset(); // minutes
lon = (offset / 60) * 15; // 15 degrees per hour
lat = (Math.random() - 0.5) * 60; // Random lat for diversity
}
return { lat, lon };
};
const latLonToVector3 = (lat, lon, radius) => {
var phi = (90 - lat) * (Math.PI / 180);
var theta = (lon + 180) * (Math.PI / 180);
var x = -(radius * Math.sin(phi) * Math.cos(theta));
var z = (radius * Math.sin(phi) * Math.sin(theta));
var y = (radius * Math.cos(phi));
return new THREE.Vector3(x, y, z);
};
window.update3DGlobe = (currentMembers) => {
if(!globeGroup) return;
// Remove old markers
markers.forEach(m => globeGroup.remove(m));
markers = [];
currentMembers.forEach(m => {
const coords = tzToCoords(m.tz);
const pos = latLonToVector3(coords.lat, coords.lon, 3.5);
const markerGeo = new THREE.CylinderGeometry(0.05, 0.05, 0.5, 8);
// Rotate to point out
markerGeo.translate(0, 0.25, 0);
markerGeo.rotateX(Math.PI / 2);
const markerMat = new THREE.MeshPhongMaterial({ color: 0x7ee787, emissive: 0x22aa33 });
const marker = new THREE.Mesh(markerGeo, markerMat);
marker.position.copy(pos);
marker.lookAt(new THREE.Vector3(0,0,0)); // Point towards center
// Notice the flip
marker.rotateX(Math.PI);
globeGroup.add(marker);
markers.push(marker);
// Add a ring
const ringGeo = new THREE.RingGeometry(0.1, 0.15, 16);
const ringMat = new THREE.MeshBasicMaterial({ color: 0x56b6c2, side: THREE.DoubleSide, transparent:true, opacity:0.8 });
const ring = new THREE.Mesh(ringGeo, ringMat);
ring.position.copy(pos);
ring.lookAt(new THREE.Vector3(0,0,0));
globeGroup.add(ring);
markers.push(ring);
});
};
function animate() {
requestAnimationFrame(animate);
if(globeGroup) {
// slow spin
globeGroup.rotation.y += 0.002;
}
renderer.render(scene, camera);
}
document.addEventListener('DOMContentLoaded', init3D);
</script>
</body>
</html>