1// ------------------------------------------------------------------- 2// Ajax XML Ticker (txt file source) 3// Author: Dynamic Drive (http://www.dynamicdrive.com) 4// ------------------------------------------------------------------- 5 6////////////No need to edit beyond here////////////// 7 8function createAjaxObj(){ 9var httprequest=false 10if (window.XMLHttpRequest){ // if Mozilla, Safari etc 11httprequest=new XMLHttpRequest() 12if (httprequest.overrideMimeType) 13httprequest.overrideMimeType('text/xml') 14} 15else if (window.ActiveXObject){ // if IE 16try { 17httprequest=new ActiveXObject("Msxml2.XMLHTTP"); 18} 19catch (e){ 20try{ 21httprequest=new ActiveXObject("Microsoft.XMLHTTP"); 22} 23catch (e){} 24} 25} 26return httprequest 27} 28 29// ------------------------------------------------------------------- 30// Main Ajax Ticker Object function 31// ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot) 32// ------------------------------------------------------------------- 33 34function ajax_ticker(xmlfile, divId, divClass, delay, fadeornot){ 35this.xmlfile=xmlfile //Variable pointing to the local ticker xml file (txt) 36this.tickerid=divId //ID of ticker div to display information 37this.delay=delay //Delay between msg change, in miliseconds. 38this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is) 39this.pointer=0 40this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : "" 41if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled 42this.opacitysetting=0.2 //Opacity value when reset. Internal use. 43this.messages=[] //Arrays to hold each message of ticker 44this.ajaxobj=createAjaxObj()
45document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">Initializing ticker...</div></div>') 46this.getXMLfile() 47} 48 49// ------------------------------------------------------------------- 50// getXMLfile()- Use Ajax to fetch xml file (txt) 51// ------------------------------------------------------------------- 52 53ajax_ticker.prototype.getXMLfile=function(){ 54if (this.ajaxobj){ 55var instanceOfTicker=this 56var url=this.xmlfile+"?bustcache="+new Date().getTime() 57this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()} 58this.ajaxobj.open('GET', url, true) 59this.ajaxobj.send(null) 60} 61} 62 63// ------------------------------------------------------------------- 64// initialize()- Initialize ticker method. 65// -Gets contents of xml file and parse it using JavaScript DOM methods 66// ------------------------------------------------------------------- 67 68ajax_ticker.prototype.initialize=function(){ 69if (this.ajaxobj.readyState == 4){ //if request of file completed 70if (this.ajaxobj.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful 71this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages 72var xmldata=this.ajaxobj.responseText 73this.contentdiv.style.display="none" 74this.contentdiv.innerHTML=xmldata 75if (this.contentdiv.getElementsByTagName("div").length==0){ //if no messages were found 76this.contentdiv.innerHTML="<b>Error</b> fetching remote ticker file!" 77return 78} 79var instanceOfTicker=this 80document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1} 81document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0} 82if (window.attachEvent) //Clean up loose references in IE 83window.attachEvent("onunload", function(){instanceOfTicker.contentdiv=instanceOfTicker.ajaxobj=null}) 84//Cycle through XML object and store each message inside array 85for (var i=0; i<this.contentdiv.getElementsByTagName("div").length; i++){ 86if (this.contentdiv.getElementsByTagName("div")[i].className=="message") 87this.messages[this.messages.length]=this.contentdiv.getElementsByTagName("div")[i].innerHTML 88} 89this.contentdiv.innerHTML="" 90this.contentdiv.style.display="block" 91this.rotatemsg() 92} 93} 94} 95 96// ------------------------------------------------------------------- 97// rotatemsg()- Rotate through ticker messages and displays them 98// ------------------------------------------------------------------- 99 100ajax_ticker.prototype.rotatemsg=function(){ 101var instanceOfTicker=this 102if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it) 103setTimeout(function(){instanceOfTicker.rotatemsg()}, 100) 104else{ //else, construct item, show and rotate it! 105this.fadetransition("reset") //FADE EFFECT- RESET OPACITY 106this.contentdiv.innerHTML=this.messages[this.pointer] 107this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT 108this.pointer=(this.pointer<this.messages.length-1)? this.pointer+1 : 0 109setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container periodically 110} 111} 112 113// ------------------------------------------------------------------- 114// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox 115// ------------------------------------------------------------------- 116 117ajax_ticker.prototype.fadetransition=function(fadetype, timerid){ 118var contentdiv=this.contentdiv 119if (fadetype=="reset") 120this.opacitysetting=0.2 121if (contentdiv.filters && contentdiv.filters[0]){ 122if (typeof contentdiv.filters[0].opacity=="number") //IE6+ 123contentdiv.filters[0].opacity=this.opacitysetting*100 124else //IE 5.5 125contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")" 126} 127else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){ 128contentdiv.style.MozOpacity=this.opacitysetting 129} 130else 131this.opacitysetting=1 132if (fadetype=="up") 133this.opacitysetting+=0.1 134if (fadetype=="up" && this.opacitysetting>=1) 135clearInterval(this[timerid]) 136}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.