User:Nx/wigo3.js

/*<![CDATA[*/

function wigoupdate(req,avg) { if (req.readyState == 4 && req.status == 200) {   arr = req.responseText.split(':'); span = document.getElementById(arr[0]); if (span) {     origvote = parseInt(span.innerHTML,10); if (avg != null && avg) { newvote = Math.round((arr[1]/arr[2])*100)/100; } else { newvote = arr[1]; }     if (origvote != newvote || span.title != arr[3]) { span.innerHTML = newvote; span.title = arr[3]; wigoinvalidate; }   }  } else { alert('An error occured: ' + req.responseText); } }

function wigoinvalidated(req) { if (req.readyState == 4 && req.status == 200) {   if (req.responseText != "ok") { alert('An error occured while invalidating the cache' + req.responseText); } } else { alert('An error occured: ' + req.responseText); }

}

function wigoinvalidate { sajax_do_call('wigoinvalidate',[wgPageName],wigoinvalidated); }

function wigovoteup(voteid) { sajax_do_call('wigovote',[voteid,1],wigoupdate); }

function wigovotedown(voteid) { sajax_do_call('wigovote',[voteid,-1],wigoupdate); }

function wigovotereset(voteid) { sajax_do_call('wigovote',[voteid,0],wigoupdate); }

function wigoupdateavg(req) { wigoupdate(req,true); }

function wigovotesend(voteid,val,min,max) { if (val < min || val > max) { alert('Invalid value'); } else if (voteid.substr(0,6) != 'slider') { alert('Invalid vote id'); } else { sajax_do_call('wigovote',[voteid,val,min,max],wigoupdateavg); } }

/*]]>*/