From 94fabf56a886ebce4b7afcebaab5bceca346bec3 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Tue, 2 Jun 2020 10:38:13 -0700 Subject: [PATCH] Store chat username on send --- webroot/index.html | 4 ++-- webroot/js/Message.js | 3 ++- webroot/js/MessageList.js | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/webroot/index.html b/webroot/index.html index a6710cfb8..c598378ac 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -118,7 +118,7 @@ else if (video.canPlayType("application/vnd.apple.mpegurl")) { video.src = videoSrc; video.addEventListener("loadedmetadata", function () { - video.play(); + document.getElementById('video').play(); }); } @@ -127,7 +127,7 @@ var app = new Vue({ el: "#app", data: { - streamStatus: "Hello Vue!", + streamStatus: "", }, }); diff --git a/webroot/js/Message.js b/webroot/js/Message.js index 75a866a98..fd08d7ccc 100644 --- a/webroot/js/Message.js +++ b/webroot/js/Message.js @@ -8,7 +8,8 @@ define( this.author = ko.observable(model.author); this.body = ko.observable(model.body); } else { - this.author = ko.observable("Anonymous"); + const storedAuthor = localStorage.author || "Viewer" + (Math.floor(Math.random() * 42) + 1) + this.author = ko.observable(storedAuthor); this.body = ko.observable(""); } this.image = ko.observable("https://robohash.org/" + this.author() + "?set=set3&size=50x50") diff --git a/webroot/js/MessageList.js b/webroot/js/MessageList.js index 1586fcf24..1493ba871 100644 --- a/webroot/js/MessageList.js +++ b/webroot/js/MessageList.js @@ -17,12 +17,13 @@ define( var message = new Message(); message.author(model.author); message.image("https://robohash.org/" + model.author); - console.log("https://robohash.org/" + model.author) this.editingMessage(message); + + localStorage.author = model.author + console.log(model.author) }; ws.onmessage = function (e) { - console.log("on message") var model = $.evalJSON(e.data); var msg = new Message(model); that.messages.push(msg);