Mercurial > hg > fapweb
changeset 321:9462a59d3ab3
Votekey activation usability improvements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Nov 2013 18:36:30 +0200 |
parents | a0a6131c37b4 |
children | a11975659f38 |
files | admajax.php admin.css admin.php |
diffstat | 3 files changed, 68 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Wed Nov 27 17:26:17 2013 +0200 +++ b/admajax.php Wed Nov 27 18:36:30 2013 +0200 @@ -121,6 +121,29 @@ } +function stGetVoteKeyClass($item) +{ + global $voteKeyMode; + + switch ($voteKeyMode) + { + case VOTE_FREELY: + $cond = 0; + break; + + case VOTE_ACTIVATE: + $cond = $item["active"]; + break; + + case VOTE_ASSIGN: + $cond = $item["key_id"] > 0; + break; + } + + return "votekey ".($cond ? "vkeyActive" : "vkeyInactive"); +} + + function stGetVoteKeyItemData($id, $item, $prefix) { global $voteKeyMode, $voteKeyLen; @@ -314,6 +337,7 @@ break; case "votekey": + case "votekeyclass": switch ($voteKeyMode) { case VOTE_FREELY: @@ -328,7 +352,12 @@ break; } if (($res = stFetchSQL($sql)) !== FALSE) - echo stGetVoteKeyItemData($res["id"], $res, "vk"); + { + if ($type == "votekeyclass") + echo stGetVoteKeyClass($res); + else + echo stGetVoteKeyItemData($res["id"], $res, "vk"); + } break; case "voters": @@ -361,7 +390,8 @@ { // This funny code is to ensure that the cells are of uniform width echo - "<div class=\"votekey\" id=\"vkey".$item["id"]."\">". + "<div class=\"".stGetVoteKeyClass($item). + "\" id=\"vkey".$item["id"]."\">". stGetVoteKeyItemData($item["id"], $item, "vk"). "</div>\n"; } @@ -385,7 +415,8 @@ foreach (stExecSQL($sql) as $item) { echo - " <tr class=\"rodd\" id=\"vkey".$item["id"]."\">\n". + " <tr class=\"".stGetVoteKeyClass($item). + "\" id=\"vkey".$item["id"]."\">\n". stGetVoteKeyItemData($item["id"], $item, "vk"). " </tr>\n"; }
--- a/admin.css Wed Nov 27 17:26:17 2013 +0200 +++ b/admin.css Wed Nov 27 18:36:30 2013 +0200 @@ -95,6 +95,10 @@ font-weight: bold; } -div.votekeys .keyactive { - margin-left: 1em; +tr.votekey:hover td { + background: red; } + +.vkeyActive { + background: green; +}
--- a/admin.php Wed Nov 27 17:26:17 2013 +0200 +++ b/admin.php Wed Nov 27 18:36:30 2013 +0200 @@ -386,16 +386,36 @@ } +function voteKeyRefresh(id, mode, args) +{ + var msuccess2 = function(txt) + { + var nitem = document.getElementById("vkey"+id); + if (nitem) + nitem.className = txt; + } + + var msuccess1 = function(txt) + { + var nitem = document.getElementById("vkey"+id); + if (nitem) + nitem.innerHTML = txt; + } + + var msuccess = function(txt) + { + sendPOSTRequest("action=get&type=votekey&id="+id, msuccess1); + sendPOSTRequest("action=get&type=votekeyclass&id="+id, msuccess2); + } + + sendPOSTRequest("action=update&type=votekey&mode="+mode+"&id="+id+"&"+args, msuccess); +} + + function voteKeySetActive(id) { var args = makePostArgs({"active":3}, "vk", id); - - var msuccess = function(txt) - { - refreshItems("vkey"+id, "votekey", "&id="+id); - } - - sendPOSTRequest("action=update&type=votekey&mode=active&id="+id+"&"+args, msuccess); + voteKeyRefresh(id, "active", args); } @@ -403,15 +423,9 @@ { var args = makePostArgs({"key_id":2}, "vk", id); - var msuccess = function(txt) - { - refreshItems("vkey"+id, "votekey", "&id="+id); - } - - // Ask confirmation for deletion if ((mode == 0 && confirm("Are you sure you want to clear vote key assign #"+id+"?")) || mode != 0) { - sendPOSTRequest("action=update&type=votekey&mode="+ (mode ? "assign" : "clear") +"&id="+id+"&"+args, msuccess); + voteKeyRefresh(id, (mode ? "assign" : "clear"), args); } }