Increase the retry timeout value by 10 seconds at each retry, up to 120 seconds. Reset on succesful connection.

This commit is contained in:
Nicolas Stepien 2011-12-14 11:01:17 +01:00
parent f07da722c7
commit 0e7d56b002
2 changed files with 12 additions and 6 deletions

View File

@ -1996,6 +1996,7 @@
} }
} }
$.add(d.body, dialog); $.add(d.body, dialog);
updater.retryCoef = 10;
return updater.lastModified = 0; return updater.lastModified = 0;
}, },
cb: { cb: {
@ -2036,6 +2037,7 @@
Favicon.update(); Favicon.update();
return; return;
} }
updater.retryCoef = 10;
updater.timer.textContent = '-' + conf['Interval']; updater.timer.textContent = '-' + conf['Interval'];
/* /*
Status Code 304: Not modified Status Code 304: Not modified
@ -2055,7 +2057,7 @@
innerHTML: this.responseText innerHTML: this.responseText
}); });
if ($('title', body).textContent === '4chan - Banned') { if ($('title', body).textContent === '4chan - Banned') {
updater.count.textContent = 'banned'; updater.count.textContent = 'Banned';
updater.count.className = 'error'; updater.count.className = 'error';
return; return;
} }
@ -2087,14 +2089,15 @@
n = 1 + Number(updater.timer.textContent); n = 1 + Number(updater.timer.textContent);
if (n === 0) { if (n === 0) {
return updater.update(); return updater.update();
} else if (n === 10) { } else if (n === updater.retryCoef) {
updater.retryCoef += 10 * (updater.retryCoef < 120);
return updater.retry(); return updater.retry();
} else { } else {
return updater.timer.textContent = n; return updater.timer.textContent = n;
} }
}, },
retry: function() { retry: function() {
updater.count.textContent = 'retry'; updater.count.textContent = 'Retry';
updater.count.className = ''; updater.count.className = '';
return updater.update(); return updater.update();
}, },

View File

@ -1593,6 +1593,7 @@ updater =
$.add d.body, dialog $.add d.body, dialog
updater.retryCoef = 10
updater.lastModified = 0 updater.lastModified = 0
cb: cb:
@ -1625,6 +1626,7 @@ updater =
Favicon.update() Favicon.update()
return return
updater.retryCoef = 10
updater.timer.textContent = '-' + conf['Interval'] updater.timer.textContent = '-' + conf['Interval']
### ###
@ -1645,7 +1647,7 @@ updater =
#this only works on Chrome because of cross origin policy #this only works on Chrome because of cross origin policy
if $('title', body).textContent is '4chan - Banned' if $('title', body).textContent is '4chan - Banned'
updater.count.textContent = 'banned' updater.count.textContent = 'Banned'
updater.count.className = 'error' updater.count.className = 'error'
return return
@ -1675,13 +1677,14 @@ updater =
if n is 0 if n is 0
updater.update() updater.update()
else if n is 10 else if n is updater.retryCoef
updater.retryCoef += 10 * (updater.retryCoef < 120)
updater.retry() updater.retry()
else else
updater.timer.textContent = n updater.timer.textContent = n
retry: -> retry: ->
updater.count.textContent = 'retry' updater.count.textContent = 'Retry'
updater.count.className = '' updater.count.className = ''
updater.update() updater.update()