ഉപയോക്താവ്:Peringz/depth
function addLoadEvent(func) { if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func); }
function GetStats() { var element = document.createElement("div"); element.setAttribute("id","Text1"); var body = document.getElementById('bodyContent'); body.appendChild(element);
var url = 'http://ml.wikipedia.org/wiki/Special:Statistics?action=raw'; var ajax; try { ajax = new XMLHTTPRequest(); } catch(e) { ajax = new ActiveXObject("Microsoft.XMLHTTP"); } ajax.onreadystatechange = function() { var txt = document.getElementById('Text1');
txt.innerText = 'working...';
if (ajax.readyState == 4) { if (ajax.status == 200) { var stats = ajax.responseText.split(';'); var total, good, edits, depth; for (i=0; i<stats.length; i++) { var list = stats[i].split('='); switch(list[0]) { case 'total': total = list[1]; break; case 'good': good = list[1]; break; case 'edits': edits = list[1]; break; default: break; } } depth = (edits/good) * ((total-good)/good); txt.innerText = 'depth of ml.wikipedia: ' + depth; } else txt.innerText = 'can not retrieve data'; } }; ajax.open('GET',url,true); ajax.send(null); } addLoadEvent(GetStats);