From ec6eb34e22db0d7102b2ad23cecf59d799dabe81 Mon Sep 17 00:00:00 2001 From: isqua Date: Sat, 7 Feb 2015 19:03:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D1=82=D1=8C=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=B8=D0=B9,=20=D0=B5=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D1=81=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D1=88=D0=BB=D0=BE=20{"error":"SomeError"}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/modules/ajax-comments.js | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/chrome_point_plus/modules/ajax-comments.js b/chrome_point_plus/modules/ajax-comments.js index 5397d2a..b53cbb2 100644 --- a/chrome_point_plus/modules/ajax-comments.js +++ b/chrome_point_plus/modules/ajax-comments.js @@ -139,21 +139,25 @@ AjaxCommentProcessor.prototype.onSuccess = function(data, textStatus) { var $textarea = this._$textarea; if (textStatus === 'success') { - this.hideForm(); - - // Creating the comment HTML - create_comment_elements({ - id: data.comment_id, - toId: this._commentId || null, - postId: this._postId, - author: $('#name h1').text(), - text: this._text, - fadeOut: true - }, this.insertComment.bind(this)); + if (data.error) { + this.onError(null, null, data.error); + } else { + // Creating the comment HTML + create_comment_elements({ + id: data.comment_id, + toId: this._commentId || null, + postId: this._postId, + author: $('#name h1').text(), + text: this._text, + fadeOut: true + }, this.insertComment.bind(this)); - // Cleaning textarea - $textarea.val(''); - this.setProgress(false); + this.hideForm(); + + // Cleaning textarea + $textarea.val(''); + this.setProgress(false); + } } };