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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. const HomeRouter = {
  2. template: `
  3. <div>
  4. <div id="om-msg-cards" class="is-hidden-desktop">
  5. <MsgCard
  6. v-for="id in messagelist.slice().reverse()"
  7. :key="id"
  8. :msg="messages[id] || {}"
  9. ></MsgCard>
  10. </div>
  11. <div id="om-msg-cards" class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
  12. <MsgCard
  13. v-for="id in messagelist.slice().reverse()"
  14. :key="id"
  15. :msg="messages[id] || {}"
  16. ></MsgCard>
  17. </div>
  18. </div>`,
  19. data: function () {
  20. return {
  21. messagelist: _messagelist,
  22. messages: _messages,
  23. };
  24. },
  25. methods: {
  26. /*refresh_messages: function () {
  27. _messages.push({ //////// alt
  28. id: 42,
  29. subject: "xxx",
  30. message: "warum habt ihr auch so viel",
  31. user: "nobody",
  32. tags: "foo"
  33. });
  34. },*/
  35. list_messages: function() {
  36. messages();
  37. }
  38. /*list_messages: function () {
  39. $.ajax({url: "api/msg/ids", method: "GET"})
  40. .done(jd => {
  41. // NICHT SO wg. Vue: _messagelist = jd;
  42. _messagelist.splice(0, _messagelist.length);
  43. _messagelist.push.apply(_messagelist, jd);
  44. //console.log("jd: "+jd);
  45. for (var e in jd) {
  46. if (!_messages[jd[e]]) {
  47. get_insert_message(jd[e]);
  48. }
  49. }
  50. if(!($".om-searchbar" = "")){
  51. for (var e in jd) {
  52. if (!_messages[jd[e]]) {
  53. get_insert_message(jd[e]);
  54. }
  55. }
  56. }else{
  57. for (var e in jd) {
  58. if (!_messages[jd[e]]) {
  59. get_search_message(jd[e]);
  60. }
  61. }
  62. }
  63. }).fail(function (e, f, g) {
  64. console.log("list_msg: err: " + e + f + g);
  65. });
  66. }*/
  67. },
  68. mounted: function () {
  69. this.list_messages();
  70. //this.refresh_messages();
  71. }
  72. };
  73. function get_insert_message(id) {
  74. $.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
  75. Vue.set(_messages, id, msg);
  76. }).fail(function (e, f, g) {
  77. console.log("cannot load " + id + ".json: " + e + f + g);
  78. })
  79. }
  80. /*function get_search_message(phrase) {
  81. $.ajax({ url: "api/msg/search/"+phrase, method: "GET" }).done(function (msg) {
  82. Vue.set(_messages, id, msg);
  83. }).fail(function (e, f, g) {
  84. console.log("cannot load " + id + ".json: " + e + f + g);
  85. })
  86. }
  87. $(document).ready(function () {
  88. console.log("egal");
  89. $.get('list.json').done(function (jd) {
  90. // _messagelist = jd;
  91. _messagelist.splice(0, _messagelist.length);
  92. _messagelist.push.apply(_messagelist, jd);
  93. console.log("egal2");
  94. //$('#xxx').text(jd[0]);
  95. for (var e in jd) {
  96. if (!_messages[jd[e]]) {
  97. get_insert_message(jd[e]);
  98. }
  99. }
  100. }).fail(function (e, f, g) {
  101. console.log("egal3: " + e + f + g);
  102. });
  103. });*/