1
0
Fork 0
XDCCParser-Global/packlist.js

2 lines
6.4 KiB
JavaScript
Raw Permalink Normal View History

2013-08-06 08:27:11 -07:00
function p(){this.k=new Array();this.lastType=0;this.lastValue="";this.url="";this.init=function(url){this.url=url;this.table=document.getElementById('listtable');this.status=document.getElementById('status');this.searchdiv=document.getElementById('searchdiv');this.listname=document.getElementById('listname');this.tablehead="<table cellspacing='0' id='listtable'><tr class='animeColumn'><th class='number'>Bot <a href='javascript:p.k.sort(p.botDesc);p.flush();'>&#8593;</a>&nbsp;&nbsp;<a href='javascript:p.k.sort(p.botAsc);p.flush();'>&#8595;</a></th><th class='number'>Pack <a href='javascript:p.k.sort(p.numberDesc);p.flush();'>&#8593;</a>&nbsp;&nbsp;<a href='javascript:p.k.sort(p.numberAsc);p.flush();'>&#8595;</a></th><th class='number'>Size <a href='javascript:p.k.sort(p.sizeDesc);p.flush();'>&#8593;</a>&nbsp;&nbsp;<a href='javascript:p.k.sort(p.sizeAsc);p.flush();'>&#8595;</a></th><th class='name'>Filename <a href='javascript:p.k.sort(p.nameDesc);p.flush();'>&#8593;</a>&nbsp;&nbsp;<a href='javascript:p.k.sort(p.nameAsc);p.flush();'>&#8595;</a></th></tr>";this.search()};this.ajax_init=function(){try{this.ajax_request=new XMLHttpRequest()}catch(trymicrosoft){try{this.ajax_request=new ActiveXObject("Msxml2.XMLHTTP")}catch(othermicrosoft){try{this.ajax_request=new ActiveXObject("Microsoft.XMLHTTP")}catch(failed){this.ajax_request=null}}}if(!this.ajax_request)alert("Sorry, your browser is to old. To use this page, please make yourself happier and download a newer browser.")};this.flush=function(){var buffer=this.tablehead;if(this.k.length<1){buffer+="<tr class='anime0' id='none' ><td class='none' colspan='4'>No packs found.</td></tr>"}else{for(i=0;i<this.k.length;i++){var size=(this.k[i]['s']==0)?"<1":this.k[i]['s'];size+="M";buffer+="<tr class='anime"+(i%2)+"' onclick=\"p.genCommand('"+this.k[i]['b']+"',"+this.k[i]['n']+");\"><td class='number'>"+this.k[i]['b']+"</td><td class='number'>"+this.k[i]['n']+"</td><td class='number'>"+size+"</td><td class='name'>"+this.k[i]['f']+"</td></tr>"}}buffer+="</table>";this.listname.innerHTML=this.getLastName();this.table.innerHTML=buffer;this.status.style.display='none'};this.getLastName=function(){var name=(this.lastType==1)?"Search: ":"Bot: ";name+=this.lastValue;name+=(this.lastType!=1)?' [<a href="rss.php?nick='+this.lastValue+'">rss</a>]':"";return name};this.getLastURI=function(){var param=(this.lastType==1)?"?search=":"?nick=";param+=this.lastValue;prompt('Permalink:',this.url+param)};this.genCommand=function(nick,pack){prompt('Paste this in your irc client:','/msg '+nick+' xdcc send #'+pack)};this.search=function(){if(document.getElementById('search').value!=""&&document.getElementById('search').value!=" "){var search=document.getElementById('search').value.replace(/\+/ig,"%2B");this.request("t="+search);this.lastType=1;this.lastValue=search}else{this.table.innerHTML=this.tablehead+"<tr class='anime0' id='start'><td class='none' colspan='4'>Please select a bot or enter search terms to start.</td></tr></table>"}};this.nickPacks=function(nick){this.request("nick="+nick);this.lastType=2;this.lastValue=nick};this.numberAsc=function(a,b){var x=a.n;var y=b.n;return((x<y)?-1:((x>y)?1:0))};this.numberDesc=function(a,b){var x=a.n;var y=b.n;return((x<y)?1:((x>y)?-1:0))};this.sizeAsc=function(a,b){var x=a.s;var y=b.s;return((x<y)?-1:((x>y)?1:0))};this.sizeDesc=function(a,b){var x=a.s;var y=b.s;return((x<y)?1:((x>y)?-1:0))};this.nameAsc=function(a,b){var x=a.f.toLowerCase();var y=b.f.toLowerCase();return((x<y)?-1:((x>y)?1:0))};this.nameDesc=function(a,b){var x=a.f.toLowerCase();var y=b.f.toLowerCase();return((x<y)?1:((x>y)?-1:0))};this.botAsc=function(a,b){var x=a.b.toLowerCase();var y=b.b.toLowerCase();return((x<y)?-1:((x>y)?1:0))};this.botDesc=function(a,b){var x=a.b.toLowerCase();var y=b.b.toLowerCase();return((x<y)?1:((x>y)?-1:0))};this.request=function(request){request="search.php?"+request;this.center_status();this.ajax_init();this.ajax_request.onreadystatechange=this.ajax_callback;this.ajax_request.open("GET",request,true);this.ajax_request.send(null);this.inited=true};this.ajax_call