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 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. list_messages: function () {
  27. console.log("egal");
  28. $.get('api/ids/').done(function (jd) {
  29. // _messagelist = jd;
  30. _messagelist.splice(0, _messagelist.length);
  31. _messagelist.push.apply(_messagelist, jd);
  32. console.log("egal2");
  33. //$('#xxx').text(jd[0]);
  34. for (var e in jd) {
  35. if (!_messages[jd[e]]) {
  36. get_insert_message(jd[e]);
  37. }
  38. }
  39. }).fail(function (e, f, g) {
  40. console.log("egal3: " + e + f + g);
  41. });
  42. }
  43. },
  44. mounted: function() {
  45. this.list_messages();
  46. /*this.refresh_messages();*/
  47. }
  48. };
  49. function get_insert_message(msg_id) {
  50. $.get(api/msg/{msg_id}).done(function (msg) {
  51. // _messages[id] = msg;
  52. Vue.set(_messages, id, msg);
  53. }).fail(function (e, f, g) {
  54. console.log("cannot load " + id + ".json: " + e + f + g);
  55. })
  56. }
  57. /*$(document).ready(function () {
  58. console.log("egal");
  59. $.get('list.json').done(function (jd) {
  60. // _messagelist = jd;
  61. _messagelist.splice(0, _messagelist.length);
  62. _messagelist.push.apply(_messagelist, jd);
  63. console.log("egal2");
  64. //$('#xxx').text(jd[0]);
  65. for (var e in jd) {
  66. if (!_messages[jd[e]]) {
  67. get_insert_message(jd[e]);
  68. }
  69. }
  70. }).fail(function (e, f, g) {
  71. console.log("egal3: " + e + f + g);
  72. });
  73. });*/