From b56a0154719cb256e53adad44d14c59a543cd78a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 16 Jun 2012 17:39:45 +0200 Subject: [PATCH] Changed filter options to display either the guide or one filter textarea. --- 4chan_x.user.js | 119 +++++++++++++++++++++++++++++++----------------- script.coffee | 101 ++++++++++++++++++++++++++-------------- 2 files changed, 145 insertions(+), 75 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a64d5f9bd..c9ae30903 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2217,7 +2217,7 @@ } }, dialog: function() { - var arr, back, checked, description, dialog, favicon, fileInfo, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, tr, ul, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3; + var arr, back, checked, description, dialog, favicon, fileInfo, filter, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, sauce, time, tr, ul, _i, _len, _ref, _ref1, _ref2; dialog = $.el('div', { id: 'options', className: 'reply dialog', @@ -2250,32 +2250,25 @@
  • $3: MD5 hash.
  • \
  • $4: Current board.
  • \ \ - \ + \ \ \
    \
    Filter is disabled.
    \ - Use regular expressions, one per line.
    \ - Lines starting with a # will be ignored.
    \ - For example, /weeaboo/i will filter posts containing `weeaboo` case-insensitive.\ - \ -

    Name:

    \ -

    Unique ID:

    \ -

    Tripcode:

    \ -

    Admin/Mod:

    \ -

    E-mail:

    \ -

    Subject:

    \ -

    Comment:

    \ -

    Filename:

    \ -

    Image dimensions:

    \ -

    Filesize:

    \ -

    Image MD5 (uses exact string matching, not regular expressions):

    \ + \
    \ \
    \ @@ -2351,13 +2344,11 @@ }); $.on($('button', li), 'click', Options.clearHidden); $.add($('ul:nth-child(2)', dialog), li); - _ref1 = $$('textarea', dialog); - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - ta = _ref1[_i]; - ta.textContent = $.get(ta.name, Conf[ta.name]); - ta.className = 'field'; - $.on(ta, 'change', $.cb.value); - } + filter = $('select[name=filter]', dialog); + $.on(filter, 'change', Options.filter); + sauce = $('#sauces', dialog); + sauce.value = $.get(sauce.name, Conf[sauce.name]); + $.on(sauce, 'change', $.cb.value); (back = $('[name=backlink]', dialog)).value = $.get('backlink', Conf['backlink']); (time = $('[name=time]', dialog)).value = $.get('time', Conf['time']); (fileInfo = $('[name=fileInfo]', dialog)).value = $.get('fileInfo', Conf['fileInfo']); @@ -2367,13 +2358,13 @@ $.on(time, 'input', Options.time); $.on(fileInfo, 'input', $.cb.value); $.on(fileInfo, 'input', Options.fileInfo); - favicon = $('select', dialog); + favicon = $('select[name=favicon]', dialog); favicon.value = $.get('favicon', Conf['favicon']); $.on(favicon, 'change', $.cb.value); $.on(favicon, 'change', Options.favicon); - _ref2 = Config.hotkeys; - for (key in _ref2) { - arr = _ref2[key]; + _ref1 = Config.hotkeys; + for (key in _ref1) { + arr = _ref1[key]; tr = $.el('tr', { innerHTML: "" + arr[1] + "" }); @@ -2383,9 +2374,9 @@ $.add($('#keybinds_tab + div tbody', dialog), tr); } indicators = {}; - _ref3 = $$('.warning', dialog); - for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) { - indicator = _ref3[_j]; + _ref2 = $$('.warning', dialog); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + indicator = _ref2[_i]; key = indicator.firstChild.textContent; indicator.hidden = $.get(key, Conf[key]); indicators[key] = indicator; @@ -2404,6 +2395,7 @@ $.add(d.body, overlay); d.body.style.setProperty('width', "" + d.body.clientWidth + "px", null); $.addClass(d.body, 'unscroll'); + Options.filter.call(filter); Options.backlink.call(back); Options.time.call(time); Options.fileInfo.call(fileInfo); @@ -2433,6 +2425,50 @@ this.value = key; return $.cb.value.call(this); }, + filter: function() { + var el, name, ta; + el = this.nextSibling; + if (el) { + $.rm(el); + } + if ((name = this.value) === 'guide') { + $.after(this, $.el('article', { + innerHTML: '

    Use regular expressions, one per line.
    \ + Lines starting with a # will be ignored.
    \ + For example, /weeaboo/i will filter posts containing the string `weeaboo`, case-insensitive.

    \ + ' + })); + return; + } + ta = $.el('textarea', { + name: name, + className: 'field', + value: $.get(name, Conf[name]) + }); + $.on(ta, 'change', $.cb.value); + return $.after(this, ta); + }, time: function() { Time.foo(); Time.date = new Date(); @@ -4690,11 +4726,13 @@ body.unscroll {\ vertical-align: middle;\ width: 600px;\ }\ +#options article li {\ + margin: 10px 0 10px 2em;\ +}\ #credits {\ float: right;\ }\ #options ul {\ - list-style: none;\ padding: 0;\ }\ #options label {\ @@ -4706,13 +4744,10 @@ body.unscroll {\ }\ #content textarea {\ font-family: monospace;\ - min-height: 100px;\ + min-height: 350px;\ resize: vertical;\ width: 100%;\ }\ -#sauces {\ - height: 300px;\ -}\ \ #updater {\ text-align: right;\ diff --git a/script.coffee b/script.coffee index 7179421b9..e5500c50c 100644 --- a/script.coffee +++ b/script.coffee @@ -1717,32 +1717,25 @@ Options =
  • $3: MD5 hash.
  • $4: Current board.
  • - +
    Filter is disabled.
    - Use regular expressions, one per line.
    - Lines starting with a # will be ignored.
    - For example, /weeaboo/i will filter posts containing `weeaboo` case-insensitive. - -

    Name:

    -

    Unique ID:

    -

    Tripcode:

    -

    Admin/Mod:

    -

    E-mail:

    -

    Subject:

    -

    Comment:

    -

    Filename:

    -

    Image dimensions:

    -

    Filesize:

    -

    Image MD5 (uses exact string matching, not regular expressions):

    +
    @@ -1813,11 +1806,14 @@ Options = $.on $('button', li), 'click', Options.clearHidden $.add $('ul:nth-child(2)', dialog), li - #filter & sauce - for ta in $$ 'textarea', dialog - ta.textContent = $.get ta.name, Conf[ta.name] - ta.className = 'field' - $.on ta, 'change', $.cb.value + #filter + filter = $ 'select[name=filter]', dialog + $.on filter, 'change', Options.filter + + #sauce + sauce = $ '#sauces', dialog + sauce.value = $.get sauce.name, Conf[sauce.name] + $.on sauce, 'change', $.cb.value #rice (back = $ '[name=backlink]', dialog).value = $.get 'backlink', Conf['backlink'] @@ -1829,7 +1825,7 @@ Options = $.on time, 'input', Options.time $.on fileInfo, 'input', $.cb.value $.on fileInfo, 'input', Options.fileInfo - favicon = $ 'select', dialog + favicon = $ 'select[name=favicon]', dialog favicon.value = $.get 'favicon', Conf['favicon'] $.on favicon, 'change', $.cb.value $.on favicon, 'change', Options.favicon @@ -1860,6 +1856,7 @@ Options = d.body.style.setProperty 'width', "#{d.body.clientWidth}px", null $.addClass d.body, 'unscroll' + Options.filter.call filter Options.backlink.call back Options.time.call time Options.fileInfo.call fileInfo @@ -1884,6 +1881,45 @@ Options = return unless (key = Keybinds.keyCode e)? @value = key $.cb.value.call @ + filter: -> + el = @nextSibling + $.rm el if el + + if (name = @value) is 'guide' + $.after @, $.el 'article', + innerHTML: '

    Use regular expressions, one per line.
    + Lines starting with a # will be ignored.
    + For example, /weeaboo/i will filter posts containing the string `weeaboo`, case-insensitive.

    + ' + return + + ta = $.el 'textarea', + name: name + className: 'field' + value: $.get name, Conf[name] + $.on ta, 'change', $.cb.value + $.after @, ta time: -> Time.foo() Time.date = new Date() @@ -3634,9 +3670,11 @@ body.unscroll { float: right; } #options ul { - list-style: none; padding: 0; } +#options article li { + margin: 10px 0 10px 2em; +} #options label { text-decoration: underline; } @@ -3646,13 +3684,10 @@ body.unscroll { } #content textarea { font-family: monospace; - min-height: 100px; + min-height: 350px; resize: vertical; width: 100%; } -#sauces { - height: 300px; -} #updater { text-align: right;