diff --git a/anonkun.py b/anonkun.py index d358463..acc4be7 100644 --- a/anonkun.py +++ b/anonkun.py @@ -96,6 +96,16 @@ def get_dice_challenge(post_id): return db.get_dice_call(post_id)[3] +@app.template_filter("num_ips") +def num_ips(ips_voted): + """ + Returns the number of IPs who voted for this option. + """ + if not ips_voted: + return 0 + return len(ips_voted.split(",")) + + @app.after_request def minify(res): """ diff --git a/anonkun.sql b/anonkun.sql index 8151b24..ee155d6 100644 --- a/anonkun.sql +++ b/anonkun.sql @@ -47,14 +47,17 @@ CREATE TABLE `polls` ( `post_id` MEDIUMINT UNSIGNED NOT NULL, `multi_choice` BOOLEAN DEFAULT FALSE, `allow_writein` BOOLEAN DEFAULT FALSE, + `total_ips` TEXT DEFAULT NULL, PRIMARY KEY (`post_id`) ) ENGINE=InnoDB CHARSET utf8mb4; CREATE TABLE `poll_options` ( + `option_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, `post_id` MEDIUMINT UNSIGNED NOT NULL, `quest_id` SMALLINT UNSIGNED NOT NULL, `option_text` VARCHAR(200) NOT NULL, - `ips_voted` TEXT DEFAULT NULL + `ips_voted` TEXT DEFAULT NULL, + PRIMARY KEY (`option_id`) ) ENGINE=InnoDB CHARSET utf8mb4; CREATE TABLE `chat_messages` ( diff --git a/static/anonkun.css b/static/anonkun.css index d8a46bd..21c1977 100644 --- a/static/anonkun.css +++ b/static/anonkun.css @@ -37,8 +37,8 @@ h3 { } #questPane { - padding-left: 10px; - padding-right: 32%; + padding-left: 5%; + padding-right: 35%; min-width: 0; } @@ -54,6 +54,7 @@ h3 { .questPostData { word-wrap: break-word; min-width: 0; + width: 100%; } #QMPostPane { @@ -110,6 +111,58 @@ h3 { margin: 0.1em; } +.pollPost { + width: 100%; +} + +.poll { + border-collapse: collapse; + width: 100%; + table-layout: fixed; + border: 1px solid #ddd; +} + +.optionVotes { + width: 10%; + text-align: center; +} + +.poll td { + padding: 0.5em; + word-wrap: break-word; + border-bottom: 1px solid #ddd; +} + +.pollCheckBox input { + display: none; +} + +.pollCheckBox { + width: 1.5em; +} + +.pollCheckBox label { + cursor: pointer; + background: #eee; + border: 1px solid #ddd; + padding: 0.2em; +} + +.pollCheckBox label:after { + content: "\2713"; + color: #bfbfbf; + opacity: 0.3; +} + +.pollCheckBox label:hover::after { + opacity: 0.5; +} + +.pollCheckBox input[type=checkbox]:checked + label:after { + opacity: 1; + color: black; +} + #chatPane { height: 100%; width: 30%; diff --git a/templates/quest.html b/templates/quest.html index d2209ad..1372b22 100644 --- a/templates/quest.html +++ b/templates/quest.html @@ -104,6 +104,8 @@ date_str += padToTwo(date.getHours()) + ':' + padToTwo(date.getMinutes()) + ':' + padToTwo(date.getSeconds()); return date_str; } + function pollVote() { + } {% if session.get("user_id") == owner_id %}