PageSourceSearch

http://www.odannyboy.com/scripts/arc90_linkthumb.js

js odannyboy.com collected 2026-10-03 23:55:18 UTC 5,470 bytes, 176 lines download raw bytes

1/*
2
3Link Thumbnail v2.0
4(c) Arc90, Inc.
5
6http://www.arc90.com
7http://lab.arc90.com
8
9Licensed under : Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/
10
11*/
12
13/* Globals */
14var arc90_navigator = navigator.userAgent.toLowerCase();
15var arc90_isOpera = arc90_navigator.indexOf('opera') >= 0? true: false;
16var arc90_isIE = arc90_navigator.indexOf('msie') >= 0 && !arc90_isOpera? true: false;
17var arc90_isSafari = arc90_navigator.indexOf('safari') >= 0 || arc90_navigator.indexOf('khtml') >= 0? true: false;
18var arc90_linkThumbUseClassName = true;
19
20var arc90_linksources = [['http://images.websnapr.com/?url=', 202, 152],
21						  ['http://thumbnails.alexa.com/image_server.cgi?size=small&url=', 160, 120],
22						  ['http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r=', 160, 120]];
23var arc90_linksource = 0;
24
25function arc90_linkpic() {
26	var b = document.domain;
27	var A = document.getElementsByTagName('A');
28
29	for (var i = 0, l = A.length, c = 0; i < l; i++) {
30		var a = A[i];
31		var h = a.href;
32		if ((b == '' || h.indexOf(b) < 0) && h.indexOf('://') > 0 && ((arc90_linkThumbUseClassName && a.className.indexOf('linkthumb') >= 0) || !arc90_linkThumbUseClassName)) {
33			try {
34				a.className += ' arc90_linkpicLNK';
35				if (a.id == '')
36					a.id = 'arc90_link'+ i;
37				var d = arc90_newNode('div', 'arc90_linkpic'+ i, 'arc90_linkpic');
38				var m = arc90_newNode('img', '', 'arc90_linkpicIMG');
39				var n = h.replace(/[^:]*:\/\/([^:\/]*)(:{0,1}\/{1}.*)/, '$1');
40				m.src = arc90_linksources[arc90_linksource][0] + n;
41				m.width = arc90_linksources[arc90_linksource][1];
42				m.height = arc90_linksources[arc90_linksource][2];
43				m.style.width = arc90_linksources[arc90_linksource][1] +'px';
44				m.style.height = arc90_linksources[arc90_linksource][2] +'px';
45				m.border = 0;
46				m.alt = '[Picture of '+ n +']';
47				m.title = a.title;
48				d.style.zIndex = '9999';
49				d.style.position = 'absolute';
50
51				d.appendChild(m);
52				document.body.appendChild(d);
53
54				arc90_addEvent(a, 'mouseover',	function () { arc90_showThumb(arc90_isIE? event.srcElement.id: this.id); } );
55				arc90_addEvent(a, 'mouseout',	function () { arc90_hideThumb(arc90_isIE? event.srcElement.id: this.id); } );
56			} catch(err) {
57				a = null;
58			}
59		}
60	}
61}
62
63function arc90_showThumb(id) {
64	try {
65		var k = document.getElementById(id);
66		var top = arc90_findDimension(k, 'Top');
67		var lnh = arc90_getStyle(k, 'lineHeight', 'font-size');
68		var default_height = 20;
69
70		if (!lnh)
71			lnh = default_height;
72		else if (lnh.indexOf('pt') > 0)
73			lnh = parseInt(lnh) * 1.3;
74		else if (lnh.indexOf('em') > 0)
75			lnh = parseInt(lnh) * 10;
76		else if (lnh.indexOf('px') > 0)
77			lnh = parseInt(lnh);
78		else if (arc90_isNumeric(lnh))
79			lnh = parseInt(arc90_isIE? lnh * 10: arc90_isOpera? lnh/100: lnh); // IE brings back em units
80		else
81			lnh = default_height;
82		var lft = arc90_findDimension(k, 'Left');
83		var nlf = arc90_findMatchingDimensionViaNodes(k, 'Left', lft, 0);
84		var pid = id.replace(/arc90_link/, 'arc90_linkpic');
85		var p = document.getElementById(pid);
86		p.style.display = 'block';
87		p.style.top = (top + (arc90_isIE && nlf? lnh + 8: 4) + lnh) + 'px';
88		p.style.left = lft + 'px';
89	} catch(err) { return; }
90}
91
92function arc90_hideThumb(id) {
93	try {
94		var k = document.getElementById(id);
95		var pid = id.replace(/arc90_link/, 'arc90_linkpic');
96		var p = document.getElementById(pid);
97		p.style.display = 'none';
98	} catch(err) { return; }
99}
100
101function arc90_getStyle(obj, styleIE, styleMoz) {
102	if (arc90_isString(obj)) obj = document.getElementById(obj);
103	if (obj.currentStyle)
104		return obj.currentStyle[styleIE];
105	else if (window.getComputedStyle)
106		return document.defaultView.getComputedStyle(obj, null).getPropertyValue(styleMoz);
107}
108
109function arc90_findDimension(obj, pType) {
110	if (arc90_isString(obj)) obj = document.getElementById(obj);
111	var cur = 0;
112	if(obj.offsetParent)
113		while(obj.offsetParent) {
114			switch(pType.toLowerCase()) {
115			case "width":
116				cur += obj.offsetWidth; break;
117			case "height":
118				cur += obj.offsetHeight; break;
119			case "top":
120				cur += obj.offsetTop; break;
121			case "left":
122				cur += obj.offsetLeft; break;
123			}
124			obj = obj.offsetParent;
125		}
126	return cur;
127}
128
129function arc90_findMatchingDimensionViaNodes(obj, pType, matching, notMatching) {
130	var cur = 0, counter = 0;
131	notMatching = notMatching == null? -1: notMatching;
132	if(obj.parentNode)
133		while(obj.parentNode) {
134			cur = arc90_findDimension(obj, pType);
135			if (cur == matching && cur != notMatching)
136				counter++;
137			if (counter >= 2) return true;
138			obj = obj.parentNode;
139		}
140	return false;
141}
142
143/* Events */
144function arc90_isString(o) { return (typeof(o) == "string"); }
145
146function arc90_isNumeric(o) { return (typeof(parseFloat(o).toString() == 'NaN'? 'xxx': parseFloat(o)) == "number" && parseFloat(o) != ''); }
147
148function arc90_addEvent(e, meth, func, cap) {
149	if (arc90_isString(e))	e = document.getElementById(e);
150
151	if (e.addEventListener){
152		e.addEventListener(meth, func, cap);
153    	return true;
154	}	else if (e.attachEvent)
155		return e.attachEvent("on"+ meth, func);
156	return false;
157}
158
159/* Nodes */
160function arc90_newNode(t, i, s, x, c) {
161	var node = document.createElement(t);
162	if (x != null && x != '') {
163		var n = document.createTextNode(x);
164		node.appendChild(n);
165	}
166	if (i != null && i != '')
167		node.id = i;
168	if (s != null && s != '')
169		node.className = s;
170	if (c != null && c != '')
171		node.appendChild(c);
172	return node;
173}
174
175/* Onload */
176arc90_addEvent(window, 'load', arc90_linkpic);

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.