| |
<P><CODE>// ------------------------------------------------------------------- <BR>// Advanced RSS Ticker (Ajax invocation) core file <BR>// Author: Dynamic Drive (http://www.dynamicdrive.com) <BR>// ------------------------------------------------------------------- <BR><BR>//Relative URL syntax: <BR>var lastrssbridgeurl="lastrss/bridge.php" <BR><BR>//Absolute URL syntax. Uncomment below line if you wish to use an absolute reference: <BR>//var lastrssbridgeurl="http://"+window.location.hostname+"/lastrss/bridge.php" <BR><BR>////////////No need to edit beyond here////////////// <BR><BR>function createAjaxObj(){ <BR>var httprequest=false <BR>if (window.XMLHttpRequest){ // if Mozilla, Safari etc <BR>httprequest=new XMLHttpRequest() <BR>if (httprequest.overrideMimeType) <BR>httprequest.overrideMimeType('text/xml') <BR>} <BR>else if (window.ActiveXObject){ // if IE <BR>try { <BR>httprequest=new ActiveXObject("Msxml2.XMLHTTP"); <BR>} <BR>catch (e){ <BR>try{ <BR>httprequest=new ActiveXObject("Microsoft.XMLHTTP"); <BR>} <BR>catch (e){} <BR>} <BR>} <BR>return httprequest <BR>} <BR><BR>// ------------------------------------------------------------------- <BR>// Main RSS Ticker Object function <BR>// rssticker_ajax(RSS_id, cachetime, divId, divClass, delay, optionallogicswitch) <BR>// ------------------------------------------------------------------- <BR><BR>function rssticker_ajax(RSS_id, cachetime, divId, divClass, delay, logicswitch){ <BR>this.RSS_id=RSS_id //Array key indicating which RSS feed to display <BR>this.cachetime=cachetime //Time to cache feed, in minutes. 0=no cache. <BR>this.tickerid=divId //ID of ticker div to display information <BR>this.delay=delay //Delay between msg change, in miliseconds. <BR>this.logicswitch=(typeof logicswitch!="undefined")? logicswitch : "" <BR>this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is) <BR>this.pointer=0 <BR>this.opacitysetting=0.2 //Opacity value when reset. Internal use. <BR>this.title=[], this.link=[], this.description=[], this.pubdate=[] //Arrays to hold each component of an RSS item <BR>this.ajaxobj=createAjaxObj() <BR>document.write('<div id="'+divId+'" class="'+divClass+'" >Veri Yükleniyor...</div>') <BR>if (window.getComputedStyle) //detect if moz-opacity is defined in external CSS for specified class <BR>this.mozopacityisdefined=(window.getComputedStyle(document.getElementById(this.tickerid), "").getPropertyValue("-moz-opacity")==1)? 0 : 1 <BR>this.getAjaxcontent() <BR>} <BR><BR>// ------------------------------------------------------------------- <BR>// getAjaxcontent()- Makes asynchronous GET request to "bridge.php" with the supplied parameters <BR>// ------------------------------------------------------------------- <BR><BR>rssticker_ajax.prototype.getAjaxcontent=function(){ <BR>if (this.ajaxobj){ <BR>var instanceOfTicker=this <BR>var parameters="id="+encodeURIComponent(this.RSS_id)+"&cachetime="+this.cachetime+"&bustcache="+new Date().getTime() <BR>this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()} <BR>this.ajaxobj.open('GET', lastrssbridgeurl+"?"+parameters, true) <BR>this.ajaxobj.send(null) <BR>} <BR>} <BR><BR>// ------------------------------------------------------------------- <BR>// initialize()- Initialize ticker method. <BR>// -Gets contents of RSS content and parse it using JavaScript DOM methods <BR>// ------------------------------------------------------------------- <BR><BR>rssticker_ajax.prototype.initialize=function(){ <BR>if (this.ajaxobj.readyState == 4){ //if request of file completed <BR>if (this.ajaxobj.status==200){ //if request was successful <BR>var xmldata=this.ajaxobj.responseXML <BR>if(xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content <BR>document.getElementById(this.tickerid).innerHTML="<b>Error</b> fetching remote RSS feed!<br />"+this.ajaxobj.responseText <BR>return <BR>} <BR>var instanceOfTicker=this <BR>this.feeditems=xmldata.getElementsByTagName("item") <BR>//Cycle through RSS XML object and store each peice of an item inside a corresponding array <BR>for (var i=0; i<this.feeditems.length; i++){ <BR>this.title[i]=this.feeditems[i].getElementsByTagName("title")[0].firstChild.nodeValue <BR>this.link[i]=this.feeditems[i].getElementsByTagName("link")[0].firstChild.nodeValue <BR>this.description[i]=this.feeditems[i].getElementsByTagName("description")[0].firstChild.nodeValue <BR>this.pubdate[i]=this.feeditems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue <BR>} <BR>document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1} <BR>document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0} <BR>this.rotatemsg() <BR>} <BR>} <BR>} <BR><BR>// ------------------------------------------------------------------- <BR>// rotatemsg()- Rotate through RSS messages and displays them <BR>// ------------------------------------------------------------------- <BR><BR>rssticker_ajax.prototype.rotatemsg=function(){ <BR>var instanceOfTicker=this <BR>if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it) <BR>setTimeout(function(){instanceOfTicker.rotatemsg()}, 100) <BR>else{ //else, construct item, show and rotate it! <BR>var tickerDiv=document.getElementById(this.tickerid) <BR>var linktitle='<div class="rsstitle"><a href="'+this.link[this.pointer]+'">'+this.title[this.pointer]+'</a></div>' <BR>var description='<div class="rssdescription">'+this.description[this.pointer]+'</div>' <BR>var feeddate='<div class="rssdate">'+this.pubdate[this.pointer]+'</div>' <BR>if (this.logicswitch.indexOf("description")==-1) description="" <BR>if (this.logicswitch.indexOf("date")==-1) feeddate="" <BR>var tickercontent=linktitle+feeddate+description //STRING FOR FEED CONTENTS <BR>this.fadetransition("reset") //FADE EFFECT- RESET OPACITY <BR>tickerDiv.innerHTML=tickercontent <BR>this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT <BR>this.pointer=(this.pointer<this.feeditems.length-1)? this.pointer+1 : 0 <BR>setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container every second <BR>} <BR>} <BR><BR>// ------------------------------------------------------------------- <BR>// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox <BR>// ------------------------------------------------------------------- <BR><BR>rssticker_ajax.prototype.fadetransition=function(fadetype, timerid){ <BR>var tickerDiv=document.getElementById(this.tickerid) <BR>if (fadetype=="reset") <BR>this.opacitysetting=0.2 <BR>if (tickerDiv.filters && tickerDiv.filters[0]){ <BR>if (typeof tickerDiv.filters[0].opacity=="number") //IE6+ <BR>tickerDiv.filters[0].opacity=this.opacitysetting*100 <BR>else //IE 5.5 <BR>tickerDiv.style.filter="alpha(opacity="+this.opacitysetting*100+")" <BR>} <BR>else if (typeof tickerDiv.style.MozOpacity!="undefined" && this.mozopacityisdefined){ <BR>tickerDiv.style.MozOpacity=this.opacitysetting <BR>} <BR>if (fadetype=="up") <BR>this.opacitysetting+=0.2 <BR>if (fadetype=="up" && this.opacitysetting>=1) <BR>clearInterval(this[timerid]) <BR>} <BR> </CODE></P></BLOCKQUOTE> |
|