Merge branch 'master' of github.com:aeosynth/4chan-x

This commit is contained in:
Nicolas Stepien 2011-07-20 23:39:19 +02:00
commit 2a91e76008
2 changed files with 119 additions and 107 deletions

View File

@ -59,10 +59,44 @@
*/
(function() {
var $, $$, Favicon, NAMESPACE, Recaptcha, Time, anonymize, config, cooldown, d, expandComment, expandThread, firstRun, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
var $, $$, Favicon, NAMESPACE, Recaptcha, Time, anonymize, config, cooldown, d, expandComment, expandThread, firstRun, g, imgExpand, imgGif, imgHover, imgPreloading, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
var __slice = Array.prototype.slice;
config = {
main: {
Enhancing: {
'404 Redirect': [true, 'Redirect dead threads'],
'Anonymize': [false, 'Make everybody anonymous'],
'Keybinds': [false, 'Binds actions to keys'],
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
'Report Button': [true, 'Add report buttons'],
'Comment Expansion': [true, 'Expand too long comments'],
'Thread Expansion': [true, 'View all replies'],
'Index Navigation': [true, 'Navigate to previous / next thread'],
'Reply Navigation': [false, 'Navigate to top / bottom of thread']
},
Hiding: {
'Reply Hiding': [true, 'Hide single replies'],
'Thread Hiding': [true, 'Hide entire threads'],
'Show Stubs': [true, 'Of hidden threads / replies']
},
Imaging: {
'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'],
'Sauce': [true, 'Add sauce to images'],
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
},
Monitoring: {
'Thread Updater': [true, 'Update threads'],
'IRC Updating': [false, 'Scroll updated posts into view'],
'Unread Count': [true, 'Show unread post count in tab title'],
'Post in Title': [true, 'Show the op\'s post in the tab title'],
'Thread Stats': [true, 'Display reply and image count'],
'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']
},
Posting: {
'Auto Noko': [true, 'Always redirect to your post'],
'Cooldown': [true, 'Prevent \'flood detected\' errors'],
@ -76,39 +110,6 @@
'Quote Inline': [true, 'Show quoted post inline on quote click'],
'Quote Preview': [true, 'Show quote content on hover'],
'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes']
},
Monitoring: {
'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 Stats': [true, 'Display reply and image count'],
'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']
},
Imaging: {
'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'],
'Sauce': [true, 'Add sauce to images'],
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
},
Hiding: {
'Reply Hiding': [true, 'Hide single replies'],
'Thread Hiding': [true, 'Hide entire threads'],
'Show Stubs': [true, 'Of hidden threads / replies']
},
Enhancing: {
'404 Redirect': [true, 'Redirect dead threads'],
'Anonymize': [false, 'Make everybody anonymous'],
'Keybinds': [false, 'Binds actions to keys'],
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'],
'Report Button': [true, 'Add report buttons'],
'Comment Expansion': [true, 'Expand too long comments'],
'Thread Expansion': [true, 'View all replies'],
'Index Navigation': [true, 'Navigate to previous / next thread'],
'Reply Navigation': [false, 'Navigate to top / bottom of thread']
}
},
flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n'),
@ -1615,7 +1616,7 @@
}
},
update: function(e) {
var arr, body, br, id, input, replies, reply, _i, _len, _ref, _ref2, _results;
var arr, body, br, id, input, replies, reply, _i, _len, _ref, _ref2;
if (this.status === 404) {
updater.timer.textContent = '';
updater.count.textContent = 404;
@ -1651,11 +1652,12 @@
updater.count.className = 'new';
}
}
_results = [];
while (reply = arr.pop()) {
_results.push($.before(br, reply));
$.before(br, reply);
}
if ($.config('IRC Updating')) {
return scrollTo(0, d.body.scrollHeight);
}
return _results;
}
},
timeout: function() {
@ -2439,30 +2441,34 @@
return _results;
}
};
imageHover = {
imgHover = {
init: function() {
imageHover.img = $.el('img', {
id: 'iHover'
return g.callbacks.push(function(root) {
var thumb;
if (!(thumb = $('img[md5]', root))) {
return;
}
$.bind(thumb, 'mouseover', imgHover.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', imgHover.mouseout);
});
$.append(d.body, imageHover.img);
return g.callbacks.push(imageHover.node);
},
node: function(root) {
var thumb;
if (!(thumb = $('img[md5]', root))) {
return;
}
$.bind(thumb, 'mouseover', imageHover.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', ui.hoverend);
},
mouseover: function(e) {
/*
img.src = null doesn't work on Chrome
http://code.google.com/p/chromium/issues/detail?id=36142
*/ imageHover.img.src = null;
imageHover.img.src = this.parentNode.href;
return ui.el = imageHover.img;
http://code.google.com/p/chromium/issues/detail?id=36142
manipulating img src via javascript will generate a massive memory leak
instead of manipulating src, we manipulate the entire img
*/ var img;
img = $.el('img', {
id: 'iHover',
src: this.parentNode.href
});
ui.el = img;
return $.append(d.body, img);
},
mouseout: function(e) {
return $.rm(ui.el);
}
};
imgPreloading = {
@ -2498,8 +2504,8 @@
g.callbacks.push(imgExpand.node);
imgExpand.dialog();
$.bind(window, 'resize', imgExpand.resize);
imgExpand.style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }");
return imgExpand.style.className = 'height';
imgExpand.style = $.addStyle('');
return imgExpand.resize();
},
node: function(root) {
var a, thumb;
@ -2716,7 +2722,7 @@
anonymize.init();
}
if ($.config('Image Hover')) {
imageHover.init();
imgHover.init();
}
if ($.config('Reply Hiding')) {
replyHiding.init();

View File

@ -1,5 +1,35 @@
config =
main:
Enhancing:
'404 Redirect': [true, 'Redirect dead threads']
'Anonymize': [false, 'Make everybody anonymous']
'Keybinds': [false, 'Binds actions to keys']
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
'Report Button': [true, 'Add report buttons']
'Comment Expansion': [true, 'Expand too long comments']
'Thread Expansion': [true, 'View all replies']
'Index Navigation': [true, 'Navigate to previous / next thread']
'Reply Navigation': [false, 'Navigate to top / bottom of thread']
Hiding:
'Reply Hiding': [true, 'Hide single replies']
'Thread Hiding': [true, 'Hide entire threads']
'Show Stubs': [true, 'Of hidden threads / replies']
Imaging:
'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']
'Sauce': [true, 'Add sauce to images']
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
Monitoring:
'Thread Updater': [true, 'Update threads']
'IRC Updating': [false, 'Scroll updated posts into view']
'Unread Count': [true, 'Show unread post count in tab title']
'Post in Title': [true, 'Show the op\'s post in the tab title']
'Thread Stats': [true, 'Display reply and image count']
'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']
Posting:
'Auto Noko': [true, 'Always redirect to your post']
'Cooldown': [true, 'Prevent \'flood detected\' errors']
@ -12,35 +42,6 @@ config =
'Quote Inline': [true, 'Show quoted post inline on quote click']
'Quote Preview': [true, 'Show quote content on hover']
'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes']
Monitoring:
'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 Stats': [true, 'Display reply and image count']
'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']
Imaging:
'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']
'Sauce': [true, 'Add sauce to images']
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
Hiding:
'Reply Hiding': [true, 'Hide single replies']
'Thread Hiding': [true, 'Hide entire threads']
'Show Stubs': [true, 'Of hidden threads / replies']
Enhancing:
'404 Redirect': [true, 'Redirect dead threads']
'Anonymize': [false, 'Make everybody anonymous']
'Keybinds': [false, 'Binds actions to keys']
'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time']
'Report Button': [true, 'Add report buttons']
'Comment Expansion': [true, 'Expand too long comments']
'Thread Expansion': [true, 'View all replies']
'Index Navigation': [true, 'Navigate to previous / next thread']
'Reply Navigation': [false, 'Navigate to top / bottom of thread']
flavors: [
'http://regex.info/exif.cgi?url='
'http://iqdb.org/?url='
@ -1348,9 +1349,11 @@ updater =
else
updater.count.className = 'new'
#XXX add replies in correct order so /b/acklinks resolve
#XXX add replies in correct order so backlinks resolve
while reply = arr.pop()
$.before br, reply
if $.config 'IRC Updating'
scrollTo 0, d.body.scrollHeight
timeout: ->
n = Number updater.timer.textContent
@ -1842,24 +1845,27 @@ nodeInserted = (e) ->
for callback in g.callbacks
callback target
imageHover =
imgHover =
init: ->
imageHover.img = $.el 'img', id: 'iHover'
$.append d.body, imageHover.img
g.callbacks.push imageHover.node
node: (root) ->
return unless thumb = $ 'img[md5]', root
$.bind thumb, 'mouseover', imageHover.mouseover
$.bind thumb, 'mousemove', ui.hover
$.bind thumb, 'mouseout', ui.hoverend
g.callbacks.push (root) ->
return unless thumb = $ 'img[md5]', root
$.bind thumb, 'mouseover', imgHover.mouseover
$.bind thumb, 'mousemove', ui.hover
$.bind thumb, 'mouseout', imgHover.mouseout
mouseover: (e) ->
###
img.src = null doesn't work on Chrome
http://code.google.com/p/chromium/issues/detail?id=36142
http://code.google.com/p/chromium/issues/detail?id=36142
manipulating img src via javascript will generate a massive memory leak
instead of manipulating src, we manipulate the entire img
###
imageHover.img.src = null
imageHover.img.src = @parentNode.href
ui.el = imageHover.img
img = $.el 'img'
id: 'iHover'
src: @parentNode.href
ui.el = img
$.append d.body, img
mouseout: (e) ->
$.rm ui.el
imgPreloading =
init: ->
@ -1881,8 +1887,8 @@ imgExpand =
g.callbacks.push imgExpand.node
imgExpand.dialog()
$.bind window, 'resize', imgExpand.resize
imgExpand.style = $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }"
imgExpand.style.className = 'height'
imgExpand.style = $.addStyle ''
imgExpand.resize()
node: (root) ->
return unless thumb = $ 'img[md5]', root
@ -2121,7 +2127,7 @@ main =
anonymize.init()
if $.config 'Image Hover'
imageHover.init()
imgHover.init()
if $.config 'Reply Hiding'
replyHiding.init()