aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2017-03-24 00:09:45 +1100
committerYingtong Li <runassudo@yingtongli.me>2017-03-24 00:09:45 +1100
commit1060ec9a0fa946900eaed56463be49230cb9631c (patch)
tree9635e637567e9746b5a71665781af69e500e78cc
parent409021d18aae17fb7e7e88b1958f52004d5254cd (diff)
Indicate status in sidebar
-rw-r--r--pblive/__init__.py5
-rw-r--r--pblive/templates/users.html8
2 files changed, 10 insertions, 3 deletions
diff --git a/pblive/__init__.py b/pblive/__init__.py
index 2170fc3..13ce055 100644
--- a/pblive/__init__.py
+++ b/pblive/__init__.py
@@ -78,6 +78,7 @@ def socket_join(session_name):
# Send initial colour picker
flask_socketio.emit('update', flask.render_template('colour_picker.html', session=session), room=flask.request.sid)
+ flask_socketio.emit('update_left', render_sidebar(user, session), room=flask.request.sid)
def render_question(user, session, question_num):
return flask.render_template(session.questions[question_num].template, session=session, user=user, question_num=session.question_num)
@@ -155,9 +156,13 @@ def socket_answer(question_num, answer):
flask_socketio.emit('update', render_question(user, user.session, user.session.question_num), room=user.sid)
# Relay change
+ for _, other_user in pblive.data.users.items():
+ if other_user.session == user.session:
+ flask_socketio.emit('update_left', render_sidebar(other_user, user.session), room=other_user.sid)
for _, admin in pblive.data.admins.items():
if admin.session == user.session:
flask_socketio.emit('update', render_question_admin(user.session, user.session.question_num), room=admin.sid)
+ flask_socketio.emit('update_left', render_sidebar(admin, user.session), room=admin.sid)
@socketio.on('reveal_answers')
def socket_reveal_answers(question_num):
diff --git a/pblive/templates/users.html b/pblive/templates/users.html
index 459969e..2eef799 100644
--- a/pblive/templates/users.html
+++ b/pblive/templates/users.html
@@ -16,14 +16,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
-{% if user.sid in data.users %}
+{% if user.sid in data.users and user.colour %}
<div>YOU:</div>
- <div><button class="ui button" style="background-color: {{ user.colour[1] }}; width: 32px; height: 32px; padding: 0 0;">{{ user.colour[0] }}</button></div>
+ <div><button class="ui button" style="{% if session.question_num in user.answers or session.questions[session.question_num].answerer == user %}background-color: {{ user.colour[1] }};{% else %}background-color: white; border: 2px solid {{ user.colour[1] }};{% endif %} width: 32px; height: 32px; padding: 0 0;">{{ user.colour[0] }}</button></div>
<div class="ui divider"></div>
{% endif %}
{% for _, other_user in data.users.items() %}
{% if other_user != user and other_user.colour and other_user.session == session %}
- <div><button class="ui button" style="background-color: {{ other_user.colour[1] }}; width: 32px; height: 32px; padding: 0 0;">{{ other_user.colour[0] }}</button></div>
+ <div><button class="ui button" style="{% if session.question_num in other_user.answers or session.questions[session.question_num].answerer == other_user %}background-color: {{ other_user.colour[1] }};{% else %}background-color: white; border: 2px solid {{ other_user.colour[1] }};{% endif %} width: 32px; height: 32px; padding: 0 0;">{{ other_user.colour[0] }}</button></div>
{% endif %}
{% endfor %}
+
+&nbsp;
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.