Mercurial > hg > fapweb
annotate ajax.js @ 115:87d3ce535834
Comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2013 12:26:06 +0300 |
parents | b5981168ed85 |
children | 986c25c2e2bc |
rev | line source |
---|---|
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 function statusMsg(msg) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 document.getElementById("nstatus").innerHTML = msg; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 function strtrim(str) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 if (!str || str == null) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 return ""; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 return str.replace(/^\s+|\s+$/g,'') |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 function strencode(str) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 return encodeURIComponent(str); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 function createXMLRequest() |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 var req; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 if (window.XMLHttpRequest) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 // Modern browsers |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 req = new XMLHttpRequest(); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 else |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 // Old IE versions |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 req = new ActiveXObject("Microsoft.XMLHTTP"); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 return req; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 function sendPOSTRequest(params, success, failure) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 var req = createXMLRequest(); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 req.open("POST", "admajax.php", true); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 req.setRequestHeader("Content-length", params.length); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 req.setRequestHeader("Connection", "close"); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 req.onreadystatechange = function() |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 if (req.readyState == 4) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 if (req.status == 404) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 window.location = "admlogout.php"; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 else |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 if (req.status == 200) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 if (success) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 success(req.responseText); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 statusMsg(req.statusText); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 else |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 if (failure) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 failure(req.status, req.statusText, req.responseText); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 else |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 statusMsg("["+req.status+" - "+req.statusText+"] "+ req.responseText); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 req.send(params); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 |
115 | 80 // |
81 // Function for creating AJAX POST request arguments list based | |
82 // on fields and giving them specified types. Also basic check | |
83 // for validity can be performed (e.g. field empty or not) | |
84 // | |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 function makePostArgs(fields, fprefix, fsuffix) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 var res = []; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 for (var id in fields) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 var elem = document.getElementById(fprefix + id + fsuffix); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 if (!elem) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 alert("No such DOM element '"+ fprefix + id + fsuffix +"'."); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 return ""; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 switch (fields[id]) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 case 0: |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 case 1: |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 case 4: |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 var str = strtrim(elem.value); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 if ((fields[id] == 1 || fields[id] == 4) && str == "") |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 alert("One or more of the required fields are empty."); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 return ""; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 if (fields[id] == 4) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 res.push(id+"="+parseInt(elem.value)); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 else |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 res.push(id+"="+strencode(str)); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 break; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 case 2: |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 res.push(id+"="+parseInt(elem.value)); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 break; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 case 3: |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 res.push(id+"="+(elem.checked ? "1" : "0")); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 break; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 return res.join("&"); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 function refreshItems(id,name,msgname) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 var msuccess = function(txt) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 var nitem = document.getElementById(id); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 nitem.innerHTML = txt; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 sendPOSTRequest("action=get&type="+name, msuccess); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 function deleteItem(id,prefix,type,func,dsc) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 var msuccess = function(txt) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 { |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 var item = document.getElementById(prefix+id); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
147 item.style.display = "none"; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 setTimeout(func, 50); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 |
115 | 151 // Clearly mark the element when asking confirmation |
114
b5981168ed85
Highlight element being queried for deletion when showing the confirmation dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
152 var item = document.getElementById(prefix+id); |
b5981168ed85
Highlight element being queried for deletion when showing the confirmation dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
153 var tmp = item.style.background; |
b5981168ed85
Highlight element being queried for deletion when showing the confirmation dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
154 item.style.background = "red"; |
b5981168ed85
Highlight element being queried for deletion when showing the confirmation dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
155 |
115 | 156 // Ask confirmation for deletion |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?")) |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 { |
115 | 159 // Okay, delete |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess); |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 } |
114
b5981168ed85
Highlight element being queried for deletion when showing the confirmation dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
162 |
115 | 163 // Restore background |
114
b5981168ed85
Highlight element being queried for deletion when showing the confirmation dialog.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
164 item.style.background = tmp; |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 } |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 |