Changed filter options to display either the guide or one filter textarea.

This commit is contained in:
Nicolas Stepien 2012-06-16 17:39:45 +02:00
parent 96021889ea
commit b56a015471
2 changed files with 145 additions and 75 deletions

View File

@ -2217,7 +2217,7 @@
} }
}, },
dialog: function() { 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', { dialog = $.el('div', {
id: 'options', id: 'options',
className: 'reply dialog', className: 'reply dialog',
@ -2250,32 +2250,25 @@
<li>$3: MD5 hash.</li>\ <li>$3: MD5 hash.</li>\
<li>$4: Current board.</li>\ <li>$4: Current board.</li>\
</ul>\ </ul>\
<textarea name=sauces id=sauces></textarea>\ <textarea name=sauces id=sauces class=field></textarea>\
</div>\ </div>\
<input type=radio name=tab hidden id=filter_tab>\ <input type=radio name=tab hidden id=filter_tab>\
<div>\ <div>\
<div class=warning><code>Filter</code> is disabled.</div>\ <div class=warning><code>Filter</code> is disabled.</div>\
Use <a href=https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions>regular expressions</a>, one per line.<br>\ <select name=filter>\
Lines starting with a <code>#</code> will be ignored.<br>\ <option value=guide>Guide</option>\
For example, <code>/weeaboo/i</code> will filter posts containing `weeaboo` case-insensitive.\ <option value=name>Name</option>\
<ul>You can use these settings with each regular expression, separate them with semicolons:\ <option value=uniqueid>Unique ID</option>\
<li>Per boards, separate them with commas. It is global if not specified.<br>For example: <code>boards:a,jp;</code>.</li>\ <option value=tripcode>Tripcode</option>\
<li>Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.</li>\ <option value=mod>Admin/Mod</option>\
<li>Overrule the `Show Stubs` setting if specified: create a stub (`yes`) or not (`no`).<br>For example: <code>stub:yes;</code> or <code>stub:no;</code></li>\ <option value=email>E-mail</option>\
<li>Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>For example: <code>highlight;</code> or <code>highlight:wallpaper;</code>.</li>\ <option value=subject>Subject</option>\
<li>Highlighted OPs will have their threads put on top of board pages by default.<br>For example: <code>top:yes</code> or <code>top:no</code>.</li>\ <option value=comment>Comment</option>\
</ul>\ <option value=filename>Filename</option>\
<p>Name:<br><textarea name=name></textarea></p>\ <option value=dimensions>Image dimensions</option>\
<p>Unique ID:<br><textarea name=uniqueid></textarea></p>\ <option value=filesize>Filesize</option>\
<p>Tripcode:<br><textarea name=tripcode></textarea></p>\ <option value=md5>Image MD5 (uses exact string matching, not regular expressions)</option>\
<p>Admin/Mod:<br><textarea name=mod></textarea></p>\ </select>\
<p>E-mail:<br><textarea name=email></textarea></p>\
<p>Subject:<br><textarea name=subject></textarea></p>\
<p>Comment:<br><textarea name=comment></textarea></p>\
<p>Filename:<br><textarea name=filename></textarea></p>\
<p>Image dimensions:<br><textarea name=dimensions></textarea></p>\
<p>Filesize:<br><textarea name=filesize></textarea></p>\
<p>Image MD5 (uses exact string matching, not regular expressions):<br><textarea name=md5></textarea></p>\
</div>\ </div>\
<input type=radio name=tab hidden id=rice_tab>\ <input type=radio name=tab hidden id=rice_tab>\
<div>\ <div>\
@ -2351,13 +2344,11 @@
}); });
$.on($('button', li), 'click', Options.clearHidden); $.on($('button', li), 'click', Options.clearHidden);
$.add($('ul:nth-child(2)', dialog), li); $.add($('ul:nth-child(2)', dialog), li);
_ref1 = $$('textarea', dialog); filter = $('select[name=filter]', dialog);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { $.on(filter, 'change', Options.filter);
ta = _ref1[_i]; sauce = $('#sauces', dialog);
ta.textContent = $.get(ta.name, Conf[ta.name]); sauce.value = $.get(sauce.name, Conf[sauce.name]);
ta.className = 'field'; $.on(sauce, 'change', $.cb.value);
$.on(ta, 'change', $.cb.value);
}
(back = $('[name=backlink]', dialog)).value = $.get('backlink', Conf['backlink']); (back = $('[name=backlink]', dialog)).value = $.get('backlink', Conf['backlink']);
(time = $('[name=time]', dialog)).value = $.get('time', Conf['time']); (time = $('[name=time]', dialog)).value = $.get('time', Conf['time']);
(fileInfo = $('[name=fileInfo]', dialog)).value = $.get('fileInfo', Conf['fileInfo']); (fileInfo = $('[name=fileInfo]', dialog)).value = $.get('fileInfo', Conf['fileInfo']);
@ -2367,13 +2358,13 @@
$.on(time, 'input', Options.time); $.on(time, 'input', Options.time);
$.on(fileInfo, 'input', $.cb.value); $.on(fileInfo, 'input', $.cb.value);
$.on(fileInfo, 'input', Options.fileInfo); $.on(fileInfo, 'input', Options.fileInfo);
favicon = $('select', dialog); favicon = $('select[name=favicon]', dialog);
favicon.value = $.get('favicon', Conf['favicon']); favicon.value = $.get('favicon', Conf['favicon']);
$.on(favicon, 'change', $.cb.value); $.on(favicon, 'change', $.cb.value);
$.on(favicon, 'change', Options.favicon); $.on(favicon, 'change', Options.favicon);
_ref2 = Config.hotkeys; _ref1 = Config.hotkeys;
for (key in _ref2) { for (key in _ref1) {
arr = _ref2[key]; arr = _ref1[key];
tr = $.el('tr', { tr = $.el('tr', {
innerHTML: "<td>" + arr[1] + "</td><td><input name=" + key + " class=field></td>" innerHTML: "<td>" + arr[1] + "</td><td><input name=" + key + " class=field></td>"
}); });
@ -2383,9 +2374,9 @@
$.add($('#keybinds_tab + div tbody', dialog), tr); $.add($('#keybinds_tab + div tbody', dialog), tr);
} }
indicators = {}; indicators = {};
_ref3 = $$('.warning', dialog); _ref2 = $$('.warning', dialog);
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) { for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
indicator = _ref3[_j]; indicator = _ref2[_i];
key = indicator.firstChild.textContent; key = indicator.firstChild.textContent;
indicator.hidden = $.get(key, Conf[key]); indicator.hidden = $.get(key, Conf[key]);
indicators[key] = indicator; indicators[key] = indicator;
@ -2404,6 +2395,7 @@
$.add(d.body, overlay); $.add(d.body, overlay);
d.body.style.setProperty('width', "" + d.body.clientWidth + "px", null); d.body.style.setProperty('width', "" + d.body.clientWidth + "px", null);
$.addClass(d.body, 'unscroll'); $.addClass(d.body, 'unscroll');
Options.filter.call(filter);
Options.backlink.call(back); Options.backlink.call(back);
Options.time.call(time); Options.time.call(time);
Options.fileInfo.call(fileInfo); Options.fileInfo.call(fileInfo);
@ -2433,6 +2425,50 @@
this.value = key; this.value = key;
return $.cb.value.call(this); 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: '<p>Use <a href=https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions>regular expressions</a>, one per line.<br>\
Lines starting with a <code>#</code> will be ignored.<br>\
For example, <code>/weeaboo/i</code> will filter posts containing the string `<code>weeaboo</code>`, case-insensitive.</p>\
<ul>You can use these settings with each regular expression, separate them with semicolons:\
<li>\
Per boards, separate them with commas. It is global if not specified.<br>\
For example: <code>boards:a,jp;</code>.\
</li>\
<li>\
Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>\
For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.\
</li>\
<li>\
Overrule the `Show Stubs` setting if specified: create a stub (`yes`) or not (`no`).<br>\
For example: <code>stub:yes;</code> or <code>stub:no;</code>\
</li>\
<li>\
Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>\
For example: <code>highlight;</code> or <code>highlight:wallpaper;</code>.\
</li>\
<li>\
Highlighted OPs will have their threads put on top of board pages by default.<br>\
For example: <code>top:yes</code> or <code>top:no</code>.\
</li>\
</ul>'
}));
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: function() {
Time.foo(); Time.foo();
Time.date = new Date(); Time.date = new Date();
@ -4690,11 +4726,13 @@ body.unscroll {\
vertical-align: middle;\ vertical-align: middle;\
width: 600px;\ width: 600px;\
}\ }\
#options article li {\
margin: 10px 0 10px 2em;\
}\
#credits {\ #credits {\
float: right;\ float: right;\
}\ }\
#options ul {\ #options ul {\
list-style: none;\
padding: 0;\ padding: 0;\
}\ }\
#options label {\ #options label {\
@ -4706,13 +4744,10 @@ body.unscroll {\
}\ }\
#content textarea {\ #content textarea {\
font-family: monospace;\ font-family: monospace;\
min-height: 100px;\ min-height: 350px;\
resize: vertical;\ resize: vertical;\
width: 100%;\ width: 100%;\
}\ }\
#sauces {\
height: 300px;\
}\
\ \
#updater {\ #updater {\
text-align: right;\ text-align: right;\

View File

@ -1717,32 +1717,25 @@ Options =
<li>$3: MD5 hash.</li> <li>$3: MD5 hash.</li>
<li>$4: Current board.</li> <li>$4: Current board.</li>
</ul> </ul>
<textarea name=sauces id=sauces></textarea> <textarea name=sauces id=sauces class=field></textarea>
</div> </div>
<input type=radio name=tab hidden id=filter_tab> <input type=radio name=tab hidden id=filter_tab>
<div> <div>
<div class=warning><code>Filter</code> is disabled.</div> <div class=warning><code>Filter</code> is disabled.</div>
Use <a href=https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions>regular expressions</a>, one per line.<br> <select name=filter>
Lines starting with a <code>#</code> will be ignored.<br> <option value=guide>Guide</option>
For example, <code>/weeaboo/i</code> will filter posts containing `weeaboo` case-insensitive. <option value=name>Name</option>
<ul>You can use these settings with each regular expression, separate them with semicolons: <option value=uniqueid>Unique ID</option>
<li>Per boards, separate them with commas. It is global if not specified.<br>For example: <code>boards:a,jp;</code>.</li> <option value=tripcode>Tripcode</option>
<li>Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.</li> <option value=mod>Admin/Mod</option>
<li>Overrule the `Show Stubs` setting if specified: create a stub (`yes`) or not (`no`).<br>For example: <code>stub:yes;</code> or <code>stub:no;</code></li> <option value=email>E-mail</option>
<li>Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>For example: <code>highlight;</code> or <code>highlight:wallpaper;</code>.</li> <option value=subject>Subject</option>
<li>Highlighted OPs will have their threads put on top of board pages by default.<br>For example: <code>top:yes</code> or <code>top:no</code>.</li> <option value=comment>Comment</option>
</ul> <option value=filename>Filename</option>
<p>Name:<br><textarea name=name></textarea></p> <option value=dimensions>Image dimensions</option>
<p>Unique ID:<br><textarea name=uniqueid></textarea></p> <option value=filesize>Filesize</option>
<p>Tripcode:<br><textarea name=tripcode></textarea></p> <option value=md5>Image MD5 (uses exact string matching, not regular expressions)</option>
<p>Admin/Mod:<br><textarea name=mod></textarea></p> </select>
<p>E-mail:<br><textarea name=email></textarea></p>
<p>Subject:<br><textarea name=subject></textarea></p>
<p>Comment:<br><textarea name=comment></textarea></p>
<p>Filename:<br><textarea name=filename></textarea></p>
<p>Image dimensions:<br><textarea name=dimensions></textarea></p>
<p>Filesize:<br><textarea name=filesize></textarea></p>
<p>Image MD5 (uses exact string matching, not regular expressions):<br><textarea name=md5></textarea></p>
</div> </div>
<input type=radio name=tab hidden id=rice_tab> <input type=radio name=tab hidden id=rice_tab>
<div> <div>
@ -1813,11 +1806,14 @@ Options =
$.on $('button', li), 'click', Options.clearHidden $.on $('button', li), 'click', Options.clearHidden
$.add $('ul:nth-child(2)', dialog), li $.add $('ul:nth-child(2)', dialog), li
#filter & sauce #filter
for ta in $$ 'textarea', dialog filter = $ 'select[name=filter]', dialog
ta.textContent = $.get ta.name, Conf[ta.name] $.on filter, 'change', Options.filter
ta.className = 'field'
$.on ta, 'change', $.cb.value #sauce
sauce = $ '#sauces', dialog
sauce.value = $.get sauce.name, Conf[sauce.name]
$.on sauce, 'change', $.cb.value
#rice #rice
(back = $ '[name=backlink]', dialog).value = $.get 'backlink', Conf['backlink'] (back = $ '[name=backlink]', dialog).value = $.get 'backlink', Conf['backlink']
@ -1829,7 +1825,7 @@ Options =
$.on time, 'input', Options.time $.on time, 'input', Options.time
$.on fileInfo, 'input', $.cb.value $.on fileInfo, 'input', $.cb.value
$.on fileInfo, 'input', Options.fileInfo $.on fileInfo, 'input', Options.fileInfo
favicon = $ 'select', dialog favicon = $ 'select[name=favicon]', dialog
favicon.value = $.get 'favicon', Conf['favicon'] favicon.value = $.get 'favicon', Conf['favicon']
$.on favicon, 'change', $.cb.value $.on favicon, 'change', $.cb.value
$.on favicon, 'change', Options.favicon $.on favicon, 'change', Options.favicon
@ -1860,6 +1856,7 @@ Options =
d.body.style.setProperty 'width', "#{d.body.clientWidth}px", null d.body.style.setProperty 'width', "#{d.body.clientWidth}px", null
$.addClass d.body, 'unscroll' $.addClass d.body, 'unscroll'
Options.filter.call filter
Options.backlink.call back Options.backlink.call back
Options.time.call time Options.time.call time
Options.fileInfo.call fileInfo Options.fileInfo.call fileInfo
@ -1884,6 +1881,45 @@ Options =
return unless (key = Keybinds.keyCode e)? return unless (key = Keybinds.keyCode e)?
@value = key @value = key
$.cb.value.call @ $.cb.value.call @
filter: ->
el = @nextSibling
$.rm el if el
if (name = @value) is 'guide'
$.after @, $.el 'article',
innerHTML: '<p>Use <a href=https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions>regular expressions</a>, one per line.<br>
Lines starting with a <code>#</code> will be ignored.<br>
For example, <code>/weeaboo/i</code> will filter posts containing the string `<code>weeaboo</code>`, case-insensitive.</p>
<ul>You can use these settings with each regular expression, separate them with semicolons:
<li>
Per boards, separate them with commas. It is global if not specified.<br>
For example: <code>boards:a,jp;</code>.
</li>
<li>
Filter OPs only along with their threads (`only`), replies only (`no`, this is default), or both (`yes`).<br>
For example: <code>op:only;</code>, <code>op:no;</code> or <code>op:yes;</code>.
</li>
<li>
Overrule the `Show Stubs` setting if specified: create a stub (`yes`) or not (`no`).<br>
For example: <code>stub:yes;</code> or <code>stub:no;</code>
</li>
<li>
Highlight instead of hiding. You can specify a class name to use with a userstyle.<br>
For example: <code>highlight;</code> or <code>highlight:wallpaper;</code>.
</li>
<li>
Highlighted OPs will have their threads put on top of board pages by default.<br>
For example: <code>top:yes</code> or <code>top:no</code>.
</li>
</ul>'
return
ta = $.el 'textarea',
name: name
className: 'field'
value: $.get name, Conf[name]
$.on ta, 'change', $.cb.value
$.after @, ta
time: -> time: ->
Time.foo() Time.foo()
Time.date = new Date() Time.date = new Date()
@ -3634,9 +3670,11 @@ body.unscroll {
float: right; float: right;
} }
#options ul { #options ul {
list-style: none;
padding: 0; padding: 0;
} }
#options article li {
margin: 10px 0 10px 2em;
}
#options label { #options label {
text-decoration: underline; text-decoration: underline;
} }
@ -3646,13 +3684,10 @@ body.unscroll {
} }
#content textarea { #content textarea {
font-family: monospace; font-family: monospace;
min-height: 100px; min-height: 350px;
resize: vertical; resize: vertical;
width: 100%; width: 100%;
} }
#sauces {
height: 300px;
}
#updater { #updater {
text-align: right; text-align: right;