Foros del Web » Programando para Internet » Javascript »

Como llamar esta funcion

Estas en el tema de Como llamar esta funcion en el foro de Javascript en Foros del Web. Que tal, siempre he querido hacer un ticker de RSS y en la reciente actualizacion de la pagina de apple tiene este. Para tomarlo como ...
  #1 (permalink)  
Antiguo 15/01/2008, 23:49
 
Fecha de Ingreso: enero-2008
Ubicación: Veracruz, MX
Mensajes: 3
Antigüedad: 16 años, 3 meses
Puntos: 0
Como llamar esta funcion

Que tal, siempre he querido hacer un ticker de RSS y en la reciente actualizacion de la pagina de apple tiene este. Para tomarlo como ejemplo ya que este funciona con prototype y me ha gustado mucho saque el codigo pero no he podido hacerlo funcionar, no se como llamar la funcion, se que va dentro del contenedor "ticker" pero dentro de este no se como llamarlo, ojala alguien me pueda ayudar, aqui el codigo:

Effect.DefaultOptions.duration = 0.3;
NewsTicker = Class.create();
Object.extend(NewsTicker.prototype, {

tickerDiv: "ticker",
tickerLocation: "main_lf",
tickerTitle: "news-link",
tickerLink: "http://www.apple.com/hotnews/",
feedURL: "http://www.apple.com/home/2008/ticker.rss",
pauseLength: 3500,
timer: 0,
currentTitle: 0,
items: null,
initialize: function() {

this.items = [];

new Ajax.Request(
this.feedURL, {
method: "get",
onSuccess: function(response) {
this.parseXML(response.responseXML);
this.buildTicker();
}.bind(this),
onFailure: function() {
console.log("Please visit http://www.apple.com/hotnews for the latest news and information on Apple.");
},
onException: function(req, err) {
// throw(err);
}
}
);
},

buildTicker: function() {
// replace the placeholder content with the first news title
if (this.items[this.currentTitle]) {
$(this.tickerTitle).innerHTML = this.items[this.currentTitle]['title'];
this.start();// start the timer if we have valid headlines
}
},

parseXML: function(xml) {
// build the array of news titles
$A(xml.getElementsByTagName("item")).each(function (item) {
title = item.getElementsByTagName("title")[0].childNodes[0].nodeValue;
var link = NewsTicker.tickerLink;
this.items.push({title: title, link: link});
}.bind(this));
},

start: function() {
this.interval = setInterval(this.showNext.bind(this), this.pauseLength);
},

stop: function() {
clearInterval(this.interval)
},

showNext: function() {

//determine next headline
if ( this.currentTitle < this.items.length-1 ) {
this.currentTitle = this.currentTitle+1;
} else {
this.currentTitle = 0;
}

new Effect.Fade('news-link', {
afterFinish: function() {
this.switchData();
new Effect.Appear('news-link'); }.bind(this)});

},

switchData: function() {
$(this.tickerTitle).setAttribute("href", this.tickerLink);
if (this.items[this.currentTitle]) {
$(this.tickerTitle).innerHTML = this.items[this.currentTitle]['title'];
}
}
});

Event.observe(window, 'load', function() {
h
});
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 17:24.