-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_ajax.js
66 lines (57 loc) · 2.85 KB
/
manage_ajax.js
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
function managePageUpdate()
{
var xhr = new XMLHttpRequest();
document.getElementById("loadManage").innerHTML = "";
var to_show = "";
xhr.onreadystatechange = function()
{
if (this.readyState==4 && this.status==200)
{
var Obj = JSON.parse(xhr.responseText);
/*to_show = xhr.responseText;*/
for (var i = 0; i < Obj.length; i++)
{
if(Obj[i].change == "Yes")
{
document.getElementById("changeC").style.backgroundColor = "yellow";
function setDefault()
{
document.getElementById("changeC").style.backgroundColor = "rgb(143, 203, 238)";
}
setTimeout(setDefault,5000);
}
to_show += "<tr id='changeC'>";
to_show += "<td style='width: 12%'>"; to_show += Obj[i].poll_createdate; to_show += "</td>";
to_show += "<td style='width: 6%'>"; to_show += Obj[i].user_uname; to_show += "</td>";
to_show += "<td style='width: 22%'><a href='PollResult.php?pid="; to_show += Obj[i].pid; to_show += "'>"; to_show += Obj[i].poll_question; to_show += "</a></td>";
to_show += "<td style='width: 18%'>";
for (var j = 0; j < Obj[i].answer.length; j++)
{
to_show += Obj[i].answer[j];
to_show += " ";
}
to_show += "</td>";
to_show += "<td class='resultMaP'>";
for (var k = 0; k < Obj[i].answer.length; k++)
{
to_show += "<div style='background-color: rgb(" + Obj[i].colorx[k] + "," + Obj[i].colory[k] + "," + Obj[i].colorz[k] + "); width: " + Obj[i].percent[k] + "%;'>";
if(Obj[i].percent[k] != 0)
{
to_show += Obj[i].answer[k];
}
to_show += "</div>";
}
to_show += "</td>";
to_show += "<td style='width: 6%'>"; to_show += Obj[i].vote; to_show += "</td>";
to_show += "<td style='width: 6%'>"; to_show += Obj[i].poll_lastdate; to_show += "</td>";
to_show += "<td style='width: 5%'><a href='PollVote.php?pid="; to_show += Obj[i].pid; to_show += "'>"; to_show += "vote"; to_show += "</a></td>";
to_show += "</tr>";
}
document.getElementById("loadManage").innerHTML = to_show;
}
}
xhr.open("GET","manage_ajax.php" ,true);
xhr.send();
}
managePageUpdate();
setInterval(managePageUpdate, 600000);