From 983531672029a2e39c41df0c381263e10b6fa3b5 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 23 Jul 2011 19:19:29 -0700 Subject: [PATCH 1/3] use conf instead of duplicating --- script.coffee | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/script.coffee b/script.coffee index 894803b9f..c916a675c 100644 --- a/script.coffee +++ b/script.coffee @@ -1268,21 +1268,17 @@ threadHiding = updater = init: -> - updater.interval = conf['Interval'] - updater.ircUpd = conf['IRC Updating'] - updater.verbose = conf['Verbose'] - - html = "
-#{updater.interval}
" - conf = config.updater.checkbox - for name of conf - title = conf[name][1] - checked = if conf[name] then 'checked' else '' + html = "
-#{conf['Interval']}
" + {checkbox} = config.updater + for name of checkbox + title = checkbox[name][1] + checked = if checkbox[name] then 'checked' else '' html += "
" checked = if conf['Auto Update'] then 'checked' else '' html += "
-
+
" dialog = ui.dialog 'updater', bottom: '0', right: '0', html @@ -1310,7 +1306,7 @@ updater = cb: verbose: -> - if updater.verbose = @checked + if conf['Verbose'] = @checked updater.count.textContent = '+0' $.show updater.timer else @@ -1324,7 +1320,7 @@ updater = else window.clearInterval updater.intervalID interval: -> - updater.interval = @value = @value.match(/\d+/)[0] + conf['Interval'] = @value = @value.match(/\d+/)[0] update: -> if @status is 404 updater.timer.textContent = '' @@ -1349,8 +1345,8 @@ updater = while (reply = replies.pop()) and (reply.id > id) arr.push reply.parentNode.parentNode.parentNode #table - updater.timer.textContent = '-' + updater.interval - if updater.verbose + updater.timer.textContent = '-' + conf['Interval'] + if conf['Verbose'] updater.count.textContent = '+' + arr.length if arr.length is 0 updater.count.className = '' @@ -1360,7 +1356,7 @@ updater = #XXX add replies in correct order so backlinks resolve while reply = arr.pop() $.before br, reply - if updater.ircUpd + if conf['IRC Updating'] scrollTo 0, d.body.scrollHeight timeout: -> @@ -1664,7 +1660,6 @@ quoteInline = quotePreview = init: -> - quotePreview.hl = conf['Quote Highlighting'] g.callbacks.push (root) -> for quote in $$ 'a.quotelink, a.backlink', root continue unless quote.hash @@ -1680,7 +1675,7 @@ quotePreview = id = @hash[1..] if el = d.getElementById id qp.innerHTML = el.innerHTML - $.addClass el, 'qphl' if quotePreview.hl + $.addClass el, 'qphl' if conf['Quote Highlighting'] if /backlink/.test @className replyID = $.x('ancestor::*[@id][1]', @).id.match(/\d+/)[0] for quote in $$ 'a.quotelink', qp From 6f00fbb75049fa32164d34a4d28a5073c1491c63 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 23 Jul 2011 19:23:26 -0700 Subject: [PATCH 2/3] use length --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9cf45dfa5..0ffda93e0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1649,8 +1649,8 @@ length = arr.length; updater.timer.textContent = '-' + conf['Interval']; if (conf['Verbose']) { - updater.count.textContent = '+' + arr.length; - if (arr.length === 0) { + updater.count.textContent = '+' + length; + if (length === 0) { updater.count.className = ''; } else { updater.count.className = 'new'; diff --git a/script.coffee b/script.coffee index 391b89cb0..2ed95abdc 100644 --- a/script.coffee +++ b/script.coffee @@ -1348,8 +1348,8 @@ updater = updater.timer.textContent = '-' + conf['Interval'] if conf['Verbose'] - updater.count.textContent = '+' + arr.length - if arr.length is 0 + updater.count.textContent = '+' + length + if length is 0 updater.count.className = '' else updater.count.className = 'new' From 060629d2d9d3b6403ad1220c66cd212d89408fa2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 23 Jul 2011 19:30:27 -0700 Subject: [PATCH 3/3] don't error --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0ffda93e0..df437db9c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1616,7 +1616,7 @@ } }, interval: function() { - return conf['Interval'] = this.value = this.value.match(/\d+/)[0]; + return conf['Interval'] = this.value = parseInt(this.value) || conf['Interval']; }, update: function() { var arr, body, br, id, input, length, replies, reply, _i, _len, _ref, _ref2; diff --git a/script.coffee b/script.coffee index 2ed95abdc..4df5755f7 100644 --- a/script.coffee +++ b/script.coffee @@ -1320,7 +1320,7 @@ updater = else window.clearInterval updater.intervalID interval: -> - conf['Interval'] = @value = @value.match(/\d+/)[0] + conf['Interval'] = @value = parseInt(@value) or conf['Interval'] update: -> if @status is 404 updater.timer.textContent = ''