1//** Featured Content Slider script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com) 2//** Last updated: Nov 3rd- 07- Added optional fade transition effect. 3 4////Ajax related settings 5var csbustcachevar=0 //bust potential caching of external pages after initial Ajax request? (1=yes, 0=no) 6var enabletransition=1 //enable fade into view transition effect? (1=yes, 0=no) 7var csloadstatustext="<img src='indexelem_files/loading.gif' /> Betöltés..." //HTML to indicate Ajax page is being fetched 8var csexternalfiles=[] //External .css or .js files to load to style the external content(s), if any. Separate multiple files with comma ie: ["cat.css", dog.js"] 9 10////NO NEED TO EDIT BELOW//////////////////////// 11var enablepersist=true 12var slidernodes=new Object() //Object array to store references to each content slider's DIV containers (<div class="contentdiv">) 13var csloadedobjects="" //Variable to store file names of .js/.css files already loaded (if Ajax is used) 14 15function ContentSlider(sliderid, autorun, customPaginateText, customNextText){ 16 var slider=document.getElementById(sliderid) 17 if (typeof customPaginateText!="undefined" && customPaginateText!="") //Custom array of pagination links text defined? 18 slider.paginateText=customPaginateText 19 if (typeof customNextText!="undefined" && customNextText!="") //Custom HTML for "Next" link defined? 20 slider.nextText=customNextText 21 slidernodes[sliderid]=[] //Array to store references to this content slider's DIV containers (<div class="contentdiv">) 22 ContentSlider.loadobjects(csexternalfiles) //Load external .js and .css files, if any 23 var alldivs=slider.getElementsByTagName("div") 24 for (var i=0; i<alldivs.length; i++){ 25 if (alldivs[i].className=="opacitylayer") 26 slider.opacitylayer=alldivs[i] 27 else if (alldivs[i].className=="contentdiv"){ 28 slidernodes[sliderid].push(alldivs[i]) //add this DIV reference to array 29 if (typeof alldivs[i].getAttribute("rel")=="string") //If get this DIV's content via Ajax (rel attr contains path to external page) 30 ContentSlider.ajaxpage(alldivs[i].getAttribute("rel"), alldivs[i]) 31 } 32 } 33 ContentSlider.buildpagination(sliderid) 34 var loadfirstcontent=true 35 if (enablepersist && getCookie(sliderid)!=""){ //if enablepersist is true and cookie contains corresponding value for slider 36 var cookieval=getCookie(sliderid).split(":") //process cookie value ([sliderid, int_pagenumber (div content to jump to)] 37 if (document.getElementById(cookieval[0])!=null && typeof slidernodes[sliderid][cookieval[1]]!="undefined"){ //check cookie value for validity 38 ContentSlider.turnpage(cookieval[0], parseInt(cookieval[1])) //restore content slider's last shown DIV 39 loadfirstcontent=false 40 } 41 } 42 if (loadfirstcontent==true) //if enablepersist is false, or cookie value doesn't contain valid value for some reason (ie: user modified the structure of the HTML) 43 ContentSlider.turnpage(sliderid, 0) //Display first DIV within slider 44 if (typeof autorun=="number" && autorun>0) //if autorun parameter (int_miliseconds) is defined, fire auto run sequence 45 window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorun)}, autorun) 46} 47 48ContentSlider.buildpagination=function(sliderid){ 49 var slider=document.getElementById(sliderid) 50 var paginatediv=document.getElementById("paginate-"+sliderid) //reference corresponding pagination DIV for slider 51 var pcontent="" 52 for (var i=0; i<slidernodes[sliderid].length; i++) //For each DIV within slider, generate a pagination link 53 pcontent+='<a href="#" onClick=\"ContentSlider.turnpage(\''+sliderid+'\', '+i+'); return false\">'+(slider.paginateText? slider.paginateText[i] : i+1)+'</a> ' 54 55 paginatediv.innerHTML=pcontent 56 paginatediv.onclick=function(){ //cancel auto run sequence (if defined) when user clicks on pagination DIV 57 if (typeof window[sliderid+"timer"]!="undefined") 58 clearTimeout(window[sliderid+"timer"]) 59 } 60} 61 62ContentSlider.turnpage=function(sliderid, thepage){ 63 var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //gather pagination links 64 for (var i=0; i<slidernodes[sliderid].length; i++){ //For each DIV within slider 65 paginatelinks[i].className="" //empty corresponding pagination link's class
65name 66 slidernodes[sliderid][i].style.display="none" //hide DIV 67 } 68 paginatelinks[thepage].className="selected" //for selected DIV, set corresponding pagination link's class name 69 if (enabletransition){ 70 if (window[sliderid+"fadetimer"]) 71 clearTimeout(window[sliderid+"fadetimer"]) 72 this.setopacity(sliderid, 0.1) 73 } 74 slidernodes[sliderid][thepage].style.display="block" //show selected DIV 75 if (enabletransition) 76 this.fadeup(sliderid, thepage) 77 //Set "Next" pagination link's (last link within pagination DIV) "rel" attribute to the next DIV number to show 78 paginatelinks[paginatelinks.length-1].setAttribute("rel", thenextpage=(thepage<paginatelinks.length-2)? thepage+1 : 0) 79 if (enablepersist) 80 setCookie(sliderid, sliderid+":"+thepage) 81} 82 83ContentSlider.autoturnpage=function(sliderid, autorunperiod){ 84 var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //Get pagination links 85 var nextpagenumber=parseInt(paginatelinks[paginatelinks.length-1].getAttribute("rel")) //Get page number of next DIV to show 86 ContentSlider.turnpage(sliderid, nextpagenumber) //Show that DIV 87 window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorunperiod)}, autorunperiod) 88} 89 90ContentSlider.setopacity=function(sliderid, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between) 91 var targetobject=document.getElementById(sliderid).opacitylayer || null //reference slider container itself 92 if (targetobject && targetobject.filters && targetobject.filters[0]){ //IE syntax 93 if (typeof targetobject.filters[0].opacity=="number") //IE6 94 targetobject.filters[0].opacity=value*100 95 else //IE 5.5 96 targetobject.style.filter="alpha(opacity="+value*100+")" 97 } 98 else if (targetobject && typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax 99 targetobject.style.MozOpacity=value 100 else if (targetobject && typeof targetobject.style.opacity!="undefined") //Standard opacity syntax 101 targetobject.style.opacity=value 102 targetobject.currentopacity=value 103} 104 105ContentSlider.fadeup=function(sliderid){ 106 var targetobject=document.getElementById(sliderid).opacitylayer || null //reference slider container itself 107 if (targetobject && targetobject.currentopacity<1){ 108 this.setopacity(sliderid, targetobject.currentopacity+0.1) 109 window[sliderid+"fadetimer"]=setTimeout(function(){ContentSlider.fadeup(sliderid)}, 100) 110 } 111} 112 113function getCookie(Name){ 114 var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair 115 if (document.cookie.match(re)) //if cookie found 116 return document.cookie.match(re)[0].split("=")[1] //return its value 117 return "" 118} 119 120function setCookie(name, value){ 121 document.cookie = name+"="+value 122} 123 124////////////////Ajax Related functions ////////////////////////////////// 125 126ContentSlider.ajaxpage=function(url, thediv){ 127 var page_request = false 128 var bustcacheparameter="" 129 if (window.XMLHttpRequest) // if Mozilla, Safari etc 130 page_request = new XMLHttpRequest() 131 else if (window.ActiveXObject){ // if IE 132 try { 133 page_request = new ActiveXObject("Msxml2.XMLHTTP") 134 } 135 catch (e){ 136 try{ 137 page_request = new ActiveXObject("Microsoft.XMLHTTP") 138 } 139 catch (e){} 140 } 141 } 142 else 143 return false 144 thediv.innerHTML=csloadstatustext 145 page_request.onreadystatechange=function(){ 146 ContentSlider.loadpage(page_request, thediv) 147 } 148 if (csbustcachevar) //if bust caching of external page 149 bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() 150 page_request.open('GET', url+bustcacheparameter, true) 151 page_request.send(null) 152} 153 154ContentSlider.loadpage=function(page_request, thediv){ 155 if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 156 thediv.innerHTML=page_request.responseText 157} 158 159ContentSlider.loadobjects=function(externalfiles){ //function to load external .js and .css files. Parameter accepts a list of external files to load (array) 160 for (var i=0; i<externalfiles.length; i++){ 161 var file=externalfiles[i] 162 var fileref="" 163 if (csloadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding 164 if (file.indexOf(".js")!=-1){ //If object is a js file 165 fileref=document.createElement('script') 166 fileref.setAttribute("type","text/javascript"); 167 fileref.setAttribute("src", file); 168 } 169 else if (file.indexOf(".css")!=-1){ //If object is a css file 170 fileref=document.createElement("link") 171 fileref.setAttribute("rel", "stylesheet"); 172 fileref.setAttribute("type", "text/css"); 173 fileref.setAttribute("href", file); 174 } 175 } 176 if (fileref!=""){ 177 document.getElementsByTagName("head").item(0).appendChild(fileref) 178 csloadedobjects+=file+" " //Remember this object as being already added to page 179 } 180 } 181}
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.