-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
822 lines (600 loc) · 28.6 KB
/
index.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
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
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
<head>
<title>Petscop Calendars</title>
<link rel="icon" href="icon.png">
<style>
/* Menu */
#wall { position: absolute; left: 0; right: 0; top: 0; bottom: 0; }
.calendar { width: 1466px; height: 963px; border: 5px solid black; border-collapse: collapse; transform: scale(0.9) translateY(-3.5em); -webkit-transform: scale(0.9) translateY(-3.5em) }
.calendarIcon { position: relative; padding-right: 8em; padding-left: 8em; padding-top: 30em; }
/* Calendar UI */
td { width: 168px; height: 145px; font-size: 65px; padding: 5px; border-width: 10px; border-color: black; font-weight: bold; font-family: "arial"; vertical-align: top; }
th { width: 195px; height: 85px; font-size: 55px; border-width: 10px; border-color: black; font-family: "arial"; }
.buttonLeft { position: relative; width: 9px; height: 10px; cursor: pointer; }
.buttonRight { position: relative; width: 9px; height: 10px; cursor: pointer; }
.currentDayHighlight { transform-origin: 15% 50%; -webkit-transform-origin: 15% 50%; }
.unselectable { user-select: none; }
@font-face {
font-family: "month";
src: url("monthFont.eot");
src: url("monthFont.ttf") format("truetype"),
url("monthFont.woff") format("woff");
}
/* Christmas tree animation */
.view { perspective: 800px; transform-style: preserve-3d; -webkit-transform-style: preserve-3d; position: relative; bottom: 1.75em; left: 0.8em }
.tree { transform-style: preserve-3d; transform: translateY(2em); -webkit-transform-style: preserve-3d; -webkit-transform: translateY(2em) }
.face, .face-wrapper { position: absolute; transform-origin: 0 0; -webkit-transform-origin: 0 0; overflow: hidden; width: 100%; height: 200%; }
.face { background: linear-gradient(to bottom right, #000000, #9ef098); -webkit-backface-visibility: hidden; backface-visibility: hidden; left: 100%; transform: rotateZ(45deg) translateX(-35.35%) translateY(35.35%); -webkit-transform: rotateZ(45deg) translateX(-35.35%) translateY(35.35%); }
.shape { position: absolute; transform-style: preserve-3d; -webkit-transform-style: preserve-3d; top: 50%; left: 50%; width: 0; height: 0; transform-origin: 50%; -webkit-transform-origin: 50%; }
</style>
</head>
<!-- Credit to u/ChappyWagon for the sound effects -->
<body style="background-color:#1a1a1a;">
<div id="wall" align="center"></div>
<div id="calendarDisplay" align="center" style="height: 0%;"></div>
</body>
<!-- Christmas tree animation
Based on samples generated by tridiv.com
-->
<script>
function createView()
{
view = document.createElement("div");
view.setAttribute("class", "view");
view.appendChild(createTree());
rotI = 0;
setInterval(function() { rotI = rotateView(view, rotI); }, 8);
return view;
}
function createTree()
{
tree = document.createElement("div");
tree.setAttribute("class", "tree");
tree.appendChild(createLayer(0));
tree.appendChild(createLayer(1));
tree.appendChild(createLayer(2));
tree.appendChild(createLayer(3));
return tree;
}
function rotateView(view, rotI)
{
transform = "transform: scale(0.3807692308) translateY(10px) translateX(-25px) rotateX(" + angles(rotI) + "deg);"
view.style = transform + "-webkit-" + transform;
return (rotI >= 210) ? 0 : rotI + 1;
}
function angles(i)
{
returnValue = 70;
if(i < 60) returnValue = 10 + smoothstep(i / 60) * 20;
else if(i < 120) returnValue = 30 + smootherstep((i - 60) / 60) * 40;
else if(i < 210) returnValue = 70 - smoothstep((i - 120) / 90) * 60;
else returnValue = 10;
return -returnValue;
}
function smoothstep(x) { return x * x * (3 - 2 * x); }
function smootherstep(x) { return x * x * x * (x * (x * 6 - 15) + 10); }
function createLayer(index)
{
layer = document.createElement("div");
for(i = 0; i < 3; i++) layer.appendChild(createPyramid(i, index));
return layer;
}
function createPyramid(index, layerIndex)
{
size = 4 - Math.pow(layerIndex, 1.5) / 2;
angle = 0;
if(index == 1) angle = 60;
if(index == 2) angle = -60;
pyramid = document.createElement("div");
pyramid.setAttribute("class", "shape pyramid");
transform = "transform: rotateY(" + angle + "deg) scaleX(0.58) translateY(" + -layerIndex * 1.25 + "em);";
pyramid.style = "width: " + size + "em; height: " + size / 4 + "em; margin: " + size * -0.125 + "em 0 0 " + size * -0.5 + "em;" + transform + "-webkit-" + transform;
isTopLayer = (layerIndex == 3);
pyramid.appendChild(createFace("ft", size, isTopLayer));
pyramid.appendChild(createFace("bk", size, isTopLayer));
pyramid.appendChild(createFace("lt", size, isTopLayer));
pyramid.appendChild(createFace("rt", size, isTopLayer));
return pyramid;
}
function createFace(type, size, isTopLayer)
{
wrapper = document.createElement("div");
wrapper.setAttribute("class", "face-wrapper " + type);
sizeFactor = 4 * Math.pow(size, -2) + 1;
scale = Math.sqrt(sizeFactor);
angle = Math.asin(1 / Math.sqrt(sizeFactor)) * 180 / Math.PI;
shortcut = ") scaleY(" + scale * 1.25 + ") rotate";
position = "";
switch(type)
{
case "ft":
transform = "scaleZ(" + scale + shortcut + "X(" + angle + "deg)";
break;
case "bk":
transform = "scaleZ(" + scale + shortcut + "X(" + -angle + "deg) rotateY(180deg)";
position = "left: 100%;";
break;
case "rt":
transform = "scaleX(" + scale + shortcut + "Z(" + angle + "deg) rotateY(-90deg)";
position = "transform-origin: 50% 0;";
break;
case "lt":
transform = "scaleX(" + scale + shortcut + "Z(" + -angle + "deg) rotateY(90deg)";
position = "transform-origin: 50% 0;";
break;
}
wrapper.style = position + "transform:" + transform + ";-webkit-transform:" + transform;
face = document.createElement("div");
face.setAttribute("class", "face");
if(isTopLayer) face.style = "background: #4f684c";
wrapper.appendChild(face);
return wrapper;
}
christmasTree = createView();
</script>
<script>
focused = true;
setTimeout(playClink, ((Math.random()>1/3) ? 25 + Math.random() * 32 : 25 - Math.random() * 17) * 1000);
function playClink()
{
if(focused) new Audio("audio/clink.mp3").play();
setTimeout(playClink, ((Math.random()>1/3) ? 25 + Math.random() * 32 : 25 - Math.random() * 17) * 1000);
}
document.fonts.load("81px month");
</script>
<script>
var currentOpenCalendar;
questionMark = document.createElementNS("http://www.w3.org/2000/svg", "svg");
triangle = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
text = document.createElementNS("http://www.w3.org/2000/svg", "text");
triangle.setAttribute("points", "0,50 -50,-50 50,-50");
triangle.style = "fill:white; transform-origin: 0% 25%; transform: inherit; -webkit-transform-origin: 0% 25%; -webkit-transform: inherit";
text.setAttribute("x", -24);
text.setAttribute("y", 20);
text.setAttribute("font-family", "Helvetica");
text.setAttribute("font-size", 80);
text.setAttribute("class", "unselectable");
text.innerHTML = "?";
questionMark.setAttribute("height", "200px");
questionMark.setAttribute("width", "200px");
questionMark.setAttribute("viewBox", "-100 -100 200 200");
questionMark.setAttribute("class", "questionMark");
questionMark.sizeI = 0;
questionMark.hoverI = 0;
questionMark.appearing = false;
questionMark.text = text;
questionMark.appendChild(triangle);
questionMark.appendChild(text);
setInterval(function() { questionMarkAnimation() }, 1);
function showQuestionMark()
{
new Audio("audio/qm.mp3").play();
questionMark.sizeI = 0;
questionMark.setAttribute("height", "0px");
questionMark.setAttribute("width", "0px");
questionMark.appearing = true;
this.self.appendChild(questionMark);
}
function hideQuestionMark() { questionMark.appearing = false; }
function questionMarkAnimation()
{
sizeI = questionMark.sizeI;
if(questionMark.appearing) { if(sizeI < 60) sizeI++; }
else { if(sizeI > 0) sizeI--; }
questionMark.sizeI = sizeI;
size = Math.sin(sizeI * Math.PI / 120) * 200;
questionMark.setAttribute("height", size + "px");
questionMark.setAttribute("width", size + "px");
questionMark.setAttribute("x", 50 - size / 2);
hoverI = questionMark.hoverI;
hoverRot = Math.sin(hoverI * Math.PI / 375);
hover = Math.sin(hoverI * Math.PI / 187.5);
questionMark.setAttribute("y", -70 - size / 2 - hover * 30);
transform = "transform: rotate(" + (hoverRot * 11.25) + "deg);";
questionMark.style = transform + "-webkit-" + transform;
transform = "transform: translate(0, 50px) rotate(" + (hoverRot * 11.25) + "deg) translate(0, -50px);"
questionMark.text.style = transform + "-webkit-" + transform;
questionMark.hoverI++;
if(questionMark.hoverI >= 750) questionMark.hoverI = 0;
}
</script>
<script>
calendarDisplay = document.getElementById("calendarDisplay");
calendarDisplay.addEventListener("mousedown", function() {returnToMenu();});
rows = 0;
cellIndex = 1;
monthName = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
weekdayName = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
monthGreenSort = [
function(day) { return day % 2 == 0; }, // Every other day
function(day) { return (day % 2 == 0 && day <= 10) || (day >= 15 && day <= 16) || (day >= 22 && day <= 23); }, // Every other day until February 11th or 12th; afterwards, weekends
function(day) { return (day - 2) % 7 == 0 || (day - 1) % 7 == 0; }, // Weekends
function(day) { return (day - 6) % 7 == 0 || (day - 5) % 7 == 0; }, // Weekends
function(day) { return (day - 4) % 7 == 0 || (day - 3) % 7 == 0; }, // Weekends
function(day) { return day == 1 || day >= 5; }, // Weekends until June 5th (according to Paul, the day "she" went missing, and also the date to which Paul returns after the first Demo scene (third calendar)); afterwards, always
function(day) { return true; }, // Always
function(day) { return true; }, // Always
function(day) { return true; }, // Always
function(day) { return true; }, // Always
function(day) { return day <= 10; }, // Always until November 10th (according to Paul, the day "she" was found); afterwards, never
function(day) { return false; } // Never
];
function createDay(index)
{
// Create day and set up some technical data
cell = document.createElement("td");
cell.className = "unselectable";
cell.id = "cell" + index;
// Light-dark color pattern
cell.setAttribute("bgcolor", (index%2==1) ? "#777777" : "#AAAAAA");
return cell;
}
calendarSvg = ["M13 0h10v26h-10v-26z (51,51,51)", "M47 0h10v26h-10v-26z (51,51,51)", "M81 0h10v26h-10v-26z (51,51,51)", "M0 13h13v13h10v-13h24v13h10v-13h24v13h10v-13h13v24h-104v-24z (36,44,25)", "M0 37h104v76h-104v-76z (170,170,170)"];
pressedLeftSvg = ["M8 0h8v1h-8v-1z (170,170,170)", "M7 1h1v1h-1v-1z (119,119,119)", "M8 1h8v1h-8v-1z (34,35,36)", "M16 1h1v1h-1v-1z (119,119,119)", "M6 2h1v1h-1v-1z (119,119,119)", "M7 2h1v1h-1v-1z (30,31,32)", "M8 2h8v15h-8v-1h-1v-1h-1v-1h-1v-1h-1v-1h-1v-1h-2v-3h2v-1h1v-1h1v-1h1v-1h1v-1h1v-1z (41,42,43)", "M16 2h1v16h-1v-16z (34,35,36)", "M17 2h1v16h-1v-16z (119,119,119)", "M5 3h1v1h-1v-1z (119,119,119)", "M6 3h1v1h-1v-1z (30,31,32)", "M4 4h1v1h-1v-1z (119,119,119)", "M5 4h1v1h-1v-1z (30,31,32)", "M3 5h1v1h-1v-1z (119,119,119)", "M4 5h1v1h-1v-1z (30,31,32)", "M2 6h1v1h-1v-1z (119,119,119)", "M3 6h1v1h-1v-1z (30,31,32)", "M1 7h1v1h-1v-1z (119,119,119)", "M2 7h1v1h-1v-1z (30,31,32)", "M0 8h1v5h-1v-5z (119,119,119)", "M1 11h1v1h-1v-1z (34,35,36)", "M2 11h1v1h-1v-1z (119,119,119)", "M1 12h1v1h-1v-1z (26,27,28)", "M2 12h1v1h-1v-1z (34,35,36)", "M3 12h1v1h-1v-1z (119,119,119)", "M1 13h1v1h-1v-1z (119,119,119)", "M2 13h1v1h-1v-1z (26,27,28)", "M3 13h1v1h-1v-1z (34,35,36)", "M4 13h1v1h-1v-1z (119,119,119)", "M2 14h1v1h-1v-1z (119,119,119)", "M3 14h1v1h-1v-1z (26,27,28)", "M4 14h1v1h-1v-1z (34,35,36)", "M5 14h1v1h-1v-1z (119,119,119)", "M3 15h1v1h-1v-1z (119,119,119)", "M4 15h1v1h-1v-1z (26,27,28)", "M5 15h1v1h-1v-1z (34,35,36)", "M6 15h1v1h-1v-1z (119,119,119)", "M4 16h1v1h-1v-1z (119,119,119)", "M5 16h1v1h-1v-1z (26,27,28)", "M6 16h1v1h-1v-1z (34,35,36)", "M7 16h1v1h-1v-1z (119,119,119)", "M5 17h1v1h-1v-1z (119,119,119)", "M6 17h1v1h-1v-1z (26,27,28)", "M7 17h1v1h-1v-1z (34,35,36)", "M8 17h8v1h-8v-1z (119,119,119)", "M6 18h1v1h-1v-1z (119,119,119)", "M7 18h1v1h-1v-1z (26,27,28)", "M8 18h7v1h-7v-1z (23,23,18)", "M15 18h1v1h-1v-1z (34,35,36)", "M16 18h1v1h-1v-1z (119,119,119)", "M7 19h9v1h-9v-1z (170,170,170)"];
pressedRightSvg = ["M2 0h8v1h-8v-1z (170,170,170)", "M1 1h1v1h-1v-1z (119,119,119)", "M2 1h8v1h-8v-1z (34,35,36)", "M10 1h1v1h-1v-1z (119,119,119)", "M0 2h1v16h-1v-16z (119,119,119)", "M1 2h1v16h-1v-16z (34,35,36)", "M2 2h8v1h1v1h1v1h1v1h1v1h1v1h2v3h-2v1h-1v1h-1v1h-1v1h-1v1h-1v1h-8v-15z (41,42,43)", "M10 2h1v1h-1v-1z (30,31,32)", "M11 2h1v1h-1v-1z (119,119,119)", "M11 3h1v1h-1v-1z (30,31,32)", "M12 3h1v1h-1v-1z (119,119,119)", "M12 4h1v1h-1v-1z (30,31,32)", "M13 4h1v1h-1v-1z (119,119,119)", "M13 5h1v1h-1v-1z (30,31,32)", "M14 5h1v1h-1v-1z (119,119,119)", "M14 6h1v1h-1v-1z (30,31,32)", "M15 6h1v1h-1v-1z (119,119,119)", "M15 7h1v1h-1v-1z (30,31,32)", "M16 7h1v1h-1v-1z (119,119,119)", "M17 8h1v5h-1v-5z (119,119,119)", "M15 11h1v1h-1v-1z (119,119,119)", "M16 11h1v1h-1v-1z (34,35,36)", "M14 12h1v1h-1v-1z (119,119,119)", "M15 12h1v1h-1v-1z (34,35,36)", "M16 12h1v1h-1v-1z (26,27,28)", "M13 13h1v1h-1v-1z (119,119,119)", "M14 13h1v1h-1v-1z (34,35,36)", "M15 13h1v1h-1v-1z (26,27,28)", "M16 13h1v1h-1v-1z (119,119,119)", "M12 14h1v1h-1v-1z (119,119,119)", "M13 14h1v1h-1v-1z (34,35,36)", "M14 14h1v1h-1v-1z (26,27,28)", "M15 14h1v1h-1v-1z (119,119,119)", "M11 15h1v1h-1v-1z (119,119,119)", "M12 15h1v1h-1v-1z (34,35,36)", "M13 15h1v1h-1v-1z (26,27,28)", "M14 15h1v1h-1v-1z (119,119,119)", "M10 16h1v1h-1v-1z (119,119,119)", "M11 16h1v1h-1v-1z (34,35,36)", "M12 16h1v1h-1v-1z (26,27,28)", "M13 16h1v1h-1v-1z (119,119,119)", "M2 17h8v1h-8v-1z (119,119,119)", "M10 17h1v1h-1v-1z (34,35,36)", "M11 17h1v1h-1v-1z (26,27,28)", "M12 17h1v1h-1v-1z (119,119,119)", "M1 18h1v1h-1v-1z (119,119,119)", "M2 18h1v1h-1v-1z (34,35,36)", "M3 18h7v1h-7v-1z (23,23,18)", "M10 18h1v1h-1v-1z (26,27,28)", "M11 18h1v1h-1v-1z (119,119,119)", "M2 19h9v1h-9v-1z (170,170,170)"];
unpressedLeftSvg = ["M8 0h8v1h-8v-1z (170,170,170)", "M7 1h1v1h-1v-1z (119,119,119)", "M8 1h8v1h-8v-1z (34,35,36)", "M16 1h1v1h-1v-1z (119,119,119)", "M6 2h1v1h-1v-1z (119,119,119)", "M7 2h1v1h-1v-1z (34,35,36)", "M8 2h8v13h-8v-1h-1v-1h-1v-1h-1v-1h-1v-1h-1v-1h-2v-1h2v-1h1v-1h1v-1h1v-1h1v-1h1v-1z (41,42,43)", "M16 2h1v16h-1v1h-1v-1h-7v1h-1v-1h-1v-1h-1v-1h-1v-1h-1v-1h-1v-1h-1v-4h1v1h1v1h1v1h1v1h1v1h1v1h1v1h8v-14z (34,35,36)", "M17 2h1v16h-1v-16z (119,119,119)", "M5 3h1v1h-1v-1z (119,119,119)", "M6 3h1v1h-1v-1z (34,35,36)", "M4 4h1v1h-1v-1z (119,119,119)", "M5 4h1v1h-1v-1z (34,35,36)", "M3 5h1v1h-1v-1z (119,119,119)", "M4 5h1v1h-1v-1z (34,35,36)", "M2 6h1v1h-1v-1z (119,119,119)", "M3 6h1v1h-1v-1z (34,35,36)", "M1 7h1v1h-1v-1z (119,119,119)", "M2 7h1v1h-1v-1z (34,35,36)", "M0 8h1v5h-1v-5z (119,119,119)", "M2 9h1v1h-1v-1z (119,119,119)", "M3 10h1v1h-1v-1z (119,119,119)", "M4 11h1v1h-1v-1z (119,119,119)", "M5 12h1v1h-1v-1z (119,119,119)", "M1 13h1v1h-1v-1z (119,119,119)", "M6 13h1v1h-1v-1z (119,119,119)", "M2 14h1v1h-1v-1z (119,119,119)", "M7 14h1v1h-1v-1z (119,119,119)", "M3 15h1v1h-1v-1z (119,119,119)", "M8 15h8v1h-8v-1z (119,119,119)", "M4 16h1v1h-1v-1z (119,119,119)", "M5 17h1v1h-1v-1z (119,119,119)", "M6 18h1v1h-1v-1z (119,119,119)", "M8 18h7v1h-7v-1z (23,23,18)", "M16 18h1v1h-1v-1z (119,119,119)", "M7 19h9v1h-9v-1z (170,170,170)"];
unpressedRightSvg = ["M2 0h8v1h-8v-1z (170,170,170)", "M1 1h1v1h-1v-1z (119,119,119)", "M2 1h8v1h-8v-1z (34,35,36)", "M10 1h1v1h-1v-1z (119,119,119)", "M0 2h1v16h-1v-16z (119,119,119)", "M1 2h1v14h8v-1h1v-1h1v-1h1v-1h1v-1h1v-1h1v-1h1v4h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1h-1v-1h-7v1h-1v-1h-1v-16z (34,35,36)", "M2 2h8v1h1v1h1v1h1v1h1v1h1v1h2v1h-2v1h-1v1h-1v1h-1v1h-1v1h-1v1h-8v-13z (41,42,43)", "M10 2h1v1h-1v-1z (34,35,36)", "M11 2h1v1h-1v-1z (119,119,119)", "M11 3h1v1h-1v-1z (34,35,36)", "M12 3h1v1h-1v-1z (119,119,119)", "M12 4h1v1h-1v-1z (34,35,36)", "M13 4h1v1h-1v-1z (119,119,119)", "M13 5h1v1h-1v-1z (34,35,36)", "M14 5h1v1h-1v-1z (119,119,119)", "M14 6h1v1h-1v-1z (34,35,36)", "M15 6h1v1h-1v-1z (119,119,119)", "M15 7h1v1h-1v-1z (34,35,36)", "M16 7h1v1h-1v-1z (119,119,119)", "M17 8h1v5h-1v-5z (119,119,119)", "M15 9h1v1h-1v-1z (119,119,119)", "M14 10h1v1h-1v-1z (119,119,119)", "M13 11h1v1h-1v-1z (119,119,119)", "M12 12h1v1h-1v-1z (119,119,119)", "M11 13h1v1h-1v-1z (119,119,119)", "M16 13h1v1h-1v-1z (119,119,119)", "M10 14h1v1h-1v-1z (119,119,119)", "M15 14h1v1h-1v-1z (119,119,119)", "M2 15h8v1h-8v-1z (119,119,119)", "M14 15h1v1h-1v-1z (119,119,119)", "M13 16h1v1h-1v-1z (119,119,119)", "M12 17h1v1h-1v-1z (119,119,119)", "M1 18h1v1h-1v-1z (119,119,119)", "M3 18h7v1h-7v-1z (23,23,18)", "M11 18h1v1h-1v-1z (119,119,119)", "M2 19h9v1h-9v-1z (170,170,170)"];
function setSvg(element, svg)
{
// Clear out old SVG components
while(element.firstChild)
element.removeChild(element.firstChild);
// Fill in new SVG components
for(i = 0; i < svg.length; i++) {
parts = svg[i].split(" (");
pathStr = parts[0];
color = parts[1];
path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", pathStr);
path.setAttribute("fill", "rgb(" + color);
if(pathStr == "M0 13h13v13h10v-13h24v13h10v-13h24v13h10v-13h13v24h-104v-24z") element.monthNamePath = path;
element.appendChild(path);
}
}
function pressLeft()
{
// Set the button's texture to a pressed one
setSvg(this, pressedLeftSvg);
this.calendar.prevMonth();
// Set the button's texture back to an unpressed one
selfR = this;
setTimeout(function() {setSvg(selfR, unpressedLeftSvg);}, 100);
}
function pressRight()
{
// Set the button's texture to a pressed one
setSvg(this, pressedRightSvg);
this.calendar.nextMonth();
// Set the button's texture back to an unpressed one
selfL = this;
setTimeout(function() {setSvg(selfL, unpressedRightSvg);}, 100);
}
function prevMonth()
{
// Make sure we're not on January
if(this.month > 1) {
this.month--;
this.update();
new Audio("audio/scroll.mp3").play();
}
}
function nextMonth()
{
// Make sure we're not on December
if(this.month < 12) {
this.month++;
this.update();
new Audio("audio/scroll.mp3").play();
}
}
function generateCalendarUI(year, month, day)
{
// Set up the calendar's date
calendar = document.createElement("table");
calendar.year = year;
calendar.presentMonth = month;
calendar.presentDay = day;
calendar.month = month;
// Style the calendar correctly
calendar.border = 1;
calendar.cellspacing = 0;
calendar.style = "display: none";
calendar.setAttribute("class", "calendar");
// Set the calendar's color to green, black, or red, depending on the year
switch(year) {
case 1997:
monthNameColor="#242c19"; break;
case 2000:
monthNameColor="#000000"; break;
case 2017:
monthNameColor="#881818"; break;
default:
monthNameColor="#ffffff"; break;
}
// Month name
firstRow = document.createElement("tr");
monthNameCell = document.createElement("th");
monthNameCell.id = "monthName";
monthNameCell.className = "unselectable";
monthNameCell.setAttribute("colspan", 7);
monthNameCell.setAttribute("bgcolor", monthNameColor);
monthNameCell.style = "font-size:81px; font-weight:200; color:#AAAAAA; margin:auto; font-family: month";
calendar.monthName = document.createTextNode(monthName[month - 1]);
monthNameCell.appendChild(calendar.monthName);
// Controls
buttonsRow = document.createElement("tr");
buttonsCell = document.createElement("th");
buttonsCell.setAttribute("colspan", 7);
buttonsCell.style = "border-color:#ffffff00";
rightSpan = document.createElement("span");
rightSpan.style = "float:right; transform: translate(-40px, 40px); -webkit-transform: translate(-40px, 40px)";
rightSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
rightSvg.id = "buttonRight";
rightSvg.setAttribute("width", "90px");
rightSvg.setAttribute("height", "100px");
rightSvg.setAttribute("viewBox", "0 0 18 20");
rightSvg.setAttribute("class", "buttonRight");
rightSvg.calendar = calendar;
rightSvg.press = pressRight;
rightSvg.addEventListener("mousedown", rightSvg.press);
setSvg(rightSvg, unpressedRightSvg);
rightSpan.appendChild(rightSvg);
calendar.nextMonth = nextMonth;
calendar.rightButton = rightSvg;
leftSpan = document.createElement("span");
leftSpan.style = "float:left; transform: translate(40px, 40px); -webkit-transform: translate(40px, 40px)";
leftSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
leftSvg.id = "buttonLeft";
leftSvg.setAttribute("width", "90px");
leftSvg.setAttribute("height", "100px");
leftSvg.setAttribute("viewBox", "0 0 18 20");
leftSvg.setAttribute("class", "buttonLeft");
leftSvg.calendar = calendar;
leftSvg.press = pressLeft;
leftSvg.addEventListener("mousedown", leftSvg.press);
setSvg(leftSvg, unpressedLeftSvg);
leftSpan.appendChild(leftSvg);
calendar.prevMonth = prevMonth;
calendar.leftButton = leftSvg;
monthNameCell.appendChild(leftSpan);
monthNameCell.appendChild(rightSpan);
firstRow.appendChild(monthNameCell);
calendar.appendChild(firstRow);
// Week-days
weekdayRow = document.createElement("tr");
weekdayRow.id = "Weekdays";
weekdayRow.className = "unselectable";
for(i = 0; i < 7; i++)
{
dayName = weekdayName[i];
dayCell = document.createElement("th");
dayCell.setAttribute("bgcolor", (i%2==1) ? "#777777" : "#AAAAAA");
dayCell.appendChild(document.createTextNode(dayName));
weekdayRow.appendChild(dayCell);
}
calendar.appendChild(weekdayRow);
// Days
cellIndex = 1;
row = document.createElement("tr");
dayArray = [];
for(rows = 0; rows < 6; rows++)
{
row = document.createElement("tr");
for(days = 0; days < 7; days++)
{
day = createDay(cellIndex);
row.appendChild(day);
dayArray.push(day);
cellIndex++;
}
calendar.appendChild(row);
}
calendar.dayCells = dayArray;
// Update function
calendar.update = updateCalendar;
calendar.update();
calendar.addEventListener("mousedown", function(event) {event.stopPropagation();});
calendarDisplay.appendChild(calendar);
return calendar;
}
function updateCalendar()
{
// Get some information about this month
this.monthName.nodeValue = monthName[this.month - 1];
weekDay = new Date(this.year, this.month-1, 1).getDay() + 1;
daysInMonth = new Date(this.year, this.month , 0).getDate();
// Reset the first few unused dates
index = 1;
if(weekDay > 1)
while(index < weekDay)
{
cell = this.dayCells[index - 1];
cell.innerHTML = "";
cell.setAttribute("bgcolor", (index%2==1) ? "#777777" : "#AAAAAA");
index++;
}
// Fill in the dates
for(monthDay = 1; monthDay <= daysInMonth; monthDay++)
{
// Day number
cell = this.dayCells[index - 1];
cell.innerHTML = monthDay;
// Date color
color = "";
evenCell = index%2==1;
pastPresentDay = (this.month == this.presentMonth && monthDay > this.presentDay) || this.month > this.presentMonth;
currentPresentDay = this.month == this.presentMonth && monthDay == this.presentDay;
greenDay = monthGreenSort[this.month - 1](monthDay) && this.year == 1997;
cell.setAttribute("bgcolor", (!pastPresentDay) ? ((greenDay && !currentPresentDay) ? ((evenCell) ? "#69a53d" : "#75b549") : ((evenCell) ? "#777777" : "#AAAAAA")) : ((evenCell) ? "#333333" : "#444444")); // Green for marked dates; gray for normal dates; dark gray for future dates
// Special dates
if(this.year == 1997 && this.month == 6 && monthDay == 13 && !pastPresentDay && !currentPresentDay)
{ // Secret "down right X" code for June 13th, 1997
symbols = document.createElement("p");
symbols.appendChild(document.createTextNode("🠋🠊X"));
symbols.align="right";
symbols.style = "font-size: 0.75em; color: rgba(0, 0, 0, 0.1); position: relative; line-height: 0px; bottom: 15px";
cell.appendChild(symbols);
}
if(currentPresentDay)
{ // Highlight for today
cell.innerHTML = "";
txt = document.createElement("p");
txt.setAttribute("class", "currentDayHighlight");
txt.appendChild(document.createTextNode(monthDay));
cell.appendChild(txt);
if(this.month == 12 && monthDay == 25)
// Animation for Christmas
cell.appendChild(christmasTree);
}
index++;
}
// Reset the remaining unused dates
while(index <= 42)
{
cell = this.dayCells[index - 1];
cell.innerHTML = "";
cell.setAttribute("bgcolor", (index%2==1) ? "#777777" : "#AAAAAA");
index++;
}
}
function createCalendar(year, month, day)
{
icon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
// Set the calendar's appearance and color
switch(year) {
case 1997:
monthNameColor="#242c19"; break;
case 2000:
monthNameColor="#222222"; break;
case 2017:
monthNameColor="#7a0000"; break;
default:
monthNameColor="#ffffff"; break;
}
setSvg(icon, calendarSvg);
icon.monthNamePath.setAttribute("fill", monthNameColor);
// Style the calendar correctly
icon.setAttribute("class", "calendarIcon");
icon.setAttribute("width", "208px");
icon.setAttribute("height", "226px");
icon.setAttribute("viewBox", "0 0 104 113");
// Selection box, for question mark overlay and inspecting the calendar
selectionRect = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
selectionRect.setAttribute("points", "0,0 104,0 104,113 0,113");
selectionRect.style = "fill:rgba(0,0,0,0); cursor: pointer";
icon.appendChild(selectionRect);
selectionRect.self = icon;
selectionRect.addEventListener("mousedown", inspectCalendar);
selectionRect.addEventListener("mouseover", showQuestionMark);
selectionRect.addEventListener("mouseout", hideQuestionMark);
// Create the calendar UI and add the calendar onto the wall
icon.ui = generateCalendarUI(year, month, day);
document.getElementById("wall").appendChild(icon);
return icon;
}
function inspectCalendar()
{
// Show the calendar's UI
calendar = this.self.ui;
calendar.month = calendar.presentMonth;
calendar.update();
calendar.style = "";
currentOpenCalendar = calendar;
calendarDisplay.style = "height: 100%";
// Play audio
new Audio("audio/" + calendar.year + ".mp3").play();
// Hide the menu
document.getElementById("wall").style = "display: none;";
}
function returnToMenu()
{
// Show the menu
document.getElementById("wall").style = "";
// Hide the calendar's UI
if(currentOpenCalendar)
{
currentOpenCalendar.style = "display: none";
calendarDisplay.style = "height: 0%";
currentOpenCalendar = null;
}
}
var isHoldingKey = false;
// If the user presses Esc, close the calendar UI
// If the user presses the arrow keys, scroll through the calendar
document.onkeydown = function(evt)
{
if(!isHoldingKey) {
evt = evt || window.event;
if("key" in evt)
{
key = evt.key;
if(key == "Escape" || key == "Esc") returnToMenu();
if(key == "ArrowLeft" && currentOpenCalendar) currentOpenCalendar.leftButton.press();
if(key == "ArrowRight" && currentOpenCalendar) currentOpenCalendar.rightButton.press();
}
else
{
key = evt.keyCode;
if(key == 27) returnToMenu();
if(key == 37 && currentOpenCalendar) currentOpenCalendar.leftButton.press();
if(key == 39 && currentOpenCalendar) currentOpenCalendar.rightButton.press();
}
isHoldingKey = true;
}
};
document.onkeyup = function(evt)
{
isHoldingKey = false;
}
window.onfocus = function()
{
focused = true;
}
window.onblur = function()
{
focused = false;
}
createCalendar(1997, 12, 25);
createCalendar(2000, 12, 25);
createCalendar(1997, 6, 5);
createCalendar(1997, 11, 12);
createCalendar(2017, 11, 12);
date = new Date();
createCalendar(date.getFullYear(), date.getMonth() + 1, date.getDate());
</script>
<!-- Animating the buttons -->
<script>
animationValue = 0;
animationProgress = 0;
setInterval(function() {
leftButtons = document.getElementsByClassName("buttonLeft");
rightButtons = document.getElementsByClassName("buttonRight");
for(i = 0; i < leftButtons.length; i++) {
leftButtons[i].style = "transform: translateX(" + (animationValue - 11) + "px) scale(10); -webkit-transform: translateX(" + (animationValue - 11) + "px) scale(10);";
rightButtons[i].style = "transform: translateX(" + -(animationValue - 11) + "px) scale(10); -webkit-transform: translateX(" + -(animationValue - 11) + "px) scale(10)";
}
if(animationProgress < 2)
animationValue += 5;
else if(animationProgress < 4)
animationValue -= 5;
else if(animationProgress >= 5)
animationProgress = -1;
animationProgress++;
}, 90);
</script>
<!-- Highlighting the current day -->
<script>
highlightValue = 0;
highlightProgress = 0;
setInterval(function() {
highlightedDays = document.getElementsByClassName("currentDayHighlight");
for(i = 0; i < highlightedDays.length; i++) {
day = highlightedDays[i];
style = "transform: rotate(" + highlightValue * -22.5 + "deg) scale(" + (1 + highlightValue / 4.7272727272) + ");";
day.style = style + "-webkit-" + style;
}
highlightValue = Math.sin(highlightProgress * Math.PI / 25);
if(highlightProgress >= 50)
highlightProgress = 0;
highlightProgress++;
}, 8);
</script>