blob: 086e2c99022446f549b1846ed77ed97052431023 [file] [log] [blame]
Andreu Huguet00f83832020-09-27 21:06:54 +02001<!DOCTYPE html>
Ferran López5b9bcfa2020-09-28 13:11:23 +02002
Andreu Huguet00f83832020-09-27 21:06:54 +02003<html lang="ca">
4 <head>
5 <meta charset="utf-8">
Ferran López5b9bcfa2020-09-28 13:11:23 +02006 <meta name="viewport" content="width=device-width, initial-scale=1">
Andreu Huguet00f83832020-09-27 21:06:54 +02007 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
Ferran López5b9bcfa2020-09-28 13:11:23 +02008 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css">
9 </head>
10 <body>
11 <style>
12 .buttons.grid {
13 display: flex;
14 flex-direction: row;
15 flex-wrap: wrap;
16
17 justify-content: center;
18 align-items : center;
19 }
20
21 .buttons.grid .button {
22 flex: 1 0 20%;
23 margin: 10px;
24 padding: 40px 20px;
Andreu Huguetcb95ed02020-09-28 14:15:20 +020025 line-height: 0px;
Ferran López5b9bcfa2020-09-28 13:11:23 +020026 }
27
28 .buttons.grid .complex-button {
Andreu Huguetcb95ed02020-09-28 14:15:20 +020029 flex: 1 0 34%;
Ferran López5b9bcfa2020-09-28 13:11:23 +020030 margin: 15px 10px;
31 }
Andreu Huguetcb95ed02020-09-28 14:15:20 +020032
33 .section {
34 padding-top: 1rem;
35 }
Ferran López5b9bcfa2020-09-28 13:11:23 +020036 </style>
Andreu Huguet00f83832020-09-27 21:06:54 +020037
Ferran López5b9bcfa2020-09-28 13:11:23 +020038 <nav class="navbar is-link">
39 <div class="navbar-brand">
40 <div class="navbar-item has-text-weight-bold">Traçabilitat DAFME</div>
41 </div>
42 </nav>
43
44 <section id="section-1" class="section">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020045 <!--
Ferran López5b9bcfa2020-09-28 13:11:23 +020046 <div class="field has-addons">
47 <p class="control">
48 <button class="button">&lt;</button>
49 </p>
50 <p class="control">
51 <input type="date" class="button">
52 </p>
53 <p class="control">
54 <button class="button">&gt;</button>
55 </p>
56 </div>
57 <div class="field has-addons">
58 <p class="control">
59 <button class="button">&lt;</button>
60 </p>
61 <p class="control">
62 <input type="button" class="button" value="08:00 - 08:30">
63 </p>
64 <p class="control">
65 <button class="button">&gt;</button>
66 </p>
67 </div><br>
Andreu Huguetcb95ed02020-09-28 14:15:20 +020068 -->
Ferran López5b9bcfa2020-09-28 13:11:23 +020069 <div id="subject-container" class="grid buttons">
70 <div class="message complex-button" id="subject-1">
71 <div class="message-header">Àlgebra lineal</div>
72 <div class="message-body">
73 <div>Aula 001</div>
74 <div>08:00 - 09:00</div>
75 </div>
76 </div>
77 <div class="message complex-button" id="subject-2">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020078 <div class="message-header">Càlcul I</div>
Ferran López5b9bcfa2020-09-28 13:11:23 +020079 <div class="message-body">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020080 <div>Aula 002</div>
81 <div>08:00 - 10:00</div>
Ferran López5b9bcfa2020-09-28 13:11:23 +020082 </div>
83 </div>
84 <div class="message complex-button" id="subject-3">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020085 <div class="message-header">Topologia</div>
Ferran López5b9bcfa2020-09-28 13:11:23 +020086 <div class="message-body">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020087 <div>Aula S02</div>
Ferran López5b9bcfa2020-09-28 13:11:23 +020088 <div>08:00 - 09:00</div>
89 </div>
90 </div>
91 <div class="message complex-button" id="subject-4">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020092 <div class="message-header">Informàtica</div>
Ferran López5b9bcfa2020-09-28 13:11:23 +020093 <div class="message-body">
Andreu Huguetcb95ed02020-09-28 14:15:20 +020094 <div>Aula PC1</div>
95 <div>08:00 - 11:00</div>
Ferran López5b9bcfa2020-09-28 13:11:23 +020096 </div>
97 </div>
98 </div><br>
99
100 </section>
101
102 <section id="section-2" class="section" style="display: none;">
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200103 <button class="button is-link is-light" onclick="switchSection('section-1')">Torna enrere (Classe)</button>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200104
105 <div id="letter-container" class="buttons grid">
106 <button class="button" id="letter-A">A</button>
107 <button class="button" id="letter-B">B</button>
108 <button class="button" id="letter-C">C</button>
109 <button class="button" id="letter-D">D</button>
110 <button class="button" id="letter-E">E</button>
111 <button class="button" id="letter-F">F</button>
112 <button class="button" id="letter-G">G</button>
113 <button class="button" id="letter-H">H</button>
114 <button class="button" id="letter-I">I</button>
115 <button class="button" id="letter-J">J</button>
116 <button class="button" id="letter-K">K</button>
117 <button class="button" id="letter-L">L</button>
118 </div>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200119 </section>
120
121 <section id="section-3" class="section" style="display: none;">
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200122 <button class="button is-link is-light" onclick="switchSection('section-2')">Torna enrere (Lletra)</button>
123
Ferran López5b9bcfa2020-09-28 13:11:23 +0200124 <div id="number-container" class="buttons grid">
125 <button class="button" id="number-1">1</button>
126 <button class="button" id="number-2">2</button>
127 <button class="button" id="number-3">3</button>
128 <button class="button" id="number-4">4</button>
129 <button class="button" id="number-5">5</button>
130 <button class="button" id="number-6">6</button>
131 <button class="button" id="number-7">7</button>
132 <button class="button" id="number-8">8</button>
133 <button class="button" id="number-9">9</button>
134 <button class="button" id="number-10">10</button>
135 </div>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200136 </section>
137 <section id="section-send" class="section" style="display: none;">
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200138 <button class="button is-link is-light" onclick="switchSection('section-3')">Torna enrere (Número)</button>
139 <br/><br/>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200140 <span class="has-text-weight-bold">Assignatura:</span>
141 <span id="subject-final">Àlgebra Lineal</span><br>
142 <span class="has-text-weight-bold">Aula:</span>
143 <span id="classroom-final">Dele</span><br>
144 <span class="has-text-weight-bold">Data:</span>
145 <span id="date-final">14/3/1879</span><br>
146 <span class="has-text-weight-bold">Hora:</span>
147 <span id="time-final">En <strong>algun moment</strong></span><br>
148 <span class="has-text-weight-bold">Posició:</span>
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200149 <span id="number-final">2</span><span id="letter-final">P</span><br><br>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200150
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200151 <button id="send-button" onclick="js: document.getElementById('send-button').classList.add('is-loading');" class="button is-link is-large">Omple el formulari</button><br><br>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200152
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200153 Hi ha errors? <br /><a class="button is-link is-light" href="https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform">Completa el formulari manualment</a>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200154 </section>
155
156
Andreu Huguet68026c02020-09-28 00:59:21 +0200157 <script>
158 // Check if user is signed in
159 var api_url = "https://covid-tracability-backend-dev.sandbox.avm99963.com/api/v1/";
160 fetch(api_url + "isSignedIn")
161 .then(response => response.json())
162 .then(data => {
163 if (!data.payload.signedIn) {
164 console.log("Not signed in!");
165 return fetch(api_url + "getAuthUrl");
166 }
167 })
168 .then(response => response.json())
169 .then(data => {
170 // TODO: redirect here
Ferran López5b9bcfa2020-09-28 13:11:23 +0200171 // alert(data.payload.url);
Andreu Huguet68026c02020-09-28 00:59:21 +0200172 });
173 </script>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200174 <script>
175 var current_section = "section-1";
Andreu Huguet00f83832020-09-27 21:06:54 +0200176
Ferran López5b9bcfa2020-09-28 13:11:23 +0200177 function toggleVisibility(id) {
178 var x = document.getElementById(id);
179 if (x.style.display === "none") {
180 x.style.display = "block";
181 } else {
182 x.style.display = "none";
183 }
Andreu Huguet00f83832020-09-27 21:06:54 +0200184 }
Ferran López5b9bcfa2020-09-28 13:11:23 +0200185
186 function switchSection(s) {
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200187 setTimeout(function(){
188 toggleVisibility(current_section);
189 toggleVisibility(s);
190 current_section = s;
191 }, 75);
Andreu Huguet0062c1c2020-09-27 22:52:58 +0200192 }
Ferran López5b9bcfa2020-09-28 13:11:23 +0200193
194 </script>
Andreu Huguet68026c02020-09-28 00:59:21 +0200195 <script>
Andreu Huguet5c866a12020-09-27 23:59:04 +0200196 var subjects_texts = {
197 "subject-1": "Àlgebra",
198 "subject-2": "Càlcul I",
199 "subject-3": "Topologia",
200 "subject-4": "Informàtica"
201 };
202
Andreu Huguet68026c02020-09-28 00:59:21 +0200203 function sendForm(data) {
204 // Add subject to user
205 fetch(api_url + "addUserSubject", {
206 "method": "POST",
207 "body": JSON.stringify({
208 subject: data["subject"]
209 }),
210 "mode": "cors",
211 "credentials": "include"
212 })
213 .then(res => res.json())
214 .then(json => {
215 console.log("Subject added to user: ", json);
216 // TODO: Redirect to Google Forms
Andreu Huguetcb95ed02020-09-28 14:15:20 +0200217 var formulari_link = "https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform?entry.1063142948=S03&entry.2115504093=2020-09-14&entry.1749141911=9:00&entry.1827359679=10:00&entry.208184485=Columna+3&entry.1600275159=[Autogenerat+per+delefme/covid-tracability]#i1";
Andreu Huguet68026c02020-09-28 00:59:21 +0200218 window.location.href = formulari_link;
219 });
220 }
221
222 document.getElementById("send-button").addEventListener('click', function (el) {
223 // TODO: emplenar això amb informació real
224 sendForm({
225 "aula": "001",
226 "subject": 1,
227 "data": "16/01/2020",
228 "hora-inici": "9:00",
229 "hora-final": "10:00",
230 "seient": "7D"
231 });
232 });
233 </script>
Andreu Huguet68026c02020-09-28 00:59:21 +0200234 <script>
Andreu Huguet5c866a12020-09-27 23:59:04 +0200235 var elements = document.getElementsByClassName("button");
236 Array.from(elements).forEach(function(element) {
237 element.addEventListener('click', clickButton);
238 element.parent = element.parentNode.id;
Andreu Huguet5c866a12020-09-27 23:59:04 +0200239 });
Ferran López5b9bcfa2020-09-28 13:11:23 +0200240 var elements = document.getElementsByClassName("complex-button");
241 Array.from(elements).forEach(function(element) {
242 element.addEventListener('click', clickButton);
243 element.parent = element.parentNode.id;
244 });
245
Andreu Huguet5c866a12020-09-27 23:59:04 +0200246 function clickButton(element) {
247 var parent = element.currentTarget.parent;
248 var id = element.currentTarget.id;
249 var final_text = (id.split("-")[0] == "subject" ? subjects_texts[id] : id.split("-")[1]);
Ferran López5b9bcfa2020-09-28 13:11:23 +0200250
Andreu Huguet5c866a12020-09-27 23:59:04 +0200251 if (parent == "subject-container") {
252 // Canvi de background del button
253 $(".current-subject").css("background-color", "white");
Ferran López5b9bcfa2020-09-28 13:11:23 +0200254 $("#subject-container .complex-button").removeClass("is-link")
255 $("#" + id).addClass("is-link");
Andreu Huguet5c866a12020-09-27 23:59:04 +0200256 // Canvi del text al final
Ferran López5b9bcfa2020-09-28 13:11:23 +0200257 $("#subject-final").html(final_text);
Andreu Huguet5c866a12020-09-27 23:59:04 +0200258 // Canvi JSON
259 // TODO
260 // Anchor següent pregunta
Ferran López5b9bcfa2020-09-28 13:11:23 +0200261 switchSection("section-2");
Andreu Huguet5c866a12020-09-27 23:59:04 +0200262 } else if (parent == "number-container") {
263 // Canvi de background del button
Ferran López5b9bcfa2020-09-28 13:11:23 +0200264 $("#number-container .button").removeClass("is-link is-light is-active")
265 $("#" + id).addClass("is-link is-light is-active");
Andreu Huguet5c866a12020-09-27 23:59:04 +0200266 // Canvi del text al final
Ferran López5b9bcfa2020-09-28 13:11:23 +0200267 $("#number-final").html(final_text);
Andreu Huguet5c866a12020-09-27 23:59:04 +0200268 // Canvi JSON
269 // TODO
270 // Anchor següent pregunta
Ferran López5b9bcfa2020-09-28 13:11:23 +0200271 switchSection("section-send");
Andreu Huguet5c866a12020-09-27 23:59:04 +0200272 } else if (parent == "letter-container") {
273 // Canvi de background del button
Ferran López5b9bcfa2020-09-28 13:11:23 +0200274 $("#letter-container .button").removeClass("is-link is-light is-active")
275 $("#" + id).addClass("is-link is-light is-active");
Andreu Huguet5c866a12020-09-27 23:59:04 +0200276 // Canvi del text al final
Ferran López5b9bcfa2020-09-28 13:11:23 +0200277 $("#letter-final").html(final_text);
Andreu Huguet5c866a12020-09-27 23:59:04 +0200278 // Canvi JSON
279 // TODO
280 // Anchor següent pregunta
Ferran López5b9bcfa2020-09-28 13:11:23 +0200281 switchSection("section-3");
Andreu Huguet5c866a12020-09-27 23:59:04 +0200282 }
283 }
284 </script>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200285
Andreu Huguet00f83832020-09-27 21:06:54 +0200286 </body>
Ferran López5b9bcfa2020-09-28 13:11:23 +0200287</html>