-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tmpl
792 lines (651 loc) · 24.1 KB
/
index.tmpl
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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
<!DOCTYPE html>
<html>
<head>
<title>Are we meeting yet?</title>
<meta charset="utf-8">
<style>
body {
text-align: center;
font-family: -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
text-rendering: optimizelegibility;
font-size: 1.8em;
font-weight: bold;
background: #fafafa;
color: #333;
padding: 2em;
}
div#wrap {
overflow: auto;
margin: 0px auto;
text-align: center;
width: 850px;
}
h1 {
text-align: center;
font-size: 1.8em;
}
p {
margin: 30px;
margin-top: 30px;
}
p#local, p#ref {
display: none;
text-align: center;
}
span.label {
display: block;
color: #aaa;
width: 100%;
font-weight: normal;
font-size: 0.7em;
margin: 10px;
}
section {
clear: both;
display: block;
font-weight: normal;
font-size: .55em;
margin: 4em auto 0em auto;
width: 450px;
}
section[hidden] {
display: none;
}
form {
text-align: left;
}
input {
font: inherit;
padding: .3em .5em;
}
label,
fieldset,
input[type="submit"] {
display: block;
margin: 1em 0 0;
}
fieldset {
border: none;
padding: 0;
}
fieldset > label {
display: inline;
padding-right: .7em;
}
label.name, legend.name {
padding-left: 1px;
padding-bottom: 5px;
}
footer p {
font-weight: normal;
font-size: 0.5em;
color: #999;
margin-top: 80px;
text-align: center;
}
a {
text-decoration: none;
color: #99f;
}
a.edit {
cursor: pointer;
}
a:hover, a:active {
color: #f99;
}
span.hint {
color: #aaa;
}
p.narrow {
margin: 0;
width: 450px;
}
</style>
</head>
<body>
<div id="wrap">
<h1></h1>
<p id="local">
<span id="your" class="label">Your time:</span>
<span class="val"></span>
<span id="delta" class="label"></span>
</p>
<p id="ref" style="display: none;">
<span class="label">For your calendar (<a id="ical">add it</a>):</span>
<span class="val"></span>
<span id="zone" class="label"></span>
</p>
<section hidden>
<h1>Build new meeting link</h1>
<form id="form" action="/" method="get">
<p class="narrow">
Enter your meeting details to build a new URL. Click the button
at the bottom of the form to go there, then send the address
of that page to other meeting participants.
</p>
<label for="timezone" class="name">Timezone <span class="hint">(reference/stable timezone for your meeting)</span></label>
<input type="text" name="timezone" id="timezone" size="30" list="tz" placeholder="Continent/Timezone" required>
<label for="date" class="name">Date</label>
<input type="date" name="date" id="date" size="20" placeholder="YYYY-MM-DD" pattern="[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])" required>
<label for="time" class="name">Time</label>
<input type="time" id="time" size="20" placeholder="HH:MM" pattern="[012][0-9]:[0-5][0-9]" required>
<fieldset>
<legend class="name">Repeat?</legend>
<input type="radio" name="repeat" id="repeat-never" value="" checked required><label for="repeat-never">Never</label>
<input type="radio" name="repeat" id="repeat-w" value="w"><label for="repeat-w">Weekly</label>
<input type="radio" name="repeat" id="repeat-b" value="b"><label for="repeat-b">Bi-weekly</label>
<input type="radio" name="repeat" id="repeat-t" value="t"><label for="repeat-t">Tri-weekly</label>
</fieldset>
<label for="title-field" class="name">Title <span class="hint">(optional)</span></label>
<input type="text" name="title" id="title-field" size="30" placeholder="My awesome meeting">
<input type="submit" value="Go to URL for new meeting">
</form>
<datalist id="tz">
<option>UTC</option>
</datalist>
</section>
<footer>
<p>
<a class="edit">Use as template</a> |
Created by <a href="http://dirkjan.ochtman.nl/">Dirkjan Ochtman</a> |
<a href="https://github.com/djc/awmy/">Feedback welcome</a>
</p>
</footer>
</div>
<script>
var ZONES = {{ zones }};
var RULES = {{ rules }};
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function(){
var ret = {}, s = {};
var seg = a.search.replace(/^\?/,'').split('&');
for (var i = 0; i < seg.length; i++) {
if (!seg[i]) { continue; }
s = seg[i].split('=');
ret[s[0]] = s[1];
}
return ret;
})(),
file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
hash: a.hash.replace('#', ''),
path: a.pathname.replace(/^([^\/])/, '/$1'),
relative: (a.href.match(/tps ? : \/\/[^\/]+(.+)/) || [, ''])[1],
segments: a.pathname.replace(/^\//, '').split('/')
};
}
function pad(x) {
if (x >= 0) {
return x < 10 ? '0' + x : x.toString();
} else {
return x < -9 ? x : '-0' + Math.abs(x);
}
}
var scales = {
'year': 365 * 24 * 60 * 60,
'month': 30 * 24 * 60 * 60,
'week': 7 * 24 * 60 * 60,
'day': 24 * 60 * 60,
'hour': 60 * 60,
'minute': 60,
'second': 1
};
function relTime(x, y) {
var delta = Math.floor((y.getTime() - x.getTime()) / 1000);
if (delta < 0) {
return 'in the past';
}
for (unit in scales) {
var s = scales[unit];
var n = delta / s;
if ((unit == 'hour') && (n < 12)) {
var h = Math.floor(n);
var m = Math.floor(n % 1 * 60);
var s = Math.floor(n % (1 / 60) * 3600);
var str = h + ':' + pad(m) + ':' + pad(s);
return str + ' from now';
}
if ((n >= 2) || (s == 1)) {
var str = Math.floor(n) + ' ' + unit + (n > 1 ? 's' : '');
return str + ' from now';
}
}
}
function refresh(d) {
var relString = relTime(new Date(), d);
document.querySelector('span#delta').innerHTML = '(' + relString + ')';
}
var DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var MONTHS = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
];
function format(d, offset) {
d = new Date(d.getTime() + offset * 60 * 1000);
var wd = d.getUTCDay();
var dn = d.getUTCDate();
var m = d.getUTCMonth();
var y = d.getUTCFullYear();
var H = d.getUTCHours();
var M = d.getUTCMinutes();
var S = d.getUTCSeconds();
var dstr = dn.toString();
var last = parseInt(dstr.substr(dstr.length - 1, 1), 10);
if (parseInt(dstr, 10) >= 7 && parseInt(dstr, 10) < 20) {
var suffix = 'th';
} else if (last == 1) {
suffix = 'st';
} else if (last == 2) {
suffix = 'nd';
} else if (last == 3) {
suffix = 'rd';
} else {
suffix = 'th';
}
var ds = DAYS[wd] + ', ' + dn + suffix + ' ' + MONTHS[m] + ', ';
var ts = pad(H) + ':' + pad(M);
var zone = '';
if (offset) {
var delta = pad(offset / 60) + ':' + pad(offset % 60);
zone = (offset > 0 ? '+' : '') + delta;
zone = zone.substr(0, 1) + ' ' + zone.substr(1);
}
return [ds + ts, zone];
}
function digit(s) {
var c = s.charCodeAt(0);
return (c > 47) && (c < 58);
}
function capitalize(s) {
return s.substr(0, 1).toUpperCase() + s.substr(1).toLowerCase();
}
function procLiteral(ds, ts) {
var dbits = ds.split('-');
var d = new Date();
d.setUTCFullYear(dbits[0]);
d.setUTCMonth(dbits[1] - 1, dbits[2]);
var tbits = ts.split(':');
d.setUTCHours(tbits[0]);
d.setUTCMinutes(tbits[1]);
d.setUTCSeconds(0);
return d;
}
function procWeekly(bits) {
var day = bits[0].length > 3 ? bits[0].substr(1) : bits[0];
var idx = DAYS.indexOf(capitalize(day));
var now = new Date(Date.now());
now.setUTCSeconds(0);
var t = pad(now.getUTCHours()) + ':' + pad(now.getUTCMinutes());
if ((now.getUTCDay() != idx) || (t >= bits[1])) {
var diff = (idx - now.getUTCDay()) % 7;
diff = diff <= 0 ? diff + 7 : diff;
now = new Date(now.getTime() + diff * 24 * 60 * 60 * 1000);
}
var tbits = bits[1].split(':');
now.setUTCHours(tbits[0]);
now.setUTCMinutes(tbits[1]);
return now;
}
var PARTS = ["Europe", "Australia", "Africa", "Asia", "Antarctica", "Indian", "Atlantic", "Pacific", "America"];
var LOCAL = {};
for (var key in ZONES) {
var local = key.split('/')[1];
LOCAL[local.toLowerCase()] = key;
}
function canonicalZone(zone) {
if (zone === 'UTC') return zone;
zone = zone.replace(' ', '_');
zone = LOCAL[zone.toLowerCase()] || zone;
if (ZONES[zone].length > 1) {
alert('This code has not been tested! (zone-multi)');
}
return zone;
}
function zoneOffset(zone, d) {
if (zone == 'UTC') {
return 0;
}
var active = ZONES[zone][ZONES[zone].length - 1];
var zoneoff = active.o;
console.log('ZONE-OFFSET: ' + zoneoff);
d = new Date(d.getTime() - zoneoff * 1000);
var changes = [];
var y = d.getUTCFullYear();
var dstoff = 0;
for (var i in RULES[active.r]) {
console.log('RULE: ' + JSON.stringify(RULES[active.r][i]));
var rule = RULES[active.r][i];
if (parseInt(rule[0], 10) > y) {
continue;
}
if (rule[1] != 'max' && parseInt(rule[1], 10) < y) {
continue;
}
if (rule[2] != '-') {
alert('This code has not been tested! (year-type)');
}
// Months handling
var rm = MONTHS.indexOf(rule[3]) + 1;
var m = d.getUTCMonth() + 1;
console.log('COMPARE: ' + m + ' ~ ' + rm);
if (m < rm) {
continue;
} else if (m > rm) {
dstoff = rule[6];
console.log('DST-OFFSET: ' + dstoff);
continue;
}
// Find the transition day
var cur = new Date(Date.UTC(y, m - 1, 1, 0, 0));
console.log('FIRST: ' + cur);
var wd = cur.getUTCDay();
if (rule[4].substr(0, 4) == 'last') {
var idx = 40;
var target = DAYS.indexOf(rule[4].substr(4));
} else {
var parts = rule[4].split('>=');
idx = parseInt(parts[1], 10);
target = DAYS.indexOf(parts[0]);
}
console.log('IDX: ' + idx + ' TARGET: ' + target);
if (wd != target) {
cur = new Date(cur.getTime() + 86400 * (7 - wd) * 1000);
}
console.log('MOVED-DAY: ' + cur);
while (cur.getUTCMonth() == m - 1 && cur.getUTCDate() < idx) {
cur = new Date(cur.getTime() + 86400 * 7 * 1000);
console.log('LOOPED: ' + cur);
}
if (cur.getUTCMonth() == m) {
cur = new Date(cur.getTime() - 86400 * 7 * 1000);
console.log('WOUND-BACK: ' + cur);
}
console.log('TRANS-DAY: ' + cur);
console.log('COMPARE-DAYS: ' + d.getUTCDate() + ' ~ ' + cur.getUTCDate());
if (d.getUTCDate() < cur.getUTCDate()) {
continue;
} else if (d.getUTCDate() > cur.getUTCDate()) {
dstoff = rule[6];
console.log('DST-OFFSET: ' + dstoff);
continue;
}
// Find the transition time
var ttime = rule[5];
console.log('FLOO: ' + ttime.charAt(ttime.length - 1));
if (['w', 'u', 's'].indexOf(ttime.charAt(ttime.length - 1)) >= 0) {
var type = ttime.charAt(ttime.length - 1);
ttime = ttime.substr(0, ttime.length - 1);
} else {
type = 'w';
}
console.log('TIME-TYPE: ' + ttime + ' ' + type);
parts = ttime.split(':');
var sdiff = parseInt(parts[0], 10) * 3600;
if (parts.length > 1) {
sdiff += parseInt(parts[1], 10) * 60;
if (parts.length > 2) {
sdiff += parseInt(parts[2], 10) * 60;
}
}
if (type == 'u') {
cur = new Date(cur.getTime() + sdiff * 1000);
} else if (type == 's') {
cur = new Date(cur.getTime() + (sdiff - zoneoff) * 1000);
} else {
cur = new Date(cur.getTime() + (sdiff - zoneoff - dstoff) * 1000);
}
console.log('TRANS-TIME: ' + cur);
console.log('MEETING-TIME: ' + d);
if (d.getTime() < cur.getTime()) {
continue;
} else {
dstoff = rule[6];
console.log('DST-OFFSET: ' + dstoff);
continue;
}
// Still moderately fucked up at transition time
// Particularly when transition is forward?
}
return zoneoff + dstoff;
}
function repeatDays(d, n) {
var diff = d.getTime() - (new Date()).getTime();
var unit = 86400 * n * 1000;
var move = (diff < 0 || diff > 1) ? -Math.floor(diff / unit) : 0;
return new Date(d.getTime() + move * unit);
}
function oldWeek(x) {
return x.charAt(0) == 'W' && x.length == 4 && x[0] != 'Wake';
}
function newWeek(x) {
return DAYS.indexOf(capitalize(x)) >= 0;
}
function stringFromUrlPath(path) {
return path.replace(/(%20|_)+/g, ' ');
}
function hashString(s) {
var hash = 0;
if (s.length == 0) return hash;
for (i = 0; i < s.length; i++) {
hash = ((hash << 5) - hash) + s.charCodeAt(i);
hash = hash & hash;
}
return Math.abs(hash).toString(32);
}
function showInfo(url) {
var bits = parseURL(url).path.split('/');
bits.shift();
if (bits.length > 1) {
document.querySelector('a.edit').innerHTML = 'Use as template';
} else {
document.querySelector('section').removeAttribute('hidden');
document.location = '#form';
return;
}
// Extract data from URL
var restrict = null;
if (newWeek(bits[0])) {
bits = ['UTC'].concat(bits);
} else if (digit(bits[0])) {
bits = ['UTC'].concat(bits);
} else if (oldWeek(bits[0])) {
bits = ['UTC'].concat(bits);
bits[1] = procWeekly(bits.slice(1, 3)).toISOString().substr(0, 10);
restrict = 'w';
} else {
if (PARTS.indexOf(bits[0]) >= 0) {
var zone = decodeURIComponent(bits[0]) + '/' + decodeURIComponent(bits[1]).replace(' ', '_');
bits = [canonicalZone(zone)].concat(bits.slice(2));
} else {
bits[0] = canonicalZone(decodeURIComponent(bits[0]));
}
}
console.log('BITS', JSON.stringify(bits));
// Calculate date value from URL data
var next = 1;
if (newWeek(bits[next])) {
var ds = procWeekly(bits.slice(next, next + 2)).toISOString().substr(0, 10);
var d = procLiteral(ds, bits[next + 1]);
restrict = 'w';
} else {
d = procLiteral(bits[next], bits[next + 1]);
}
console.log('DATE', d);
// Apply repetitions to get future date
var mode = null;
next += 2;
if (bits[next] == 'w') {
d = repeatDays(d, 7);
next += 1;
mode = 'w';
} else if (bits[next] == 'b') {
d = repeatDays(d, 14);
next += 1;
mode = 'b';
} else if (bits[next] == 't') {
d = repeatDays(d, 21);
next += 1;
mode = 't';
} else {
bits.splice(next, 0, null);
next += 1;
}
// Apply necessary offset
var offset = zoneOffset(bits[0], d);
d = new Date(d.getTime() - offset * 1000);
var now = new Date();
if (mode == 'w' && now.getTime() < (d.getTime() - (86400 * 7 * 1000))) {
d = new Date(d.getTime() - (86400 * 7 * 1000));
} else if (mode == 'b' && now.getTime() < (d.getTime() - (86400 * 14 * 1000))) {
d = new Date(d.getTime() - (86400 * 14 * 1000));
} else if (mode == 't' && now.getTime() < (d.getTime() - (86400 * 21 * 1000))) {
d = new Date(d.getTime() - (86400 * 21 * 1000));
}
// Show results in document
var para = document.querySelector('p#local');
var local = format(d, -d.getTimezoneOffset());
para.querySelector('span.val').innerHTML = local[0];
var label = para.querySelector('span#your');
if (mode) {
label.innerHTML = 'Next occurrence, your time (UTC ' + local[1] + '):';
} else {
label.innerHTML = 'Your time (UTC ' + local[1] + '):';
}
para.style.display = 'block';
var ref = format(d, offset / 60);
document.querySelector('p#ref span.val').innerHTML = ref[0];
if (bits[0] == 'UTC') {
var text = '(in UTC)';
} else {
text = '(in timezone ' + bits[0].replace('_', ' ') + ', UTC ' + ref[1] + ')';
}
document.querySelector('p#ref span#zone').innerHTML = text;
document.querySelector('p#ref').style.display = 'block';
var title = decodeURIComponent(bits.slice(next).join('/'));
if (title != 'undefined') {
document.querySelector('h1').innerHTML = title;
document.querySelector('h1').style.display = 'block';
document.title = title + ' - Are we meeting yet?';
}
// Build iCal event
function iCalDate(d) {
return d.toISOString().replace(/[-:]+/g, '').substr(0, 15);
}
var specDate = new Date(d.getTime() + offset * 1000);
if (bits[0] === 'UTC') {
var iCalStart = ':' + iCalDate(specDate) + 'Z';
} else {
iCalStart = ';TZID=' + bits[0] + ':' + iCalDate(specDate);
}
var iCalLines = [
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//XavaMedia//arewemeetingyet.com//EN',
'BEGIN:VEVENT',
'UID:' + hashString(JSON.stringify(bits)) + '@arewemeetingyet.com',
'DTSTAMP:' + iCalDate(new Date()) + 'Z',
'DTSTART' + iCalStart,
'SUMMARY:' + title,
'END:VEVENT',
'END:VCALENDAR'
];
if (mode) {
var iCalInterval = {'w': '', 'b': ';INTERVAL=2', 't': ';INTERVAL=3'}
var iCalRule = 'RRULE:FREQ=WEEKLY' + iCalInterval[mode];
iCalLines.splice(6, 0, iCalRule);
}
var iCalData = iCalLines.join('\r\n') + '\r\n';
var iCalLink = document.getElementById('ical');
iCalLink.href = 'data:text/calendar;base64,' + btoa(iCalData);
iCalLink.title = "iCalendar event for '" + title + "'";
// Set values in form for editing
bits = parseURL(url).path.split('/');
bits.shift();
document.getElementById('timezone').setAttribute('value', stringFromUrlPath(bits[0]));
document.getElementById('date').setAttribute('value', bits[1]);
document.getElementById('time').setAttribute('value', (bits[2].length < 5 ? '0' : '') + bits[2]);
if (bits.length === 5 && /^[wbt]$/.test(bits[3])) {
document.getElementById('repeat-' + bits[3]).checked = true;
}
document.getElementById('title-field').setAttribute('value', title);
// Warn about data which is only valid in repeating mode
if (restrict && mode !== restrict) {
alert('Weekdays are only valid for weekly repeating.');
}
refresh(d);
window.setInterval(refresh, 100, d);
}
showInfo(document.location);
(function($) {
'use strict';
// add timezones
var options = document.getElementById('tz').innerHTML;
Object.keys(ZONES).sort().forEach(function(key) {
options += '<option>' + key + '</option>';
});
document.getElementById('tz').innerHTML = options;
// create URL when form submitted
document.querySelector('form').addEventListener('submit', function(event) {
event.preventDefault();
// construct URL
var form = this,
URL = '/',
params = ['timezone', 'date', 'time', 'title'],
linkElement;
params = params.map(function(name) {
return form.elements[name].value;
}).filter(function(value) {
return !!value;
});
var repeat = '';
for (var i in form.elements['repeat']) {
var f = form.elements['repeat'][i];
if (f.checked) {
repeat = f.value;
break;
}
}
if (repeat) {
params.splice(3, 0, [repeat]);
}
// keep the timezone, lose the continent
params[0] = params[0].replace(/^.*\/(.*)$/, '$1');
// replace spaces with underscore in timezone
params[0] = params[0].replace('_', ' ');
// encode all params and append to URL
URL += params
.map(encodeURIComponent)
.join('/')
// replace %3A with ':' (%3A not handled)
.replace(/%3A/g, ':');
// goto URL
location.href = URL;
return false;
});
// hide form behind button
document.querySelector('a.edit').addEventListener('click', function() {
document.querySelector('section').removeAttribute('hidden');
document.location = '#form';
});
}());
// check time format
document.getElementById('time').addEventListener('change', function() {
// append :00 minutes to 2-digit entry
var timeInput = document.getElementById('time');
if (/^\d\d$/.test(timeInput.value)) {
timeInput.value += ':00';
}
if (timeInput.value > '21' || timeInput.value < '06') {
alert("Meeting planned during reference timezone's night, are you sure?");
}
});
</script>
</body>
</html>