change options dialog

This commit is contained in:
James Campos 2010-10-21 01:01:14 -07:00
parent 918d06ccc6
commit 5c2a3831ba
2 changed files with 20 additions and 25 deletions

View File

@ -184,8 +184,7 @@ tn = (s) ->
d.createTextNode s d.createTextNode s
x = (path, root) -> x = (path, root) ->
root or= d.body root or= d.body
d. d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
singleNodeValue singleNodeValue
#let's get this party started. #let's get this party started.
@ -315,44 +314,42 @@ clearHidden = ->
options = -> options = ->
#redo this #redo this
if div = $('#options') if div = $('#options')
remove(div) remove div
else else
div = AEOS.makeDialog 'options', 'center' div = AEOS.makeDialog 'options', 'center'
hiddenNum = hiddenReplies.length + hiddenThreads.length hiddenNum = hiddenReplies.length + hiddenThreads.length
html = '<div class="move">4chan X</div><div>' html = '<div class="move">Options <a class=pointer>X</a></div><div>'
for option of config for option of config
checked = if getConfig(option) then "checked" else "" checked = if getConfig option then "checked" else ""
html += "<label>#{option}<input #{checked} name=\"#{option}\" type=\"checkbox\"></label><br>" html += "<label>#{option}<input #{checked} name=\"#{option}\" type=\"checkbox\"></label><br>"
html += "<input type=\"button\" value=\"hidden: #{hiddenNum}\"><br>" html += "<input type=\"button\" value=\"hidden: #{hiddenNum}\"><br>"
html += '<a name="save">save</a> <a name="cancel">cancel</a></div>'
div.innerHTML = html div.innerHTML = html
$('div.move', div).addEventListener('mousedown', AEOS.move, true) $('div.move', div).addEventListener('mousedown', AEOS.move, true)
$('a.pointer', div).addEventListener 'click', optionsClose, true
$('input[type="button"]', div).addEventListener('click', clearHidden, true) $('input[type="button"]', div).addEventListener('click', clearHidden, true)
$('a[name="save"]', div).addEventListener('click', optionsSave, true)
$('a[name="cancel"]', div).addEventListener('click', close, true)
addTo d.body, div addTo d.body, div
showThread = -> showThread = ->
div = this.nextSibling div = @nextSibling
show(div) show div
hide(this) hide this
id = div.id id = div.id
slice(hiddenThreads, id) slice hiddenThreads, id
GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads)) GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads))
hideThread = (div) -> hideThread = (div) ->
if p = this.parentNode if p = @parentNode
div = p div = p
hiddenThreads.push({ hiddenThreads.push {
id: div.id id: div.id
timestamp: getTime() timestamp: getTime()
}) }
GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads)) GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads))
hide(div) hide div
if getConfig('Show Stubs') if getConfig 'Show Stubs'
if span = $('.omittedposts', div) if span = $ '.omittedposts', div
num = Number(span.textContent.match(/\d+/)[0]) num = Number(span.textContent.match(/\d+/)[0])
else else
num = 0 num = 0
@ -428,7 +425,7 @@ hideReply = (reply) ->
inBefore table, div inBefore table, div
optionsSave = -> optionsClose = ->
div = this.parentNode.parentNode div = this.parentNode.parentNode
inputs = $$('input', div) inputs = $$('input', div)
for input in inputs for input in inputs

View File

@ -1,5 +1,5 @@
(function() { (function() {
var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, THREAD_ID, _i, _j, _len, _len2, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, d, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, link, magic, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, pathname, quickReply, r, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, sauce, sauces, show, showReply, showThread, slice, span, spans, src, stopPropagation, submit, suffix, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs; var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, THREAD_ID, _i, _j, _len, _len2, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, d, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, link, magic, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, r, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, sauce, sauces, show, showReply, showThread, slice, span, spans, src, stopPropagation, submit, suffix, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs;
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty; var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
config = { config = {
'Thread Hiding': true, 'Thread Hiding': true,
@ -370,7 +370,7 @@
} else { } else {
div = AEOS.makeDialog('options', 'center'); div = AEOS.makeDialog('options', 'center');
hiddenNum = hiddenReplies.length + hiddenThreads.length; hiddenNum = hiddenReplies.length + hiddenThreads.length;
html = '<div class="move">4chan X</div><div>'; html = '<div class="move">Options <a class=pointer>X</a></div><div>';
_ref2 = config; _ref2 = config;
for (option in _ref2) { for (option in _ref2) {
if (!__hasProp.call(_ref2, option)) continue; if (!__hasProp.call(_ref2, option)) continue;
@ -379,12 +379,10 @@
html += ("<label>" + (option) + "<input " + (checked) + " name=\"" + (option) + "\" type=\"checkbox\"></label><br>"); html += ("<label>" + (option) + "<input " + (checked) + " name=\"" + (option) + "\" type=\"checkbox\"></label><br>");
} }
html += ("<input type=\"button\" value=\"hidden: " + (hiddenNum) + "\"><br>"); html += ("<input type=\"button\" value=\"hidden: " + (hiddenNum) + "\"><br>");
html += '<a name="save">save</a> <a name="cancel">cancel</a></div>';
div.innerHTML = html; div.innerHTML = html;
$('div.move', div).addEventListener('mousedown', AEOS.move, true); $('div.move', div).addEventListener('mousedown', AEOS.move, true);
$('a.pointer', div).addEventListener('click', optionsClose, true);
$('input[type="button"]', div).addEventListener('click', clearHidden, true); $('input[type="button"]', div).addEventListener('click', clearHidden, true);
$('a[name="save"]', div).addEventListener('click', optionsSave, true);
$('a[name="cancel"]', div).addEventListener('click', close, true);
return addTo(d.body, div); return addTo(d.body, div);
} }
}; };
@ -491,7 +489,7 @@
return inBefore(table, div); return inBefore(table, div);
} }
}; };
optionsSave = function() { optionsClose = function() {
var _i, _len, _ref2, div, input, inputs; var _i, _len, _ref2, div, input, inputs;
div = this.parentNode.parentNode; div = this.parentNode.parentNode;
inputs = $$('input', div); inputs = $$('input', div);