Advertisement
rg443

picsarus simple thumbnail grid

Feb 10th, 2013
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var r=new XMLHttpRequest();
  2. r.open("GET","picsarus-ps.txt")
  3. r.onreadystatechange=function(){
  4.    if (this.readyState!=4) return;
  5.    if (this.status!=200) {console.log(this.status,this.statusText);return -1}
  6.    var s=this.responseText;
  7.    var a=[],h={};
  8.    s.match(/(\w+) (\S+)/g).forEach(function(v){
  9.       var x=v.match(/(\w+) (.*)/);
  10.       if(!h.hasOwnProperty(x[2])){
  11.          a.push(x[1]);
  12.          h[x[2]]=x[1];
  13.          }
  14.    });
  15.    
  16.    window.il=a.join(" ");
  17.    window.page1=~~(a.length/1000)+1;
  18.    var b=il.match(/\w+/g).map(function(v,i){return '<img src="http://127.0.0.1/wp1/www.picsarus.com/'+v+'.jpg?resize=280,280" alt="" width="280" height="280"/>' });
  19.    document.body.insertAdjacentHTML("beforeEnd","<div id=\"data1\">"+ b.slice(0,1000).join("") +"</div>");
  20.    }
  21. r.send();
  22.  
  23. function show_page(page)  {
  24.    var d=document.getElementById("data1"); if(!d) {d=document.createElement("div");d.id="data1"; document.body.insertAdjacentElement("beforeEnd",d);}
  25.    var pageSize=1000;
  26.    if (!il) return -1;
  27.    
  28.    var b=il.match(/\w+/g).map(function(v,i){return '<img src="http://127.0.0.'+ ((i%10)+1)+'/wp1/www.picsarus.com/'+v+'.jpg?resize=280,280" alt="" width="280" height="280"/>' });
  29.    d.innerHTML= b.slice((page-1)*pageSize,page*pageSize).join("");
  30.  
  31. }
  32. var nav1=document.createElement("A");nav1.href="#";nav1.innerText=" Next "; nav1.onclick=function(){if(!page1||page1<1)page1=52; window.stop&&window.stop();show_page(page1--);this.title=page1;return false;};document.body.insertAdjacentElement("afterBegin",nav1);
  33. // show_page(page1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement