You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
643 B
29 lines
643 B
define( |
|
"Message", |
|
[], |
|
function() { |
|
|
|
function Message(model) { |
|
if (model !== undefined) { |
|
this.author = ko.observable(model.author); |
|
this.body = ko.observable(model.body); |
|
} else { |
|
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") |
|
|
|
|
|
this.toModel = function() { |
|
return { |
|
author: this.author(), |
|
body: this.body(), |
|
image: this.image() |
|
}; |
|
} |
|
} |
|
|
|
return Message; |
|
} |
|
);
|
|
|