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