diff --git a/4chan_x.js b/4chan_x.js index cbf855c61..a9a1a9541 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -68,35 +68,45 @@ } config = { main: { - checkbox: { - '404 Redirect': [true, 'Redirect dead threads'], - 'Anonymize': [false, 'Make everybody anonymous'], + monitor: { + 'Thread Updater': [true, 'Update threads'], + 'Unread Count': [true, 'Show unread post count in tab title'], + 'Post in Title': [true, 'Show the op\'s post in the tab title'], + 'Thread Watcher': [true, 'Bookmark threads'], 'Auto Watch': [true, 'Automatically watch threads that you start'], - 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'], - 'Comment Expansion': [true, 'Expand too long comments'], - 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'], + 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] + }, + img: { 'Image Auto-Gif': [false, 'Animate gif thumbnails'], 'Image Expansion': [true, 'Expand images'], 'Image Hover': [false, 'Show full image on mouseover'], 'Image Preloading': [false, 'Preload Images'], - 'Keybinds': [false, 'Binds actions to keys'], - 'Localize Time': [true, 'Show times based on your timezone'], - 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'], - 'Post in Title': [true, 'Show the op\'s post in the tab title'], + 'Sauce': [true, 'Add sauce to images'] + }, + post: { + 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'], 'Quick Reply': [true, 'Reply without leaving the page'], + 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] + }, + quote: { 'Quote Backlinks': [false, 'Add quote backlinks'], 'Quote Inline': [false, 'Show quoted post inline on quote click'], - 'Quote Preview': [false, 'Show quote content on hover'], + 'Quote Preview': [false, 'Show quote content on hover'] + }, + filter: { 'Reply Hiding': [true, 'Hide single replies'], - 'Report Button': [true, 'Add report buttons'], - 'Sauce': [true, 'Add sauce to images'], - 'Show Stubs': [true, 'Of hidden threads / replies'], - 'Thread Expansion': [true, 'View all replies'], 'Thread Hiding': [true, 'Hide entire threads'], - 'Thread Navigation': [true, 'Navigate to previous / next thread'], - 'Thread Updater': [true, 'Update threads'], - 'Thread Watcher': [true, 'Bookmark threads'], - 'Unread Count': [true, 'Show unread post count in tab title'] + 'Show Stubs': [true, 'Of hidden threads / replies'] + }, + misc: { + '404 Redirect': [true, 'Redirect dead threads'], + 'Anonymize': [false, 'Make everybody anonymous'], + 'Keybinds': [false, 'Binds actions to keys'], + 'Localize Time': [true, 'Show times based on your timezone'], + 'Report Button': [true, 'Add report buttons'], + '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') @@ -176,18 +186,18 @@ e.preventDefault(); el = ui.el; left = e.clientX - ui.dx; - if (left < 20) { + if (left < 10) { left = '0px'; - } else if (ui.width - left < 20) { + } else if (ui.width - left < 10) { left = ''; } right = left ? '' : '0px'; el.style.left = left; el.style.right = right; top = e.clientY - ui.dy; - if (top < 20) { + if (top < 10) { top = '0px'; - } else if (ui.height - top < 20) { + } else if (ui.height - top < 10) { top = ''; } bottom = top ? '' : '0px'; @@ -906,26 +916,20 @@ } }, dialog: function() { - var checked, conf, dialog, hiddenNum, hiddenThreads, html, input, name, title, _i, _len, _ref; - html = "
Options X
"; - conf = config.main.checkbox; - for (name in conf) { - title = conf[name][1]; - checked = $.config(name) ? "checked" : ""; - html += "
"; - } - html += "
Flavors
"; - html += "
"; + var dialog, hiddenNum, hiddenThreads, html, input, _i, _len, _ref; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html += "
"; - html += "
"; - html += "
support throd
"; - html += '
Donate
'; + html = "
Options X



Sauce flavors
Donate
Support: GitHub | support throd | uso
"; dialog = ui.dialog('options', { top: '25%', - left: '50%' + 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.filter, $('#filter', 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]; @@ -936,6 +940,19 @@ $.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'); @@ -2470,11 +2487,28 @@ #options {\ position: fixed;\ padding: 5px;\ + }\ + #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;\ + }\ #options textarea {\ height: 100px;\ - width: 500px;\ + width: 100%;\ }\ \ #qr {\ diff --git a/script.coffee b/script.coffee index f1bfa3499..27d0a8c11 100644 --- a/script.coffee +++ b/script.coffee @@ -11,35 +11,40 @@ if console? config = main: - checkbox: - '404 Redirect': [true, 'Redirect dead threads'] - 'Anonymize': [false, 'Make everybody anonymous'] + monitor: + 'Thread Updater': [true, 'Update threads'] + 'Unread Count': [true, 'Show unread post count in tab title'] + 'Post in Title': [true, 'Show the op\'s post in the tab title'] + 'Thread Watcher': [true, 'Bookmark threads'] 'Auto Watch': [true, 'Automatically watch threads that you start'] 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] - 'Comment Expansion': [true, 'Expand too long comments'] - 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'] + img: 'Image Auto-Gif': [false, 'Animate gif thumbnails'] 'Image Expansion': [true, 'Expand images'] 'Image Hover': [false, 'Show full image on mouseover'] 'Image Preloading': [false, 'Preload Images'] - 'Keybinds': [false, 'Binds actions to keys'] - 'Localize Time': [true, 'Show times based on your timezone'] - 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] - 'Post in Title': [true, 'Show the op\'s post in the tab title'] + 'Sauce': [true, 'Add sauce to images'] + post: + 'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'] 'Quick Reply': [true, 'Reply without leaving the page'] + 'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.'] + quote: 'Quote Backlinks': [false, 'Add quote backlinks'] 'Quote Inline': [false, 'Show quoted post inline on quote click'] 'Quote Preview': [false, 'Show quote content on hover'] + filter: 'Reply Hiding': [true, 'Hide single replies'] - 'Report Button': [true, 'Add report buttons'] - 'Sauce': [true, 'Add sauce to images'] - 'Show Stubs': [true, 'Of hidden threads / replies'] - 'Thread Expansion': [true, 'View all replies'] 'Thread Hiding': [true, 'Hide entire threads'] + 'Show Stubs': [true, 'Of hidden threads / replies'] + misc: + '404 Redirect': [true, 'Redirect dead threads'] + 'Anonymize': [false, 'Make everybody anonymous'] + 'Keybinds': [false, 'Binds actions to keys'] + 'Localize Time': [true, 'Show times based on your timezone'] + 'Report Button': [true, 'Add report buttons'] + 'Comment Expansion': [true, 'Expand too long comments'] + 'Thread Expansion': [true, 'View all replies'] 'Thread Navigation': [true, 'Navigate to previous / next thread'] - 'Thread Updater': [true, 'Update threads'] - 'Thread Watcher': [true, 'Bookmark threads'] - 'Unread Count': [true, 'Show unread post count in tab title'] textarea: flavors: [ 'http://regex.info/exif.cgi?url=' @@ -103,14 +108,14 @@ ui = e.preventDefault() {el} = ui left = e.clientX - ui.dx - if left < 20 then left = '0px' - else if ui.width - left < 20 then left = '' + if left < 10 then left = '0px' + else if ui.width - left < 10 then left = '' right = if left then '' else '0px' el.style.left = left el.style.right = right top = e.clientY - ui.dy - if top < 20 then top = '0px' - else if ui.height - top < 20 then top = '' + if top < 10 then top = '0px' + else if ui.height - top < 10 then top = '' bottom = if top then '' else '0px' el.style.top = top el.style.bottom = bottom @@ -688,24 +693,34 @@ options = options.dialog() dialog: -> - html = "
Options X
" - conf = config.main.checkbox - for name of conf - title = conf[name][1] - checked = if $.config name then "checked" else "" - html += "
" - html += "
Flavors
" - html += "
" - hiddenThreads = $.getValue "hiddenThreads/#{g.BOARD}/", {} hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length - html += "
" + html = " +
Options X
+
+
+
+
+
+
+
+
+
Sauce flavors
+
+
+
Donate
+
Support: GitHub | support throd | uso
+
+
+ " - html += "
" - html += "
support throd
" - html += '
Donate
' - - dialog = ui.dialog 'options', top: '25%', left: '50%', html + 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.filter, $('#filter', dialog) + options.append config.main.misc, $('#misc', dialog) for input in $$ 'input[type=checkbox]', dialog $.bind input, 'click', $.cb.checked $.bind $('input[type=button]', dialog), 'click', options.cb.clearHidden @@ -713,6 +728,14 @@ 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 @@ -1929,11 +1952,28 @@ main = #options { position: fixed; padding: 5px; + } + #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; + } #options textarea { height: 100px; - width: 500px; + width: 100%; } #qr {