Mercurial > hg > fapweb
changeset 350:2a12f5c72b66
Modularize a bit and add confirmation for deactivating of votekeys.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 02 Dec 2013 06:01:21 +0200 |
parents | 61c4dda0ec03 |
children | 78a18b8b3511 |
files | admin.php |
diffstat | 1 files changed, 25 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/admin.php Mon Dec 02 05:52:29 2013 +0200 +++ b/admin.php Mon Dec 02 06:01:21 2013 +0200 @@ -398,7 +398,7 @@ } -function voteKeyRefresh(id, mode, args) +function voteKeyRefresh(id) { var msuccess2 = function(txt) { @@ -414,10 +414,16 @@ nitem.innerHTML = txt; } + jsSendPOSTRequest("action=get&type=votekey&id="+id, msuccess1); + jsSendPOSTRequest("action=get&type=votekeyclass&id="+id, msuccess2); +} + + +function voteKeyUpdate(id, mode, args) +{ var msuccess = function(txt) { - jsSendPOSTRequest("action=get&type=votekey&id="+id, msuccess1); - jsSendPOSTRequest("action=get&type=votekeyclass&id="+id, msuccess2); + voteKeyRefresh(id); } jsSendPOSTRequest("action=update&type=votekey&mode="+mode+"&id="+id+"&"+args, msuccess); @@ -427,7 +433,21 @@ function voteKeySetActive(id) { var args = jsMakePostArgs({"active":3}, "vk", id); - voteKeyRefresh(id, "active", args); + + var mcb_ok = function (data) + { + voteKeyUpdate(id, "active", args); + } + + var mcb_cancel = function (data) + { + voteKeyRefresh(id); + } + + if (lastPostArgs["active"] == 0) + jsConfirmBox("Are you sure you want to deactivate vote key #"+id+"?", mcb_ok, mcb_cancel, 0); + else + mcb_ok(0); } @@ -437,7 +457,7 @@ var mcb_ok = function (data) { - voteKeyRefresh(id, (mode ? "assign" : "clear"), args); + voteKeyUpdate(id, (mode ? "assign" : "clear"), args); } if (mode == 0)