diff --git a/4chan_x.user.js b/4chan_x.user.js index 95557f732..951296e95 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -5882,7 +5882,7 @@ return; } setTimeout(QR.cooldown.count, 1000); - isReply = g.BOARD.ID === 'f' ? g.VIEW === 'thread' : QR.nodes.thread.value !== 'new'; + isReply = QR.nodes.thread.value !== 'new'; if (isReply) { post = QR.posts[0]; isSage = /sage/i.test(post.email); @@ -5943,7 +5943,7 @@ text = !text && post === OP && (!QR.nodes || QR.nodes.el.hidden) ? "" : ">>" + post + "\n" + text; QR.open(); ta = QR.nodes.com; - if (QR.nodes.thread && !ta.value) { + if (!ta.value) { QR.nodes.thread.value = OP.ID; } caretPos = ta.selectionStart; @@ -6018,11 +6018,7 @@ return $.addClass(QR.nodes.el, 'dump'); }, resetThreadSelector: function() { - if (g.BOARD.ID === 'f') { - if (g.VIEW === 'index') { - return QR.nodes.flashTag.value = '9999'; - } - } else if (g.VIEW === 'thread') { + if (g.VIEW === 'thread') { return QR.nodes.thread.value = g.THREAD; } else { return QR.nodes.thread.value = 'new'; @@ -6450,12 +6446,13 @@ } }, dialog: function() { - var dialog, key, mimeTypes, name, nodes, thread, threads, _i, _len, _ref, _ref1; - dialog = UI.dialog('qr', 'top:0;right:0;', "
\n \n \n ×\n
\n
\n
\n \n \n \n \n
\n
\n
\n +\n
\n
\n \n \n
\n
\n \n \n No selected file\n \n \n ×\n \n \n
\n \n
".replace(/>\s+<')); + var dialog, mimeTypes, name, nodes, thread, _i, _len, _ref; + dialog = UI.dialog('qr', 'top:0;right:0;', "
\n \n \n \n ×\n
\n
\n
\n \n \n \n \n
\n
\n
\n +\n
\n
\n \n \n
\n
\n \n \n No selected file\n \n \n ×\n \n \n
\n \n
".replace(/>\s+<')); QR.nodes = nodes = { el: dialog, move: $('.move', dialog), autohide: $('#autohide', dialog), + thread: $('select', dialog), close: $('.close', dialog), form: $('form', dialog), dumpButton: $('#dump-button', dialog), @@ -6495,23 +6492,19 @@ QR.spoiler = !!$('input[name=spoiler]'); nodes.spoiler.hidden = !QR.spoiler; if (g.BOARD.ID === 'f') { - if (g.VIEW === 'index') { - nodes.flashTag = $('select[name=filetag]').cloneNode(true); - $.after(nodes.autohide, nodes.flashTag); - } - } else { - nodes.thread = $.el('select', { - title: 'Create a new thread / Reply' + nodes.flashTag = $.el('select', { + name: 'filetag', + innerHTML: "\n\n\n\n\n\n" }); - threads = ''; - _ref = g.BOARD.threads; - for (key in _ref) { - thread = _ref[key]; - threads += ""; - } - nodes.thread.innerHTML = threads; - $.after(nodes.autohide, nodes.thread); + $.add(nodes.form, nodes.flashTag); } + for (thread in g.BOARD.threads) { + $.add(nodes.thread, $.el('option', { + value: thread, + textContent: "Thread No." + thread + })); + } + $.after(nodes.autohide, nodes.thread); QR.resetThreadSelector(); $.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.close, 'click', QR.close); @@ -6533,9 +6526,9 @@ }); $.on(nodes.fileInput, 'change', QR.fileInput); new QR.post().select(); - _ref1 = ['name', 'email', 'sub', 'com']; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - name = _ref1[_i]; + _ref = ['name', 'email', 'sub', 'com']; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + name = _ref[_i]; $.on(nodes[name], 'input', function() { return QR.selected.save(this); }); @@ -6563,23 +6556,15 @@ post = QR.posts[0]; post.forceSave(); if (g.BOARD.ID === 'f') { - if (g.VIEW === 'index') { - filetag = QR.nodes.flashTag.value; - threadID = 'new'; - } else { - threadID = g.THREAD; - } - } else { - threadID = QR.nodes.thread.value; + filetag = QR.nodes.flashTag.value; } + threadID = QR.nodes.thread.value; if (threadID === 'new') { threadID = null; if (((_ref = g.BOARD.ID) === 'vg' || _ref === 'q') && !post.sub) { err = 'New threads require a subject.'; } else if (!(post.file || (textOnly = !!$('input[name=textonly]', $.id('postForm'))))) { err = 'No file selected.'; - } else if (g.BOARD.ID === 'f' && filetag === '9999') { - err = 'Invalid tag specified.'; } } else if (g.BOARD.threads[threadID].isSticky) { err = 'You can\'t reply to this thread anymore.'; diff --git a/src/qr.coffee b/src/qr.coffee index 8b1f26f46..482020929 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -195,10 +195,7 @@ QR = setTimeout QR.cooldown.count, 1000 - isReply = if g.BOARD.ID is 'f' - g.VIEW is 'thread' - else - QR.nodes.thread.value isnt 'new' + isReply = QR.nodes.thread.value isnt 'new' if isReply post = QR.posts[0] isSage = /sage/i.test post.email @@ -264,8 +261,7 @@ QR = QR.open() ta = QR.nodes.com - if QR.nodes.thread and !ta.value - QR.nodes.thread.value = OP.ID + QR.nodes.thread.value = OP.ID unless ta.value caretPos = ta.selectionStart # Replace selection for text. @@ -331,10 +327,7 @@ QR = new QR.post().setFile file $.addClass QR.nodes.el, 'dump' resetThreadSelector: -> - if g.BOARD.ID is 'f' - if g.VIEW is 'index' - QR.nodes.flashTag.value = '9999' - else if g.VIEW is 'thread' + if g.VIEW is 'thread' QR.nodes.thread.value = g.THREAD else QR.nodes.thread.value = 'new' @@ -639,6 +632,9 @@ QR = dialog = UI.dialog 'qr', 'top:0;right:0;', """
+ ×
@@ -675,6 +671,7 @@ QR = el: dialog move: $ '.move', dialog autohide: $ '#autohide', dialog + thread: $ 'select', dialog close: $ '.close', dialog form: $ 'form', dialog dumpButton: $ '#dump-button', dialog @@ -714,17 +711,25 @@ QR = nodes.spoiler.hidden = !QR.spoiler if g.BOARD.ID is 'f' - if g.VIEW is 'index' - nodes.flashTag = $('select[name=filetag]').cloneNode true - $.after nodes.autohide, nodes.flashTag - else # Make a list of visible threads. - nodes.thread = $.el 'select', - title: 'Create a new thread / Reply' - threads = '' - for key, thread of g.BOARD.threads - threads += "" - nodes.thread.innerHTML = threads - $.after nodes.autohide, nodes.thread + nodes.flashTag = $.el 'select', + name: 'filetag' + innerHTML: """ + + + + + + + + """ + $.add nodes.form, nodes.flashTag + + # Make a list of threads. + for thread of g.BOARD.threads + $.add nodes.thread, $.el 'option', + value: thread + textContent: "Thread No.#{thread}" + $.after nodes.autohide, nodes.thread QR.resetThreadSelector() $.on nodes.autohide, 'change', QR.toggleHide @@ -766,13 +771,8 @@ QR = post = QR.posts[0] post.forceSave() if g.BOARD.ID is 'f' - if g.VIEW is 'index' - filetag = QR.nodes.flashTag.value - threadID = 'new' - else - threadID = g.THREAD - else - threadID = QR.nodes.thread.value + filetag = QR.nodes.flashTag.value + threadID = QR.nodes.thread.value # prevent errors if threadID is 'new' @@ -781,8 +781,6 @@ QR = err = 'New threads require a subject.' else unless post.file or textOnly = !!$ 'input[name=textonly]', $.id 'postForm' err = 'No file selected.' - else if g.BOARD.ID is 'f' and filetag is '9999' - err = 'Invalid tag specified.' else if g.BOARD.threads[threadID].isSticky err = 'You can\'t reply to this thread anymore.' else unless post.com or post.file