Prevent Updater's countdown from creating lazily GC'd DOM Nodes.
This commit is contained in:
parent
aeb4b6f5a7
commit
e079596e31
@ -2889,7 +2889,7 @@
|
|||||||
}
|
}
|
||||||
Updater.unsuccessfulFetchCount = 0;
|
Updater.unsuccessfulFetchCount = 0;
|
||||||
if (Updater.timer.textContent < -Conf['Interval']) {
|
if (Updater.timer.textContent < -Conf['Interval']) {
|
||||||
return Updater.timer.textContent = -Updater.getInterval();
|
return Updater.set('timer', -Updater.getInterval());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
interval: function() {
|
interval: function() {
|
||||||
@ -2897,17 +2897,15 @@
|
|||||||
val = parseInt(this.value, 10);
|
val = parseInt(this.value, 10);
|
||||||
this.value = val > 5 ? val : 5;
|
this.value = val > 5 ? val : 5;
|
||||||
$.cb.value.call(this);
|
$.cb.value.call(this);
|
||||||
return Updater.timer.textContent = -Updater.getInterval();
|
return Updater.set('timer', -Updater.getInterval());
|
||||||
},
|
},
|
||||||
verbose: function() {
|
verbose: function() {
|
||||||
if (Conf['Verbose']) {
|
if (Conf['Verbose']) {
|
||||||
Updater.count.textContent = '+0';
|
Updater.set('count', '+0');
|
||||||
return Updater.timer.hidden = false;
|
return Updater.timer.hidden = false;
|
||||||
} else {
|
} else {
|
||||||
$.extend(Updater.count, {
|
Updater.set('count', 'Thread Updater');
|
||||||
className: '',
|
Updater.count.className = '';
|
||||||
textContent: 'Thread Updater'
|
|
||||||
});
|
|
||||||
return Updater.timer.hidden = true;
|
return Updater.timer.hidden = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2928,8 +2926,8 @@
|
|||||||
update: function() {
|
update: function() {
|
||||||
var count, doc, id, lastPost, nodes, reply, scroll, _i, _len, _ref, _ref1, _ref2;
|
var count, doc, id, lastPost, nodes, reply, scroll, _i, _len, _ref, _ref1, _ref2;
|
||||||
if (this.status === 404) {
|
if (this.status === 404) {
|
||||||
Updater.timer.textContent = '';
|
Updater.set('timer', '');
|
||||||
Updater.count.textContent = 404;
|
Updater.set('count', 404);
|
||||||
Updater.count.className = 'warning';
|
Updater.count.className = 'warning';
|
||||||
clearTimeout(Updater.timeoutID);
|
clearTimeout(Updater.timeoutID);
|
||||||
g.dead = true;
|
g.dead = true;
|
||||||
@ -2944,14 +2942,14 @@
|
|||||||
}
|
}
|
||||||
if ((_ref = this.status) !== 0 && _ref !== 200 && _ref !== 304) {
|
if ((_ref = this.status) !== 0 && _ref !== 200 && _ref !== 304) {
|
||||||
if (Conf['Verbose']) {
|
if (Conf['Verbose']) {
|
||||||
Updater.count.textContent = this.statusText;
|
Updater.set('count', this.statusText);
|
||||||
Updater.count.className = 'warning';
|
Updater.count.className = 'warning';
|
||||||
}
|
}
|
||||||
Updater.unsuccessfulFetchCount++;
|
Updater.unsuccessfulFetchCount++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Updater.unsuccessfulFetchCount++;
|
Updater.unsuccessfulFetchCount++;
|
||||||
Updater.timer.textContent = -Updater.getInterval();
|
Updater.set('timer', -Updater.getInterval());
|
||||||
/*
|
/*
|
||||||
Status Code 304: Not modified
|
Status Code 304: Not modified
|
||||||
By sending the `If-Modified-Since` header we get a proper status code, and no response.
|
By sending the `If-Modified-Since` header we get a proper status code, and no response.
|
||||||
@ -2961,7 +2959,7 @@
|
|||||||
|
|
||||||
if ((_ref1 = this.status) === 0 || _ref1 === 304) {
|
if ((_ref1 = this.status) === 0 || _ref1 === 304) {
|
||||||
if (Conf['Verbose']) {
|
if (Conf['Verbose']) {
|
||||||
Updater.count.textContent = '+0';
|
Updater.set('count', '+0');
|
||||||
Updater.count.className = null;
|
Updater.count.className = null;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -2982,14 +2980,14 @@
|
|||||||
}
|
}
|
||||||
count = nodes.length;
|
count = nodes.length;
|
||||||
if (Conf['Verbose']) {
|
if (Conf['Verbose']) {
|
||||||
Updater.count.textContent = "+" + count;
|
Updater.set('count', "+" + count);
|
||||||
Updater.count.className = count ? 'new' : null;
|
Updater.count.className = count ? 'new' : null;
|
||||||
}
|
}
|
||||||
if (!count) {
|
if (!count) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Updater.unsuccessfulFetchCount = 0;
|
Updater.unsuccessfulFetchCount = 0;
|
||||||
Updater.timer.textContent = -Updater.getInterval();
|
Updater.set('timer', -Updater.getInterval());
|
||||||
scroll = Conf['Scrolling'] && Updater.scrollBG() && lastPost.getBoundingClientRect().bottom - d.documentElement.clientHeight < 25;
|
scroll = Conf['Scrolling'] && Updater.scrollBG() && lastPost.getBoundingClientRect().bottom - d.documentElement.clientHeight < 25;
|
||||||
$.add(Updater.thread, nodes.reverse());
|
$.add(Updater.thread, nodes.reverse());
|
||||||
if (scroll) {
|
if (scroll) {
|
||||||
@ -2997,6 +2995,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
set: function(name, text) {
|
||||||
|
var el, node;
|
||||||
|
el = Updater[name];
|
||||||
|
if (node = el.firstChild) {
|
||||||
|
return node.data = text;
|
||||||
|
} else {
|
||||||
|
return el.textContent = text;
|
||||||
|
}
|
||||||
|
},
|
||||||
getInterval: function() {
|
getInterval: function() {
|
||||||
var i, j;
|
var i, j;
|
||||||
i = +Conf['Interval'];
|
i = +Conf['Interval'];
|
||||||
@ -3009,21 +3016,21 @@
|
|||||||
timeout: function() {
|
timeout: function() {
|
||||||
var n;
|
var n;
|
||||||
Updater.timeoutID = setTimeout(Updater.timeout, 1000);
|
Updater.timeoutID = setTimeout(Updater.timeout, 1000);
|
||||||
n = 1 + Number(Updater.timer.textContent);
|
n = 1 + Number(Updater.timer.firstChild.data);
|
||||||
if (n === 0) {
|
if (n === 0) {
|
||||||
return Updater.update();
|
return Updater.update();
|
||||||
} else if (n >= Updater.getInterval()) {
|
} else if (n >= Updater.getInterval()) {
|
||||||
Updater.unsuccessfulFetchCount++;
|
Updater.unsuccessfulFetchCount++;
|
||||||
Updater.count.textContent = 'Retry';
|
Updater.set('count', 'Retry');
|
||||||
Updater.count.className = null;
|
Updater.count.className = null;
|
||||||
return Updater.update();
|
return Updater.update();
|
||||||
} else {
|
} else {
|
||||||
return Updater.timer.textContent = n;
|
return Updater.set('timer', n);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update: function() {
|
update: function() {
|
||||||
var url, _ref;
|
var url, _ref;
|
||||||
Updater.timer.textContent = 0;
|
Updater.set('timer', 0);
|
||||||
if ((_ref = Updater.request) != null) {
|
if ((_ref = Updater.request) != null) {
|
||||||
_ref.abort();
|
_ref.abort();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2314,20 +2314,19 @@ Updater =
|
|||||||
# Reset the counter when we focus this tab.
|
# Reset the counter when we focus this tab.
|
||||||
Updater.unsuccessfulFetchCount = 0
|
Updater.unsuccessfulFetchCount = 0
|
||||||
if Updater.timer.textContent < -Conf['Interval']
|
if Updater.timer.textContent < -Conf['Interval']
|
||||||
Updater.timer.textContent = -Updater.getInterval()
|
Updater.set 'timer', -Updater.getInterval()
|
||||||
interval: ->
|
interval: ->
|
||||||
val = parseInt @value, 10
|
val = parseInt @value, 10
|
||||||
@value = if val > 5 then val else 5
|
@value = if val > 5 then val else 5
|
||||||
$.cb.value.call @
|
$.cb.value.call @
|
||||||
Updater.timer.textContent = -Updater.getInterval()
|
Updater.set 'timer', -Updater.getInterval()
|
||||||
verbose: ->
|
verbose: ->
|
||||||
if Conf['Verbose']
|
if Conf['Verbose']
|
||||||
Updater.count.textContent = '+0'
|
Updater.set 'count', '+0'
|
||||||
Updater.timer.hidden = false
|
Updater.timer.hidden = false
|
||||||
else
|
else
|
||||||
$.extend Updater.count,
|
Updater.set 'count', 'Thread Updater'
|
||||||
className: ''
|
Updater.count.className = ''
|
||||||
textContent: 'Thread Updater'
|
|
||||||
Updater.timer.hidden = true
|
Updater.timer.hidden = true
|
||||||
autoUpdate: ->
|
autoUpdate: ->
|
||||||
if Conf['Auto Update This'] = @checked
|
if Conf['Auto Update This'] = @checked
|
||||||
@ -2342,9 +2341,9 @@ Updater =
|
|||||||
-> !(d.hidden or d.oHidden or d.mozHidden or d.webkitHidden)
|
-> !(d.hidden or d.oHidden or d.mozHidden or d.webkitHidden)
|
||||||
update: ->
|
update: ->
|
||||||
if @status is 404
|
if @status is 404
|
||||||
Updater.timer.textContent = ''
|
Updater.set 'timer', ''
|
||||||
Updater.count.textContent = 404
|
Updater.set 'count', 404
|
||||||
Updater.count.className = 'warning'
|
Updater.count.className = 'warning'
|
||||||
clearTimeout Updater.timeoutID
|
clearTimeout Updater.timeoutID
|
||||||
g.dead = true
|
g.dead = true
|
||||||
if Conf['Unread Count']
|
if Conf['Unread Count']
|
||||||
@ -2357,13 +2356,13 @@ Updater =
|
|||||||
unless @status in [0, 200, 304]
|
unless @status in [0, 200, 304]
|
||||||
# XXX 304 -> 0 in Opera
|
# XXX 304 -> 0 in Opera
|
||||||
if Conf['Verbose']
|
if Conf['Verbose']
|
||||||
Updater.count.textContent = @statusText
|
Updater.set 'count', @statusText
|
||||||
Updater.count.className = 'warning'
|
Updater.count.className = 'warning'
|
||||||
Updater.unsuccessfulFetchCount++
|
Updater.unsuccessfulFetchCount++
|
||||||
return
|
return
|
||||||
|
|
||||||
Updater.unsuccessfulFetchCount++
|
Updater.unsuccessfulFetchCount++
|
||||||
Updater.timer.textContent = -Updater.getInterval()
|
Updater.set 'timer', -Updater.getInterval()
|
||||||
|
|
||||||
###
|
###
|
||||||
Status Code 304: Not modified
|
Status Code 304: Not modified
|
||||||
@ -2374,8 +2373,8 @@ Updater =
|
|||||||
if @status in [0, 304]
|
if @status in [0, 304]
|
||||||
# XXX 304 -> 0 in Opera
|
# XXX 304 -> 0 in Opera
|
||||||
if Conf['Verbose']
|
if Conf['Verbose']
|
||||||
Updater.count.textContent = '+0'
|
Updater.set 'count', '+0'
|
||||||
Updater.count.className = null
|
Updater.count.className = null
|
||||||
return
|
return
|
||||||
Updater.lastModified = @getResponseHeader 'Last-Modified'
|
Updater.lastModified = @getResponseHeader 'Last-Modified'
|
||||||
|
|
||||||
@ -2391,19 +2390,28 @@ Updater =
|
|||||||
|
|
||||||
count = nodes.length
|
count = nodes.length
|
||||||
if Conf['Verbose']
|
if Conf['Verbose']
|
||||||
Updater.count.textContent = "+#{count}"
|
Updater.set 'count', "+#{count}"
|
||||||
Updater.count.className = if count then 'new' else null
|
Updater.count.className = if count then 'new' else null
|
||||||
|
|
||||||
return unless count
|
return unless count
|
||||||
|
|
||||||
Updater.unsuccessfulFetchCount = 0
|
Updater.unsuccessfulFetchCount = 0
|
||||||
Updater.timer.textContent = -Updater.getInterval()
|
Updater.set 'timer', -Updater.getInterval()
|
||||||
scroll = Conf['Scrolling'] && Updater.scrollBG() &&
|
scroll = Conf['Scrolling'] && Updater.scrollBG() &&
|
||||||
lastPost.getBoundingClientRect().bottom - d.documentElement.clientHeight < 25
|
lastPost.getBoundingClientRect().bottom - d.documentElement.clientHeight < 25
|
||||||
$.add Updater.thread, nodes.reverse()
|
$.add Updater.thread, nodes.reverse()
|
||||||
if scroll
|
if scroll
|
||||||
nodes[0].scrollIntoView()
|
nodes[0].scrollIntoView()
|
||||||
|
|
||||||
|
set: (name, text) ->
|
||||||
|
el = Updater[name]
|
||||||
|
if node = el.firstChild
|
||||||
|
# Prevent the creation of a new DOM Node
|
||||||
|
# by setting the text node's data.
|
||||||
|
node.data = text
|
||||||
|
else
|
||||||
|
el.textContent = text
|
||||||
|
|
||||||
getInterval: ->
|
getInterval: ->
|
||||||
i = +Conf['Interval']
|
i = +Conf['Interval']
|
||||||
j = Math.min @unsuccessfulFetchCount, 9
|
j = Math.min @unsuccessfulFetchCount, 9
|
||||||
@ -2414,20 +2422,20 @@ Updater =
|
|||||||
|
|
||||||
timeout: ->
|
timeout: ->
|
||||||
Updater.timeoutID = setTimeout Updater.timeout, 1000
|
Updater.timeoutID = setTimeout Updater.timeout, 1000
|
||||||
n = 1 + Number Updater.timer.textContent
|
n = 1 + Number Updater.timer.firstChild.data
|
||||||
|
|
||||||
if n is 0
|
if n is 0
|
||||||
Updater.update()
|
Updater.update()
|
||||||
else if n >= Updater.getInterval()
|
else if n >= Updater.getInterval()
|
||||||
Updater.unsuccessfulFetchCount++
|
Updater.unsuccessfulFetchCount++
|
||||||
Updater.count.textContent = 'Retry'
|
Updater.set 'count', 'Retry'
|
||||||
Updater.count.className = null
|
Updater.count.className = null
|
||||||
Updater.update()
|
Updater.update()
|
||||||
else
|
else
|
||||||
Updater.timer.textContent = n
|
Updater.set 'timer', n
|
||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
Updater.timer.textContent = 0
|
Updater.set 'timer', 0
|
||||||
Updater.request?.abort()
|
Updater.request?.abort()
|
||||||
# Fool the cache.
|
# Fool the cache.
|
||||||
url = location.pathname + '?' + Date.now()
|
url = location.pathname + '?' + Date.now()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user