I was tired that my client always hung after working for some hours and decided to code little hack. Now it seems to me its working much smoother.
Sorry, but i am no way a programmer, so could some gurus look at it? It is very rude attempt to regulate connected peers.
I added two functions in activePeers.html into "function initialize()"
Original code:
function initialize() {
setInterval(function() {
var i, time = (new Date()).getTime(), element;
for (i = 0; i < downloadingDeadlines.length; i++) {
if (downloadingDeadlines[i] > 0 && downloadingDeadlines[i] <= time) {
element = document.getElementById("downloading" + i);
if (element != null) {
element.className = "disabledDownloading";
}
downloadingDeadlines[i] = 0;
}
}
for (i = 0; i < uploadingDeadlines.length; i++) {
if (uploadingDeadlines[i] > 0 && uploadingDeadlines[i] <= time) {
element = document.getElementById("uploading" + i);
if (element != null) {
element.className = "disabledUploading";
}
uploadingDeadlines[i] = 0;
}
}
}, 100);
}
And with my hack:
function initialize() {
setInterval(function() {
var i, time = (new Date()).getTime(), element;
for (i = 0; i < downloadingDeadlines.length; i++) {
if (downloadingDeadlines[i] > 0 && downloadingDeadlines[i] <= time) {
element = document.getElementById("downloading" + i);
if (element != null) {
element.className = "disabledDownloading";
}
downloadingDeadlines[i] = 0;
}
}
for (i = 0; i < uploadingDeadlines.length; i++) {
if (uploadingDeadlines[i] > 0 && uploadingDeadlines[i] <= time) {
element = document.getElementById("uploading" + i);
if (element != null) {
element.className = "disabledUploading";
}
uploadingDeadlines[i] = 0;
}
}
}, 100);
setInterval(function() {
var ev = new Event("click");
var p = document.getElementById("peers");
for (var k = 0; k < p.rows.length; k++) {
if (p.rows[k].cells[0].className == "disconnected" || p.rows[k].cells[4].className == "disabledWeight") p.rows[k].cells[12].dispatchEvent(ev);
}
}, 60000);
setInterval(function() {
var ev = new Event("click");
var p = document.getElementById("peers");
for (var k = 0; k < p.rows.length; k=k + 2) {
p.rows[k].cells[12].dispatchEvent(ev);
}
}, 300000);
}
Can anyone comment on this?