Time to stop being silly.

This commit is contained in:
Zixaphir 2013-08-07 20:55:23 -07:00
parent 80884e2bde
commit ce6e317c98
5 changed files with 49 additions and 96 deletions

View File

@ -336,15 +336,6 @@
return this.indexOf(string) > -1; return this.indexOf(string) > -1;
}; };
Array.prototype.add = function(object, position) {
var keep;
keep = this.slice(position);
this.length = position;
this.push(object);
return this.pushArrays(keep);
};
Array.prototype.contains = function(object) { Array.prototype.contains = function(object) {
return this.indexOf(object) > -1; return this.indexOf(object) > -1;
}; };
@ -361,27 +352,6 @@
return i; return i;
}; };
Array.prototype.pushArrays = function() {
var arg, args, _i, _len;
args = arguments;
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
this.push.apply(this, arg);
}
return this;
};
Array.prototype.remove = function(object) {
var index;
if ((index = this.indexOf(object)) > -1) {
return this.splice(index, 1);
} else {
return false;
}
};
$ = function(selector, root) { $ = function(selector, root) {
if (root == null) { if (root == null) {
root = d.body; root = d.body;
@ -3683,7 +3653,7 @@
if (Conf['Quote Inlining']) { if (Conf['Quote Inlining']) {
$.on(link, 'click', QuoteInline.toggle); $.on(link, 'click', QuoteInline.toggle);
if (Conf['Quote Hash Navigation']) { if (Conf['Quote Hash Navigation']) {
frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered'))); frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
} }
} }
$.add(container, frag); $.add(container, frag);
@ -7992,17 +7962,28 @@
height = doc.clientHeight; height = doc.clientHeight;
posts = Unread.posts; posts = Unread.posts;
i = 0; i = 0;
while (post = posts[i++]) { while (post = posts[i]) {
bottom = post.nodes.root.getBoundingClientRect().bottom; bottom = post.nodes.root.getBoundingClientRect().bottom;
if (bottom < height) { if (bottom > height) {
ID = post.ID; i++;
posts.remove(post); continue;
} }
ID = post.ID;
if (Conf['Quote Threading']) {
posts.splice(i, 1);
continue;
} else {
posts.splice(0, i);
break;
}
i++;
} }
if (!ID) { if (!ID) {
return; return;
} }
Unread.lastReadPost = ID; if (Unread.lastReadPost < ID || !Unread.lastReadPost) {
Unread.lastReadPost = ID;
}
Unread.saveLastReadPost(); Unread.saveLastReadPost();
Unread.readArray(Unread.postsQuotingYou); Unread.readArray(Unread.postsQuotingYou);
return Unread.update(); return Unread.update();

View File

@ -317,15 +317,6 @@
return this.indexOf(string) > -1; return this.indexOf(string) > -1;
}; };
Array.prototype.add = function(object, position) {
var keep;
keep = this.slice(position);
this.length = position;
this.push(object);
return this.pushArrays(keep);
};
Array.prototype.contains = function(object) { Array.prototype.contains = function(object) {
return this.indexOf(object) > -1; return this.indexOf(object) > -1;
}; };
@ -342,27 +333,6 @@
return i; return i;
}; };
Array.prototype.pushArrays = function() {
var arg, args, _i, _len;
args = arguments;
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
this.push.apply(this, arg);
}
return this;
};
Array.prototype.remove = function(object) {
var index;
if ((index = this.indexOf(object)) > -1) {
return this.splice(index, 1);
} else {
return false;
}
};
$ = function(selector, root) { $ = function(selector, root) {
if (root == null) { if (root == null) {
root = d.body; root = d.body;
@ -3688,7 +3658,7 @@
if (Conf['Quote Inlining']) { if (Conf['Quote Inlining']) {
$.on(link, 'click', QuoteInline.toggle); $.on(link, 'click', QuoteInline.toggle);
if (Conf['Quote Hash Navigation']) { if (Conf['Quote Hash Navigation']) {
frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered'))); frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
} }
} }
$.add(container, frag); $.add(container, frag);
@ -7973,17 +7943,28 @@
height = doc.clientHeight; height = doc.clientHeight;
posts = Unread.posts; posts = Unread.posts;
i = 0; i = 0;
while (post = posts[i++]) { while (post = posts[i]) {
bottom = post.nodes.root.getBoundingClientRect().bottom; bottom = post.nodes.root.getBoundingClientRect().bottom;
if (bottom < height) { if (bottom > height) {
ID = post.ID; i++;
posts.remove(post); continue;
} }
ID = post.ID;
if (Conf['Quote Threading']) {
posts.splice(i, 1);
continue;
} else {
posts.splice(0, i);
break;
}
i++;
} }
if (!ID) { if (!ID) {
return; return;
} }
Unread.lastReadPost = ID; if (Unread.lastReadPost < ID || !Unread.lastReadPost) {
Unread.lastReadPost = ID;
}
Unread.saveLastReadPost(); Unread.saveLastReadPost();
Unread.readArray(Unread.postsQuotingYou); Unread.readArray(Unread.postsQuotingYou);
return Unread.update(); return Unread.update();

View File

@ -4,12 +4,6 @@ String::capitalize = ->
String::contains = (string) -> String::contains = (string) ->
@indexOf(string) > -1 @indexOf(string) > -1
Array::add = (object, position) ->
keep = @slice position
@length = position
@push object
@pushArrays keep
Array::contains = (object) -> Array::contains = (object) ->
@indexOf(object) > -1 @indexOf(object) > -1
@ -19,18 +13,6 @@ Array::indexOf = (object) ->
return i if @[i] is object return i if @[i] is object
return i return i
Array::pushArrays = ->
args = arguments
for arg in args
@push.apply @, arg
return @
Array::remove = (object) ->
if (index = @indexOf object) > -1
@splice index, 1
else
false
# loosely follows the jquery api: # loosely follows the jquery api:
# http://api.jquery.com/ # http://api.jquery.com/
# not chainable # not chainable

View File

@ -121,14 +121,23 @@ Unread =
{posts} = Unread {posts} = Unread
i = 0 i = 0
while post = posts[i++] while post = posts[i]
{bottom} = post.nodes.root.getBoundingClientRect() {bottom} = post.nodes.root.getBoundingClientRect()
if (bottom < height) # post is completely read if bottom > height # post isnt completely read
{ID} = post i++
posts.remove post continue
{ID} = post
if Conf['Quote Threading']
posts.splice i, 1
continue
else
posts.splice 0, i
break
i++
return unless ID return unless ID
Unread.lastReadPost = ID Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost
Unread.saveLastReadPost() Unread.saveLastReadPost()
Unread.readArray Unread.postsQuotingYou Unread.readArray Unread.postsQuotingYou
Unread.update() Unread.update()

View File

@ -41,7 +41,7 @@ QuoteBacklink =
$.on link, 'mouseover', QuotePreview.mouseover $.on link, 'mouseover', QuotePreview.mouseover
if Conf['Quote Inlining'] if Conf['Quote Inlining']
$.on link, 'click', QuoteInline.toggle $.on link, 'click', QuoteInline.toggle
frag.pushArrays QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation'] frag.push.apply frag, QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation']
$.add container, frag $.add container, frag
return return
secondNode: -> secondNode: ->