Dani Vilardell | aae4e2d | 2020-09-22 17:33:39 +0200 | [diff] [blame] | 1 | |
| 2 | function completeSubjectList() { |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 3 | var trobat = false; |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 4 | var jaEsta = false; |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 5 | for(var i = 0; i < totesLesClasses.length; i++) { |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 6 | |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 7 | if(document.getElementById("myInput").value == totesLesClasses[i].nom) { |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 8 | 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 Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 24 | } |
| 25 | } |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 26 | if(!trobat && !jaEsta) { |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 27 | showAlert(); |
| 28 | } |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 29 | else if(jaEsta) { |
| 30 | |
| 31 | } |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 32 | } |
| 33 | |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 34 | |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 35 | function returnAllSubjectArray() { |
| 36 | for(var i = 0; i < totesLesClasses.length; i++) { |
| 37 | subjects.push(totesLesClasses[i].nom); |
| 38 | } |
Dani Vilardell | aae4e2d | 2020-09-22 17:33:39 +0200 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | function writeSubjectList() { |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 42 | for(var i = 0; i < dataHorarisAlumne.length; i++) { |
Dani Vilardell | 824ec33 | 2020-09-23 16:00:40 +0200 | [diff] [blame] | 43 | document.getElementById("subjectList").innerHTML += "<br>" + dataHorarisAlumne[i].nom + " " + dataHorarisAlumne[i].hora[hora_actual.getDay()]; |
Dani Vilardell | aae4e2d | 2020-09-22 17:33:39 +0200 | [diff] [blame] | 44 | } |
Dani Vilardell | d4f2c90 | 2020-09-23 13:54:19 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | function 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 | |
| 53 | function dissapearAlert() { |
| 54 | document.getElementById("alert").style.opacity = "0"; |
| 55 | document.getElementById("alert").innerHTML = ""; |
Dani Vilardell | aae4e2d | 2020-09-22 17:33:39 +0200 | [diff] [blame] | 56 | } |