Mercurial > hg > fapweb
changeset 124:986c25c2e2bc
Move some relevant javascript code from ajax.js to admin module.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2013 15:34:41 +0300 |
parents | 5837b9333964 |
children | f364b50e07f7 |
files | admin.inc.php ajax.js |
diffstat | 2 files changed, 39 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/admin.inc.php Tue Oct 22 15:18:09 2013 +0300 +++ b/admin.inc.php Tue Oct 22 15:34:41 2013 +0300 @@ -53,7 +53,45 @@ { ?> <script type="text/javascript"> -// <? stCreateSettingsData(); include "ajax.js"; ?> +// <? stCreateSettingsData(); echo "\n"; include "ajax.js"; ?> + + +function refreshItems(id,name,msgname) +{ + var msuccess = function(txt) + { + var nitem = document.getElementById(id); + nitem.innerHTML = txt; + } + + sendPOSTRequest("action=get&type="+name, msuccess); +} + + +function deleteItem(id,prefix,type,func,dsc) +{ + var msuccess = function(txt) + { + var item = document.getElementById(prefix+id); + item.style.display = "none"; + setTimeout(func, 50); + } + + // Clearly mark the element when asking confirmation + var item = document.getElementById(prefix+id); + var tmp = item.style.background; + item.style.background = "red"; + + // Ask confirmation for deletion + if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?")) + { + // Okay, delete + sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess); + } + + // Restore background + item.style.background = tmp; +} function refreshSettings()
--- a/ajax.js Tue Oct 22 15:18:09 2013 +0300 +++ b/ajax.js Tue Oct 22 15:34:41 2013 +0300 @@ -125,43 +125,3 @@ } return res.join("&"); } - - -function refreshItems(id,name,msgname) -{ - var msuccess = function(txt) - { - var nitem = document.getElementById(id); - nitem.innerHTML = txt; - } - - sendPOSTRequest("action=get&type="+name, msuccess); -} - - -function deleteItem(id,prefix,type,func,dsc) -{ - var msuccess = function(txt) - { - var item = document.getElementById(prefix+id); - item.style.display = "none"; - setTimeout(func, 50); - } - - // Clearly mark the element when asking confirmation - var item = document.getElementById(prefix+id); - var tmp = item.style.background; - item.style.background = "red"; - - // Ask confirmation for deletion - if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?")) - { - // Okay, delete - sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess); - } - - // Restore background - item.style.background = tmp; -} - -