comparison ajax.js @ 115:87d3ce535834

Comments.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Oct 2013 12:26:06 +0300
parents b5981168ed85
children 986c25c2e2bc
comparison
equal deleted inserted replaced
114:b5981168ed85 115:87d3ce535834
75 } 75 }
76 req.send(params); 76 req.send(params);
77 } 77 }
78 78
79 79
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 //
80 function makePostArgs(fields, fprefix, fsuffix) 85 function makePostArgs(fields, fprefix, fsuffix)
81 { 86 {
82 var res = []; 87 var res = [];
83 for (var id in fields) 88 for (var id in fields)
84 { 89 {
141 var item = document.getElementById(prefix+id); 146 var item = document.getElementById(prefix+id);
142 item.style.display = "none"; 147 item.style.display = "none";
143 setTimeout(func, 50); 148 setTimeout(func, 50);
144 } 149 }
145 150
151 // Clearly mark the element when asking confirmation
146 var item = document.getElementById(prefix+id); 152 var item = document.getElementById(prefix+id);
147 var tmp = item.style.background; 153 var tmp = item.style.background;
148 item.style.background = "red"; 154 item.style.background = "red";
149 155
156 // Ask confirmation for deletion
150 if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?")) 157 if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?"))
151 { 158 {
159 // Okay, delete
152 sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess); 160 sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess);
153 } 161 }
154 162
163 // Restore background
155 item.style.background = tmp; 164 item.style.background = tmp;
156 } 165 }
157 166
158 167