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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const HomeRouter = {
  2. template: `
  3. <div>
  4. <div id="om-msg-cards" class="column pull-right-sm is-four-fifths-desktop">
  5. <a id="escape-search-link" @click="goBackToDashboard">< zurück zu allen Einträgen</a>
  6. <b-button id="subscribe-btn" type="is-primary" @click="changeSubscribtion"><div id="btn-text"></div></b-button>
  7. <MsgCard
  8. v-for="id in messagelist.slice().reverse()"
  9. :key="id"
  10. :msg="messages[id] || {}"
  11. ></MsgCard>
  12. </div>
  13. </div>`,
  14. data: function () {
  15. return {
  16. messagelist: _messagelist,
  17. messages: _messages,
  18. isSearchActiv: _isSearchActiv,
  19. isSubscripeButtonActiv: _isSubscripeButtonActiv
  20. };
  21. },
  22. methods: {
  23. list_messages: function() {
  24. messages();
  25. },
  26. goBackToDashboard: function() {
  27. //Home neu rendern ...
  28. //windows.history.go();
  29. router.push('/files')
  30. router.push('/home')
  31. $("#escape-search-link").css("visibility", "hidden");
  32. $("#subscribe-btn").css("visibility", "hidden");
  33. },
  34. changeSubscribtion: function(){
  35. var btnString = $("#btn-text").text();
  36. //console.log(btnString);
  37. if($("#btn-text").hasClass("subscribed")){
  38. $("#btn-text").removeClass("subscribed");
  39. var newBtnString = "#" + $("#btn-text").text(/deabonnieren/g, '') + "abonnieren";
  40. //console.log(btnString);
  41. $("#btn-text").text(newBtnString);
  42. }else{
  43. $("#btn-text").addClass("subscribed");
  44. var newBtnString = "#" + $("#btn-text").text(/abonnieren/g, '') + "deabonnieren";
  45. //console.log(newBtnString);
  46. $("#btn-text").text(newBtnString);
  47. }
  48. }
  49. },
  50. mounted: function () {
  51. this.list_messages();
  52. //this.refresh_messages();
  53. }
  54. };
  55. function get_insert_message(id) {
  56. $.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
  57. Vue.set(_messages, id, msg);
  58. }).fail(function (e, f, g) {
  59. console.log("cannot load " + id + ".json: " + e + f + g);
  60. })
  61. }