blob: 24ae8d94a0b885057f8de64f80cb0a4d1b5808e3 [file] [log] [blame]
Dani Vilardellaae4e2d2020-09-22 17:33:39 +02001
2function completeSubjectList() {
Dani Vilardelld4f2c902020-09-23 13:54:19 +02003 var trobat = false;
Dani Vilardell824ec332020-09-23 16:00:40 +02004 var jaEsta = false;
Dani Vilardelld4f2c902020-09-23 13:54:19 +02005 for(var i = 0; i < totesLesClasses.length; i++) {
Dani Vilardell824ec332020-09-23 16:00:40 +02006
Dani Vilardelld4f2c902020-09-23 13:54:19 +02007 if(document.getElementById("myInput").value == totesLesClasses[i].nom) {
Dani Vilardell824ec332020-09-23 16:00:40 +02008 for(var j = 0; j < dataHorarisAlumne.length; j++) {
9 if(totesLesClasses[i].nom == dataHorarisAlumne[j].nom) {
10 jaEsta = true;
11 break;
12 }
13 }
14 if(!jaEsta) {
15 dataHorarisAlumne.push({ "nom":totesLesClasses[i].nom, "hora":totesLesClasses[i].hora, "aula": totesLesClasses[i].aula })
16 document.getElementById("subjectList").innerHTML += "<br>" + document.getElementById("myInput").value + " " + totesLesClasses[i].hora[hora_actual.getDay()];
17 localStorage.dataHorarisAlumne = JSON.stringify(dataHorarisAlumne);
18 trobat = true;
19 completaHTML();
20 }
21 else {
22 break;
23 }
Dani Vilardelld4f2c902020-09-23 13:54:19 +020024 }
25 }
Dani Vilardell824ec332020-09-23 16:00:40 +020026 if(!trobat && !jaEsta) {
Dani Vilardelld4f2c902020-09-23 13:54:19 +020027 showAlert();
28 }
Dani Vilardell824ec332020-09-23 16:00:40 +020029 else if(jaEsta) {
30
31 }
Dani Vilardelld4f2c902020-09-23 13:54:19 +020032}
33
Dani Vilardell824ec332020-09-23 16:00:40 +020034
Dani Vilardelld4f2c902020-09-23 13:54:19 +020035function returnAllSubjectArray() {
36 for(var i = 0; i < totesLesClasses.length; i++) {
37 subjects.push(totesLesClasses[i].nom);
38 }
Dani Vilardellaae4e2d2020-09-22 17:33:39 +020039}
40
41function writeSubjectList() {
Dani Vilardelld4f2c902020-09-23 13:54:19 +020042 for(var i = 0; i < dataHorarisAlumne.length; i++) {
Dani Vilardell824ec332020-09-23 16:00:40 +020043 document.getElementById("subjectList").innerHTML += "<br>" + dataHorarisAlumne[i].nom + " " + dataHorarisAlumne[i].hora[hora_actual.getDay()];
Dani Vilardellaae4e2d2020-09-22 17:33:39 +020044 }
Dani Vilardelld4f2c902020-09-23 13:54:19 +020045}
46
47function showAlert() {
48 document.getElementById("alert").innerHTML = "Aquesta assignatura no esta dins de la llista"
49 document.getElementById("alert").style.opacity = "1";
50 setTimeout(()=> dissapearAlert() ,2000); // hide the alert after 2.5s
51}
52
53function dissapearAlert() {
54 document.getElementById("alert").style.opacity = "0";
55 document.getElementById("alert").innerHTML = "";
Dani Vilardellaae4e2d2020-09-22 17:33:39 +020056}