Sup!
Ehm... das ganze vielleicht noch mal in lesbar:
function threadinfo(node,time) {
this.node = node;
this.time = time;
}
function sortthreads(a,b) {
// alert(a.time - b.time);
return (b.time - a.time);
}
function check(){
dt = document.title;
rn=document.getElementById("root");
non = rn.childNodes.length;
real_thread_list = new Array();
realthreads = new Array();
threads = 0;
for (i=0;i<non;i++) {
document.title=dt +"BioSorting - Phase 1 - ("+ Math.floor((i/non) * 100) + "%)";
if (rn.childNodes.item(i).nodeType == 1) {
a = analyse_thread_get_latest_date(rn.childNodes.item(i));
if (a) {
real_thread_list[threads] = i;
realthreads[threads++] = new threadinfo(rn.childNodes.item(i).cloneNode(1),a);
}
}
}
realthreads.sort(sortthreads);
for (i=0; i < threads; i++) {
document.title=dt +"BioSorting - Phase 2 - ("+ Math.floor((i/threads) * 100) + "%)";
rn.replaceChild(realthreads[i].node,rn.childNodes.item(real_thread_list[i]));
}
document.title=dt + " - BioSorted - most active threads first"
}
function analyse_thread_get_latest_date(node) {
if (node.childNodes.item(0).nodeType == 3) return false;
var content = node.innerHTML;
var timearray = new Array();
var myregexp = /</b>, (\d{2}). (\d{2}). (\d{4}), (\d{2}):(\d{2}) /;
results = content.match(/</b>, \d{2}. \d{2}. \d{4}, \d{2}:\d{2} /g);
if (results) {
for (a = 0; a<results.length; a++) {
myregexp.exec(results[a]);
timearray[a] = new Date(RegExp.$3,RegExp.$2,RegExp.$1,RegExp.$4,RegExp.$5,0);
}
} else {
return false;
}
timearray.sort();
// alert(timearray[timearray.length-1]);
return timearray[timearray.length-1];
}
check();
Ich habe auch mittlerweile das ungute Gefühl entwickelt, dass es nicht immer funktioniert - aber was erwartet man von einer ersten Version ;-)
Gruesse,
Bio
Tötet DJ Ötzi! (Nicht wirklich!)