123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- const HomeRouter = {
- template: `
- <div>
- <div id="om-msg-cards" class="is-hidden-desktop">
- <MsgCard
- v-for="id in messagelist.slice().reverse()"
- :key="id"
- :msg="messages[id] || {}"
- ></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>
- </div>`,
- data: function () {
- return {
- messagelist: _messagelist,
- messages: _messages,
- };
- },
- methods: {
- /*refresh_messages: function () {
- _messages.push({ //////// alt
- id: 42,
- subject: "xxx",
- message: "warum habt ihr auch so viel",
- user: "nobody",
- tags: "foo"
- });
- },*/
- list_messages: function() {
- messages();
- }
- /*list_messages: function () {
- $.ajax({url: "api/msg/ids", method: "GET"})
- .done(jd => {
- // NICHT SO wg. Vue: _messagelist = jd;
- _messagelist.splice(0, _messagelist.length);
- _messagelist.push.apply(_messagelist, jd);
- //console.log("jd: "+jd);
- for (var e in jd) {
- if (!_messages[jd[e]]) {
- get_insert_message(jd[e]);
- }
- }
- 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]);
- }
- }
- }
- }).fail(function (e, f, g) {
- console.log("list_msg: err: " + e + f + g);
- });
- }*/
- },
-
- mounted: function () {
- this.list_messages();
- //this.refresh_messages();
- }
- };
-
- function get_insert_message(id) {
- $.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
- Vue.set(_messages, id, msg);
- }).fail(function (e, f, g) {
- console.log("cannot load " + id + ".json: " + e + f + g);
- })
- }
-
- /*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 () {
- 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);
- });
- });*/
|