OSDN Git Service

js: add comments.js
authorhylom <hylom@users.sourceforge.jp>
Sat, 29 Oct 2016 14:28:47 +0000 (23:28 +0900)
committerhylom <hylom@users.sourceforge.jp>
Sat, 29 Oct 2016 14:28:47 +0000 (23:28 +0900)
src/newslash_web/public/js/comments.js [new file with mode: 0644]

diff --git a/src/newslash_web/public/js/comments.js b/src/newslash_web/public/js/comments.js
new file mode 100644 (file)
index 0000000..02c3fbb
--- /dev/null
@@ -0,0 +1,38 @@
+/* commentst.js */
+const comments = {};
+var vm;
+
+Vue.component('comment-node', {
+  template: '#comment-node-template',
+  props: ["comments",],
+  //props: {comments: Object,},
+});
+
+comments.run = function run (params) {
+  const data = {
+    type: params.type,
+    stoid: params.stoid,
+    sid: params.sid,
+    discussion_id: params.discussion_id,
+    comments: params.comments,
+  };
+
+  const computed = {};
+  const methods = {};
+  const endPoint = "/api/v1/comment?discussion_id=" + data.discussion_id;
+
+  vm = new Vue({el: params.el,
+                data: data,
+                computed: computed,
+                methods: methods,
+                created: function () {
+                  this.$http.get(endPoint).then(
+                    (resp) => { // success
+                      this.comments = resp.body.comments;
+                    },
+                    (resp) => { // fail
+                    }
+                  );
+                },
+               });
+};