OSDN Git Service

js: fix indenting
authorhylom <hylom@users.sourceforge.jp>
Tue, 1 Nov 2016 11:23:48 +0000 (20:23 +0900)
committerhylom <hylom@users.sourceforge.jp>
Tue, 1 Nov 2016 11:23:48 +0000 (20:23 +0900)
src/newslash_web/public/js/editor.js

index 610904c..34bb472 100644 (file)
@@ -4,139 +4,139 @@ var editor = {};
 var viewModel;
 
 var allowed_tags = {
-    "a": ["href"],
-    "blockquote": [],
-    "i": [],
-    "strong": [],
+  "a": ["href"],
+  "blockquote": [],
+  "i": [],
+  "strong": [],
 };
 
 post.quote_html = function _post_quote_html(html) {
-    const escaped = eh.escape(allowed_tags, html);
-    const quoted = eh.blank_line_to_paragraph(escaped);
-    const parsed = $.parseHTML(quoted, null);
-    const result = [];
-    parsed.forEach((i) => {
-        i.normalize();
-        result.push(i.outerHTML);
-    });
-    return result.join('\n');
+  const escaped = eh.escape(allowed_tags, html);
+  const quoted = eh.blank_line_to_paragraph(escaped);
+  const parsed = $.parseHTML(quoted, null);
+  const result = [];
+  parsed.forEach((i) => {
+    i.normalize();
+    result.push(i.outerHTML);
+  });
+  return result.join('\n');
 };
 
 post.quote_title = function _post_quote_title(html) {
-    const escaped = '<div>' + eh.escape({}, html) + '</div>';
-    const parsed = $.parseHTML(escaped, null);
-    const result = [];
-    parsed.forEach((i) => {
-        i.normalize();
-        const t = i.innerHTML || i.wholeText;
-        result.push(t);
-    });
-    return result.join('');
+  const escaped = '<div>' + eh.escape({}, html) + '</div>';
+  const parsed = $.parseHTML(escaped, null);
+  const result = [];
+  parsed.forEach((i) => {
+    i.normalize();
+    const t = i.innerHTML || i.wholeText;
+    result.push(t);
+  });
+  return result.join('');
 };
 
 var editor = {
-    title: "",
-    createtime: "",
-    author: "anonymous coward",
-    dept: "",
-    introtext: "",
-    bodytext: "",
-    add_related: "",
-    url: "",
-    mediaurl: "",
-    mediatype: "",
-    email: "",
-    commentstatus: "enabled",
-    display: 1,
+  title: "",
+  createtime: "",
+  author: "anonymous coward",
+  dept: "",
+  introtext: "",
+  bodytext: "",
+  add_related: "",
+  url: "",
+  mediaurl: "",
+  mediatype: "",
+  email: "",
+  commentstatus: "enabled",
+  display: 1,
   submissioncopy: 0,
 
-    show_form: true,
-    show_submit: false,
-    preview_introtext: "",
-    preview_bodytext: "",
-    preview_title: "",
-    message: "",
-    action: "preview",
+  show_form: true,
+  show_submit: false,
+  preview_introtext: "",
+  preview_bodytext: "",
+  preview_title: "",
+  message: "",
+  action: "preview",
 };
 
 var computed = {
-    introtext_raw: function () {
-        if (this.preview_introtext.length > 0) {
-            return this.preview_introtext;
-        } else {
-            return post.quote_html(this.introtext);
-        }
-    },
-    bodytext_raw: function () {
-        if (this.preview_bodytext.length > 0) {
-            return this.preview_bodytext;
-        } else {
-            return post.quote_html(this.bodytext);
-        }
-    },
-    title_raw: function () {
-        if (this.preview_title.length > 0) {
-            return this.preview_title;
-        } else {
-            return post.quote_title(this.title);
-        }
-    },
-    author_name: function () {
-        if (this.author.length > 0) {
-            return this.author;
-        } else {
-            return authors[this.uid];
-        }
+  introtext_raw: function () {
+    if (this.preview_introtext.length > 0) {
+      return this.preview_introtext;
+    } else {
+      return post.quote_html(this.introtext);
+    }
+  },
+  bodytext_raw: function () {
+    if (this.preview_bodytext.length > 0) {
+      return this.preview_bodytext;
+    } else {
+      return post.quote_html(this.bodytext);
     }
+  },
+  title_raw: function () {
+    if (this.preview_title.length > 0) {
+      return this.preview_title;
+    } else {
+      return post.quote_title(this.title);
+    }
+  },
+  author_name: function () {
+    if (this.author.length > 0) {
+      return this.author;
+    } else {
+      return authors[this.uid];
+    }
+  }
 };
 
 var methods = {
-    show_preview: function (event) {
-        this.action = "preview";
+  show_preview: function (event) {
+    this.action = "preview";
+    this.message = "";
+    this.$http.post(this.postUrl, this.$data).then(
+      (response) => { // success
         this.message = "";
-        this.$http.post(this.postUrl, this.$data).then(
-            (response) => { // success
-                this.message = "";
-                this.preview_title = response.body.title;
-                this.preview_introtext = response.body.introtext;
-                this.show_form = false;
-                this.show_submit = true;
-            },
-            (response) => { // fail
-                if (response.body.message) {
-                    this.message = response.body.message;
-                }
-            }
-        );
-    },
-    post_submission: function (event) {
-        this.action = "post";
+        this.preview_title = response.body.title;
+        this.preview_introtext = response.body.introtext;
+        this.show_form = false;
+        this.show_submit = true;
+      },
+      (response) => { // fail
+        if (response.body.message) {
+          this.message = response.body.message;
+        }
+      }
+    );
+  },
+  post_submission: function (event) {
+    this.action = "post";
+    this.message = "";
+    this.$http.post(this.postUrl, this.$data).then(
+      (response) => { // success
         this.message = "";
-        this.$http.post(this.postUrl, this.$data).then(
-            (response) => { // success
-                this.message = "";
-                const id = response.body.id;
-                const type = response.body.type;
-                const url = '/' + type + '/' + id;
-                this.message = "投稿しました。URL:"
-                    + "<a href='" + url + "'>" + url + "</a>";
-                this.show_form = false;
-                this.show_submit = false;
-            },
-            (response) => { // fail
-                if (response.body.message) {
-                    this.message = response.body.message;
-                }
-            }
-        );
-    },
-    leave_preview: function (event) {
-        this.preview_title = "";
-        this.preview_introtext = "";
-        this.preview_bodytext = "";
-        this.show_form = true;
+        const id = response.body.id;
+        const type = response.body.type;
+        const url = '/' + type + '/' + id;
+        this.message = "投稿しました。URL:"
+          + "<a href='" + url + "'>" + url + "</a>";
+        this.show_form = false;
         this.show_submit = false;
-    },
+      },
+      (response) => { // fail
+        if (response.body.message) {
+          this.message = response.body.message;
+        }
+      }
+    );
+  },
+  leave_preview: function (event) {
+    this.preview_title = "";
+    this.preview_introtext = "";
+    this.preview_bodytext = "";
+    this.show_form = true;
+    this.show_submit = false;
+  },
 };
 
 editor.run = function run (params) {