Foros del Web » Programando para Internet » Jquery »

Traducir función JS a jQuery

Estas en el tema de Traducir función JS a jQuery en el foro de Jquery en Foros del Web. Hola, tengo una función hecha en javascript para lograr un efecto de scroll infinito que me gustaría traducir a jQuery, debido a que (aunque está ...
  #1 (permalink)  
Antiguo 18/04/2014, 10:19
 
Fecha de Ingreso: abril-2014
Mensajes: 72
Antigüedad: 9 años, 11 meses
Puntos: 5
Traducir función JS a jQuery

Hola, tengo una función hecha en javascript para lograr un efecto de scroll infinito que me gustaría traducir a jQuery, debido a que (aunque está funcionando bien) de no traducirla tendría que hacer un cruce entre JS y jQuery que hasta ahora me ha resultado imposible... y la verdad... no sé nada de jQuery y debo resolver esto rápido (me vi obligado tumbar la página poner la página hasta arreglar ese bug ).

Bueno, aquí está mi función JS:
Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.     window.onscroll = scroll;
  3.        
  4.     //setInterval('contador()',5000);
  5.        
  6.     function scroll(){
  7.                    
  8.         // declarar variables de body y html
  9.         var body = document.body,
  10.         html = document.documentElement;
  11.         // declarar variable height igual a la mayor de las alturas para todos los navegadores
  12.         var height = Math.max( body.scrollHeight, body.offsetHeight,
  13.         html.clientHeight, html.scrollHeight, html.offsetHeight );
  14.            
  15.         // ver si el scroll esta a una altura que se empieza a ver las estadisticas o el pie de pagina.
  16.         var stats = document.getElementById('contact').offsetHeight;
  17.         var footer = document.getElementById('footer').offsetHeight;
  18.         var pantalla = window.innerHeight;
  19.            
  20.            
  21.         if ((parseInt(height)-parseInt(stats)-parseInt(footer)-parseInt(pantalla)) <= window.pageYOffset){
  22.                
  23.             // traer mas contenido nuevo
  24.             refreshPosts();
  25.         }
  26.     }
  27.  
  28.     function refreshPosts(){
  29.        
  30.         if(document.getElementById("canRefreshWall").value == 1){
  31.  
  32.             // declarar variable start igual a la cantidad de post en el muro
  33.             var start = 0;
  34.             var numDiv = document.getElementsByTagName("div");
  35.             for (i=0; ele = numDiv[i]; i++){
  36.                 if (ele.className == 'photo-holder'){
  37.                     start++;
  38.                 }
  39.             }
  40.                
  41.             var filter = "<?php echo $_GET['filter']; ?>";
  42.                
  43.             // Ajax para cargar post antiguos
  44.             var OBJrefreshAllPosts=new XMLHttpRequest();
  45.             OBJrefreshAllPosts.onreadystatechange=function()
  46.               {
  47.               if (OBJrefreshAllPosts.readyState==4 && OBJrefreshAllPosts.status==200)
  48.                 {
  49.                 document.getElementById("work-items").innerHTML = document.getElementById("work-items").innerHTML + OBJrefreshAllPosts.responseText;
  50.                 }
  51.               }
  52.             OBJrefreshAllPosts.open("GET","system/ajax/showVideos.php?filter="+filter+"&start="+start,true);
  53.             OBJrefreshAllPosts.send();
  54.                
  55.             // Evitar que siga refrescando
  56.             document.getElementById("canRefreshWall").value = 0;
  57.             setTimeout(function(){document.getElementById("canRefreshWall").value = 1;}, 4000);
  58.             setTimeout( colorBoxx(), 4000); // colorBoxx() es una función hecha en jQuery
  59.         }      
  60.     }
  61. </script>

Espero me puedan ayudar, y gracias por anticipado.

Última edición por zyxer; 18/04/2014 a las 10:57

Etiquetas: js, traducir
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:34.