From a8c726ba8168cf449ca754b8f27928e094a65edd Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 5 Jun 2011 19:42:59 -0700 Subject: [PATCH] start time editing --- 4chan_x.user.js | 22 ++++++++++++++++------ script.coffee | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3a42ea2c5..8840751b4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -114,6 +114,7 @@ } }, flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n'), + time: '%m/%d/%y(%D)%H:%i', updater: { checkbox: { 'Verbose': [true, 'Show countdown timer, new post count'], @@ -957,7 +958,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, html, input, key, li, main, obj, ul, _i, _len, _ref, _ref2; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "
Options X


Sauce flavors
Donate
support throd | github | uso
"; + html = "
Options X


Sauce flavors
Time Formatting
Donate
support throd | github | uso
"; dialog = ui.dialog('options', { top: '25%', left: '25%' @@ -987,18 +988,28 @@ } $.bind($('input[type=button]', dialog), 'click', options.cb.clearHidden); $.bind($('a[name=flavors]', dialog), 'click', options.flavors); - $.bind($('textarea', dialog), 'change', $.cb.value); + $.bind($('a[name=time]', dialog), 'click', options.time); + $.bind($('textarea[name=flavors]', dialog), 'change', $.cb.value); return $.append(d.body, dialog); }, flavors: function() { var ta; - ta = $('#options textarea'); + ta = $('#options textarea[name=flavors]'); if (ta.style.display) { return $.show(ta); } else { return $.hide(ta); } }, + time: function() { + var div; + div = $('#time'); + if (div.style.display) { + return $.show(div); + } else { + return $.hide(div); + } + }, cb: { clearHidden: function(e) { $.deleteValue("hiddenReplies/" + g.BOARD + "/"); @@ -1659,9 +1670,8 @@ }; time = { init: function() { - var code, format; - format = '%m/%d/%y(%D)%H:%i'; - code = format.replace(/%(.)/g, function(s, c) { + var code; + code = $.config('time').replace(/%(.)/g, function(s, c) { switch (c) { case '%': return '%'; diff --git a/script.coffee b/script.coffee index 40850b55c..64944760e 100644 --- a/script.coffee +++ b/script.coffee @@ -49,6 +49,7 @@ config = 'http://tineye.com/search?url=' '#http://saucenao.com/search.php?db=999&url=' ].join '\n' + time: '%m/%d/%y(%D)%H:%i' updater: checkbox: 'Verbose': [true, 'Show countdown timer, new post count'] @@ -729,12 +730,18 @@ options =
Sauce flavors
+
Time Formatting
Donate
support throd | github | uso
+ " dialog = ui.dialog 'options', top: '25%', left: '25%', html @@ -753,13 +760,18 @@ options = $.bind input, 'click', $.cb.checked $.bind $('input[type=button]', dialog), 'click', options.cb.clearHidden $.bind $('a[name=flavors]', dialog), 'click', options.flavors - $.bind $('textarea', dialog), 'change', $.cb.value + $.bind $('a[name=time]', dialog), 'click', options.time + $.bind $('textarea[name=flavors]', dialog), 'change', $.cb.value $.append d.body, dialog flavors: -> - ta = $ '#options textarea' + ta = $ '#options textarea[name=flavors]' if ta.style.display then $.show ta else $.hide ta + time: -> + div = $ '#time' + if div.style.display then $.show div else $.hide div + cb: clearHidden: (e) -> #'hidden' might be misleading; it's the number of IDs we're *looking* for, @@ -1307,8 +1319,7 @@ sauce = time = init: -> - format = '%m/%d/%y(%D)%H:%i' - code = format.replace /%(.)/g, (s, c) -> + code = $.config('time').replace /%(.)/g, (s, c) -> switch c when '%' then '%' when 'A', 'D', 'H', 'a', 'd', 'i', 'm', 'y' then "' + time.#{c}() + '"