rg443

artfreelance.me grid (paging)

Jun 9th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tag="",pageSize=20,tag1=""; /* category/editors-choice/ popular-photos top-photos editors-choice top-sharing the-favourite-of-the-day portfolios */
  2. for (var i=1,t=new Date();i<=pageSize;i++) setTimeout(get_url,i*250,"http://users1.jabry.com/rg443/text.asp?url=http://artfreelance.me/"+tag1+"page/"+i+"/",parse1);
  3. if (!data1) {var data1=document.createElement("div");document.body.insertAdjacentElement("afterBegin",data1)}; data1.innerHTML="";data1.style.marginLeft="140px";data1.style.cursor="pointer"; data1.style.width="1260px"; data1.style.minHeight="30000";data1.style.overflowY="visible";
  4. if (!next1) {var next1=document.createElement("span");next1.innerText="more..."; var n=next1.style; n.font="16pt Arial";n.color="blue";n.cursor="pointer";n.marginLeft=data1.style.marginLeft; data1.insertAdjacentElement("AfterEnd",next1);}
  5.  
  6. function parse1(){
  7.   var a=this.substring(this.indexOf('<div id="content"')+1).match(/http:\/\/artfreelancedotorg.files.wordpress.com\/\S+\.jpg/gim),b=unique1(a).map(function(v){return '<img src="'+v+'?w=248&amp;h=330&amp;crop=1" style="width:248px;height:330px;margin:2px;"/>'});data1.insertAdjacentHTML("beforeEnd",b.join(""));
  8.   }
  9.  
  10. data1.onclick=function(e){
  11.    var e=e.srcElement||e.target;
  12.    if (e.tagName!="IMG") return;
  13.    // var tag=e.src.match(/(\d+)\/(\w{40})/);
  14.    // console.log(tag[1],tag[2])
  15.    var w=window.open("about:blank");w.location=e.src.match(/http\S+.jpg/)
  16.    }
  17.  
  18. var j=pageSize;
  19. next1.onclick=function(){
  20.    window.scroll(0,0); // data1.offsetTop
  21.    data1.innerHTML="";
  22.    for (var i=j,t=new Date();i<j+pageSize;i++) setTimeout(get_url,(i-j)*200,"http://users1.jabry.com/rg443/text.asp?url=http://artfreelance.me/page/"+i+"/",parse1);
  23.    document.title="artfreelance - " +j;
  24.    j+=pageSize;
  25.    }
  26.  
  27. document.onkeyup=function(e){
  28.    //console.log(e.which , e.keyCode,document.height,window.pageYOffset,window.innerHeight)
  29.    // eof && pgdn
  30.    if (e.keyCode==34 && (document.height-window.pageYOffset-window.innerHeight)==0){next1.onclick();console.log("more");}
  31.    }
  32. /*
  33. document.onmousewheel=function(e){
  34.   //console.log(e.wheelDelta);
  35.   if (e.wheelDelta<0 && (document.height-window.pageYOffset-window.innerHeight)==0){next1.onclick();console.log("more");}
  36. }
  37. */
  38. console.log()
  39.  
  40. function get_url(url,callback) {
  41.     var r=new XMLHttpRequest();
  42.     r.open("GET",url,true);
  43.     r.onreadystatechange=function(){
  44.        if (this.readyState==4 && this.status==200) callback.call(this.responseText);
  45.        }
  46.     r.send();      
  47.  
  48. }
  49. function unique1(a){for(var c=Object.create(null),d=[],b=a.length;b--;)c[a[b]]||(c[a[b]]=!0,d.push(a[b]));return d};
  50.  
  51. /* <div id="content" class="portfolios" style="display:none"> */
Add Comment
Please, Sign In to add comment