function showPreview(event) {
var type = this.item.content_type;
if (!type) {
- console.log("no content_type!");
+ console.warn("no content_type!");
return;
}
var postData = _preparePostData(this, "preview");
var postData = _preparePostData(this, "post");
var type = this.item.content_type;
if (!type) {
- console.log("no content_type!");
+ console.warn("no content_type!");
return;
}
+ // journal post
if (type == "journal") {
postData.csrf_token = this.csrfToken;
newslash.postJournal(postData).then(
// check if new post
if (!postData.id) {
this.createdUrl = url;
- this.message = "post_success";
this.item.subid = id;
}
+ this.message = "";
this.mode = "posted";
},
(resp) => { // fail
return;
}
+ // submission post
this.$newslash.post(type, postData, {csrfToken: this.csrfToken},
- (response) => { // success
- this.message = "";
- var id = response.body.id;
- var type = response.body.type;
- var url = '/' + type + '/' + id;
-
- // check if new post
- if (!postData.id) {
- this.createdUrl = url;
- this.message = "post_success";
- this.item.subid = id;
- }
-
- this.mode = "posted";
- },
- (response) => { // fail
- this.message = response.body.message;
- this.mode = "preview";
- }
- );
-
+ (response) => { // success
+ this.message = "";
+ var id = response.body.id;
+ var type = response.body.type;
+ var url = '/' + type + '/' + id;
+
+ // check if new post
+ if (!postData.id) {
+ this.createdUrl = url;
+ this.item.subid = id;
+ }
+ this.message = "";
+ this.mode = "posted";
+ },
+ (response) => { // fail
+ this.message = response.body.message;
+ this.mode = "preview";
+ }
+ );
+
}
function _preparePostData(vm, action) {
}
function quoteHtml(html) {
- return nsUtil.quoteHtml(html, editorConfig.allowed_tags);
+ return nsUtil.quoteHtml(html, siteConfig.editorConfig.allowed_tags);
}
function quoteTitle(html) {
articleItem.run = function (params) {
params = params || {};
if (!params.el) {
- console.log('error in articleItem.run(): no element given');
+ console.error('error in articleItem.run(): no element given');
return;
}
this.vm = new Vue({el: params.el});
articleItem.addTrigger = function addTrigger (selector, params) {
params = params || {};
if (!params.el) {
- console.log('error in articleItem.addTrigger(): no element given');
+ console.error('error in articleItem.addTrigger(): no element given');
return;
}
if (!selector) {
- console.log('error in articleItem.addTrigger(): no selector given');
+ console.error('error in articleItem.addTrigger(): no selector given');
return;
}
$(selector).on('click', function (e) {
VueNewslash.prototype.executeCaptcha = function executeCaptcha(onSuccess, onFail) {
if (typeof grecaptcha === 'undefined' || !grecaptcha) {
- console.log("$newslash.executeCaptcha: no grecaptcha!");
- onFail({});
+ console.warn("$newslash.executeCaptcha: no grecaptcha!");
+ onFail({message: "no_grecaptcha"});
return;
}
onSuccess(token);
} else {
if (statusBar) { statusBar.error("captcha_error"); }
- onFail({});
+ onFail({resp: "captcha_error"});
}
};
grecaptcha.reset();
VueNewslash.prototype.post = function post(type, data, options, onSuccess, onFail) {
var url = this.postUrlOf[type];
if (!url) {
- console.log("$newslash.post: invalid type");
- onFail({});
+ console.error("$newslash.post: invalid type");
+ onFail({message:"invalid_type"});
return;
}
_doPost(this.vm, url, data, csrfToken, 0, onSuccess, onFail);
},
(resp) => {
+ console.error("$newslash.post: captcha check failed.");
onFail(resp);
});
return;
}
-
_doPost(this.vm, url, data, csrfToken, 0, onSuccess, onFail);
function _doPost(vm, url, data, newToken, retry, onSuccess, onFail, lastResp) {
*/
function recaptchaDone(token) {
if (!VueNewslash.currentRecaptchaCallback) {
- console.log("recapcha: no VueNewslash.currentRecaptchaCallback!");
+ console.warn("recapcha: no VueNewslash.currentRecaptchaCallback!");
return;
}
VueNewslash.currentRecaptchaCallback(token);