PageSourceSearch

https://holidaysatsea.co.uk/frontjs/contentslider.js

js holidaysatsea.co.uk collected 2026-10-02 14:28:45 UTC 10,743 bytes, 237 lines download raw bytes

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		//prevBtn = (nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') nextBtn = (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '')phtml = "<div style='flout:right;'>" + prevBtn +nextBtn + phtml + "</div>"
81		phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '')
82		
83		pdiv.innerHTML=phtml
84	}
85	var pdivlinks=pdiv.getElementsByTagName("a")
86	var toclinkscount=0 //var to keep track of actual # of toc links
87	for (var i=0; i<pdivlinks.length; i++){
88		if (this.css(pdivlinks[i], "toc", "check")){
89			if (toclinkscount>setting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents)
90				pdivlinks[i].style.display="none" //hide this toc link
91				continue
92			}
93			pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link
94			pdivlinks[i][setting.revealtype]=function(){
95				featuredcontentslider.turnpage(setting, this.getAttribute("rel"))
96				return false
97			}
98			setting.toclinks.push(pdivlinks[i])
99		}
100		else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next"
101			pdivlinks[i].onclick=function(){
102				featuredcontentslider.turnpage(setting, this.className)
103				return false
104			}
105		}
106	}
107	this.turnpage(setting, setting.currentpage, true)
108	if (setting.autorotate[0]){ //if auto rotate enabled
109		pdiv[setting.revealtype]=function(){
110			featuredcontentslider.cleartimer(setting, window["fcsautorun"+sett
110ing.id])
111		}
112		sliderdiv["onclick"]=function(){ //stop content slider when slides themselves are clicked on
113			featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id])
114		}
115		setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*50) //add time to run fade animation (roughly) to delay between rotation
116	 this.autorotate(setting)
117	}
118},
119
120urlparamselect:function(fcsid){
121	var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL
122	return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
123},
124
125turnpage:function(setting, thepage, autocall){
126	var currentpage=setting.currentpage //current page # before change
127	var totalpages=setting.contentdivs.length
128	var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage)
129	turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage //test for out of bound and adjust
130	if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly
131		return
132	setting.currentpage=turntopage
133	setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex
134	this.cleartimer(setting, window["fcsfade"+setting.id])
135	setting.cacheprevpage=setting.prevpage
136	if (setting.enablefade[0]==true){
137		setting.curopacity=0
138		this.fadeup(setting)
139	}
140	if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete)
141		setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block")
142		setting.onChange(setting.prevpage, setting.currentpage)
143	}
144	setting.contentdivs[turntopage-1].style.visibility="visible"
145	setting.contentdivs[turntopage-1].style.display="block"
146	if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted)
147		this.css(setting.toclinks[setting.prevpage-1], "selected", "remove")
148	if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted)
149		this.css(setting.toclinks[turntopage-1], "selected", "add")
150	setting.prevpage=turntopage
151	if (this.enablepersist)
152		this.setCookie("fcspersist"+setting.id, turntopage)
153},
154
155setopacity:function(setting, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
156	var targetobject=setting.contentdivs[setting.currentpage-1]
157	if (targetobject.filters && targetobject.filters[0]){ //IE syntax
158		if (typeof targetobject.filters[0].opacity=="number") //IE6
159			targetobject.filters[0].opacity=value*100
160		else //IE 5.5
161			targetobject.style.filter="alpha(opacity="+value*100+")"
162	}
163	else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
164		targetobject.style.MozOpacity=value
165	else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
166		targetobject.style.opacity=value
167	setting.curopacity=value
168},
169
170fadeup:function(setting){
171	if (setting.curopacity<1){
172		this.setopacity(setting, setting.curopacity+setting.enablefade[1])
173		window["fcsfade"+setting.id]=setTimeout(function(){featuredcontentslider.fadeup(setting)}, 50)
174	}
175	else{ //when fade is complete
176		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)
177			setting.contentdivs[setting.cacheprevpage-1].style.display="none" //collapse last content div shown (it was set to "block")
178		setting.onChange(setting.cacheprevpage, setting.currentpage)
179	}
180},
181
182cleartimer:function(setting, timervar){
183	if (typeof timervar!="undefined"){
184		clearTimeout(timervar)
185		clearInterval(timervar)
186		if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div
187			setting.contentdivs[setting.cacheprevpage-1].style.display="none"
188		}
189	}
190},
191
192css:function(el, targetclass, action){
193	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
194	if (action=="check")
195		return needle.test(el.className)
196	else if (action=="remove")
197		el.className=el.className.replace(needle, "")
198	else if (action=="add")
199		el.className+=" "+targetclass
200},
201
202autorotate:function(setting){
203 window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1])
204},
205
206getCookie:function(Name){ 
207	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
208	if (document.cookie.match(re)) //if cookie found
209		return document.cookie.match(re)[0].split("=")[1] //return its value
210	return null
211},
212
213setCookie:function(name, value){
214	document.cookie = name+"="+value
215
216},
217
218
219init:function(setting){
220	var persistedpage=this.getCookie("fcspersist"+setting.id) || 1
221	var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index
222	this.settingcaches[setting.id]=setting //cache "setting" object
223	setting.contentdivs=[]
224	setting.toclinks=[]
225	setting.topzindex=0
226	setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1)
227	setting.prevpage=setting.currentpage
228	setting.revealtype="on"+(setting.revealtype || "click")
229	setting.curopacity=0
230	setting.onChange=setting.onChange || function(){}
231	if (setting.contentsource[0]=="inline")
232		this.buildpaginate(setting)
233	if (setting.contentsource[0]=="ajax")
234		this.ajaxconnect(setting)
235}
236
237}

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.