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

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