Ohm-Management - Projektarbeit B-ME
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.

home.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const HomeRouter = {
  2. template: `
  3. <div id="om-msg-cards">
  4. <MsgCard
  5. v-for="id in messagelist"
  6. :key="id"
  7. :msg="messages[id] || {}"
  8. ></MsgCard>
  9. </div>`,
  10. data: function () {
  11. return {
  12. messagelist: _messagelist,
  13. messages: _messages,
  14. };
  15. },
  16. methods: {
  17. refresh_messages: function () {
  18. _messages.push({ //////// alt
  19. id: 42,
  20. subject: "xxx",
  21. message: "warum habt ihr auch so viel",
  22. user: "nobody",
  23. tags: "foo"
  24. });
  25. },
  26. },
  27. /*mounted: function() {
  28. this.refresh_messages();
  29. }*/
  30. };
  31. function get_insert_message(id) {
  32. $.get(id + ".json").done(function (msg) {
  33. // _messages[id] = msg;
  34. Vue.set(_messages, id, msg);
  35. }).fail(function (e, f, g) {
  36. console.log("cannot load " + id + ".json: " + e + f + g);
  37. })
  38. }
  39. $(document).ready(function () {
  40. console.log("egal");
  41. $.get('list.json').done(function (jd) {
  42. // _messagelist = jd;
  43. _messagelist.splice(0, _messagelist.length);
  44. _messagelist.push.apply(_messagelist, jd);
  45. console.log("egal2");
  46. //$('#xxx').text(jd[0]);
  47. for (var e in jd) {
  48. if (!_messages[jd[e]]) {
  49. get_insert_message(jd[e]);
  50. }
  51. }
  52. }).fail(function (e, f, g) {
  53. console.log("egal3: " + e + f + g);
  54. });
  55. });