13 post.quote_html = function _post_quote_html(html) {
14 const escaped = eh.escape(allowed_tags, html);
15 const quoted = eh.blank_line_to_paragraph(escaped);
16 const parsed = $.parseHTML(quoted, null);
18 parsed.forEach((i) => {
20 result.push(i.outerHTML);
22 return result.join('\n');
25 post.quote_title = function _post_quote_title(html) {
26 const escaped = '<div>' + eh.escape({}, html) + '</div>';
27 const parsed = $.parseHTML(escaped, null);
29 parsed.forEach((i) => {
31 const t = i.innerHTML || i.wholeText;
34 return result.join('');
40 author: "anonymous coward",
49 commentstatus: "enabled",
55 preview_introtext: "",
63 introtext_raw: function () {
64 if (this.preview_introtext.length > 0) {
65 return this.preview_introtext;
67 return post.quote_html(this.introtext);
70 bodytext_raw: function () {
71 if (this.preview_bodytext.length > 0) {
72 return this.preview_bodytext;
74 return post.quote_html(this.bodytext);
77 title_raw: function () {
78 if (this.preview_title.length > 0) {
79 return this.preview_title;
81 return post.quote_title(this.title);
84 author_name: function () {
85 if (this.author.length > 0) {
88 return authors[this.uid];
94 show_preview: function (event) {
95 this.action = "preview";
97 this.$http.post(this.postUrl, this.$data).then(
98 (response) => { // success
100 this.preview_title = response.body.title;
101 this.preview_introtext = response.body.introtext;
102 this.show_form = false;
103 this.show_submit = true;
105 (response) => { // fail
106 if (response.body.message) {
107 this.message = response.body.message;
112 post_submission: function (event) {
113 this.action = "post";
115 this.$http.post(this.postUrl, this.$data).then(
116 (response) => { // success
118 const id = response.body.id;
119 const type = response.body.type;
120 const url = '/' + type + '/' + id;
121 this.message = "投稿しました。URL:"
122 + "<a href='" + url + "'>" + url + "</a>";
123 this.show_form = false;
124 this.show_submit = false;
126 (response) => { // fail
127 if (response.body.message) {
128 this.message = response.body.message;
133 leave_preview: function (event) {
134 this.preview_title = "";
135 this.preview_introtext = "";
136 this.preview_bodytext = "";
137 this.show_form = true;
138 this.show_submit = false;
142 editor.run = function run (params) {
143 if (params.type == 'submission') {
144 editor.postUrl = '/api/v1/submission';
145 } else if (params.type == 'story') {
146 editor.postUrl = '/api/v1/story';
147 } else if (params.type == 'journal') {
148 editor.postUrl = '/api/v1/journal';
151 editor.author = params.author;
153 viewModel = new Vue({el: params.el,