Andreu Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 2 | |
Andreu Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 3 | <html lang="ca"> |
| 4 | <head> |
| 5 | <meta charset="utf-8"> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 6 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
Andreu Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 7 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 8 | <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 Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 25 | line-height: 0px; |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | .buttons.grid .complex-button { |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 29 | flex: 1 0 34%; |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 30 | margin: 15px 10px; |
| 31 | } |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 32 | |
| 33 | .section { |
| 34 | padding-top: 1rem; |
| 35 | } |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 36 | </style> |
Andreu Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 37 | |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 38 | <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 Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 45 | <!-- |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 46 | <div class="field has-addons"> |
| 47 | <p class="control"> |
| 48 | <button class="button"><</button> |
| 49 | </p> |
| 50 | <p class="control"> |
| 51 | <input type="date" class="button"> |
| 52 | </p> |
| 53 | <p class="control"> |
| 54 | <button class="button">></button> |
| 55 | </p> |
| 56 | </div> |
| 57 | <div class="field has-addons"> |
| 58 | <p class="control"> |
| 59 | <button class="button"><</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">></button> |
| 66 | </p> |
| 67 | </div><br> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 68 | --> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 69 | <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 Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 78 | <div class="message-header">Càlcul I</div> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 79 | <div class="message-body"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 80 | <div>Aula 002</div> |
| 81 | <div>08:00 - 10:00</div> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 82 | </div> |
| 83 | </div> |
| 84 | <div class="message complex-button" id="subject-3"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 85 | <div class="message-header">Topologia</div> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 86 | <div class="message-body"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 87 | <div>Aula S02</div> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 88 | <div>08:00 - 09:00</div> |
| 89 | </div> |
| 90 | </div> |
| 91 | <div class="message complex-button" id="subject-4"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 92 | <div class="message-header">Informàtica</div> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 93 | <div class="message-body"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 94 | <div>Aula PC1</div> |
| 95 | <div>08:00 - 11:00</div> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 96 | </div> |
| 97 | </div> |
| 98 | </div><br> |
| 99 | |
| 100 | </section> |
| 101 | |
| 102 | <section id="section-2" class="section" style="display: none;"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 103 | <button class="button is-link is-light" onclick="switchSection('section-1')">Torna enrere (Classe)</button> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 104 | |
| 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ópez | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 119 | </section> |
| 120 | |
| 121 | <section id="section-3" class="section" style="display: none;"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 122 | <button class="button is-link is-light" onclick="switchSection('section-2')">Torna enrere (Lletra)</button> |
| 123 | |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 124 | <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ópez | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 136 | </section> |
| 137 | <section id="section-send" class="section" style="display: none;"> |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 138 | <button class="button is-link is-light" onclick="switchSection('section-3')">Torna enrere (Número)</button> |
| 139 | <br/><br/> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 140 | <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 Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 149 | <span id="number-final">2</span><span id="letter-final">P</span><br><br> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 150 | |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 151 | <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ópez | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 152 | |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 153 | 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ópez | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 154 | </section> |
| 155 | |
| 156 | |
Andreu Huguet | 68026c0 | 2020-09-28 00:59:21 +0200 | [diff] [blame] | 157 | <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ópez | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 171 | // alert(data.payload.url); |
Andreu Huguet | 68026c0 | 2020-09-28 00:59:21 +0200 | [diff] [blame] | 172 | }); |
| 173 | </script> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 174 | <script> |
| 175 | var current_section = "section-1"; |
Andreu Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 176 | |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 177 | 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 Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 184 | } |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 185 | |
| 186 | function switchSection(s) { |
Andreu Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 187 | setTimeout(function(){ |
| 188 | toggleVisibility(current_section); |
| 189 | toggleVisibility(s); |
| 190 | current_section = s; |
| 191 | }, 75); |
Andreu Huguet | 0062c1c | 2020-09-27 22:52:58 +0200 | [diff] [blame] | 192 | } |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 193 | |
| 194 | </script> |
Andreu Huguet | 68026c0 | 2020-09-28 00:59:21 +0200 | [diff] [blame] | 195 | <script> |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 196 | 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 Huguet | 68026c0 | 2020-09-28 00:59:21 +0200 | [diff] [blame] | 203 | 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 Huguet | cb95ed0 | 2020-09-28 14:15:20 +0200 | [diff] [blame^] | 217 | 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 Huguet | 68026c0 | 2020-09-28 00:59:21 +0200 | [diff] [blame] | 218 | 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 Huguet | 68026c0 | 2020-09-28 00:59:21 +0200 | [diff] [blame] | 234 | <script> |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 235 | var elements = document.getElementsByClassName("button"); |
| 236 | Array.from(elements).forEach(function(element) { |
| 237 | element.addEventListener('click', clickButton); |
| 238 | element.parent = element.parentNode.id; |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 239 | }); |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 240 | 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 Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 246 | 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ópez | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 250 | |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 251 | if (parent == "subject-container") { |
| 252 | // Canvi de background del button |
| 253 | $(".current-subject").css("background-color", "white"); |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 254 | $("#subject-container .complex-button").removeClass("is-link") |
| 255 | $("#" + id).addClass("is-link"); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 256 | // Canvi del text al final |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 257 | $("#subject-final").html(final_text); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 258 | // Canvi JSON |
| 259 | // TODO |
| 260 | // Anchor següent pregunta |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 261 | switchSection("section-2"); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 262 | } else if (parent == "number-container") { |
| 263 | // Canvi de background del button |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 264 | $("#number-container .button").removeClass("is-link is-light is-active") |
| 265 | $("#" + id).addClass("is-link is-light is-active"); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 266 | // Canvi del text al final |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 267 | $("#number-final").html(final_text); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 268 | // Canvi JSON |
| 269 | // TODO |
| 270 | // Anchor següent pregunta |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 271 | switchSection("section-send"); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 272 | } else if (parent == "letter-container") { |
| 273 | // Canvi de background del button |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 274 | $("#letter-container .button").removeClass("is-link is-light is-active") |
| 275 | $("#" + id).addClass("is-link is-light is-active"); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 276 | // Canvi del text al final |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 277 | $("#letter-final").html(final_text); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 278 | // Canvi JSON |
| 279 | // TODO |
| 280 | // Anchor següent pregunta |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 281 | switchSection("section-3"); |
Andreu Huguet | 5c866a1 | 2020-09-27 23:59:04 +0200 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | </script> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 285 | |
Andreu Huguet | 00f8383 | 2020-09-27 21:06:54 +0200 | [diff] [blame] | 286 | </body> |
Ferran López | 5b9bcfa | 2020-09-28 13:11:23 +0200 | [diff] [blame] | 287 | </html> |