Store chat username on send

This commit is contained in:
Gabe Kangas 2020-06-02 10:38:13 -07:00
parent 4cb282040b
commit 94fabf56a8
3 changed files with 7 additions and 5 deletions

View file

@ -118,7 +118,7 @@
else if (video.canPlayType("application/vnd.apple.mpegurl")) { else if (video.canPlayType("application/vnd.apple.mpegurl")) {
video.src = videoSrc; video.src = videoSrc;
video.addEventListener("loadedmetadata", function () { video.addEventListener("loadedmetadata", function () {
video.play(); document.getElementById('video').play();
}); });
} }
</script> </script>
@ -127,7 +127,7 @@
var app = new Vue({ var app = new Vue({
el: "#app", el: "#app",
data: { data: {
streamStatus: "Hello Vue!", streamStatus: "",
}, },
}); });
</script> </script>

View file

@ -8,7 +8,8 @@ define(
this.author = ko.observable(model.author); this.author = ko.observable(model.author);
this.body = ko.observable(model.body); this.body = ko.observable(model.body);
} else { } 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.body = ko.observable("");
} }
this.image = ko.observable("https://robohash.org/" + this.author() + "?set=set3&size=50x50") this.image = ko.observable("https://robohash.org/" + this.author() + "?set=set3&size=50x50")

View file

@ -17,12 +17,13 @@ define(
var message = new Message(); var message = new Message();
message.author(model.author); message.author(model.author);
message.image("https://robohash.org/" + model.author); message.image("https://robohash.org/" + model.author);
console.log("https://robohash.org/" + model.author)
this.editingMessage(message); this.editingMessage(message);
localStorage.author = model.author
console.log(model.author)
}; };
ws.onmessage = function (e) { ws.onmessage = function (e) {
console.log("on message")
var model = $.evalJSON(e.data); var model = $.evalJSON(e.data);
var msg = new Message(model); var msg = new Message(model);
that.messages.push(msg); that.messages.push(msg);