add message timestamp on title #7

Merged
nyancrimew merged 1 commits from annie/watch-party:timestamps into main 2022-01-15 23:06:24 +00:00
6 changed files with 21 additions and 5 deletions

View File

@ -52,6 +52,6 @@
</form> </form>
</div> </div>
<script type="module" src="/main.mjs?v=5"></script> <script type="module" src="/main.mjs?v=6"></script>
</body> </body>
</html> </html>

View File

@ -96,6 +96,21 @@ const checkDebounce = (event) => {
return shouldIgnore; 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} eventType
* @param {string?} user * @param {string?} user
@ -105,6 +120,7 @@ const printChatMessage = (eventType, user, content) => {
const chatMessage = document.createElement("div"); const chatMessage = document.createElement("div");
chatMessage.classList.add("chat-message"); chatMessage.classList.add("chat-message");
chatMessage.classList.add(eventType); chatMessage.classList.add(eventType);
chatMessage.title = getCurrentTimestamp();
if (user != null) { if (user != null) {
const userName = document.createElement("strong"); const userName = document.createElement("strong");

View File

@ -1,4 +1,4 @@
import { createSession } from "./watch-session.mjs?v=5"; import { createSession } from "./watch-session.mjs?v=6";
export const setupCreateSessionForm = () => { export const setupCreateSessionForm = () => {
const form = document.querySelector("#create-session-form"); const form = document.querySelector("#create-session-form");

View File

@ -1,4 +1,4 @@
import { joinSession } from "./watch-session.mjs?v=5"; import { joinSession } from "./watch-session.mjs?v=6";
/** /**
* @param {HTMLInputElement} field * @param {HTMLInputElement} field

View File

@ -1,5 +1,5 @@
import { setupVideo } from "./video.mjs?v=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 * @param {string} sessionId

View File

@ -1,4 +1,4 @@
import { setupJoinSessionForm } from "./lib/join-session.mjs?v=5"; import { setupJoinSessionForm } from "./lib/join-session.mjs?v=6";
const main = () => { const main = () => {
setupJoinSessionForm(); setupJoinSessionForm();