om/public/routes/home.js

45 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-12-05 16:35:54 +01:00
const HomeRouter = {
2018-12-28 10:18:21 +01:00
template: `
<div>
<div id="om-msg-cards" class="is-hidden-desktop">
2018-12-05 16:35:54 +01:00
<MsgCard
v-for="id in messagelist.slice().reverse()"
2018-12-19 18:18:42 +01:00
:key="id"
:msg="messages[id] || {}"
2018-12-05 16:35:54 +01:00
></MsgCard>
</div>
<div id="om-msg-cards" class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
<MsgCard
v-for="id in messagelist.slice().reverse()"
:key="id"
:msg="messages[id] || {}"
></MsgCard>
</div>
2018-12-05 16:35:54 +01:00
</div>`,
2018-12-28 10:18:21 +01:00
data: function () {
return {
messagelist: _messagelist,
messages: _messages,
};
},
methods: {
2019-07-19 12:52:43 +02:00
list_messages: function() {
messages();
}
2018-12-28 10:18:21 +01:00
},
2018-12-19 18:18:42 +01:00
mounted: function () {
this.list_messages();
//this.refresh_messages();
2019-01-31 19:01:40 +01:00
}
2018-12-05 16:35:54 +01:00
};
2018-12-28 10:18:21 +01:00
function get_insert_message(id) {
$.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
2018-12-28 10:18:21 +01:00
Vue.set(_messages, id, msg);
}).fail(function (e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g);
})
}