Advertisement
rg443

simple endless page example (1x)

Jan 31st, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tmr1=setInterval(function(){
  2.    var pos1=document.height-window.pageYOffset-window.innerHeight;
  3.    if (!loadState && pos1<=2000) {
  4.        console.log("fire");
  5.        
  6.        get_url(location.pathname+"?q="+tag + "&p=" + page2,function(){
  7.           loadState=false;
  8.           console.log(tag,page2);
  9.           var data2=this.toString().match(/<div id="data1" >(.*?)<\/div>/im);
  10.           data2&&data1.insertAdjacentHTML("beforeEnd",data2[1]);
  11.           });
  12.        loadState=1;
  13.        page2++;
  14.        setTimeout(get_url,1000,location.pathname+"?q="+tag + "&p=" + page2); // prefetch next page
  15.        }
  16.  
  17.  
  18.  
  19.  
  20. },300);var loadState=false,page2=page||2;
  21.  
  22.  
  23. function get_url(url,callback) {
  24.         var r=new XMLHttpRequest();
  25.         r.open("GET",url,true);
  26.         //r.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  27.         //r.setRequestHeader("Accept-Encoding", "gzip");
  28.         r.onreadystatechange=function(){
  29.        if (this.readyState==4 && this.status==200 && callback) callback.call(this.responseText);
  30.        }
  31.     r.send();      
  32.  
  33. }
  34.  
  35. function post_imgur(a,callback) {        
  36. var r=new XMLHttpRequest();
  37. r.open("POST","http://176.34.162.148/jabry/imgur1.asp?u=&b=",true);
  38. //r.open("POST","http://notebook1.lan:8000/jabry/imgur1.asp?u=&b=",true);
  39. r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  40. r.onreadystatechange=function(){if (this.readyState==4 && this.status==200) callback&&callback.call(this.responseText); }
  41. r.send("u=" + a.join(","));
  42. }
  43.  
  44. // post_imgur(data1.innerHTML.match(/\d+\.jpg/gim).map(function(v){return "http://imghost.1x.com/"+v}),function(){console.log("imgur:",this.toString().split("\n").length-1)});
  45. // post_imgur(data1.innerHTML.match(/\d+\/\w+/gim).map(function(v){return "http://pcdn.500px.net/"+v+"/4.jpg"}),function(){console.log("imgur:",this.toString().split("\n").length-1)});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement