Merge branch 'master' of github.com:aeosynth/4chan-x
This commit is contained in:
commit
9de8b54f15
93
4chan_x.js
93
4chan_x.js
@ -58,7 +58,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quickReport, redirect, replyHiding, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
|
var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quickReport, quotePreview, redirect, replyHiding, sauce, threadHiding, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
if (typeof console !== "undefined" && console !== null) {
|
if (typeof console !== "undefined" && console !== null) {
|
||||||
log = function(arg) {
|
log = function(arg) {
|
||||||
@ -84,6 +84,7 @@
|
|||||||
'Post in Title': [true, 'Show the op\'s post in the tab title'],
|
'Post in Title': [true, 'Show the op\'s post in the tab title'],
|
||||||
'Quick Reply': [true, 'Reply without leaving the page'],
|
'Quick Reply': [true, 'Reply without leaving the page'],
|
||||||
'Quick Report': [true, 'Add quick report buttons'],
|
'Quick Report': [true, 'Add quick report buttons'],
|
||||||
|
'Quote Preview': [true, 'Show quote content on hover'],
|
||||||
'Reply Hiding': [true, 'Hide single replies'],
|
'Reply Hiding': [true, 'Hide single replies'],
|
||||||
'Sauce': [true, 'Add sauce to images'],
|
'Sauce': [true, 'Add sauce to images'],
|
||||||
'Show Stubs': [true, 'Of hidden threads / replies'],
|
'Show Stubs': [true, 'Of hidden threads / replies'],
|
||||||
@ -1207,18 +1208,20 @@
|
|||||||
}
|
}
|
||||||
$.append(op, node);
|
$.append(op, node);
|
||||||
op.id = $('input[name]', op).name;
|
op.id = $('input[name]', op).name;
|
||||||
node = op;
|
if (!g.REPLY) {
|
||||||
div = $.el('div', {
|
node = op;
|
||||||
className: 'thread'
|
div = $.el('div', {
|
||||||
});
|
className: 'thread'
|
||||||
$.before(node, div);
|
});
|
||||||
while (node.nodeName !== 'HR') {
|
$.before(node, div);
|
||||||
$.append(div, node);
|
while (node.nodeName !== 'HR') {
|
||||||
node = div.nextSibling;
|
$.append(div, node);
|
||||||
}
|
node = div.nextSibling;
|
||||||
node = node.nextElementSibling;
|
}
|
||||||
if (!(node.align || node.nodeName === 'CENTER')) {
|
node = node.nextElementSibling;
|
||||||
return threading.thread(node);
|
if (!(node.align || node.nodeName === 'CENTER')) {
|
||||||
|
return threading.thread(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stopPropagation: function(e) {
|
stopPropagation: function(e) {
|
||||||
@ -1653,6 +1656,53 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
quotePreview = {
|
||||||
|
init: function() {
|
||||||
|
var preview;
|
||||||
|
g.callbacks.push(quotePreview.node);
|
||||||
|
preview = $.el('div', {
|
||||||
|
id: 'qp',
|
||||||
|
className: 'reply'
|
||||||
|
});
|
||||||
|
$.hide(preview);
|
||||||
|
return $.append(d.body, preview);
|
||||||
|
},
|
||||||
|
node: function() {
|
||||||
|
var quote, quotes, _i, _len, _results;
|
||||||
|
quotes = $$('a.quotelink');
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
|
||||||
|
quote = quotes[_i];
|
||||||
|
_results.push($.bind(quote, 'mouseover', quotePreview.mouseover));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
},
|
||||||
|
mouseover: function(e) {
|
||||||
|
var clientX, clientY, id, preview, target;
|
||||||
|
target = e.target, clientX = e.clientX, clientY = e.clientY;
|
||||||
|
preview = $('#qp');
|
||||||
|
id = target.textContent.replace(">>", '');
|
||||||
|
preview.innerHTML = d.getElementById(id).innerHTML;
|
||||||
|
$.show(preview);
|
||||||
|
$.bind(target, 'mousemove', quotePreview.mousemove);
|
||||||
|
return $.bind(target, 'mouseout', quotePreview.mouseout);
|
||||||
|
},
|
||||||
|
mousemove: function(e) {
|
||||||
|
var clientX, clientY, preview;
|
||||||
|
clientX = e.clientX, clientY = e.clientY;
|
||||||
|
preview = $('#qp');
|
||||||
|
preview.style.left = clientX + 45;
|
||||||
|
return preview.style.top = clientY - 120;
|
||||||
|
},
|
||||||
|
mouseout: function(e) {
|
||||||
|
var preview, target;
|
||||||
|
target = e.target;
|
||||||
|
preview = $('#qp');
|
||||||
|
$.hide(preview);
|
||||||
|
$.unbind(target, 'mousemove', quotePreview.mousemove);
|
||||||
|
return $.unbind(target, 'mouseout', quotePreview.mouseout);
|
||||||
|
}
|
||||||
|
};
|
||||||
quickReport = {
|
quickReport = {
|
||||||
init: function() {
|
init: function() {
|
||||||
return g.callbacks.push(quickReport.cb.node);
|
return g.callbacks.push(quickReport.cb.node);
|
||||||
@ -1841,13 +1891,9 @@
|
|||||||
id: 'iHover'
|
id: 'iHover'
|
||||||
});
|
});
|
||||||
$.hide(img);
|
$.hide(img);
|
||||||
d.body.appendChild(img);
|
$.append(d.body, img);
|
||||||
return g.callbacks.push(imageHover.cb.node);
|
return g.callbacks.push(imageHover.cb.node);
|
||||||
},
|
},
|
||||||
offset: {
|
|
||||||
x: 45,
|
|
||||||
y: -120
|
|
||||||
},
|
|
||||||
cb: {
|
cb: {
|
||||||
node: function(root) {
|
node: function(root) {
|
||||||
var thumb, thumbs, _i, _len, _results;
|
var thumb, thumbs, _i, _len, _results;
|
||||||
@ -1875,10 +1921,10 @@
|
|||||||
clientX = e.clientX, clientY = e.clientY;
|
clientX = e.clientX, clientY = e.clientY;
|
||||||
img = $('#iHover');
|
img = $('#iHover');
|
||||||
imgHeight = img.offsetHeight;
|
imgHeight = img.offsetHeight;
|
||||||
top = clientY + imageHover.offset.y;
|
top = clientY - 120;
|
||||||
bot = top + imgHeight;
|
bot = top + imgHeight;
|
||||||
img.style.top = imageHover.winHeight < imgHeight || top < 0 ? '0px' : bot > imageHover.winHeight ? imageHover.winHeight - imgHeight + 'px' : top + 'px';
|
img.style.top = imageHover.winHeight < imgHeight || top < 0 ? '0px' : bot > imageHover.winHeight ? imageHover.winHeight - imgHeight + 'px' : top + 'px';
|
||||||
return img.style.left = clientX + imageHover.offset.x;
|
return img.style.left = clientX + 45;
|
||||||
},
|
},
|
||||||
mouseout: function(e) {
|
mouseout: function(e) {
|
||||||
var img, target;
|
var img, target;
|
||||||
@ -2156,12 +2202,16 @@
|
|||||||
if ($.config('Quick Report')) {
|
if ($.config('Quick Report')) {
|
||||||
quickReport.init();
|
quickReport.init();
|
||||||
}
|
}
|
||||||
|
if ($.config('Quote Preview')) {
|
||||||
|
quotePreview.init();
|
||||||
|
}
|
||||||
if ($.config('Thread Watcher')) {
|
if ($.config('Thread Watcher')) {
|
||||||
watcher.init();
|
watcher.init();
|
||||||
}
|
}
|
||||||
if ($.config('Keybinds')) {
|
if ($.config('Keybinds')) {
|
||||||
keybinds.init();
|
keybinds.init();
|
||||||
}
|
}
|
||||||
|
threading.init();
|
||||||
if (g.REPLY) {
|
if (g.REPLY) {
|
||||||
if ($.config('Thread Updater')) {
|
if ($.config('Thread Updater')) {
|
||||||
updater.init();
|
updater.init();
|
||||||
@ -2182,7 +2232,6 @@
|
|||||||
watcher.watch(null, g.THREAD_ID);
|
watcher.watch(null, g.THREAD_ID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
threading.init();
|
|
||||||
if ($.config('Thread Hiding')) {
|
if ($.config('Thread Hiding')) {
|
||||||
threadHiding.init();
|
threadHiding.init();
|
||||||
}
|
}
|
||||||
@ -2241,7 +2290,7 @@
|
|||||||
display: none;\
|
display: none;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
#iHover {\
|
#qp, #iHover {\
|
||||||
position: fixed;\
|
position: fixed;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
|
|||||||
@ -28,6 +28,7 @@ config =
|
|||||||
'Post in Title': [true, 'Show the op\'s post in the tab title']
|
'Post in Title': [true, 'Show the op\'s post in the tab title']
|
||||||
'Quick Reply': [true, 'Reply without leaving the page']
|
'Quick Reply': [true, 'Reply without leaving the page']
|
||||||
'Quick Report': [true, 'Add quick report buttons']
|
'Quick Report': [true, 'Add quick report buttons']
|
||||||
|
'Quote Preview': [true, 'Show quote content on hover']
|
||||||
'Reply Hiding': [true, 'Hide single replies']
|
'Reply Hiding': [true, 'Hide single replies']
|
||||||
'Sauce': [true, 'Add sauce to images']
|
'Sauce': [true, 'Add sauce to images']
|
||||||
'Show Stubs': [true, 'Of hidden threads / replies']
|
'Show Stubs': [true, 'Of hidden threads / replies']
|
||||||
@ -964,20 +965,21 @@ threading =
|
|||||||
$.append op, node #add the blockquote
|
$.append op, node #add the blockquote
|
||||||
op.id = $('input[name]', op).name
|
op.id = $('input[name]', op).name
|
||||||
|
|
||||||
node = op
|
unless g.REPLY
|
||||||
|
node = op
|
||||||
|
|
||||||
div = $.el 'div',
|
div = $.el 'div',
|
||||||
className: 'thread'
|
className: 'thread'
|
||||||
$.before node, div
|
$.before node, div
|
||||||
|
|
||||||
while node.nodeName isnt 'HR'
|
while node.nodeName isnt 'HR'
|
||||||
$.append div, node
|
$.append div, node
|
||||||
node = div.nextSibling
|
node = div.nextSibling
|
||||||
|
|
||||||
node = node.nextElementSibling #skip text node
|
node = node.nextElementSibling #skip text node
|
||||||
#{N,}SFW
|
#{N,}SFW
|
||||||
unless node.align or node.nodeName is 'CENTER'
|
unless node.align or node.nodeName is 'CENTER'
|
||||||
threading.thread node
|
threading.thread node
|
||||||
|
|
||||||
stopPropagation: (e) ->
|
stopPropagation: (e) ->
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@ -1316,6 +1318,36 @@ titlePost =
|
|||||||
if tc = $('span.filetitle').textContent or $('blockquote').textContent
|
if tc = $('span.filetitle').textContent or $('blockquote').textContent
|
||||||
d.title = "/#{g.BOARD}/ - #{tc}"
|
d.title = "/#{g.BOARD}/ - #{tc}"
|
||||||
|
|
||||||
|
quotePreview =
|
||||||
|
init: ->
|
||||||
|
g.callbacks.push quotePreview.node
|
||||||
|
preview = $.el 'div', id: 'qp', className: 'reply'
|
||||||
|
$.hide preview
|
||||||
|
$.append d.body, preview
|
||||||
|
node: ->
|
||||||
|
quotes = $$ 'a.quotelink'
|
||||||
|
for quote in quotes
|
||||||
|
$.bind quote, 'mouseover', quotePreview.mouseover
|
||||||
|
mouseover: (e) ->
|
||||||
|
{target, clientX, clientY} = e
|
||||||
|
preview = $ '#qp'
|
||||||
|
id = target.textContent.replace ">>", ''
|
||||||
|
preview.innerHTML = d.getElementById(id).innerHTML
|
||||||
|
$.show preview
|
||||||
|
$.bind target, 'mousemove', quotePreview.mousemove
|
||||||
|
$.bind target, 'mouseout', quotePreview.mouseout
|
||||||
|
mousemove: (e) ->
|
||||||
|
{clientX, clientY} = e
|
||||||
|
preview = $ '#qp'
|
||||||
|
preview.style.left = clientX + 45
|
||||||
|
preview.style.top = clientY - 120
|
||||||
|
mouseout: (e) ->
|
||||||
|
{target} = e
|
||||||
|
preview = $ '#qp'
|
||||||
|
$.hide preview
|
||||||
|
$.unbind target, 'mousemove', quotePreview.mousemove
|
||||||
|
$.unbind target, 'mouseout', quotePreview.mouseout
|
||||||
|
|
||||||
quickReport =
|
quickReport =
|
||||||
init: ->
|
init: ->
|
||||||
g.callbacks.push quickReport.cb.node
|
g.callbacks.push quickReport.cb.node
|
||||||
@ -1433,11 +1465,8 @@ imageHover =
|
|||||||
init: ->
|
init: ->
|
||||||
img = $.el 'img', id: 'iHover'
|
img = $.el 'img', id: 'iHover'
|
||||||
$.hide img
|
$.hide img
|
||||||
d.body.appendChild img
|
$.append d.body, img
|
||||||
g.callbacks.push imageHover.cb.node
|
g.callbacks.push imageHover.cb.node
|
||||||
offset:
|
|
||||||
x: 45
|
|
||||||
y: -120
|
|
||||||
cb:
|
cb:
|
||||||
node: (root) ->
|
node: (root) ->
|
||||||
thumbs = $$ 'img[md5]', root
|
thumbs = $$ 'img[md5]', root
|
||||||
@ -1457,7 +1486,7 @@ imageHover =
|
|||||||
img = $ '#iHover'
|
img = $ '#iHover'
|
||||||
imgHeight = img.offsetHeight
|
imgHeight = img.offsetHeight
|
||||||
|
|
||||||
top = clientY + imageHover.offset.y
|
top = clientY - 120
|
||||||
bot = top + imgHeight
|
bot = top + imgHeight
|
||||||
img.style.top =
|
img.style.top =
|
||||||
if imageHover.winHeight < imgHeight or top < 0
|
if imageHover.winHeight < imgHeight or top < 0
|
||||||
@ -1466,7 +1495,7 @@ imageHover =
|
|||||||
imageHover.winHeight - imgHeight + 'px'
|
imageHover.winHeight - imgHeight + 'px'
|
||||||
else
|
else
|
||||||
top + 'px'
|
top + 'px'
|
||||||
img.style.left = clientX + imageHover.offset.x
|
img.style.left = clientX + 45
|
||||||
mouseout: (e) ->
|
mouseout: (e) ->
|
||||||
{target} = e
|
{target} = e
|
||||||
img = $ '#iHover'
|
img = $ '#iHover'
|
||||||
@ -1687,12 +1716,17 @@ main =
|
|||||||
if $.config 'Quick Report'
|
if $.config 'Quick Report'
|
||||||
quickReport.init()
|
quickReport.init()
|
||||||
|
|
||||||
|
if $.config 'Quote Preview'
|
||||||
|
quotePreview.init()
|
||||||
|
|
||||||
if $.config 'Thread Watcher'
|
if $.config 'Thread Watcher'
|
||||||
watcher.init()
|
watcher.init()
|
||||||
|
|
||||||
if $.config 'Keybinds'
|
if $.config 'Keybinds'
|
||||||
keybinds.init()
|
keybinds.init()
|
||||||
|
|
||||||
|
threading.init()
|
||||||
|
|
||||||
if g.REPLY
|
if g.REPLY
|
||||||
if $.config 'Thread Updater'
|
if $.config 'Thread Updater'
|
||||||
updater.init()
|
updater.init()
|
||||||
@ -1714,8 +1748,6 @@ main =
|
|||||||
watcher.watch null, g.THREAD_ID
|
watcher.watch null, g.THREAD_ID
|
||||||
|
|
||||||
else #not reply
|
else #not reply
|
||||||
threading.init()
|
|
||||||
|
|
||||||
if $.config 'Thread Hiding'
|
if $.config 'Thread Hiding'
|
||||||
threadHiding.init()
|
threadHiding.init()
|
||||||
|
|
||||||
@ -1769,7 +1801,7 @@ main =
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#iHover {
|
#qp, #iHover {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user