Скрипт подсчёта кому чаще пишешь.
Код:
javascript:var f=[],friendsData,index=0,user=null,out={counter:0,init:function(){ge("content").innerHTML="";ge("content").appendChild(ce("img",{src:"/images/progress7.gif"},{paddingLeft:"240px"}));ge("header").innerHTML="<h1>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043b\u0438\u0447\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0438</h1>"},loaded:function(){ge("content").innerHTML="";var b=ce("div",{id:"sprogr"},{position:"relative",width:"100%",height:"30px",margin:"3px",
backgroundColor:"#DAE2E8"});b.appendChild(ce("div",{id:"sprogb"},{width:"0",height:"inherit",backgroundColor:"#45688E"}));b.appendChild(ce("div",{id:"scnt"},{position:"absolute",left:"10px",top:"7px",width:"200px",height:"inherit",color:"#fff",zIndex:69}));ge("content").appendChild(b)},progress:function(){ge("sprogb").style.width=100*index/f.length+"%";ge("scnt").innerHTML="\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439: "+this.counter},
debug:function(){},results:function(){ge("content").innerHTML="\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0436\u0434\u0430\u043b\u0438\u0441\u044c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u043e\u043d\u043e \u0442\u043e\u0433\u043e \u0441\u0442\u043e\u0438\u043b\u043e!<br/><br/>";var b=ce("table",{className:"wikiTable"});b.innerHTML+='<thead><th></th><th>\u0418\u043c\u044f</th><th onclick="javascript: calculation(\'\');" style="cursor: pointer">\u0412\u0441\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439</th><th onclick="javascript: calculation(\'out\');" style="cursor: pointer">\u0412\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438</th><th onclick="javascript: calculation(\'in\');" style="cursor: pointer">\u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438</th></thead>';
var c=ce("tbody");b.appendChild(c);for(var a=0;a<f.length;a++){var e=ce("tr"),d=ce("td",{innerHTML:a+1}),g=ce("td",{innerHTML:'<a href="id'+f[a].mid+'">'+f[a].name+"</a>"}),h=ce("td",{innerHTML:f[a].count}),i=ce("td",{innerHTML:f[a].count_outgoing}),j=ce("td",{innerHTML:f[a].count_incoming});e.appendChild(d);e.appendChild(g);e.appendChild(h);e.appendChild(i);e.appendChild(j);c.appendChild(e)}ge("content").appendChild(b)}};out.init();
Ajax.Post({url:"friends_ajax.php",onDone:function(b,c){friendsData=eval("("+c+")");for(var a=0;a<friendsData.friends.length;a++){f.push({mid:friendsData.friends[a][0],name:friendsData.friends[a][1],count:-1,count_incoming:-1,count_outgoing:-1});out.debug(friendsData.friends[a][0]+" - "+friendsData.friends[a][1])}out.loaded();user=f[index++];countMessagesFor()}});
function countMessagesFor(){var b=new Ajax,c=(new Date).getTime();b.onDone=function(a,e){var d=ce("div");d.innerHTML=e;user.count=d.getElementsByClassName("message_shown").length;user.count_incoming=d.getElementsByClassName("incoming").length;user.count_outgoing=d.getElementsByClassName("outgoing").length;out.debug(user.name+": "+user.count+" ("+user.count_incoming+" / "+user.count_outgoing+")");out.counter+=user.count;out.progress();user=f[index++];if(index<=f.length){d=(new Date).getTime()-c;if(d<
1500){out.debug("timeout: "+(1500-d)+"ms");setTimeout("countMessagesFor()",1500-d)}else countMessagesFor()}else calculation("")};b.post("/mail.php",{act:"history",mid:user.mid,offset:-1})}function calculation(b){if(b=="out")f.sort(function(c,a){return a.count_outgoing-c.count_outgoing});else b=="in"?f.sort(function(c,a){return a.count_incoming-c.count_incoming}):f.sort(function(c,a){return a.count-c.count});for(b=0;b<10;b++)out.debug(f[b].name+": "+f[b].count);out.results()};
|