From e1cc3079b4e167a72e995fa4ae196cace1a2b23f Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 5 Jun 2011 19:05:44 -0700 Subject: [PATCH] start options rewrite --- 4chan_x.user.js | 63 ++++++++++++++++++++++--------------------------- script.coffee | 56 ++++++++++++++++++------------------------- 2 files changed, 51 insertions(+), 68 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 922f786cf..3a42ea2c5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -111,11 +111,9 @@ 'Comment Expansion': [true, 'Expand too long comments'], 'Thread Expansion': [true, 'View all replies'], 'Thread Navigation': [true, 'Navigate to previous / next thread'] - }, - textarea: { - 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') } }, + 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'), updater: { checkbox: { 'Verbose': [true, 'Show countdown timer, new post count'], @@ -956,23 +954,35 @@ } }, dialog: function() { - var dialog, hiddenNum, hiddenThreads, html, input, _i, _len, _ref; + 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
Donate
support throd | github | uso
"; dialog = ui.dialog('options', { top: '25%', left: '25%' }, html); - options.append(config.main.monitor, $('#monitor', dialog)); - options.append(config.main.img, $('#img', dialog)); - options.append(config.main.post, $('#post', dialog)); - options.append(config.main.quote, $('#quote', dialog)); - options.append(config.main.hide, $('#hide', dialog)); - options.append(config.main.misc, $('#misc', dialog)); - _ref = $$('input[type=checkbox]', dialog); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - input = _ref[_i]; + main = $('#main', dialog); + _ref = config.main; + for (key in _ref) { + obj = _ref[key]; + ul = $.el('ul', { + textContent: key + }); + for (key in obj) { + arr = obj[key]; + checked = $.config(key) ? "checked" : ""; + description = arr[1]; + li = $.el('li', { + innerHTML: "" + description + "" + }); + $.append(ul, li); + } + $.append(main, ul); + } + _ref2 = $$('input[type=checkbox]', dialog); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + input = _ref2[_i]; $.bind(input, 'click', $.cb.checked); } $.bind($('input[type=button]', dialog), 'click', options.cb.clearHidden); @@ -980,19 +990,6 @@ $.bind($('textarea', dialog), 'change', $.cb.value); return $.append(d.body, dialog); }, - append: function(conf, id) { - var checked, li, name, title, _results; - _results = []; - for (name in conf) { - title = conf[name][1]; - checked = $.config(name) ? "checked" : ""; - li = $.el('li', { - innerHTML: "" - }); - _results.push($.append(id, li)); - } - return _results; - }, flavors: function() { var ta; ta = $('#options textarea'); @@ -2634,18 +2631,10 @@ #options .move, #credits {\ text-align: right;\ }\ - .column {\ - float: left;\ - margin: 0 10px;\ - }\ #options ul {\ list-style: none;\ - margin: 0;\ padding: 0;\ }\ - #options li:first-child {\ - text-decoration: underline;\ - }\ #floaty {\ float: left;\ }\ @@ -2653,6 +2642,10 @@ height: 100px;\ width: 100%;\ }\ + #options #main {\ + overflow: auto;\ + height: 500px;\ + }\ \ #qr {\ position: fixed;\ diff --git a/script.coffee b/script.coffee index 43d4261b2..40850b55c 100644 --- a/script.coffee +++ b/script.coffee @@ -43,13 +43,12 @@ config = 'Comment Expansion': [true, 'Expand too long comments'] 'Thread Expansion': [true, 'View all replies'] 'Thread Navigation': [true, 'Navigate to previous / next thread'] - textarea: - 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' + 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' updater: checkbox: 'Verbose': [true, 'Show countdown timer, new post count'] @@ -724,10 +723,8 @@ options = html = "
Options X

-
-
-
-
+
+

@@ -741,12 +738,17 @@ options = " dialog = ui.dialog 'options', top: '25%', left: '25%', html - options.append config.main.monitor, $('#monitor', dialog) - options.append config.main.img, $('#img', dialog) - options.append config.main.post, $('#post', dialog) - options.append config.main.quote, $('#quote', dialog) - options.append config.main.hide, $('#hide', dialog) - options.append config.main.misc, $('#misc', dialog) + main = $('#main', dialog) + for key, obj of config.main + ul = $.el 'ul', + textContent: key + for key, arr of obj + checked = if $.config key then "checked" else "" + description = arr[1] + li = $.el 'li', + innerHTML: "#{description}" + $.append ul, li + $.append main, ul for input in $$ 'input[type=checkbox]', dialog $.bind input, 'click', $.cb.checked $.bind $('input[type=button]', dialog), 'click', options.cb.clearHidden @@ -754,14 +756,6 @@ options = $.bind $('textarea', dialog), 'change', $.cb.value $.append d.body, dialog - append: (conf, id) -> - for name of conf - title = conf[name][1] - checked = if $.config name then "checked" else "" - li = $.el 'li', - innerHTML: "" - $.append id, li - flavors: -> ta = $ '#options textarea' if ta.style.display then $.show ta else $.hide ta @@ -1989,18 +1983,10 @@ main = #options .move, #credits { text-align: right; } - .column { - float: left; - margin: 0 10px; - } #options ul { list-style: none; - margin: 0; padding: 0; } - #options li:first-child { - text-decoration: underline; - } #floaty { float: left; } @@ -2008,6 +1994,10 @@ main = height: 100px; width: 100%; } + #options #main { + overflow: auto; + height: 500px; + } #qr { position: fixed;