]> gitweb.michael.orlitzky.com - charm-bypass.git/blob - src/index.html.in
src/index.html.in: add the main page template
[charm-bypass.git] / src / index.html.in
1 <!doctype html>
2 <html lang="en-US">
3 <head>
4 <meta name="viewport" content="width=device-width, initial-scale=1" />
5
6 <title>
7 CharmBypass.
8 </title>
9
10 <style>
11 /*
12 * Reset styles for the html and body elements, the only two HTML
13 * elements we use. */
14 html, body {
15 margin: 0;
16 padding: 0;
17 border: 0;
18 font-weight: normal;
19 font-style: inherit;
20 font-size: 100%;
21 line-height: 1.5;
22 font-family: inherit;
23 text-align: inherit;
24 text-decoration: none;
25 vertical-align: baseline;
26 background: transparent;
27 }
28
29 /* The blinking fade in/out animation for the ticket date and time */
30 @keyframes blink {
31 25% {
32 opacity: 0.5;
33 }
34 50% {
35 opacity: 0;
36 }
37 75% {
38 opacity: 0.5;
39 }
40 }
41
42 #tickettime, #ticketdate {
43 animation: blink 2s linear infinite;
44 }
45
46 /* Define, load, and specify the custom font we use for the ticket
47 * date, time, and service name. */
48 @font-face {
49 font-family: "CharmBypass Ticket Text";
50 src:
51 url("data:font/woff2;base64,@TICKETFONT@") format("woff2")
52 }
53
54 #servicename, #tickettime, #ticketdate {
55 font-family: "CharmBypass Ticket Text" !important;
56 }
57
58 </style>
59 </head>
60
61 <body>
62 @SVGDATA@
63
64 <script>
65 /******************************************/
66 /* First, set up the ticket date and time */
67 /******************************************/
68
69 /* There are two parameters, time and date, that we store in one
70 * underlying "date" variable. Default both to an hour from now. This
71 * is sensible because the date/time shown on your ticket is its
72 * EXPIRATION time, and tickets are valid for two hours. Having it
73 * show one hour in the future means that you didn't just use your
74 * ticket a second ago (if you just got caught on the light rail, for
75 * example) but also means that it's not expiring for a while.
76 */
77 const date = new Date();
78
79 /* Add an hour. We use the low-level get/setTime to change the number
80 * of milliseconds since the epoch that this date represents. Obviously
81 * correct, and avoids all suspicious corner cases (well, for a few more
82 * decades). */
83 date.setTime(date.getTime() + (60*60*1000));
84
85 /* All <text> elements produced by inkscape contain a single <tspan>
86 * that itself contains the actual text. */
87 tt = document.getElementById("tickettime");
88 tt.firstChild.textContent = date.toLocaleTimeString();
89
90 td = document.getElementById("ticketdate");
91 const dateopts = {
92 day: "2-digit",
93 month: "2-digit",
94 year: "2-digit"
95 };
96 td.firstChild.textContent = date.toLocaleDateString("en-US", dateopts);
97
98
99 /************************************************************/
100 /* Second, add the onclick handler for the night/day switch */
101 /************************************************************/
102
103 /* We always start in "day" mode */
104 is_day = true;
105
106 function set_day() {
107 sky.style.fill = "#efb02f";
108 }
109
110 function set_night() {
111 sky.style.fill = "#143b66";
112 }
113
114 function swap_colors() {
115 if (is_day) {
116 set_night();
117 is_day = false;
118 }
119 else {
120 set_day();
121 is_day = true;
122 }
123 }
124
125 document.body.addEventListener("click", swap_colors);
126 </script>
127 </body>
128 </html>