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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. :isBookmark="bookmarkArray[id]"
  12. ></MsgCard>
  13. </div>
  14. </div>`,
  15. data: function () {
  16. return {
  17. messagelist: _messagelist,
  18. messages: _messages,
  19. isSearchActiv: _isSearchActiv,
  20. isSubscripeButtonActiv: _isSubscripeButtonActiv,
  21. bookmarkArray: auth.bookmarks,
  22. };
  23. },
  24. methods: {
  25. list_messages: function() {
  26. messages();
  27. },
  28. goBackToDashboard: function() {
  29. //Home neu rendern ...
  30. //windows.history.go();
  31. router.push('/files')
  32. router.push('/home')
  33. $("#escape-search-link").css("visibility", "hidden");
  34. $("#subscribe-btn").css("visibility", "hidden");
  35. },
  36. changeSubscribtion: function(){
  37. var btnString = $("#btn-text").text();
  38. //console.log(btnString);
  39. if($("#btn-text").hasClass("subscribed")){
  40. $("#btn-text").removeClass("subscribed");
  41. var newBtnString = "#" + $("#btn-text").text(/deabonnieren/g, '') + "abonnieren";
  42. //console.log(btnString);
  43. $("#btn-text").text(newBtnString);
  44. }else{
  45. $("#btn-text").addClass("subscribed");
  46. var newBtnString = "#" + $("#btn-text").text(/abonnieren/g, '') + "deabonnieren";
  47. //console.log(newBtnString);
  48. $("#btn-text").text(newBtnString);
  49. }
  50. }
  51. },
  52. mounted: function () {
  53. this.list_messages();
  54. //this.refresh_messages();
  55. }
  56. };
  57. function get_insert_message(id) {
  58. $.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) {
  59. Vue.set(_messages, id, msg);
  60. }).fail(function (e, f, g) {
  61. console.log("cannot load " + id + ".json: " + e + f + g);
  62. })
  63. }