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.9KB

5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. const HomeRouter = {
  2. template: `
  3. <div id="om-msg-cards">
  4. <MsgCard
  5. v-for="id in messagelist.slice().reverse()"
  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. messages();
  28. }
  29. /*list_messages: function () {
  30. $.ajax({url: "api/msg/ids", method: "GET"})
  31. .done(jd => {
  32. // NICHT SO wg. Vue: _messagelist = jd;
  33. _messagelist.splice(0, _messagelist.length);
  34. _messagelist.push.apply(_messagelist, jd);
  35. //console.log("jd: "+jd);
  36. for (var e in jd) {
  37. if (!_messages[jd[e]]) {
  38. get_insert_message(jd[e]);
  39. }
  40. }
  41. if(!($".om-searchbar" = "")){
  42. for (var e in jd) {
  43. if (!_messages[jd[e]]) {
  44. get_insert_message(jd[e]);
  45. }
  46. }
  47. }else{
  48. for (var e in jd) {
  49. if (!_messages[jd[e]]) {
  50. get_search_message(jd[e]);
  51. }
  52. }
  53. }
  54. }).fail(function (e, f, g) {
  55. console.log("list_msg: err: " + e + f + g);
  56. });
  57. }*/
  58. },
  59. mounted: function () {
  60. this.list_messages();
  61. //this.refresh_messages();
  62. }
  63. };
  64. function get_insert_message(id) {
  65. $.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
  66. Vue.set(_messages, id, msg);
  67. }).fail(function (e, f, g) {
  68. console.log("cannot load " + id + ".json: " + e + f + g);
  69. })
  70. }
  71. /*function get_search_message(phrase) {
  72. $.ajax({ url: "api/msg/search/"+phrase, method: "GET" }).done(function (msg) {
  73. Vue.set(_messages, id, msg);
  74. }).fail(function (e, f, g) {
  75. console.log("cannot load " + id + ".json: " + e + f + g);
  76. })
  77. }
  78. $(document).ready(function () {
  79. console.log("egal");
  80. $.get('list.json').done(function (jd) {
  81. // _messagelist = jd;
  82. _messagelist.splice(0, _messagelist.length);
  83. _messagelist.push.apply(_messagelist, jd);
  84. console.log("egal2");
  85. //$('#xxx').text(jd[0]);
  86. for (var e in jd) {
  87. if (!_messages[jd[e]]) {
  88. get_insert_message(jd[e]);
  89. }
  90. }
  91. }).fail(function (e, f, g) {
  92. console.log("egal3: " + e + f + g);
  93. });
  94. });*/