fix #8, finish unread count rewrite
This commit is contained in:
parent
8e6d9484f2
commit
b40b19d2b2
21
4chan_x.js
21
4chan_x.js
@ -62,7 +62,9 @@
|
||||
var $, $$, NAMESPACE, anonymize, autoWatch, callback, config, d, el, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageTypeChange, imgExpansion, imgGif, imgPreloading, keybinds, localize, log, nav, navtopr, nodeInserted, options, pathname, qr, quickReport, recaptcha, redirect, replyHiding, sauce, temp, threadHiding, titlePost, tzOffset, ui, unread, updater, watcher, _config, _i, _j, _len, _len2, _ref, _ref2, _ref3;
|
||||
var __slice = Array.prototype.slice;
|
||||
if (typeof console != "undefined" && console !== null) {
|
||||
log = console.log;
|
||||
log = function(arg) {
|
||||
return console.log(arg);
|
||||
};
|
||||
}
|
||||
config = {
|
||||
main: {
|
||||
@ -1760,6 +1762,7 @@
|
||||
};
|
||||
unread = {
|
||||
init: function() {
|
||||
unread.replies = [];
|
||||
d.title = '(0) ' + d.title;
|
||||
$.bind(window, 'scroll', unread.cb.scroll);
|
||||
return g.callbacks.push(unread.cb.node);
|
||||
@ -1767,10 +1770,14 @@
|
||||
cb: {
|
||||
node: function(root) {
|
||||
unread.replies = unread.replies.concat($$('td[id]', root));
|
||||
return unread.updateTitle();
|
||||
unread.updateTitle();
|
||||
return unread.updateFavicon();
|
||||
},
|
||||
scroll: function(e) {
|
||||
var bottom, height, i, reply, _len, _ref;
|
||||
if (unread.replies.length === 0) {
|
||||
return;
|
||||
}
|
||||
height = d.body.clientHeight;
|
||||
_ref = unread.replies;
|
||||
for (i = 0, _len = _ref.length; i < _len; i++) {
|
||||
@ -1784,14 +1791,14 @@
|
||||
return;
|
||||
}
|
||||
unread.replies = unread.replies.slice(i);
|
||||
return unread.updateTitle();
|
||||
unread.updateTitle();
|
||||
if (unread.replies.length === 0) {
|
||||
return unread.updateFavicon();
|
||||
}
|
||||
}
|
||||
},
|
||||
updateTitle: function() {
|
||||
var l;
|
||||
l = unread.replies.length;
|
||||
d.title = d.title.replace(/\d+/, l);
|
||||
return updateFavicon();
|
||||
return d.title = d.title.replace(/\d+/, unread.replies.length);
|
||||
},
|
||||
updateFavicon: function() {
|
||||
var clone, favicon, href, l;
|
||||
|
||||
@ -4,8 +4,10 @@
|
||||
# (floating) qr no-quote button?
|
||||
# updater cache hacks
|
||||
|
||||
# XXX error on FUCKING CHROME
|
||||
{log} = console if console?
|
||||
# XXX chrome can't into `{log} = console`
|
||||
if console?
|
||||
log = (arg) ->
|
||||
console.log arg
|
||||
|
||||
# TODO reset defaults
|
||||
config =
|
||||
@ -620,6 +622,7 @@ keybinds =
|
||||
|
||||
nav =
|
||||
#TODO page nav
|
||||
#FIXME /b/
|
||||
# ◀ ▶
|
||||
init: ->
|
||||
span = $.el 'span',
|
||||
@ -1364,6 +1367,7 @@ quickReport =
|
||||
|
||||
unread =
|
||||
init: ->
|
||||
unread.replies = []
|
||||
d.title = '(0) ' + d.title
|
||||
$.bind window, 'scroll', unread.cb.scroll
|
||||
g.callbacks.push unread.cb.node
|
||||
@ -1372,21 +1376,25 @@ unread =
|
||||
node: (root) ->
|
||||
unread.replies = unread.replies.concat $$ 'td[id]', root
|
||||
unread.updateTitle()
|
||||
unread.updateFavicon()
|
||||
|
||||
scroll: (e) ->
|
||||
return if unread.replies.length is 0
|
||||
|
||||
height = d.body.clientHeight
|
||||
for reply, i in unread.replies
|
||||
bottom = reply.getBoundingClientRect().bottom
|
||||
{bottom} = reply.getBoundingClientRect()
|
||||
if bottom > height #post is not completely read
|
||||
break
|
||||
if i is 0 then return
|
||||
return if i is 0
|
||||
|
||||
unread.replies = unread.replies[i..]
|
||||
unread.updateTitle()
|
||||
if unread.replies.length is 0
|
||||
unread.updateFavicon()
|
||||
|
||||
updateTitle: ->
|
||||
l = unread.replies.length
|
||||
d.title = d.title.replace /\d+/, l
|
||||
updateFavicon()
|
||||
d.title = d.title.replace /\d+/, unread.replies.length
|
||||
|
||||
updateFavicon: ->
|
||||
l = unread.replies.length
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user