-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadminPage.js
More file actions
44 lines (40 loc) · 1.42 KB
/
Copy pathadminPage.js
File metadata and controls
44 lines (40 loc) · 1.42 KB
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
$.ajax({
url: "http://ec2-3-209-137-117.compute-1.amazonaws.com/campaignsAll/",
type: 'GET',
data: {},
async: true,
success: function (data) {
var tableBody = "";
for (campaign of data){
tableBody += "<tr> <td>" + campaign.campaignID + "</td><td>" + campaign.count + "</td><td onclick='deleteCampaign(this)' style='cursor: pointer'>*DELETE*</td></tr>";
}
document.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].innerHTML = tableBody;
},
error: function(data) {
console.log("Failed to get all campaign info");
}
});
function deleteCampaign(element){
var campaign = element.parentElement.getElementsByTagName('td')[0].innerText;
$.ajax({
url: "http://ec2-3-209-137-117.compute-1.amazonaws.com/adminDelete/",
type: 'POST',
data: {token: Cookies.get('token'), campaignID: campaign, type: "campaign"},
async: true,
success: function (data) {
console.log("Deleted");
location.reload();
},
error: function(data) {
console.log("Failed to get all campaign info");
}
});
}
// Logs out the admin
function logout(){
Cookies.remove('token');//, { path: '' });
Cookies.remove('campaignID');//, { path: '' });
Cookies.remove('token', { path: '' });
Cookies.remove('campaignID', { path: '' });
window.location.href = "mainPage.html";
}