2018-12-05 16:35:54 +01:00
|
|
|
const HomeRouter = {
|
2018-12-28 10:18:21 +01:00
|
|
|
template: `
|
2018-12-19 18:18:42 +01:00
|
|
|
<div id="om-msg-cards">
|
2018-12-05 16:35:54 +01:00
|
|
|
<MsgCard
|
2019-02-08 14:59:19 +01:00
|
|
|
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>`,
|
2018-12-28 10:18:21 +01:00
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
messagelist: _messagelist,
|
|
|
|
messages: _messages,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2019-01-31 19:01:40 +01:00
|
|
|
/*refresh_messages: function () {
|
2018-12-28 10:18:21 +01:00
|
|
|
_messages.push({ //////// alt
|
|
|
|
id: 42,
|
|
|
|
subject: "xxx",
|
|
|
|
message: "warum habt ihr auch so viel",
|
|
|
|
user: "nobody",
|
|
|
|
tags: "foo"
|
|
|
|
});
|
2019-01-31 19:01:40 +01:00
|
|
|
},*/
|
2019-02-06 17:00:38 +01:00
|
|
|
list_messages: function () {
|
2019-02-08 13:52:48 +01:00
|
|
|
$.ajax({url: "api/ids", method: "GET"})
|
2019-02-06 17:00:38 +01:00
|
|
|
.done(jd => {
|
|
|
|
// NICHT SO wg. Vue: _messagelist = jd;
|
|
|
|
_messagelist.splice(0, _messagelist.length);
|
|
|
|
_messagelist.push.apply(_messagelist, jd);
|
2019-02-08 13:40:21 +01:00
|
|
|
console.log("jd: "+jd);
|
2019-02-06 17:00:38 +01:00
|
|
|
for (var e in jd) {
|
2019-06-04 15:26:38 +02:00
|
|
|
if (!_messages[jd[e]]) {
|
|
|
|
get_insert_message(jd[e]);
|
|
|
|
}
|
2019-02-06 17:00:38 +01:00
|
|
|
}
|
2019-06-04 15:26:38 +02:00
|
|
|
/*if(!($".om-searchbar" = "")){
|
|
|
|
for (var e in jd) {
|
|
|
|
if (!_messages[jd[e]]) {
|
|
|
|
get_insert_message(jd[e]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
for (var e in jd) {
|
|
|
|
if (!_messages[jd[e]]) {
|
|
|
|
get_search_message(jd[e]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
2019-02-06 17:00:38 +01:00
|
|
|
}).fail(function (e, f, g) {
|
|
|
|
console.log("err: " + e + f + g);
|
|
|
|
});
|
|
|
|
}
|
2018-12-28 10:18:21 +01:00
|
|
|
},
|
2018-12-19 18:18:42 +01:00
|
|
|
|
2019-02-06 17:00:38 +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
|
|
|
|
2019-02-06 17:00:38 +01:00
|
|
|
function get_insert_message(id) {
|
2019-02-08 13:52:48 +01:00
|
|
|
$.ajax({ url: "api/msg/"+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);
|
|
|
|
})
|
|
|
|
}
|
2019-06-04 15:26:38 +02:00
|
|
|
|
|
|
|
/*function get_search_message(phrase) {
|
|
|
|
$.ajax({ url: "api/msg/search/"+phrase, method: "GET" }).done(function (msg) {
|
|
|
|
Vue.set(_messages, id, msg);
|
|
|
|
}).fail(function (e, f, g) {
|
|
|
|
console.log("cannot load " + id + ".json: " + e + f + g);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
$(document).ready(function () {
|
2018-12-28 10:18:21 +01:00
|
|
|
console.log("egal");
|
|
|
|
$.get('list.json').done(function (jd) {
|
|
|
|
// _messagelist = jd;
|
|
|
|
_messagelist.splice(0, _messagelist.length);
|
|
|
|
_messagelist.push.apply(_messagelist, jd);
|
|
|
|
console.log("egal2");
|
|
|
|
//$('#xxx').text(jd[0]);
|
|
|
|
for (var e in jd) {
|
|
|
|
if (!_messages[jd[e]]) {
|
|
|
|
get_insert_message(jd[e]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).fail(function (e, f, g) {
|
|
|
|
console.log("egal3: " + e + f + g);
|
|
|
|
});
|
2019-01-31 19:01:40 +01:00
|
|
|
});*/
|