PageSourceSearch

http://antiquebrasscashregisters.com/thumbnailviewer.js

js antiquebrasscashregisters.com collected 2026-10-08 10:06:16 UTC 7,512 bytes, 153 lines download raw bytes

1// -------------------------------------------------------------------
2// Image Thumbnail Viewer Script- By Dynamic Drive, available at: http://www.dynamicdrive.com
3// Last updated: Jan 22nd, 2007
4// -------------------------------------------------------------------
5
6var thumbnailviewer={
7enableTitle: true, //Should "title" attribute of link be used as description?
8enableAnimation: true, //Enable fading animation?
9definefooter: '<div class="footerbar">CLOSE X</div>', //Define HTML for footer interface
10defineLoading: '<img src="loading.gif" /> Loading Image...', //Define HTML for "loading" div
11
12/////////////No need to edit beyond here/////////////////////////
13
14scrollbarwidth: 16,
15opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',
16targetlinks:[], //Array to hold links with rel="thumbnail"
17
18createthumbBox:function(){
19//write out HTML for Image Thumbnail Viewer plus loading div
20document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
21document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
22this.thumbBox=document.getElementById("thumbBox")
23this.thumbImage=document.getElementById("thumbImage") //Reference div that holds the shown image
24this.thumbLoading=document.getElementById("thumbLoading") //Reference "loading" div that will be shown while image is fetched
25this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
26},
27
28
29centerDiv:function(divobj){ //Centers a div element on the page
30var ie=document.all && !window.opera
31var dom=document.getElementById
32var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
33var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
34var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
35var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
36var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document
37var objwidth=divobj.offsetWidth //width of div element
38var objheight=divobj.offsetHeight //height of div element
39var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint
40divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally
41divobj.style.top=Math.floor(parseInt(topposition))+"px"
42divobj.style.visibility="visible"
43},
44
45showthumbBox:function(){ //Show ThumbBox div
46this.centerDiv(this.thumbBox)
47if (this.enableAnimation){ //If fading animation enabled
48this.currentopacity=0.1 //Starting opacity value
49this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20)
50}
51},
52
53
54loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail"
55if (this.thumbBox.style.visibility=="visible") //if thumbox is visible on the page already
56this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox
57var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image
58if (this.enableTitle && link.getAttribute("title")) //Use title attr of the link as description?
59imageHTML+='<br />'+link.getAttribute("title")
60this.centerDiv(this.thumbLoading) //Center and display "loading" div while we set up the image to be shown
61this.thumbImage.innerHTML=imageHTML //Populate thumbImage div with shown image's HTML (while still hidden)
62this.featureImage=this.thumbImage.getElementsByTagName("img")[0] //Reference shown image itself
63this.featureImage.onload=function(){ //When target image has completely loaded
64thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div
65thumbnailviewer.showthumbBox() //Display "thumbbox" div to the world!
66}
67if (document.all && !window.createPopup) //Target IE5.0 browsers only. Address IE image cache not firing onload bug: panoramio.com/blog/onload-event/
68this.featureImage.src=link.getAttribute("href")
69this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
70thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div, game over
71}
72},
73
74setimgopacity:function(value){ //Sets the opacity of "thumbimage" div per the passed in value setting (0 to 1 and in between)
75var targetobject=this.featureImage
76if (targetobject.filters && targetobject.filters[0]){ //IE syntax
77if (typeof targetobject.filters[0].opacity=="number") //IE6
78targetobject.filters[0].opacity=value*100
79else //IE 5.5
80targetobject.style.filter="alpha(opacity="+value*100+")"
81}
82else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
83targetobject.style.MozOpacity=value
84else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
85targetobject.style.opacity=value
86else //Non of the above, stop opacity animation
87this.stopanimation()
88},
89
90opacityanimation:function(){ //Gradually increase opacity function
91this.setimgopacity(this.currentopacity)
92this.currentopacity+=0.1
93if (this.currentopacity>1)
94this.stopanimation()
95},
96
97stopanimation:function(){
98if (typeof this.opacitytimer!="undefined")
99clearInterval(this.opacitytimer)
100},
101
102
103closeit:function(){ //Close "thumbbox" div function
104this.stopanimation()
105this.thumbBox.style.visibility="hidden"
106this.thumbImage.innerHTML=""
107this.thumbBox.style.left="-2000px"
108this.thumbBox.style.top="-2000px"
109},
110
111cleanup:function(){ //Clean up routine on page unload
112this.thumbLoading=null
113if (this.featureImage) this.featureImage.onload=null
114this.featureImage=null
115this.thumbImage=null
116for (var i=0; i<this.targetlinks.length; i++)
117this.targetlinks[i].onclick=null
118this.thumbBox=null
119},
120
121dotask:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
122var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
123if (target.addEventListener)
124target.addEventListener(tasktype, functionref, false)
125else if (target.attachEvent)
126target.attachEvent(tasktype, functionref)
127},
128
129init:function(){ //Initialize thumbnail viewer script by scanning page and attaching appropriate function to links with rel="thumbnail"
130if (!this.enableAnimation)
131this.opacitystring=""
132var pagelinks=document.getElementsByTagName("a")
133for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
134if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ //Begin if statement
135pagelinks[i].onclick=function(){
136thumbnailviewer.stopanimation() //Stop any currently running fade animation on "thumbbox" div before proceeding
137thumbnailviewer.loadimage(this) //Load image
138return false
139}
140this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link
141} //end if statement
142} //END FOR LOOP
143//Reposition "thumbbox" div when page is resized
144this.dotask(window, function(){if (thumbnailviewer.thumbBox.style.visibility=="visible") thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)}, "resize")
145
146
147} //END init() function
148
149}
150
151thumbnailviewer.createthumbBox() //Output HTML for the image thumbnail viewer
152thumbnailviewer.dotask(window, function(){thumbnailviewer.init()}, "load") //Initialize script on page load
153thumbnailviewer.dotask(window, function(){thumbnailviewer.cleanup()}, "unload")

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.