OSDN Git Service

timeline: add up/down vote feature for journal timeline
[newslash/newslash.git] / src / newslash_web / public / js / timeline.js
index ee5f3a3..99ae3a0 100644 (file)
@@ -40,6 +40,28 @@ timeline.run = function (params) {
     created: function () { return; },
   });
 
+  /*
+   * register <timeline-vote>
+   */
+  Vue.component('timeline-vote', {
+    template: '#timeline-vote-template',
+    props: { item: Object },
+    data: function () { return {}; },
+    created: function () { return; },
+    methods: {
+      vote: function vote(voteType) {
+        var globjid = this.item.globjid;
+        newslash.vote(globjid, voteType).then(
+          (resp) => { // success
+            console.log("vote " + voteType + " for " + globjid + " succeeded. tag_id: " + resp.result.tag_id );
+          },
+          (resp) => { // fail
+            console.log("vote " + voteType + " for " + globjid + " failed.");
+          }
+        );
+      },
+    }
+  });
 
   /*
    * register <timeline-item>