Merge pull request #2998 from evazion/fix-quote-stripping

Fix [quote] stripping for comments, forum post replies.
This commit is contained in:
Albert Yi
2017-04-26 12:43:30 -07:00
committed by GitHub
7 changed files with 50 additions and 46 deletions

View File

@@ -18,22 +18,6 @@
}
}
Danbooru.Comment.quote_message = function(data) {
var blocks = data["body"].match(/\[\/?quote\]|.|\n|\r/gm);
var n = 0;
var stripped_body = "";
$.each(blocks, function(i, block) {
if (block === "[quote]") {
n += 1;
} else if (block == "[/quote]") {
n -= 1;
} else if (n === 0) {
stripped_body += block;
}
});
return "[quote]\n" + data["creator_name"] + " said:\n\n" + stripped_body + "\n[/quote]\n\n";
}
Danbooru.Comment.quote = function(e) {
$.get(
"/comments/" + $(e.target).data('comment-id') + ".json",
@@ -41,7 +25,7 @@
var $link = $(e.target);
var $div = $link.closest("div.comments-for-post").find(".new-comment");
var $textarea = $div.find("textarea");
var msg = Danbooru.Comment.quote_message(data);
var msg = data["quoted_response"];
if ($textarea.val().length > 0) {
msg = $textarea.val() + "\n\n" + msg;
}