summaryrefslogtreecommitdiffstats
path: root/js/master.js
blob: eca9ee790d6776086cf4424516f74e99dce418e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var title, status, task;
function modalFix(task_s, status_s, title_s){
  document.getElementById("modal-title").value = title_s;
  title = title_s;
  document.getElementById("modalstatus").value = status_s;
  status = status_s;
  document.getElementById("modaltask").value = task_s;
  task = task_s;
    console.log("modalFix");

}
function addTask(){
    var xmlhttp = new XMLHttpRequest();
    var tasktitle = document.getElementById("tasktitle").value;
    var taskbody = document.getElementById("taskbody").value;
    var taskperson = document.getElementById("taskperson").value;
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        document.getElementById("tasktitle").value = "";
        document.getElementById("taskbody").value = "";
        document.getElementById("taskperson").value = "";
        getLastTask();
      }
    };
    xmlhttp.open("POST", "App/formhandler/add_listitem.php", true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.send("tasktitle="+tasktitle+"&taskbody="+taskperson+"&taskperson="+taskperson);
}
function getLastTask(){
  var xmlhttp = new XMLHttpRequest();
  console.log("Häre är jag!");
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

      $("#feed").prepend(xmlhttp.responseText);
    }
  };
  xmlhttp.open("POST", "App/ajax/lasttask.php", true);
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.send();
}
function changeStatus(){
    var xmlhttp = new XMLHttpRequest();
    var user = document.getElementById("modalname").value;
    console.debug(user);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        $('#statusmodal').modal('hide');
        UpdateTaskVisuals(task);
      }
    };
    xmlhttp.open("POST", "App/formhandler/changestatus.php", true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.send("task="+task+"&status="+status+"&user="+user);
}
function UpdateTaskVisuals(taskID){
  var xmlhttp = new XMLHttpRequest();
  var user = document.getElementById("modalname").value;
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      document.getElementById("task_nr_"+taskID).innerHTML = xmlhttp.responseText;
    }
  };
  xmlhttp.open("POST", "App/ajax/gettask_inner.php", true);
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.send("task="+taskID);
}
function getStatusHistory(task){

}

function applyFilter(){
  var status_options = ["done","indev","prio1"];
  for(var i = 0; i < status_options.length;i++){
              console.log("Häre är jag!");
    if(document.getElementById(status_options[i]).checked){
      $(".status-"+status_options[i]).hide();
    }else{
      $(".status-"+status_options[i]).show();
    }
  }
}