]> gitweb.michael.orlitzky.com - charm-bypass.git/blob - src/index.html.in
src/day.svg: finish the back of the train
[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 /************************/
59 /* Scrolling animations */
60 /************************/
61
62 /* Bus */
63 @keyframes busroll {
64 from {
65 transform: translateX(0%);
66 }
67 to {
68 transform: translateX(100%);
69 }
70 }
71
72 #bus {
73 animation: busroll 20s linear infinite;
74 }
75
76
77 /* Tram */
78 @keyframes tramroll {
79 from {
80 transform: translateX(0%);
81 }
82 to {
83 transform: translateX(100%);
84 }
85 }
86
87 #tram {
88 animation: tramroll 15s linear infinite;
89 }
90
91
92 /* Clouds */
93 @keyframes cloudsfloat {
94 from {
95 transform: translateX(0%);
96 }
97 to {
98 transform: translateX(-50%);
99 }
100 }
101
102 #clouds {
103 animation: cloudsfloat 40s linear infinite;
104 }
105
106 @keyframes cloudscopyfloat {
107 from {
108 transform: translateX(0%);
109 }
110 to {
111 transform: translateX(-50%);
112 }
113 }
114
115 #cloudscopy {
116 animation: cloudscopyfloat 40s linear infinite;
117 }
118
119
120 /* Trees */
121 @keyframes treespass {
122 from {
123 transform: translateX(0%);
124 }
125 to {
126 transform: translateX(-50%);
127 }
128 }
129
130 #trees {
131 /* The trees move a little faster than the clouds */
132 animation: treespass 30s linear infinite;
133 }
134
135 @keyframes treescopypass {
136 from {
137 transform: translateX(0%);
138 }
139 to {
140 transform: translateX(-50%);
141 }
142 }
143
144 #treescopy {
145 /* The trees move a little faster than the clouds */
146 animation: treescopypass 30s linear infinite;
147 }
148 </style>
149 </head>
150
151 <body>
152 @SVGDATA@
153
154 <script>
155 /******************************************/
156 /* First, set up the ticket date and time */
157 /******************************************/
158
159 /* There are two parameters, time and date, that we store in one
160 * underlying "date" variable. Default both to an hour from now. This
161 * is sensible because the date/time shown on your ticket is its
162 * EXPIRATION time, and tickets are valid for two hours. Having it
163 * show one hour in the future means that you didn't just use your
164 * ticket a second ago (if you just got caught on the light rail, for
165 * example) but also means that it's not expiring for a while.
166 */
167 const date = new Date();
168
169 /* Add an hour. We use the low-level get/setTime to change the number
170 * of milliseconds since the epoch that this date represents. Obviously
171 * correct, and avoids all suspicious corner cases (well, for a few more
172 * decades). */
173 date.setTime(date.getTime() + (60*60*1000));
174
175 /* All <text> elements produced by inkscape contain a single <tspan>
176 * that itself contains the actual text. */
177 tt = document.getElementById("tickettime");
178 tt.firstChild.textContent = date.toLocaleTimeString();
179
180 td = document.getElementById("ticketdate");
181 const dateopts = {
182 day: "2-digit",
183 month: "2-digit",
184 year: "2-digit"
185 };
186 td.firstChild.textContent = date.toLocaleDateString("en-US", dateopts);
187
188
189 /************************************************************/
190 /* Second, add the onclick handler for the night/day switch */
191 /************************************************************/
192
193 /* We always start in "day" mode */
194 is_day = true;
195
196 function set_day() {
197 sky.style.fill = "#efb02f";
198 }
199
200 function set_night() {
201 sky.style.fill = "#143b66";
202 }
203
204 function swap_colors() {
205 if (is_day) {
206 set_night();
207 is_day = false;
208 }
209 else {
210 set_day();
211 is_day = true;
212 }
213 }
214
215 document.body.addEventListener("click", swap_colors);
216 </script>
217 </body>
218 </html>