blob: ff0ecb5919d95876af8216dd41fdaf01b484b84b [file] [log] [blame]
Dani Vilardell996d8692020-09-21 23:48:12 +02001<!DOCTYPE html>
Dani Vilardell21dacea2020-09-21 14:25:20 +02002<script type="text/javascript" src="./horaris.json"></script>
Dani Vilardelld4bfb752020-09-21 21:32:55 +02003<script type="text/javascript" src="./autocomplete.js"></script>
Dani Vilardell12518e22020-09-21 16:00:07 +02004<meta charset="utf-8">
Dani Vilardell21dacea2020-09-21 14:25:20 +02005
Andreu Huguet8d2e08f2020-09-17 14:15:23 +02006<html>
7 <head>
8 </head>
Dani Vilardelld4bfb752020-09-21 21:32:55 +02009 <link rel="stylesheet" href="autocomplete.css">
Andreu Huguet8d2e08f2020-09-17 14:15:23 +020010 <body>
11 <h1>App de traçabilitat DAFME</h1>
Dani Vilardell21dacea2020-09-21 14:25:20 +020012 <h2 id = "assignatura"></h2>
Dani Vilardell21dacea2020-09-21 14:25:20 +020013 <h3 id = "aula"></h3>
Andreu Huguet8d2e08f2020-09-17 14:15:23 +020014 <a href="#">No és així? Canvia-ho.</a>
15
16 <h2 id="hora">
17 <span id="inici"></span> -
18 <span id="fi"></span>
19 </h2>
20 <h3 id="data"></h3>
21 <a href="#">No és així? Canvia-ho.</a>
Dani Vilardell12518e22020-09-21 16:00:07 +020022
Dani Vilardell996d8692020-09-21 23:48:12 +020023 <form id="subjectListInput" autocomplete="off">
24 <div class="autocomplete" id="input2" style="width:300px;">
Dani Vilardelld4bfb752020-09-21 21:32:55 +020025 <input id="myInput" type="text" name="mySubject" placeholder="Subject">
26 </div>
Dani Vilardell996d8692020-09-21 23:48:12 +020027
28 </form>
29 <button onclick="completeSubjectList()">Afegeix</button>
30
31 <div id="subjectList"></div>
32
33 <form>
34 <label for="seient" id="seient2"></label><br>
35 <input type="text" id="seientInput" placeholder="Seient"><br>
Dani Vilardelld4bfb752020-09-21 21:32:55 +020036 </form>
37
Dani Vilardell996d8692020-09-21 23:48:12 +020038 <form id = "link">
39 <!--<form id = "link" action = 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.1077148310=Columna+3&entry.1600275159=[Autogenerat+per+delefme/covid-tracability]>-->
40 <input type="submit" value="Continua"/>
Dani Vilardell12518e22020-09-21 16:00:07 +020041 </form>
42
Dani Vilardelld4bfb752020-09-21 21:32:55 +020043 <script>
Dani Vilardell996d8692020-09-21 23:48:12 +020044 var classesAlumne = [{}];
45 if(localStorage.pos == null) localStorage.pos = 0;
46
47 document.getElementById("seientInput").value = "hola";
Dani Vilardelld4bfb752020-09-21 21:32:55 +020048
49 var subjects = ["Calcul 1", "Calcul 2", "Algebra Lineal", "Geometria", "Numerica", "EDOS"];
50
51 autocomplete(document.getElementById("myInput"), subjects);
52
Dani Vilardell996d8692020-09-21 23:48:12 +020053
54
55 var linkOutput = "https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform";
Dani Vilardelld4bfb752020-09-21 21:32:55 +020056
Dani Vilardell21dacea2020-09-21 14:25:20 +020057 var mydata = JSON.parse(classes);
Dani Vilardell996d8692020-09-21 23:48:12 +020058 let datahoraris = JSON.stringify(classesAlumne);
Dani Vilardell21dacea2020-09-21 14:25:20 +020059
Andreu Huguet8d2e08f2020-09-17 14:15:23 +020060 var hora_actual = new Date();
61 var minuts;
62
63 // Hora d'inici
64 hora_actual.setMinutes(0, 0, 0); // Arrodonir per baix els minuts
65 minuts = hora_actual.getMinutes() < 10 ? hora_actual.getMinutes().toString() + '0' : hora_actual.getMinutes().toString();
66 document.getElementById("inici").innerHTML = hora_actual.getHours().toString() + ":" + minuts;
67
68 // Hora de fi
69 hora_actual.setHours(hora_actual.getHours() + 1); // Sumar una hora
70 minuts = hora_actual.getMinutes() < 10 ? hora_actual.getMinutes().toString() + '0' : hora_actual.getMinutes().toString();
71 document.getElementById("fi").innerHTML = hora_actual.getHours().toString() + ":" + minuts;
72
73 // Data
74 var dia = hora_actual.getDate();
75 var mes = hora_actual.getMonth() + 1;
76 var any = hora_actual.getFullYear();
77 var data = dia.toString() + '/' + mes.toString() + '/' + any.toString();
Dani Vilardell21dacea2020-09-21 14:25:20 +020078
Dani Vilardell996d8692020-09-21 23:48:12 +020079 document.getElementById("link").onclick = completaLink();
Dani Vilardelld4bfb752020-09-21 21:32:55 +020080
Dani Vilardell996d8692020-09-21 23:48:12 +020081 if(localStorage.classesAlumne != null) classesAlumne = JSON.parse(localStorage.classesAlumne);
82
83 for(i = 0; i < classesAlumne.length; i++) {
84 document.getElementById("subjectList").innerHTML += "<br>" + classesAlumne[i];
85 }
86
87
88 function completaLink() {
89 console.log(document.getElementById("seientInput").value);
90 for (i = 0; i < mydata.length; i++) {
91 var h = mydata[i].hora.split(":");
92 if(h[0] == (hora_actual.getHours() - 7).toString()) {
93 console.log("trobat");
94 document.getElementById("assignatura").innerHTML = mydata[i].nom;
95 document.getElementById("aula").innerHTML = "Aula " + mydata[i].aula;
96
97 var datamap=[
98 "entry.1063142948=" + mydata[i].aula,
99 "entry.1749141911=" + (hora_actual.getHours().toString() - 11) +":00",
100 "entry.1827359679=" + (hora_actual.getHours().toString() - 10) +":00",
101 "entry.2115504093=" + any.toString() + '-' + mes.toString() + '-' + dia.toString(),
102 "entry.1077148310=Columna+" + document.getElementById("seientInput").value
103 ];
104 linkOutput += "?"+ datamap[1] + "&" + datamap[2] + "&" + datamap[3] + "&" + datamap[0] + "&" + datamap[4];
105 }
106 }
107 //window.location.href = linkOutput;
108 }
Andreu Huguet8d2e08f2020-09-17 14:15:23 +0200109 document.getElementById("data").innerHTML = data;
Dani Vilardell996d8692020-09-21 23:48:12 +0200110 //document.getElementById("link").action = linkOutput;
Andreu Huguet8d2e08f2020-09-17 14:15:23 +0200111 </script>
Dani Vilardell12518e22020-09-21 16:00:07 +0200112
Dani Vilardell996d8692020-09-21 23:48:12 +0200113 <script>
114 function completeSubjectList() {
115 classesAlumne[localStorage.pos] = document.getElementById("myInput").value;
116 localStorage.pos++;
117 console.log(document.getElementById("myInput").value);
118 document.getElementById("subjectList").innerHTML += "<br>" + document.getElementById("myInput").value;
119 localStorage.classesAlumne = JSON.stringify(classesAlumne);
120 }
121
122 </script>
Dani Vilardell12518e22020-09-21 16:00:07 +0200123
Andreu Huguet8d2e08f2020-09-17 14:15:23 +0200124 </body>
125</html>