# HG changeset patch # User neko259 # Date 2016-05-04 14:14:23 # Node ID 13db88c3d25e33a29fc3d75a9891b68faf4bef56 # Parent 427880bd2dd5ccc9ba865074bf3a24b535fe2fd6 Fixed inserting post reflink upon "reply" button diff --git a/boards/static/js/thread.js b/boards/static/js/thread.js --- a/boards/static/js/thread.js +++ b/boards/static/js/thread.js @@ -67,13 +67,21 @@ function addQuickReply(postId) { if (getForm().prev().attr('id') == postId) { resetFormPosition(); } else { - var blockToInsert = null; - + var textAreaJq = $('textarea'); + var postLinkRaw = '[post]' + postId + '[/post]' + var textToAdd = ''; if (postId != null) { var post = $('#' + postId); + // If this is not OP, add reflink to the post. If there already is + // the same reflink, don't add it again. + if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) { + textToAdd += postLinkRaw + '\n'; + } + + textAreaJq.val(textAreaJq.val()+ textToAdd); blockToInsert = post; } else { blockToInsert = $('.thread'); @@ -93,15 +101,6 @@ function addQuickQuote(postId) { var textToAdd = ''; var textAreaJq = $('textarea'); var postLinkRaw = '[post]' + postId + '[/post]' - if (postId != null) { - var post = $('#' + postId); - - // If this is not OP, add reflink to the post. If there already is - // the same reflink, don't add it again. - if (!post.is(':first-child') && textAreaJq.val().indexOf(postLinkRaw) < 0) { - textToAdd += postLinkRaw + '\n'; - } - } var selection = window.getSelection().toString(); if (selection.length > 0) { textToAdd += '[quote]' + selection + '[/quote]\n';