PageSourceSearch

https://www.sciencetosage.com/wp-content/plugins/amazon-product-in…/js/amazon-lightbox.js?ver=1685557258

js sciencetosage.com collected 2026-10-05 11:39:02 UTC 5,414 bytes, 141 lines download raw bytes

1(function($){
2	// Updated 06/18/18
3	$(document).ready(function() {
4	  appiplightbox();
5	});
6	
7	function appiplightbox() {
8		var newLinks 		= [];
9		var overlay 		= $($('<div id="overlay" style="display: none"></div>'));
10		var container 		= $($('<div id="appiplightbox" style="display: none"></div>'));
11		var close 			= $($('<a href="#close" class="close">&times; Close</a>'));
12		var target 			= $($('<div class="target"></div>'));
13		var prev 			= $($('<a href="#prev" class="prev">&laquo;</a>'));
14		var next 			= $($('<a href="#next" class="next">&raquo;</a>'));
15		$('a[rel^=appiplightbox]').each(function () {
16			if($.inArray($(this).attr('rel'), newLinks)=== -1){
17				newLinks.push($(this).attr('rel'));
18			}
19		});
20		//console.log(newLinks);
21		var itemapp = '';
22		var itemtext = '';
23		var i;
24		var len = newLinks.length;
25		//console.log(len);
26		for( i = len; i >= 0; i-- ){
27			itemtext = 'a[rel='+newLinks[i]+']';
28			$(itemtext).each( function(index) {
29				itemapp = $(this);
30				//console.log(itemapp);
31				itemapp.on('click',function(c) {
32					//console.log(itemapp.data('appiplg'));
33					c.preventDefault();
34					$('a[target="amazonwin"]').removeClass('selected');
35					open($(this).data('appiplg'));
36					$(this).addClass('selected');
37				});
38				itemapp.attr({'lb-position': index});
39			});
40		}
41		$('body').append(overlay).append(container);
42		container.append(close).append(target).append(prev).append(next);
43		container.show().css({'top': Math.round((($(window).height() > window.innerHeight ? window.innerHeight : $(window).height()) - container.outerHeight()) / 2) + 'px', 'left': Math.round(($(window).width() - container.outerWidth()) / 2) + 'px', 'margin-top': 0, 'margin-left': 0}).hide();
44		prev.add(next).on('click', function(c) {
45			c.preventDefault();
46			var tempo 		= $('a[rel*="appiplightbox-"].selected');
47			var itemgr 		= tempo.attr('rel');
48			var itemgb 		= tempo.attr('lb-position');
49			var mgsize 		= $('a[rel='+itemgr+']').size();
50			//var maingroup 	= $(itemgr);
51			var current 	= parseInt(itemgb,10);
52			var to			= null;
53			tempo.removeClass('selected');
54			if($(this).is('.prev')){
55				to = $('[rel='+itemgr+'][lb-position="'+(current - 1)+'"]');
56				if(current === 0){
57					$('[rel='+itemgr+'][lb-position="'+(mgsize - 1)+'"]').addClass('selected');
58				}else{
59					$('[rel='+itemgr+'][lb-position="'+(itemgb + 1)+'"]').addClass('selected');
60				}
61				if(current === 0 && mgsize === 1){
62					to = $('[rel='+itemgr+'][lb-position="0"]');
63				}else if(current === 0){
64					to = $('[rel='+itemgr+'][lb-position="'+(mgsize-1)+'"]');
65				}
66			}else{
67				to = $('[rel='+itemgr+'][lb-position="'+(current + 1)+'"]');
68				if(itemgb === (mgsize - 1) ){
69					$('[rel='+itemgr+'][lb-position="'+((itemgb + 1 > mgsize ? 0 : itemgb + 1))+'"]').addClass('selected');
70				}else{
71					$('[rel='+itemgr+'][lb-position="'+(itemgb + 1)+'"]').addClass('selected');
72				}
73				if(current === 0 && mgsize === 1){
74					to = $('[rel='+itemgr+'][lb-position="0"]');
75				}else if(current === (mgsize - 1)){
76					to = $('[rel='+itemgr+'][lb-position="0"]');
77				}
78			}
79			if(!to.size()){
80			  to = $(this).is('.prev') ? $('[rel='+itemgr+'][lb-position='+(mgsize-1)+']') : $('[rel='+itemgr+'][lb-position="0"]');
81			}else{
82			  to.click();
83			}
84		});
85		close.add(overlay).on('click',function(c) {
86			c.preventDefault();
87			overlay.add(container).fadeOut('normal');
88		});
89	
90		var open;
91		open = function (url) {
92			if (container.is(':visible')) {
93				target.children().fadeOut('normal', function () {
94					target.children().remove();
95					loadImage(url);
96				});
97			} else {
98				target.children().remove();
99				overlay.add(container).fadeIn('normal', function () {
100					loadImage(url);
101				});
102			}
103		};
104	
105		var loadImage;
106		loadImage = function (url) {
107			if (container.is('.loading')) {
108				return;
109			}
110			container.addClass('loading');
111			var img = new Image();
112			img.onload = function () {
113				img.style.display = 'none';
114				var maxWidth = ($(window).width() - parseInt(container.css('padding-left'), 10) - parseInt(container.css('padding-right'), 10)) - 100;
115				var maxHeight = (($(window).height() > window.innerHeight ? window.innerHeight : $(window).height()) - parseInt(container.css('padding-top'), 10) - parseInt(container.css('padding-bottom'), 10)) - 100;
116				if (img.width > maxWidth || img.height > maxHeight) { // One of these is larger than the window
117					var ratio = img.width / img.height;
118					if (img.height >= maxHeight) {
119						img.height = maxHeight;
120						img.width = maxHeight * ratio;
121					} else {
122						img.width = maxWidth;
123						img.height = maxWidth * ratio;
124					}
125				}
126				container.animate({
127					'width': img.width,
128					'height': img.height,
129					'top': Math.round((($(window).height() > window.innerHeight ? window.innerHeight : $(window).height()) - img.height - parseInt(container.css('padding-top'), 10) - parseInt(container.css('padding-bottom'), 10)) / 2) + 'px',
130					'left': Math.round(($(window).width() - img.width - parseInt(container.css('padding-left'), 10) - parseInt(container.css('padding-right'), 10)) / 2) + 'px'
131				}, 'normal', function () {
132					target.append(img);
133					$(img).fadeIn('normal', function () {
134						container.removeClass('loading');
135					});
136				});
137			};
138			img.src = url;
139		};
140	}
141})(jQuery);

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.