link completion and subject autocomplete
diff --git a/autocomplete.css b/autocomplete.css
new file mode 100644
index 0000000..bea6091
--- /dev/null
+++ b/autocomplete.css
@@ -0,0 +1,49 @@
+* { box-sizing: border-box; }
+body {
+  font: 16px Arial; 
+}
+.autocomplete {
+  /*the container must be positioned relative:*/
+  position: relative;
+  display: inline-block;
+}
+input {
+  border: 1px solid transparent;
+  background-color: #f1f1f1;
+  padding: 10px;
+  font-size: 16px;
+}
+input[type=text] {
+  background-color: #f1f1f1;
+  width: 100%;
+}
+input[type=submit] {
+  background-color: DodgerBlue;
+  color: #fff;
+}
+.autocomplete-items {
+  position: absolute;
+  border: 1px solid #d4d4d4;
+  border-bottom: none;
+  border-top: none;
+  z-index: 99;
+  /*position the autocomplete items to be the same width as the container:*/
+  top: 100%;
+  left: 0;
+  right: 0;
+}
+.autocomplete-items div {
+  padding: 10px;
+  cursor: pointer;
+  background-color: #fff; 
+  border-bottom: 1px solid #d4d4d4; 
+}
+.autocomplete-items div:hover {
+  /*when hovering an item:*/
+  background-color: #e9e9e9; 
+}
+.autocomplete-active {
+  /*when navigating through the items using the arrow keys:*/
+  background-color: DodgerBlue !important; 
+  color: #ffffff; 
+}
\ No newline at end of file
diff --git a/autocomplete.js b/autocomplete.js
new file mode 100644
index 0000000..11c65cc
--- /dev/null
+++ b/autocomplete.js
@@ -0,0 +1,96 @@
+function autocomplete(inp, arr) {
+  /*the autocomplete function takes two arguments,
+  the text field element and an array of possible autocompleted values:*/
+  var currentFocus;
+  /*execute a function when someone writes in the text field:*/
+  inp.addEventListener("input", function(e) {
+      var a, b, i, val = this.value;
+      /*close any already open lists of autocompleted values*/
+      closeAllLists();
+      if (!val) { return false;}
+      currentFocus = -1;
+      /*create a DIV element that will contain the items (values):*/
+      a = document.createElement("DIV");
+      a.setAttribute("id", this.id + "autocomplete-list");
+      a.setAttribute("class", "autocomplete-items");
+      /*append the DIV element as a child of the autocomplete container:*/
+      this.parentNode.appendChild(a);
+      /*for each item in the array...*/
+      for (i = 0; i < arr.length; i++) {
+        /*check if the item starts with the same letters as the text field value:*/
+        if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
+          /*create a DIV element for each matching element:*/
+          b = document.createElement("DIV");
+          /*make the matching letters bold:*/
+          b.innerHTML = "<strong>" + arr[i].substr(0, val.length) + "</strong>";
+          b.innerHTML += arr[i].substr(val.length);
+          /*insert a input field that will hold the current array item's value:*/
+          b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
+          /*execute a function when someone clicks on the item value (DIV element):*/
+              b.addEventListener("click", function(e) {
+              /*insert the value for the autocomplete text field:*/
+              inp.value = this.getElementsByTagName("input")[0].value;
+              /*close the list of autocompleted values,
+              (or any other open lists of autocompleted values:*/
+              closeAllLists();
+          });
+          a.appendChild(b);
+        }
+      }
+  });
+  /*execute a function presses a key on the keyboard:*/
+  inp.addEventListener("keydown", function(e) {
+      var x = document.getElementById(this.id + "autocomplete-list");
+      if (x) x = x.getElementsByTagName("div");
+      if (e.keyCode == 40) {
+        /*If the arrow DOWN key is pressed,
+        increase the currentFocus variable:*/
+        currentFocus++;
+        /*and and make the current item more visible:*/
+        addActive(x);
+      } else if (e.keyCode == 38) { //up
+        /*If the arrow UP key is pressed,
+        decrease the currentFocus variable:*/
+        currentFocus--;
+        /*and and make the current item more visible:*/
+        addActive(x);
+      } else if (e.keyCode == 13) {
+        /*If the ENTER key is pressed, prevent the form from being submitted,*/
+        e.preventDefault();
+        if (currentFocus > -1) {
+          /*and simulate a click on the "active" item:*/
+          if (x) x[currentFocus].click();
+        }
+      }
+  });
+  function addActive(x) {
+    /*a function to classify an item as "active":*/
+    if (!x) return false;
+    /*start by removing the "active" class on all items:*/
+    removeActive(x);
+    if (currentFocus >= x.length) currentFocus = 0;
+    if (currentFocus < 0) currentFocus = (x.length - 1);
+    /*add class "autocomplete-active":*/
+    x[currentFocus].classList.add("autocomplete-active");
+  }
+  function removeActive(x) {
+    /*a function to remove the "active" class from all autocomplete items:*/
+    for (var i = 0; i < x.length; i++) {
+      x[i].classList.remove("autocomplete-active");
+    }
+  }
+  function closeAllLists(elmnt) {
+    /*close all autocomplete lists in the document,
+    except the one passed as an argument:*/
+    var x = document.getElementsByClassName("autocomplete-items");
+    for (var i = 0; i < x.length; i++) {
+      if (elmnt != x[i] && elmnt != inp) {
+      x[i].parentNode.removeChild(x[i]);
+    }
+  }
+}
+/*execute a function when someone clicks in the document:*/
+document.addEventListener("click", function (e) {
+    closeAllLists(e.target);
+});
+}
\ No newline at end of file
diff --git a/horaris.json b/horaris.json
index 11dba99..d938bb4 100644
--- a/horaris.json
+++ b/horaris.json
@@ -1 +1,3 @@
-classes = '[{"nom" : "ÀLGEBRA MULTILINIAL", "hora" : "08:00-9:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL2", "hora" : "09:00-10:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL3", "hora" : "10:00-11:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL4", "hora" : "11:00-12:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL5", "hora" : "12:00-13:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL6", "hora" : "13:00-14:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL7", "hora" : "14:00-15:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL8", "hora" : "15:00-16:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL9", "hora" : "16:00-17:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL10", "hora" : "17:00-18:00", "aula" : "S02"}]';
\ No newline at end of file
+classes = '[{"nom" : "ÀLGEBRA MULTILINIAL", "hora" : "08:00-9:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL2", "hora" : "09:00-10:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL3", "hora" : "10:00-11:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL4", "hora" : "11:00-12:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL5", "hora" : "12:00-13:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL6", "hora" : "13:00-14:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL7", "hora" : "14:00-15:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL8", "hora" : "15:00-16:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL9", "hora" : "16:00-17:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL10", "hora" : "17:00-18:00", "aula" : "S02"}]';
+
+classesAlumne = '[{"nom" : "ÀLGEBRA MULTILINIAL", "hora" : "08:00-9:00", "aula" : "S02"}, {"nom" : "ÀLGEBRA MULTILINIAL3", "hora" : "10:00-11:00", "aula" : "S02"}]'
\ No newline at end of file
diff --git a/main.html b/main.html
index 8c4de98..77da1e4 100644
--- a/main.html
+++ b/main.html
@@ -1,9 +1,11 @@
 <script type="text/javascript" src="./horaris.json"></script>
+<script type="text/javascript" src="./autocomplete.js"></script>
 <meta charset="utf-8">
 
 <html>
     <head>
     </head>
+    <link rel="stylesheet" href="autocomplete.css">
     <body>
         <h1>App de traçabilitat DAFME</h1>
         <h2 id = "assignatura"></h2>
@@ -22,15 +24,27 @@
 			<input type="text" id="seient" name="seient"><br>
 		</form>
 
+        <form autocomplete="off" action="/action_page.php">
+            <div class="autocomplete" style="width:300px;">
+                <input id="myInput" type="text" name="mySubject" placeholder="Subject">
+            </div>
+            <input type="submit">
+        </form>
+
 		<form id = "link" action = https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform?entry.1063142948=S02>
 		    <input type="submit" value="Continua"/>
 		</form>
 
-        <script>
-        	//var linkOutput = "https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform?entry.1063142948=S03"
-        	var linkOutput = "https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform.entry.1063142948=S03"
-        	//var linkOutput = "https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform?entry.1749141911=8:00"
 
+
+        <script>
+
+            var subjects = ["Calcul 1", "Calcul 2", "Algebra Lineal", "Geometria", "Numerica", "EDOS"];
+
+            autocomplete(document.getElementById("myInput"), subjects);
+
+        	var linkOutput = "https://docs.google.com/forms/d/e/1FAIpQLSfT9o287VqLyhwR8LPdloAQWhuqCgA3NfdhgP5vb9_sVQHL-g/viewform"
+        	
         	var mydata = JSON.parse(classes);
 
             var hora_actual = new Date();
@@ -54,15 +68,23 @@
 
             for (i = 0; i < mydata.length; i++) { 
             	var h = mydata[i].hora.split(":");
-				if(h[0] == (hora_actual.getHours() - 1).toString()) {
+				if(h[0] == (hora_actual.getHours() - 5).toString()) {
 					console.log("trobat");
 					document.getElementById("assignatura").innerHTML = mydata[i].nom;
 					document.getElementById("aula").innerHTML = "Aula " + mydata[i].aula;
-					linkOutput += "?entry.1063142948=" + mydata[i].aula;
+
+                    var datamap=[
+                        "entry.1063142948=" + mydata[i].aula,
+                        "entry.1749141911=" + (hora_actual.getHours().toString() - 11) +":00",
+                        "entry.1827359679=" + (hora_actual.getHours().toString() - 10) +":00",
+                        "entry.2115504093=" + data
+                        ];
+                    var linkOutput = linkOutput+"?"+ datamap[1] + "&" + datamap[2] + "&" + datamap[3] + "&" + datamap[0];
 				}
 			}
             document.getElementById("data").innerHTML = data;
             document.getElementById("link").action = linkOutput;
+            console.log(document.getElementById("link").action);
         </script>