# HG changeset patch # User neko259 # Date 2016-12-30 16:06:58 # Node ID 30b6f53c5659d3abdd91fdc3bad5ee38ad837992 # Parent e1a0b47bc9d63c6ab56c6caa4a202615875a539c Refactoring of the scripts accessing textarea diff --git a/boards/static/js/form.js b/boards/static/js/form.js --- a/boards/static/js/form.js +++ b/boards/static/js/form.js @@ -88,6 +88,10 @@ function selectFileChoice() { localStorage.setItem(ITEM_FILE_SOURCE, source); } +function getPostTextarea() { + return $('textarea#id_text'); +} + $(document).ready(function() { var powDifficulty = parseInt($('body').attr('data-pow-difficulty')); if (powDifficulty > 0 && typeof SharedWorker != 'undefined') { diff --git a/boards/static/js/panel.js b/boards/static/js/panel.js --- a/boards/static/js/panel.js +++ b/boards/static/js/panel.js @@ -30,7 +30,7 @@ * @param end End (right) text */ function addMarkToMsg(start, end) { - var textareas = $('textarea#id_text'); + var textareas = getPostTextarea(); for (var i = 0; i < textareas.length; i++) { var textarea = textareas[i]; 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 @@ -68,7 +68,7 @@ function addQuickReply(postId) { resetFormPosition(); } else { var blockToInsert = null; - var textAreaJq = $('textarea#id_text'); + var textAreaJq = getPostTextarea(); var postLinkRaw = '[post]' + postId + '[/post]' var textToAdd = ''; @@ -101,7 +101,7 @@ function addQuickReply(postId) { } function addQuickQuote() { - var textAreaJq = $('textarea#id_text'); + var textAreaJq = getPostTextarea(); var quoteButton = $("#quote-button"); var postId = quoteButton.attr('data-post-id');