From 2bbf0982344d2b50a6b8b318b4549982081300ed Mon Sep 17 00:00:00 2001 From: tisboyo <10230718+tisboyo@users.noreply.github.com> Date: Sat, 11 Sep 2021 02:41:34 +0000 Subject: [PATCH] Add question details to display #231 --- bot/mods/trivia.py | 4 +++- web/static_files/trivia/play.css | 10 ++++++++++ web/static_files/trivia/play.js | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bot/mods/trivia.py b/bot/mods/trivia.py index 8ef3d33..0fe8831 100644 --- a/bot/mods/trivia.py +++ b/bot/mods/trivia.py @@ -136,6 +136,7 @@ def check_send_time(seconds_into_trivia: int): "image": self.active_question.id if self.active_question.image is None else self.active_question.image, "sound": self.active_question.id if self.active_question.sound is None else self.active_question.sound, "active": True, + "question_num": self.questions_into_trivia, } # Pad out the answers if there are less than 4 so the spacing is correct on the front end if len(mqtt_question_setup["answers"]) < min_number_of_questions_to_send: @@ -328,7 +329,8 @@ async def trivia_start(self, msg: Message, debug=False): "text": "", "choices": [], "answers": {}, - "id": "default", + "id": "", + "question_num": "", "active": True, "image": "thumb-for-twitch", "sound": 0, diff --git a/web/static_files/trivia/play.css b/web/static_files/trivia/play.css index f52f614..ffb5f45 100644 --- a/web/static_files/trivia/play.css +++ b/web/static_files/trivia/play.css @@ -72,6 +72,7 @@ body { max-width:100%; } + .big-boi-container { font-size: 1em; position: relative; @@ -197,7 +198,16 @@ body { margin-top: 5%; margin-right: 5%; } +#questioninfo{ + text-align:left; + position: absolute; + color:white; + font: 0.5em; + top: 950px; + right: 1100px; + width: 150px; +} #footer-div { margin: auto; width: 80%; diff --git a/web/static_files/trivia/play.js b/web/static_files/trivia/play.js index 7a929be..948fba1 100644 --- a/web/static_files/trivia/play.js +++ b/web/static_files/trivia/play.js @@ -153,6 +153,10 @@ let box = document.createElement('div'); let picturebox = document.createElement('div'); + let questioninfo = document.createElement('div'); + questioninfo.setAttribute('id', 'questioninfo'); + questioninfo.innerHTML = data.question_num + " " + data.id; + big_boi.appendChild(questioninfo); if (Object.keys(data.answers).length) { @@ -276,7 +280,7 @@ if (document.visibilityState === 'visible') { //navigator.sendBeacon('/trivia/start?key=' + params.key); - var Httpreq = new XMLHttpRequest(); // a new request + //var Httpreq = new XMLHttpRequest(); // a new request var url = "start?key=" + params.key; if (params.debug) { url = url + "&debug=" + params.debug