From 8f8a60a3b35020daedadfa041b01bda2fc163164 Mon Sep 17 00:00:00 2001 From: User Content Date: Sun, 22 Dec 2024 23:03:02 +0000 Subject: Introduce dark mode --- static/rater.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'static/rater.js') diff --git a/static/rater.js b/static/rater.js index ec1bcfe..495775f 100644 --- a/static/rater.js +++ b/static/rater.js @@ -97,6 +97,14 @@ function fourcol() { document.body.classList.remove('three-column'); document.body.classList.toggle('four-column'); } +function darkmode() { + document.body.classList.remove('light-mode'); + document.body.classList.toggle('dark-mode'); +} +function lightmode() { + document.body.classList.remove('dark-mode'); + document.body.classList.toggle('light-mode'); +} function invert_sort() { var evl = document.getElementById('event-list'); @@ -283,16 +291,35 @@ function do_take(eid) { } function update_status() { - var accepted_count = document.querySelectorAll('.event-list-item[event_state=accepted]').length; - var rejected_count = document.querySelectorAll('.event-list-item[event_state=rejected]').length; + var accepted_count = document.querySelectorAll('.event-list-item[event_state=accepted]').length + document.querySelectorAll('.event-list-item[event_state=accepting]').length; + var rejected_count = document.querySelectorAll('.event-list-item[event_state=rejected]').length + document.querySelectorAll('.event-list-item[event_state=rejecting]').length; var taken_count = document.querySelectorAll('.event-list-item .event-coordinator').length; var total_count = document.getElementsByClassName('event-list-item').length; var total_voted_count = document.querySelectorAll('.event-rating:first-child').length; + var total_minute_count = 0; + document.querySelectorAll('.event-list-item[event_state=accepted]').forEach(function(ev) { + var event_duration = Number(ev.getAttribute('event_duration') || 0); + if (event_duration == 40) { + total_minute_count += 45; + } else { + total_minute_count += event_duration; + } + }); + document.querySelectorAll('.event-list-item[event_state=accepting]').forEach(function(ev) { + var event_duration = Number(ev.getAttribute('event_duration') || 0); + if (event_duration == 40) { + total_minute_count += 45; + } else { + total_minute_count += event_duration; + } + }); + var username = document.getElementById('Username').value; var own_voted_count = 0; if (username) own_voted_count = document.querySelectorAll('.event-rating[submitter="'+username+'"]').length; - document.getElementById('status').innerHTML = total_count + ' events. ' + accepted_count + ' accepted. ' + rejected_count + ' rejected. ' + (total_count - own_voted_count) + ' todo. ' + (total_count - total_voted_count) + ' unvoted. ' + (total_count - taken_count) + ' untaken.'; + document.getElementById('status').innerHTML = total_count + ' events. ' + accepted_count + ' accepted (' + Math.floor(total_minute_count / 60) + ':' + ('0'+(total_minute_count % 60)).slice(-2) + 'h). ' + rejected_count + ' rejected. ' + (total_count - own_voted_count) + ' todo. ' + (total_count - total_voted_count) + ' unvoted. ' + (total_count - taken_count) + ' untaken.'; + /* Do the math */ document.querySelectorAll('.event-list-item').forEach(function(ev) { -- cgit v1.2.3