Advertisement
Guest User

LDView Parts List Sorter v1.1s

a guest
Feb 24th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. javascript:(function(d){var n,m,i,c='Sorted by Stephen\'s LDView Parts List Sorter v1.1s';if(d.body.id=='LDVS'){alert('Already Run');return;}d.body.id='LDVS';function ga(n,m,l){if(n.innerHTML==l)n.innerHTML='<a href=%22#%22 onclick=%22Resort('+m+');return false;%22>'+l+'</a>';};n=d.getElementsByTagName('th');i=n.length;while(i--){if(n[i].className=='title')n[i].title=c;ga(n[i],1,'Quantity');ga(n[i],2,'Part');ga(n[i],3,'Color');ga(n[i],4,'Description');}i=0;n=d.getElementsByTagName('tbody')[1].firstChild;while(n){if(n.tagName=='TR'){i++;m=n.firstChild;while(m){c=m.className;if(m.tagName=='TD'){if(c==''){if(!m.innerHTML.match(/ /)){m.className='xpart';m.innerHTML='<span>'+m.innerHTML+'</span>';m.id='p'+i;}else if(!m.innerHTML.match(/\n/))m.className='xdesc';}else if(c=='image')m.id='i'+i;else if(c=='colorNumber')m.id='c'+i;}m=m.nextSibling;}}n=n.nextSibling;}var s=d.createElement('script');s.type='text/javascript';s.text='function Resort(m){var o,t,n,r,i;function gk(f,n){n=n.firstChild;while(n){i=n.innerHTML;o=n.className;if((f==1)&&(o==\'quantity\'))return parseInt(i);if((f==2)&&(o==\'xpart\'))return n.firstChild.innerHTML;if((f==3)&&(o==\'colorNumber\'))return i[0]==\'#\'?parseInt(i.substr(1),16):parseInt(i.replace(/[^\\-\\d]*/g,\'\'));if((f==4)&&(o==\'xdesc\'))return i;n=n.nextSibling;}return 0;}function sorter(f,r){return function(a,b){var at=parseInt(a.title),bt=parseInt(b.title);return a=gk(f,a),b=gk(f,b),a!=b?r*((a>b)-(b>a)):at>bt?1:-1;}}t=document.getElementsByTagName(\'tbody\')[1];n=t.firstChild;var r=new Array();i=1;while(n){o=n;n=n.nextSibling;if((o.tagName==\'TR\')&&(!o.innerHTML.match(/list generated by/))){o.title=i++;r.push(t.removeChild(o));}}try{if(m==om)m=-m;}catch(e){}om=m;r.sort(sorter(m<0?-m:m,m<0?-1:1));n=r.length;while(n--){r[n].removeAttribute(\'title\');t.insertBefore(r[n],t.firstChild);}}';d.getElementsByTagName('head')[0].appendChild(s);})(document);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement