Mercurial > hg > fapweb
diff admajax.php @ 321:9462a59d3ab3
Votekey activation usability improvements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Nov 2013 18:36:30 +0200 |
parents | a0a6131c37b4 |
children | f3dfdb4fb221 |
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"; }