1//** Featured Content Slider script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com. 2//** May 2nd, 08'- Script rewritten and updated to 2.0. 3//** June 12th, 08'- Script updated to v 2.3, which adds the following features: 4 //1) Changed behavior of script to actually collapse the previous content when the active one is shown, instead of just tucking it underneath the later. 5 //2) Added setting to reveal a content either via "click" or "mouseover" of pagination links (default is former). 6 //3) Added public function for jumping to a particular slide within a Featured Content instance using an arbitrary link, for example. 7 8//** July 11th, 08'- Script updated to v 2.4: 9 //1) Added ability to select a particular slide when the page first loads using a URL parameter (ie: mypage.htm?myslider=4 to select 4th slide in "myslider") 10 //2) Fixed bug where the first slide disappears when the mouse clicks or mouses over it when page first loads. 11 12var featuredcontentslider={ 13 14//3 variables below you can customize if desired: 15ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="loading.gif" /> Fetching slider Contents. Please wait...</div>', 16bustajaxcache: true, //bust caching of external ajax page after 1st request? 17enablepersist: true, //persist to last content viewed when returning to page? 18 19settingcaches: {}, //object to cache "setting" object of each script instance 20 21jumpTo:function(fcsid, pagenumber){ //public function to go to a slide manually. 22 this.turnpage(this.settingcaches[fcsid], pagenumber) 23}, 24 25ajaxconnect:function(setting){ 26 var page_request = false 27 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) 28 try { 29 page_request = new ActiveXObject("Msxml2.XMLHTTP") 30 } 31 catch (e){ 32 try{ 33 page_request = new ActiveXObject("Microsoft.XMLHTTP") 34 } 35 catch (e){} 36 } 37 } 38 else if (window.XMLHttpRequest) // if Mozilla, Safari etc 39 page_request = new XMLHttpRequest() 40 else 41 return false 42 var pageurl=setting.contentsource[1] 43 page_request.onreadystatechange=function(){ 44 featuredcontentslider.ajaxpopulate(page_request, setting) 45 } 46 document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg 47 var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() 48 page_request.open('GET', pageurl+bustcache, true) 49 page_request.send(null) 50}, 51 52ajaxpopulate:function(page_request, setting){ 53 if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ 54 document.getElementById(setting.id).innerHTML=page_request.responseText 55 this.buildpaginate(setting) 56 } 57}, 58 59buildcontentdivs:function(setting){ 60 var alldivs=document.getElementById(setting.id).getElementsByTagName("div") 61 for (var i=0; i<alldivs.length; i++){ 62 if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv" 63 setting.contentdivs.push(alldivs[i]) 64 alldivs[i].style.display="none" //collapse all content DIVs to begin with 65 } 66 } 67}, 68 69buildpaginate:function(setting){ 70 this.buildcontentdivs(setting) 71 var sliderdiv=document.getElementById(setting.id) 72 var pdiv=document.getElementById("paginate-"+setting.id) 73 var phtml="" 74 var toc=setting.toc 75 var nextprev=setting.nextprev 76 if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){ 77 for (var i=1; i<=setting.contentdivs.length; i++){ 78 phtml+='<a href="#'+i+'" class="toc">'+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+'</a> ' 79 } 80 phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '') 81 pdiv.innerHTML=phtml 82 } 83 var pdivlinks=pdiv.getElementsByTagName("a") 84 var toclinkscount=0 //var to keep track of actual # of toc links 85 for (var i=0; i<pdivlinks.length; i++){ 86 if (this.css(pdivlinks[i], "toc", "check")){ 87 if (toclinkscount>setting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents) 88 pdivlinks[i].style.display="none" //hide this toc link 89 continue 90 } 91 pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link 92 pdivlinks[i][setting.revealtype]=function(){ 93 featuredcontentslider.turnpage(setting, this.getAttribute("rel")) 94 return false 95 } 96 setting.toclinks.push(pdivlinks[i]) 97 } 98 else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next" 99 pdivlinks[i].onclick=function(){ 100 featuredcontentslider.turnpage(setting, this.className) 101 return false 102 } 103 } 104 } 105 this.turnpage(setting, setting.currentpage, true) 106 if (setting.autorotate[0]){ //if auto rotate enabled 107 pdiv[setting.revealtype]=function(){ 108 featuredcontentslider.cleartimer(setting, window["fcsautorun"+sett
108ing.id]) 109 } 110 sliderdiv["onclick"]=function(){ //stop content slider when slides themselves are clicked on 111 featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) 112 } 113 setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*50) //add time to run fade animation (roughly) to delay between rotation 114 this.autorotate(setting) 115 } 116}, 117 118urlparamselect:function(fcsid){ 119 var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL 120 return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index 121}, 122 123turnpage:function(setting, thepage, autocall){ 124 var currentpage=setting.currentpage //current page # before change 125 var totalpages=setting.contentdivs.length 126 var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage) 127 turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage //test for out of bound and adjust 128 if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly 129 return 130 setting.currentpage=turntopage 131 setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex 132 this.cleartimer(setting, window["fcsfade"+setting.id]) 133 setting.cacheprevpage=setting.prevpage 134 if (setting.enablefade[0]==true){ 135 setting.curopacity=0 136 this.fadeup(setting) 137 } 138 if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete) 139 setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block") 140 setting.onChange(setting.prevpage, setting.currentpage) 141 } 142 setting.contentdivs[turntopage-1].style.visibility="visible" 143 setting.contentdivs[turntopage-1].style.display="block" 144 if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) 145 this.css(setting.toclinks[setting.prevpage-1], "selected", "remove") 146 if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) 147 this.css(setting.toclinks[turntopage-1], "selected", "add") 148 setting.prevpage=turntopage 149 if (this.enablepersist) 150 this.setCookie("fcspersist"+setting.id, turntopage) 151}, 152 153setopacity:function(setting, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between) 154 var targetobject=setting.contentdivs[setting.currentpage-1] 155 if (targetobject.filters && targetobject.filters[0]){ //IE syntax 156 if (typeof targetobject.filters[0].opacity=="number") //IE6 157 targetobject.filters[0].opacity=value*100 158 else //IE 5.5 159 targetobject.style.filter="alpha(opacity="+value*100+")" 160 } 161 else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax 162 targetobject.style.MozOpacity=value 163 else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax 164 targetobject.style.opacity=value 165 setting.curopacity=value 166}, 167 168fadeup:function(setting){ 169 if (setting.curopacity<1){ 170 this.setopacity(setting, setting.curopacity+setting.enablefade[1]) 171 window["fcsfade"+setting.id]=setTimeout(function(){featuredcontentslider.fadeup(setting)}, 50) 172 } 173 else{ //when fade is complete 174 if (setting.cacheprevpage!=setting.currentpage) //if previous content isn't the same as the current shown div (happens the first time the page loads/ script is run) 175 setting.contentdivs[setting.cacheprevpage-1].style.display="none" //collapse last content div shown (it was set to "block") 176 setting.onChange(setting.cacheprevpage, setting.currentpage) 177 } 178}, 179 180cleartimer:function(setting, timervar){ 181 if (typeof timervar!="undefined"){ 182 clearTimeout(timervar) 183 clearInterval(timervar) 184 if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div 185 setting.contentdivs[setting.cacheprevpage-1].style.display="none" 186 } 187 } 188}, 189 190css:function(el, targetclass, action){ 191 var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") 192 if (action=="check") 193 return needle.test(el.className) 194 else if (action=="remove") 195 el.className=el.className.replace(needle, "") 196 else if (action=="add") 197 el.className+=" "+targetclass 198}, 199 200autorotate:function(setting){
201 window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1]) 202}, 203 204getCookie:function(Name){ 205 var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair 206 if (document.cookie.match(re)) //if cookie found 207 return document.cookie.match(re)[0].split("=")[1] //return its value 208 return null 209}, 210 211setCookie:function(name, value){ 212 document.cookie = name+"="+value 213 214}, 215 216 217init:function(setting){ 218 var persistedpage=this.getCookie("fcspersist"+setting.id) || 1 219 var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index 220 this.settingcaches[setting.id]=setting //cache "setting" object 221 setting.contentdivs=[] 222 setting.toclinks=[] 223 setting.topzindex=0 224 setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1) 225 setting.prevpage=setting.currentpage 226 setting.revealtype="on"+(setting.revealtype || "click") 227 setting.curopacity=0 228 setting.onChange=setting.onChange || function(){} 229 if (setting.contentsource[0]=="inline") 230 this.buildpaginate(setting) 231 if (setting.contentsource[0]=="ajax") 232 this.ajaxconnect(setting) 233} 234 235}
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.