From a91a0665cb1b6bc406bab1b245358208b547da98 Mon Sep 17 00:00:00 2001 From: annieversary Date: Sat, 15 Jan 2022 23:03:50 +0000 Subject: [PATCH] add message timestamp on title and also change cache busting thing on so many files wtf --- frontend/index.html | 2 +- frontend/lib/chat.mjs | 16 ++++++++++++++++ frontend/lib/create-session.mjs | 2 +- frontend/lib/join-session.mjs | 2 +- frontend/lib/watch-session.mjs | 2 +- frontend/main.mjs | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index b779929..b51e20d 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -52,6 +52,6 @@ - + diff --git a/frontend/lib/chat.mjs b/frontend/lib/chat.mjs index a5ff30e..b00e2a8 100644 --- a/frontend/lib/chat.mjs +++ b/frontend/lib/chat.mjs @@ -96,6 +96,21 @@ const checkDebounce = (event) => { return shouldIgnore; }; +/** + * @returns {string} + */ +const getCurrentTimestamp = () => { + const t = new Date(); + return `${matpad(t.getHours())}:${matpad(t.getMinutes())}:${matpad(t.getSeconds())}`; +}; + +/** + * https://media.discordapp.net/attachments/834541919568527361/931678814751301632/66d2c68c48daa414c96951381665ec2e.png + */ +const matpad = (n) => { + return ("00" + n).slice(-2); +}; + /** * @param {string} eventType * @param {string?} user @@ -105,6 +120,7 @@ const printChatMessage = (eventType, user, content) => { const chatMessage = document.createElement("div"); chatMessage.classList.add("chat-message"); chatMessage.classList.add(eventType); + chatMessage.title = getCurrentTimestamp(); if (user != null) { const userName = document.createElement("strong"); diff --git a/frontend/lib/create-session.mjs b/frontend/lib/create-session.mjs index 45f15b3..137fbcd 100644 --- a/frontend/lib/create-session.mjs +++ b/frontend/lib/create-session.mjs @@ -1,4 +1,4 @@ -import { createSession } from "./watch-session.mjs?v=5"; +import { createSession } from "./watch-session.mjs?v=6"; export const setupCreateSessionForm = () => { const form = document.querySelector("#create-session-form"); diff --git a/frontend/lib/join-session.mjs b/frontend/lib/join-session.mjs index 6eaf1fc..19f565f 100644 --- a/frontend/lib/join-session.mjs +++ b/frontend/lib/join-session.mjs @@ -1,4 +1,4 @@ -import { joinSession } from "./watch-session.mjs?v=5"; +import { joinSession } from "./watch-session.mjs?v=6"; /** * @param {HTMLInputElement} field diff --git a/frontend/lib/watch-session.mjs b/frontend/lib/watch-session.mjs index d1b1d1a..0e12e6d 100644 --- a/frontend/lib/watch-session.mjs +++ b/frontend/lib/watch-session.mjs @@ -1,5 +1,5 @@ import { setupVideo } from "./video.mjs?v=5"; -import { setupChat, logEventToChat } from "./chat.mjs?v=5"; +import { setupChat, logEventToChat } from "./chat.mjs?v=6"; /** * @param {string} sessionId diff --git a/frontend/main.mjs b/frontend/main.mjs index 90bafa0..3f6829a 100644 --- a/frontend/main.mjs +++ b/frontend/main.mjs @@ -1,4 +1,4 @@ -import { setupJoinSessionForm } from "./lib/join-session.mjs?v=5"; +import { setupJoinSessionForm } from "./lib/join-session.mjs?v=6"; const main = () => { setupJoinSessionForm();