Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/02/2014, 09:23
RaulCDT
 
Fecha de Ingreso: febrero-2014
Ubicación: Murcia
Mensajes: 119
Antigüedad: 10 años, 3 meses
Puntos: 0
¿Para que sirve este codigo?

Quiero ver para que sirve este codigo que hace tiempo vi en una web porque creo que era para hacer un tipo scrool de noticias y ahora no se utilizarlo.

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.     //<!--
  3. (function() {
  4.     var addthis = document.createElement('script');
  5.     addthis.type = 'text/javascript';
  6.     addthis.async = true;
  7.     addthis.src = 'http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f157aaf28da46ac';
  8.     var s = document.getElementsByTagName('script')[0];
  9.     s.parentNode.insertBefore(addthis, s);
  10. })();
  11. window.fbAsyncInit = function() {
  12.     FB.init({
  13.         appId   : '176329475780885',
  14.         channelUrl : '//http://www.tuweb.com/channel.html', // Channel File
  15.         cookie  : true,
  16.         xfbml   : true,
  17.         oauth   : true
  18.     });
  19.  
  20.     FB.Event.subscribe('auth.login', function(response) {
  21.         window.location.reload();
  22.     });
  23.  
  24.     FB.Event.subscribe("auth.logout", function(response) {
  25.         window.location.reload();
  26.     });
  27. };
  28.  
  29. (function(d){
  30.     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
  31.     js = d.createElement('script'); js.id = id; js.async = true;
  32.     js.src = "//connect.facebook.net/es_ES/all.js";
  33.     d.getElementsByTagName('head')[0].appendChild(js);
  34. }(document));
  35. var sfs_url = 'http://sfs.tuweb.com';
  36. function switchTab(tab) {
  37.     // Remove active clases
  38.     $('ul#menu-events a.active').removeClass('active');
  39.  
  40.     _gaq.push(['_trackPageview', window.location.pathname + '/' + tab]);
  41.  
  42.     // Set as active and update text
  43.     var toActive = $('#tab-'+tab).addClass('active');
  44.  
  45.     // Hide shown layer
  46.     $('div.show').removeClass('show').addClass('hide');
  47.  
  48.     // Show right layer
  49.     $('#'+tab).removeClass('hide').addClass('show');
  50. };
  51.  
  52. $(document).ready(function() {
  53.  
  54.     /*
  55.      * News slideshow
  56.      */
  57.     var newsArray = $('#landings ul li');
  58.     var newsCount = newsArray.length;
  59.     var currentNews = 0;
  60.     var maxNews = 3;
  61.  
  62.     function triggerNextNews() {
  63.         setTimeout(switchNews, 6000);
  64.         //console.log('Triggering timer ' + currentNews);
  65.     };
  66.  
  67.     function switchNews() {
  68.         $('#landings ul li').first().remove();
  69.         if ((currentNews +1) < newsCount) {
  70.             currentNews++;
  71.         } else {
  72.             currentNews = 0;
  73.         }
  74.  
  75.         var news = newsArray[currentNews];
  76.         $('#landings ul').append(news);
  77.         triggerNextNews();
  78.     };
  79.  
  80.     $('#landings ul li').remove();
  81.     newsArray.each(function() {
  82.         $(this).removeClass('hide');
  83.     })
  84.     for (var i = 0; i <  maxNews; i++) {
  85.         if (i > newsCount) break;
  86.         $('#landings ul').append(newsArray[i]);
  87.         currentNews = i;
  88.     }
  89.     // Run
  90.     triggerNextNews();
  91. });
  92.     //-->
  93.  
  94. </script>

y la tabla donde estaban las noticias era así:

Código HTML:
Ver original
  1. <div id="landings">
  2.             <h2 class="small">Noticias</h2>
  3.             <ul>
  4.  
  5. <li class="hide">
  6. <img src=".jpg" class="fromdb" alt="tituloimagen"/>
  7. <a title="tituloenlace" href="enlace">Noticia1</a></li>
  8.  
  9. <li class="hide">
  10. <img src=".jpg" class="fromdb" alt="tituloimagen"/>
  11. <a title="tituloenlace" href="enlace">Noticia2</a></li>
  12.  
  13. <li class="hide">
  14. <img src=".jpg" class="fromdb" alt="tituloimagen"/>
  15. <a title="tituloenlace" href="enlace">Noticia3</a></li>
  16.  
  17. <li class="hide">
  18. <img src=".jpg" class="fromdb" alt="tituloimagen"/>
  19. <a title="tituloenlace" href="enlace">Noticia4</a></li>
  20.  
  21. <li class="hide">
  22. <img src=".jpg" class="fromdb" alt="tituloimagen"/>
  23. <a title="tituloenlace" href="enlace">Noticia5</a></li>
  24.  
  25. <li class="hide">
  26. <img src=".jpg" class="fromdb" alt="tituloimagen"/>
  27. <a title="tituloenlace" href="enlace">Noticia6</a></li>
  28.  
  29. </ul>        
  30.  
  31. </div>

¿Podrian ayudarme para hacerlo funcionar? ¿Que tengo que añadir o datos rellenar en el script?

Muchisimas gracias!!