PageSourceSearch

https://lightslategray-guanaco-232543.hostingersite.com/wp-content…/lib/frontend/js/frontend.js?ver=13.7.1

js lightslategray-guanaco-232543.hostingersite.com collected 2026-10-03 04:34:13 UTC 40,287 bytes, 1,440 lines download raw bytes

1/*
2	Document   :  frontend
3	Created on :  August, 2013
4	Author     :  Andrei Dinca, AA-Team http://codecanyon.net/user/AA-Team
5*/
6
7// Initialization and events code for the app
8WooZone = (function ($) {
9	"use strict";
10	
11	var ajaxurl			= woozone_vars.ajax_url,
12		lang			= woozone_vars.lang;
13	var current_aff		= {};
14	
15	// init function, autoload
16	(function init() {
17		
18		// load the triggers
19		$(document).ready(function(){
20			console.log( 'WooZone frontend script is loaded!' );
21
22			var $current_aff = $('#WooZone_current_aff');
23			if ( $current_aff.length > 0 ) {
24				current_aff = $current_aff.data('current_aff');
25			}
26
27			triggers();
28		});
29
30		// synchronization on frontend
31		var syncfront = syncfront_func();
32		syncfront.init();
33		
34	})();
35
36
37	//====================================================
38	//== :: TRIGGERS
39	function triggers() {
40
41		checkout_email();
42
43		load_amazon_reviews();
44
45		fix_images();
46	};
47
48
49	//====================================================
50	//== :: OTHERS
51
52	//:: LOAD AMAZON REVIEWS
53	function load_amazon_reviews() {
54		var wrapper = $('body #amzaff-amazon-review-tab');
55		wrapper.each(function(){
56			var data = {
57				action			: 'WooZone_frontend',
58				sub_action		: 'load_amazon_reviews',
59				prodid 			: wrapper.data('prodid')
60			};
61			//if (DEBUG) console.log( data );
62				
63			//loading( 'show', lang.saving );
64
65			$.post(ajaxurl, data, function(response) {
66				if ( misc.hasOwnProperty(response, 'status') ) {
67					if ( 'valid' == response.status ) {
68						wrapper.html( response.html );
69					}
70				}
71				//loading( 'close' );
72			}, 'json')
73			.fail(function() {})
74			.done(function() {})
75			.always(function() {});
76		});
77	}
78
79	//:: FIX IMAGES
80	function fix_images() {
81		// fix images on https/ssl
82		setInterval( function() {
83			var $imgFound = $("img[src*='ssl-images']");
84			
85			$imgFound.each(function(){
86				var that = $(this),
87					src = that.attr('src');
88				
89				if( src.indexOf('//') == 0 ){
90					if( src.indexOf("ssl-images") != false ){
91						that.attr('src', "https:" + src );
92						that.attr('srcset', "https:" + that.attr('srcset'));
93					}
94				}
95			});
96		}, 1000 );
97	}
98
99	//:: custom user email collecting before redirect to amazon
100	function checkout_email() {
101		if ( ! $('.cart_totals').length ) return false;
102
103		var woozone_email_wrapper 		= $('.woozone_email_wrapper'),
104			  woozone_checkout_email 		= $('#woozone_checkout_email'),
105			  woozone_email_mandatory 	= $('#woozone_checkout_email_required');
106
107		// checkout email is active
108  
109		if( woozone_checkout_email.length > 0 ) {
110			woozone_email_wrapper.insertBefore( $('.wc-proceed-to-checkout') );
111
112			var checkout_btn = $('.wc-proceed-to-checkout .checkout-button'),
113				  checkout_link = checkout_btn.attr('href');
114 
115			if( woozone_email_mandatory.length > 0 && woozone_email_mandatory.val() == '1' ) {
116				checkout_btn.addClass('disabled');
117				checkout_btn.attr('href', '#amz_checkout_email');
118				//console.log( checkout_btn );
119				//alert('E-mail field is mandatory!');
120			}
121
122			woozone_email_wrapper.on('keyup', woozone_checkout_email, function(e) {
123				var woozone_validate_email = /([A-Z0-9a-z_-][^@])+?@[^$#<>?]+?\.[\w]{2,4}/.test(woozone_checkout_email.val());
124						 
125				 if( woozone_validate_email ) {
126
127					if( woozone_email_mandatory.length > 0 && woozone_email_mandatory.val() == '1' ) {
128						checkout_btn.removeClass('disabled');
129						checkout_btn.attr('href', checkout_link);
130					 }
131
132					 woozone_checkout_email.css({'border': '1px solid #d1d1d1'});
133
134				 } else {
135
136					if( woozone_email_mandatory.length > 0 && woozone_email_mandatory.val() == '1' ) {
137						checkout_btn.addClass('disabled');
138						checkout_btn.attr('href', '#amz_checkout_email');
139					}
140
141					woozone_checkout_email.css({'border': '1px solid red'});
142
143				}
144			});
145		}
146
147		$('.wc-proceed-to-checkout').on('click', '.checkout-button', function(e) {
148			// checkout email is active
149			if ( woozone_checkout_email.length > 0 ) {
150				if( woozone_email_mandatory.length > 0 && woozone_email_mandatory.val() == '1' ) {
151					if ( $(this).hasClass('disabled') ) {
152						e.preventDefault();
153						return false;
154					}
155				}
156
157				if ( ! country_shop_checkout.allow_checkout() ) {
158					//console.log( 'checkout: You must check or cancel all amazon shops!' );
159					country_shop_checkout.set_msg_html( false, lang.amzcart_cancel_msg );
160					return false;
161				}
162				else {
163					//console.log( 'checkout: all good.' );
164					country_shop_checkout.set_msg_html( true, lang.amzcart_checkout_msg );
165				}
166				//return false; // uncomment to debug
167
168				if ( woozone_checkout_email.val() != '' ) {
169					jQuery.post(woozone_vars.ajax_url, 
170					{
171						'action': 'WooZone_before_user_checkout',
172						'_nonce': $('#woozone_checkout_email_nonce').val(),
173						'email': woozone_checkout_email.val()
174					}, function(data, textStatus) {
175						if ( (textStatus === 'success') || (textStatus === 'email_exists') ) {
176							//window.location.href = woozone_vars.checkout_url;
177							$(this).prop('href', woozone_vars.checkout_url); // to be sure it does the action!
178						} else {
179							alert( textStatus );
180						}
181					});
182				}
183			}
184			// checkout email is NOT active
185			else {
186				if ( ! country_shop_checkout.allow_checkout() ) {
187					//console.log( 'checkout: You must check or cancel all amazon shops!' );
188					country_shop_checkout.set_msg_html( false, lang.amzcart_cancel_msg );
189					return false;
190				}
191				else {
192					//console.log( 'checkout: all good.' );
193					country_shop_checkout.set_msg_html( true, lang.amzcart_checkout_msg );
194				}
195				//return false; // uncomment to debug
196				
197				// update feb 2017
198				// no need to do anything, as the current button action will go to checkout and do the reload itself
199				$(this).prop('href', woozone_vars.checkout_url); // to be sure it does the action!
200
201				// dageorge: i've commented this as I don't know why an ajax request is needed when email checkout is not active! (feedback from a client)
202				//jQuery.post(woozone_vars.ajax_url, 
203				//{
204				//	'action': 'WooZone_before_user_checkout',
205				//}, function(data, textStatus) {
206				//	if ( (textStatus === 'success') ) {
207				//		window.location.href = woozone_vars.checkout_url;
208				//	}
209				//});
210				
211			}
212		});
213	};
214	
215	//:: open popup
216	function popup(url, title, params) {
217		//url = 'http://www.amazon' + current_aff['user_country']['website'] + url;
218		window.open(url, title, params);
219	};
220
221
222	//====================================================
223	//== :: PRODUCT COUNTRY AVAILABILITY
224	var product_country_check = (function() {
225		
226		var DISABLED				= false; // disable this module!
227		var DEBUG					= true;
228		var maincontainer			= null,
229			mainloader				= null,
230			product_data			= {},
231			current_country			= {},
232			available_countries 	= [],
233			main_aff_id				= '',
234			aff_ids					= [],
235			cc_template 			= null,
236			us_li 					= null,
237			verify_interval			= 300, // verify requests: interval in miliseconds
238			verify_max_steps		= 15, // verify requests: maximum number of steps
239			updated_countries = false;
240			  
241
242		// Test!
243		function __() { console.log('__ method'); };
244		
245		// get public vars
246		function get_vars() {
247			return $.extend( {}, {
248			} );
249		};
250		
251		// init function, autoload
252		(function init() {
253			
254			if ( DISABLED ) return false;
255
256			// load the triggers
257			$(document).ready(function(){
258				maincontainer = $(".WooZone-country-check:first");
259				mainloader	  = maincontainer.find('.WooZone-country-loader');
260				//console.log( 'box country maincontainer', maincontainer );
261
262				// main box
263				build_main_box();
264
265				// small box on minicart
266				build_box_minicart();
267				
268				triggers();
269			});
270		})();
271		
272		// triggers
273		function triggers() {
274			maincontainer.on('click', 'li .WooZone-cc_checkbox input[type="radio"]', function (e) {
275				if (DEBUG) console.log( 'clicked', $(this) );
276				//save_countries();
277				save_product_country( $(this).parents('li:first').data('country') );
278			});
279		};
280		
281		function build_box_minicart() {
282			var newel 	  		= null,
283				  tpl				= $('#WooZone-cc-small-template'),
284				  minicart		= $('div.kd_small-cart .cart-details ul.kd_small_cart_items'),
285				  //minicart		= $('div.widget_shopping_cart_content .cart-details ul.kd_small_cart_items'),
286				  is_kingdom = minicart.length; // theme: kingdom
287
288			var cached = $('.WooZone-cc-small-cached').html();
289			//cached = JSON.stringify(cached);
290			cached = typeof cached != 'undefined'
291				? JSON && JSON.parse(cached) || $.parseJSON(cached) : cached;
292			if (DEBUG) console.log( 'cached', cached );
293
294			if ( ! tpl.length ) return false;
295			if ( ! is_kingdom || ! cached.length ) return false;
296 
297			$.each(cached, function(index, value) {
298				//console.log( index, value );
299				var current = minicart.find('li').filter(function(i) {
300					return value['cart_item_key'] == $(this).data('prodid');
301				});
302 
303				var __ = $( tpl.html() ).clone();
304				__.find(".WooZone-cc_domain").addClass( value.product_country.replace(".", "-") ).prop('title', value.country_name);
305				__.find(".WooZone-cc_status").addClass( value.country_status_css ).prop('title', value.country_status_text);
306
307				//console.log( current.find('.kd_cart_item-details'), __ ); 
308				current.find('.kd_cart_item-details').append( __ );
309			});
310		};
311
312		function build_main_box( pms ) {
313			var pms = pms || {};
314			var do_position = misc.hasOwnProperty(pms, 'do_position') ? pms.do_position : false;
315
316			if ( ! maincontainer.length ) {
317				if (DEBUG) console.log( '!!! ERROR: main box container not found!', maincontainer );
318				return false;
319			}
320
321			var _product_data = maincontainer.find('.WooZone-product-data').html();
322			//_product_data = JSON.stringify(_product_data);
323			_product_data = typeof _product_data != 'undefined'
324				? JSON && JSON.parse(_product_data) || $.parseJSON(_product_data) : _product_data;
325
326			// var product_pms = {
327			// 	'id'					: maincontainer.data('prodid'),
328			// 	'asin'				: maincontainer.data('asin'),
329			// 	'country'			: maincontainer.data('prodcountry'),
330			// 	'boxpos'			: maincontainer.data('boxpos'),
331			// 	'do_update'		: maincontainer.data('do_update')
332			// };
333			var product_pms = {
334				'id'					: _product_data.prodid,
335				'asin'				: _product_data.asin,
336				'country'			: _product_data.prodcountry,
337				'boxpos'			: _product_data.boxpos,
338				'do_update'		: _product_data.do_update
339			};
340			setTimeout( function() {
341				loading( 'show', lang.loading );
342				maincontainer.show();
343
344				if (do_position) {
345					position_box( product_pms );
346				}
347
348				var _update = function() {
349					if (updated_countries) {
350						if (DEBUG) console.log( 'countries: already updated!' );
351						return true;
352					}
353					if (product_data['do_update']) {
354						if (DEBUG) console.log( 'countries: updating...' );
355						update_countries();
356						return true;
357					}
358					if (DEBUG) console.log( 'countries: no need to update!' );
359				}
360
361				set_product_data( product_pms );
362				build_countries_list();
363				if (DEBUG) console.log( product_data, available_countries );
364
365				load_template();
366				//make_requests();
367				build_countries_elements( _update );
368
369			}, 0);
370		}
371
372		// position product box
373		function position_box( pms ) {
374			var newel 	  		= null,
375				is_bravo = $('body.bravostore-body div.product#product-' + pms.id + ' form.cart').length, // theme: kingdom
376				is_kingdom = $('div.product#product-' + pms.id + ' > div.row:first .kd_description').length; // theme: kingdom
377
378			if ( 'before_add_to_cart' == pms.boxpos ) {
379				// theme: kingdom
380				if ( is_kingdom ) {
381					newel = $('div.product#product-' + pms.id + ' > div.row:first .kd_description .cart');
382				}
383				
384				if ( is_bravo ) {
385					newel = $('div.product#product-' + pms.id + ' form.cart');
386				}
387				
388				maincontainer.insertBefore( newel ).show();
389				
390			}
391			else if ( 'before_title_and_thumb' == pms.boxpos ) {
392				newel = $('div.product#product-' + pms.id);
393				if ( newel.length )
394					maincontainer.prependTo( newel ).show();
395				else {
396					// theme: kingdom
397					if ( is_kingdom ) {
398						newel = $('div.product#product-' + pms.id + ' > div.row:first');
399						maincontainer.insertBefore( newel ).show();
400					}
401				}
402			}
403			else if ( 'before_woocommerce_tabs' == pms.boxpos ) {
404				newel = $('div.product#product-' + pms.id + ' div.woocommerce-tabs.wc-tabs-wrapper');
405				if ( newel.length )
406					maincontainer.insertBefore( newel ).addClass('WooZone-boxpos-before_woocommerce_tabs').show();
407				else {
408					// theme: kingdom
409					if ( is_kingdom ) {
410						newel = $('div.product#product-' + pms.id + ' > div.row:first');
411						maincontainer.insertAfter( newel ).show();
412					}
413				}
414			}
415		};
416		
417		// add country to countries list
418		function add_country( new_country, where ) {
419			var where = where || 'available';
420			
421			if ( 'available' == where ) {
422				available_countries.push( new_country );
423			}
424		};
425	
426		// per country template - ul.li (to build the final box with all available countries)
427		function load_template() {
428
429			cc_template = maincontainer.find("#WooZone-cc-template").html();
430		};
431	
432		// set product data
433		function set_product_data( pms ) {
434
435			product_data = pms;
436		};
437
438		// build countries list
439		function build_countries_list() {
440			available_countries 	= [];
441
442			// aff ids json parse
443			var cached_aff_ids = maincontainer.find('.WooZone-country-affid').html();
444			//cached_aff_ids = JSON.stringify(cached_aff_ids);
445			cached_aff_ids = typeof cached_aff_ids != 'undefined'
446				? JSON && JSON.parse(cached_aff_ids) || $.parseJSON(cached_aff_ids) : cached_aff_ids;
447			//if (DEBUG) console.log( cached_aff_ids );
448			if ( cached_aff_ids && misc.hasOwnProperty(cached_aff_ids, 'main_aff_id') )
449				main_aff_id = cached_aff_ids.main_aff_id;
450			if ( cached_aff_ids && misc.hasOwnProperty(cached_aff_ids, 'aff_ids') )
451				aff_ids = cached_aff_ids.aff_ids;
452
453			// countries json parse
454			var cached_countries = maincontainer.find('.WooZone-country-cached').html();
455			//cached_countries = JSON.stringify(cached_countries);
456			cached_countries = typeof cached_countries != 'undefined'
457				? JSON && JSON.parse(cached_countries) || $.parseJSON(cached_countries) : cached_countries;
458			//if (DEBUG) console.log( cached_countries );
459			
460			$.each( cached_countries, function( index, value ){
461				var __ = {
462					'domain'		: value.domain,
463					'name'			: value.name
464				};
465				if ( misc.hasOwnProperty( value, 'available' ) ) {
466					__['available'] = value.available;
467				}
468				add_country( __ );
469			});
470			return false;
471		};
472
473		function build_countries_elements( callback ) {
474
475			var cc = 0;
476			$.each( available_countries, function( key, value ) {
477				//if ( cc >= 10 ) { return false; }
478				var __ = $(cc_template).clone();
479
480				__.data('country', value.domain);
481				__.find(".WooZone-cc_domain").addClass( value.domain.replace(".", "-") ).prop('title', value.name);
482				__.find(".WooZone-cc_name > a").text( value.name ).attr('href', build_product_link( value.domain, product_data['asin'], true ));
483				
484				var _countryflag_aslink = __.find(".WooZone-cc_domain > a");
485				if ( _countryflag_aslink.length ) { // add link to country flag
486					_countryflag_aslink.attr('href', build_product_link( value.domain, product_data['asin'], true ));
487				}
488				
489				// default country
490				if ( value.domain == product_data['country'] ) {
491					__.find('.WooZone-cc_checkbox input[type=radio]').prop('checked', true);
492					current_country['elm'] = __.find('.WooZone-cc_checkbox input[type=radio]');
493					current_country['country'] = value.domain;
494				}
495
496				maincontainer.append( __ );
497				//console.log( value ); return true;
498
499				// cached
500				if ( misc.hasOwnProperty( value, 'available' ) ) {
501					add_country_status_html( __, value.available );
502				}
503
504				cc++;
505
506			});
507			
508			setTimeout( function() {
509				loading( 'close' );
510				if ( $.isFunction( callback ) ) {
511					callback();
512				}
513			}, 0);
514		};
515
516		/*
517		function async_product_exist( data ) {
518			console.log( 'data', data );
519			console.log( 'data.NumRecords', data.NumRecords );
520			var __ = data.NumRecords == 0 ? 0 : 1;
521			add_country_status_html( us_li, __ );
522			add_country_status( 'com', __ );
523		}
524		
525		// product exists on amazon shops
526		function product_exist( elm, domain ) {
527
528			if ( domain === 'com' ) {
529				us_li = elm;
530
531				//console.log( product_data );
532
533				// search api url 
534				var search_api_url = 'https://ws-na.amazon-adsystem.com/widgets/q?TemplateId=PubStudio&ServiceVersion=20070822&MarketPlace=US&Operation=ItemSearch&InstanceId=5affe5b46c317&dataType=jsonp&Keywords=' + ( product_data['asin'] ) + '&SearchIndex=All&multipageStart=0&multipageCount=9&callback=check_product_asin&_=1526719917078';
535				console.log('search_api_url', search_api_url); return false;
536
537				$.ajax({
538				    url: search_api_url,
539				    jsonp: "check_product_asin",
540				    dataType: "jsonp"
541				})
542				.fail(function() {})
543				.done(function() {})
544				.always(function() {});
545			}
546			else {
547				var jqxhr = $.ajax({
548					crossDomain: true,
549					type:"GET",
550					processData: false,
551					contentType: "application/json; charset=utf-8",
552					async: true,
553					converters: {
554						"* text": window.String,
555						"text html": true,
556						"text json": true,
557						"text xml": jQuery.parseXML
558					},
559					url: build_product_link( domain, product_data['asin'] ),
560					data: {},
561					dataType: "jsonp",
562					jsonp: false,
563					complete: function (XMLHttpRequest, textStatus) {
564						if (DEBUG) console.log( 'product_exist function', XMLHttpRequest, textStatus );
565						if ( 404 == XMLHttpRequest.status ) {
566							add_country_status_html( elm, 0 );
567							add_country_status( domain, 0 );
568						} else {
569							add_country_status_html( elm, 1 );
570							add_country_status( domain, 1 );
571						}
572					}
573				})
574			}
575		};
576
577		// make requests to amazon shops
578		function make_requests() {
579			var pending = 0;
580
581			$.each( available_countries, function( key, value ) {
582				var __ = $(cc_template).clone();
583
584				__.data('country', value.domain);
585				__.find(".WooZone-cc_domain").addClass( value.domain.replace(".", "-") ).prop('title', value.name);
586				__.find(".WooZone-cc_name > a").text( value.name ).attr('href', build_product_link( value.domain, product_data['asin'], true ));
587				
588				var _countryflag_aslink = __.find(".WooZone-cc_domain > a");
589				if ( _countryflag_aslink.length ) { // add link to country flag
590					_countryflag_aslink.attr('href', build_product_link( value.domain, product_data['asin'], true ));
591				}
592				
593				// default country
594				if ( value.domain == product_data['country'] ) {
595					__.find('.WooZone-cc_checkbox input[type=radio]').prop('checked', true);
596					current_country['elm'] = __.find('.WooZone-cc_checkbox input[type=radio]');
597					current_country['country'] = value.domain;
598				}
599
600				maincontainer.append( __ );
601
602				//console.log( value ); return true;
603
604				// cached
605				if ( misc.hasOwnProperty( value, 'available' ) ) {
606					add_country_status_html( __, value.available );
607				}
608				else {
609					pending++;
610					product_exist( __, value.domain );					
611				}
612			} );
613
614			// verify all product amazon country verify requests are finished
615			if ( pending ) {
616				verify_requests();
617			}
618		};
619		
620		// verify status of requests to amazon shops
621		function verify_requests() {
622			var timer 		= null,
623				  contor		= 0;
624
625			function _verify() {
626				var pending = 0,
627					  is_done = contor >= verify_max_steps;
628
629				$.each( available_countries, function( key, value ) {
630					if ( ! misc.hasOwnProperty( value, 'available' ) )
631						pending++;
632				} );
633				//if (DEBUG) console.log( contor, pending );
634
635				if ( ! pending || is_done ) {
636					clearTimeout( timer );
637					timer = null;
638
639					if ( pending && is_done ) {
640						$.each( available_countries, function( key, value ) {
641							if ( ! misc.hasOwnProperty( value, 'available' ) ) {
642								var $current = maincontainer.find('li').filter(function(i) {
643									return $(this).data('country') == value.domain;
644								});
645
646								add_country_status_html( $current, 0 );
647								add_country_status( value.domain, 0 );
648							}
649						} );
650					}
651
652					save_countries();
653
654					return false;
655				}
656
657				contor++;
658				
659				timer = setTimeout( function() {
660					_verify();
661				}, verify_interval );
662			};
663
664			timer = setTimeout( function() {
665				_verify();
666			}, verify_interval );
667		};
668
669		// add country status: available or not
670		function add_country_status( country, status ) {
671			var index = get_available_country_index( country );
672			if ( index <= -1 ) return false;
673			available_countries[ index ]['available'] = status;
674			//console.log( country, index, status, available_countries );
675			return true;
676		};
677		
678		// get available country index from array of 'available_countries' based on country domain
679		function get_available_country_index( country ) {
680			var index = -1;
681			$.each( available_countries, function( key, value ) {
682				if ( country == value.domain ) {
683					index = key;
684					return false;
685				}
686			} );
687			return index;
688		};
689
690		// save countries per product
691		function save_countries() {
692			var countries = JSON.stringify( available_countries );
693			var data = {
694				action					: 'WooZone_frontend',
695				sub_action			: 'save_countries',
696				product_id			: product_data['id'],
697				product_country	: current_country['country'],
698				countries				: countries
699			};
700			if (DEBUG) console.log( data );
701			
702			loading( 'show', lang.saving );
703			$.post(ajaxurl, data, function(response) {
704
705				if ( misc.hasOwnProperty(response, 'status') ) {}
706				loading( 'close' );
707			}, 'json')
708			.fail(function() {})
709			.done(function() {})
710			.always(function() {});
711		};
712		*/
713
714		function update_countries() {
715			var countries = JSON.stringify( available_countries );
716			var data = {
717				action					: 'WooZone_frontend',
718				sub_action			: 'update_countries',
719				product_id			: product_data['id'],
720				asin 						: product_data['asin'],
721				product_country	: current_country['country']
722			};
723			if (DEBUG) console.log( data );
724			
725			loading( 'show', lang.updating );
726			$.post(ajaxurl, data, function(response) {
727
728				if ( misc.hasOwnProperty(response, 'status') ) {}
729				if (DEBUG) console.log( 'countries: ajax update done!' );
730				//if (DEBUG) console.log( response.html );
731				loading( 'close' );
732				maincontainer.html( response.html );
733				mainloader = maincontainer.find('.WooZone-country-loader');
734				build_main_box({ do_position: false });
735
736			}, 'json')
737			.fail(function() {})
738			.done(function() {})
739			.always(function() { updated_countries = true; });
740		};
741
742		// save countries per product
743		function save_product_country( country ) {
744			var data = {
745				action					: 'WooZone_frontend',
746				sub_action			: 'save_product_country',
747				product_id				: product_data['id'],
748				product_country	: country || current_country['country']
749			};
750			if (DEBUG) console.log( data );
751			
752			loading( 'show', lang.saving );
753			$.post(ajaxurl, data, function(response) {
754
755				if ( misc.hasOwnProperty(response, 'status') ) {}
756				loading( 'close' );
757			}, 'json')
758			.fail(function() {})
759			.done(function() {})
760			.always(function() {});
761		};
762
763		function add_country_status_html( elm, status ) {
764			//console.log( elm, status );
765			if ( status ) {
766				if (DEBUG) console.log( elm.data('country') , "product valid" );
767				elm.find(".WooZone-cc-status").html( "<span class='WooZone-status-available'>" + lang.available_yes + "</span" );
768			} else {
769				if (DEBUG) console.log( elm.data('country') , "product not found" );
770				elm.find(".WooZone-cc-status").html( "<span class='WooZone-status-unavailable'>" + lang.available_no + "</span" );
771			}
772		};
773
774		// build product link for amazon country shop
775		function build_product_link( domain, asin, add_tag ) {
776			var addtag 	= add_tag || false,
777				  link 			=  "https://www.amazon." + ( domain ) + "/dp/" + asin;
778			
779			if ( addtag )
780				link += '/?tag=' + get_aff_id( domain );
781			//console.log( domain, asin, link );
782			return link;
783		};
784		
785		function get_aff_id( country ) {
786			var aff_id = main_aff_id;
787
788			$.each(aff_ids, function( index, value ) {
789				if ( value.country == country ) {
790					aff_id = value.aff_id;
791					return false;
792				}
793			});
794			return aff_id;
795		};
796		
797		// Loading
798		function loading( status, msg ) {
799			var msg = msg || '';
800
801			if ( '' == msg && 'show' == status )
802				msg = lang.loading;
803
804			if ( '' != msg )
805				mainloader.find('.WooZone-country-loader-text').html( msg );
806
807			if ( 'show' == status )
808				mainloader.fadeIn('fast');
809			else
810				mainloader.fadeOut('fast');
811		};
812
813		// external usage
814		return {
815			// attributes
816			'v'               : get_vars,
817			
818			// methods
819			'__'              : __
820			//,'add_country'			: add_country
821			//,'make_requests'		: make_requests
822			//,'set_product_data'	: set_product_data
823			//,'async_product_exist': async_product_exist
824		};
825	})();
826	
827	
828	//====================================================
829	//== :: AMAZON SHOPS CHECKOUT ON CART PAGE
830	var country_shop_checkout = (function() {
831		
832		var DISABLED				= false; // disable this module!
833		var DEBUG					= false;
834		var maincontainer			= null,
835			shops					= [],
836			shops_status			= {
837				'success'		: [],
838				'cancel'		: []
839			};
840			  
841
842		// Test!
843		function __() { console.log('__ method'); };
844		
845		// get public vars
846		function get_vars() {
847			return $.extend( {}, {
848			} );
849		};
850		
851		// init function, autoload
852		(function init() {
853			
854			if ( DISABLED ) return false;
855
856			// load the triggers
857			$(document).ready(function(){
858				maincontainer = $(".WooZone-cart-checkout");
859
860				// main box
861				if ( maincontainer.length ) {
862					maincontainer.find('ul li').each(function(index, value) {
863						var $this 		= $(this),
864							  country	= $this.data('domain');
865
866						shops.push( country );
867					});
868					if (DEBUG) console.log( shops ); 	
869				}
870
871				triggers();
872			});
873		})();
874		
875		// triggers
876		function triggers() {
877			// checkout form
878			maincontainer.on('submit', 'li .WooZone-cc_checkout form', function (e) {
879				e.preventDefault();
880				if (DEBUG) console.log( 'form to submit!' );
881				
882				var form 			= this,
883					  $form			= $(form),
884					  $li 				= $form.parents('li:first'),
885					  country 		= $li.data('domain');
886
887				//console.log( form, $form );
888				if ( $.inArray( country, shops_status.success) <= -1 && $.inArray( country, shops_status.cancel) <= -1 )
889					shops_status.success.push( country );
890				//console.log( shops_status );
891				set_status_html( $li, 1 );
892
893				form.submit();
894
895				return true;
896			});
897
898			// cancel
899			maincontainer.on('click', 'li .WooZone-cc_checkout input[type="button"].cancel', function (e) {
900				e.preventDefault();
901				if (DEBUG) console.log( 'form canceled!' );
902				
903				var $form 		= $(this).parents('form:first'),
904					  $li 				= $form.parents('li:first'),
905					  country 		= $li.data('domain');
906 
907				//console.log( $form );
908				if ( $.inArray( country, shops_status.success) <= -1 && $.inArray( country, shops_status.cancel) <= -1 )
909					shops_status.cancel.push( country );
910				//console.log( shops_status );
911				set_status_html( $li, 0 );
912
913				return true;
914			});
915		};
916		
917		function allow_checkout() {
918			var __ = [].concat( shops_status.success, shops_status.cancel );
919			if (DEBUG) console.log( __, __.length == shops.length );
920			return __.length == shops.length;
921		};
922		
923		function set_status_html( elm, status ) {
924			var text 			= status ? lang.amzcart_checkout : lang.amzcart_cancel,
925				  css_class 	= status ? 'success' : 'cancel';
926			elm.find('.WooZone-cc_status').removeClass('success cancel').addClass( css_class ).text( text );
927		};
928		
929		function set_msg_html( status, text ) {
930			var elm 			= maincontainer.find('.WooZone-cart-msg'),
931				  css_class 	= status ? 'success' : 'cancel';
932			//elm.prepend( $('<div />').removeClass('success cancel').addClass( css_class ).text( text ) );
933			var __ = $('<div />').removeClass('success cancel').addClass( css_class ).text( text );
934			elm.html( __ );
935		};
936		
937		// external usage
938		return {
939			// attributes
940			'v'                     			: get_vars,
941			
942			// methods
943			'__'                    			: __,
944			'allow_checkout'			: allow_checkout,
945			'set_msg_html'				: set_msg_html
946		};
947	})();
948
949
950	//====================================================
951	//== :: CROSS SELL BOX
952	var cross_sell_box = (function() {
953		
954		var DISABLED				= false; // disable this module!
955		var DEBUG					= false;
956		var maincontainer			= null,
957			mainloader				= null,
958			multiple_asins 			= [];
959			  
960
961		// Test!
962		function __() { console.log('__ method'); };
963		
964		// get public vars
965		function get_vars() {
966			return $.extend( {}, {
967			} );
968		};
969		
970		// init function, autoload
971		(function init() {
972			
973			if ( DISABLED ) return false;
974
975			// load the triggers
976			$(document).ready(function(){
977				maincontainer = $("body");
978				mainloader	  = maincontainer.find('.WooZone-cross-sell-loader');
979
980				triggers();
981
982				if ( maincontainer.find('.main-cross-sell').length ) {
983					load_box();
984				}
985			});
986		})();
987		
988		// load box
989		function load_box() {
990			var box 	= maincontainer.find('.main-cross-sell'),
991				  asin	= maincontainer.find('.main-cross-sell').data('asin'),
992				  boxd 	= maincontainer.find('#WooZone-cross-sell-debug');
993
994			var data = {
995				action					: 'WooZone_frontend',
996				sub_action			: 'load_cross_sell',
997				asin						: asin
998			};
999			if (DEBUG) console.log( data );
1000
1001			if ( boxd.length ) {
1002				boxd.html( 'Loading Ajax : make amazon request to retrieve products ...' ); boxd.show();
1003			}
1004
1005			loading( 'show', lang.load_cross_sell_box );
1006
1007			$.post(ajaxurl, data, function(response) {
1008
1009				if ( misc.hasOwnProperty(response, 'status') ) {
1010					box.html( response.html ).css({
1011						'min-height' : 'initial'
1012					});
1013					if ( boxd.length ) {
1014						boxd.html( response.debug ); boxd.show();
1015					}
1016				}
1017				loading( 'close' );
1018			}, 'json')
1019			.fail(function() {})
1020			.done(function() {})
1021			.always(function() {});
1022		};
1023		
1024		// empty cache
1025		function empty_cache( that ) {
1026			var box 	= maincontainer.find('.main-cross-sell'),
1027				  asin	= maincontainer.find('.main-cross-sell').data('asin'),
1028				  boxd 	= maincontainer.find('#WooZone-cross-sell-debug');
1029				  
1030			var data = {
1031				action				: 'WooZone_frontend',
1032				sub_action			: 'cross_sell_empty_cache',
1033				asin				: asin
1034			};
1035			if (DEBUG) console.log( data );
1036
1037			that.prop('disabled', true).after( lang.saving );
1038
1039			$.post(ajaxurl, data, function(response) {
1040
1041				if ( misc.hasOwnProperty(response, 'status') ) {
1042					window.location.reload();
1043				}
1044				loading( 'close' );
1045			}, 'json')
1046			.fail(function() {})
1047			.done(function() {})
1048			.always(function() {});
1049		};
1050		
1051		// triggers
1052		function triggers() {
1053
1054			// debug mode
1055			$("body").on("click", '#WooZone-cross-sell-debug button', function(e) {
1056				empty_cache( $(this) );
1057			});
1058
1059			// selection checkboxes
1060			$("body").on("change", '.cross-sell input', function(e) {
1061				var that				= $(this),
1062					row				= that.parents('li').eq(0),
1063					asin				= that.val(),
1064					the_thumb	= $('#cross-sell-thumb-' + asin).parents('li'),
1065					buy_block		= $('div.cross-sell-buy-btn');
1066
1067				var price_dec_sep = $('.cross-sell .cross-sell-price-sep').data('price_dec_sep');
1068
1069				buy_block.fadeOut('fast');
1070				if( that.is(':checked') ){
1071					row.attr('class', '');
1072					the_thumb.fadeIn('fast');
1073				}
1074				else{
1075					row.attr('class', '');
1076					row.addClass('cross-sale-uncheck');
1077
1078					the_thumb.fadeOut('fast');
1079				}
1080
1081				var _total_price 		= 0,
1082					  remaining_items	= 0;
1083
1084				$(".cross-sell ul.cross-sell-items li:not(.cross-sale-uncheck)").each(function(){
1085					var that    = $(this);
1086					var price   = that.find('.cross-sell-item-price').data('item_price'); //that.find('.cross-sell-item-price').text().replace(/[^-\d\.,]/g, '')
1087
1088					_total_price = _total_price + parseFloat(price);
1089
1090					remaining_items++;
1091				});
1092
1093				if ( _total_price > 0 ) {
1094					_total_price = _total_price.toFixed(2);
1095					if ( ',' == price_dec_sep ) {
1096						_total_price = numberFormat( _total_price );
1097					}
1098					$("#feq-products").show();
1099					var curr_price = $("#cross-sell-buying-price").text().match(/[\d.,]+/);
1100					$("#cross-sell-buying-price").text( $("#cross-sell-buying-price").text().replace(curr_price, _total_price) );
1101				}
1102				else{
1103					$("#feq-products").fadeOut('fast');
1104					var curr_price = $("#cross-sell-buying-price").text().match(/[\d.,]+/);
1105					$("#cross-sell-buying-price").text( $("#cross-sell-buying-price").text().replace(curr_price, _total_price) );
1106				}
1107
1108				buy_block.fadeIn('fast');
1109			});
1110
1111			// add to cart / checkout button
1112			$("body").on("click", '.cross-sell a#cross-sell-add-to-cart', function(e) {
1113				e.preventDefault();
1114
1115				var that = $(this);
1116
1117				// get all selected products
1118				var totals_checked  = $(".cross-sell ul.cross-sell-items li:not(.cross-sale-uncheck)").size();
1119				$(".cross-sell ul.cross-sell-items li:not(.cross-sale-uncheck)").each(function() {
1120					var that		= $(this),
1121						  q			= 1,
1122						  asin		= that.find('input').val();
1123
1124					multiple_asins.push(asin);
1125				});
1126
1127				if( totals_checked > 0 ){
1128					var newurl = that.attr('href') + '?amz_cross_sell=yes&asins=' + multiple_asins.join(',');
1129
1130					// window.location.href seems to have inconstant behavior in some browsers & also window.location directly not working in versions of IE
1131					// didn't work in my chrome/jimmy
1132					//window.location = newurl;
1133
1134					$(location).attr('href', newurl);
1135				}
1136			});
1137		};
1138		
1139		// Loading
1140		function loading( status, msg ) {
1141			var msg = msg || '';
1142
1143			if ( '' == msg && 'show' == status )
1144				msg = lang.loading;
1145
1146			if ( '' != msg )
1147				mainloader.find('.WooZone-cross-sell-loader-text').html( msg );
1148
1149			if ( 'show' == status )
1150				mainloader.fadeIn('fast');
1151			else
1152				mainloader.fadeOut('fast');
1153		};
1154
1155		function numberWithCommas(number) {
1156			var parts = number.toString().split(".");
1157			parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
1158			return parts.join(".");
1159		};
1160
1161		function numberFormat(number) {
1162			var formatted_number = number.replace(',', '###');
1163				formatted_number = formatted_number.replace('.', ',');
1164				formatted_number = formatted_number.replace('###', '.');
1165				
1166			return formatted_number;
1167		};
1168
1169		// external usage
1170		return {
1171			// attributes
1172			'v'                     		: get_vars,
1173
1174			// methods
1175			'__'                    		: __
1176		};
1177	})();
1178
1179
1180	//====================================================
1181	//== :: SYNCHRONIZATION ON FRONTEND
1182	function syncfront_func() {
1183		
1184		var DISABLED				= false; // disable this module!
1185		var DEBUG					= false;
1186		var maincontainer			= null,
1187			mod_alias 				= 'syncfront/ ',
1188			sync_wrapper			= '#WooZone-syncfront-wrapper',
1189			sync_content 			= '#WooZone-syncfront-content',
1190			sync_debug 				= '#WooZone-syncfront-debug',
1191			is_page_product 		= false,
1192			sync_params 			= {},
1193			timer 					= null;
1194
1195		// init function, autoload
1196		function init() {
1197
1198			if ( DISABLED ) return false;
1199
1200			// load the triggers
1201			$(document).ready(function(){
1202				maincontainer = $("body");
1203
1204				// is this a product page?
1205				if ( $(sync_wrapper).length ) {
1206					is_page_product = true;
1207				}
1208
1209				// not a product page!
1210				if ( ! is_page_product ) {
1211					return false;
1212				}
1213
1214				sync_params = get_sync_params();
1215
1216				timer = dotimer();
1217
1218				triggers();
1219			});
1220		};
1221
1222		// triggers
1223		function triggers() {
1224			if (DEBUG) {
1225				//$(sync_wrapper).show();
1226				//$(sync_debug).show();
1227				console.log( mod_alias, 'is product page: ' + is_page_product );
1228			}
1229
1230			//:: yes, do refresh timer
1231			maincontainer.on('click', '#WooZone-syncfront-content .WooZone-syncfront-action-refresh-yes', function (e) {
1232				e.preventDefault();
1233
1234				timer.stop();
1235				window.location.reload();
1236			});
1237
1238			//:: no, don't refresh timer
1239			maincontainer.on('click', '#WooZone-syncfront-content .WooZone-syncfront-action-refresh-no', function (e) {
1240				e.preventDefault();
1241
1242				timer.stop();
1243				$(sync_wrapper).hide();
1244			});
1245
1246			//:: last sync status info
1247			//set_operation_product_info();
1248			set_operation_time();
1249
1250			//:: do ajax sync
1251			if ( 'yes' == sync_params.do_ajax ) {
1252				do_sync();
1253			}
1254			else {
1255				set_operation_msg( sync_params.do_msg );
1256			}
1257		};
1258
1259		function get_sync_params() {
1260			// get params
1261			var _params = $(sync_wrapper).find('.WooZone-syncfront-params').html();
1262			//_params = JSON.stringify(_params);
1263			_params = typeof _params != 'undefined'
1264				? JSON && JSON.parse(_params) || $.parseJSON(_params) : _params;
1265			if (DEBUG) console.log( mod_alias, 'params', _params );
1266
1267			return _params;
1268		};
1269
1270		// load box
1271		function do_sync() {
1272			var time_start 	= new Date().getTime(),
1273				time_end 	= null,
1274				duration 	= null;
1275
1276			set_operation_msg( 'STARTING AJAX TO SYNC PRODUCT...' );
1277
1278			var data = {
1279				'action'		: 'WooZone_frontend',
1280				'sub_action'	: 'do_sync',
1281				'asin' 			: sync_params.asin,
1282				'product_id'	: sync_params.product_id,
1283				'product_type' 	: sync_params.product_type
1284			};
1285			//if (DEBUG) console.log( data );
1286
1287			$.post(ajaxurl, data, function(response) {
1288
1289				if ( misc.hasOwnProperty(response, 'status') ) {
1290
1291					set_operation_msg( response.html );
1292
1293					// main wrapper
1294					if ( 'yes' == response.do_refresh ) {
1295					//if (1) { //DEBUG
1296						$(sync_wrapper).show();
1297						timer.start();
1298					}
1299
1300					set_operation_msg( 'FINISHED AJAX TO SYNC PRODUCT!' );
1301					if ( misc.hasOwnProperty(response, 'html_aftersync') ) {
1302						if ( $(sync_debug).length && '' != response.html_aftersync ) {
1303							$(sync_debug).find('table tbody').prepend( response.html_aftersync );
1304							set_operation_time();
1305						}
1306					}
1307
1308					time_end = new Date().getTime();
1309					duration = ( time_end - time_start ) / 1000;
1310					set_operation_msg( 'AJAX SYNC DURATION: {duration} seconds'.replace('{duration}', duration) );
1311				}
1312
1313			}, 'json')
1314			.fail(function() {})
1315			.done(function() {})
1316			.always(function() {});
1317		};
1318
1319		function dotimer() {
1320			var _timer 		= null,
1321				$remained 	= $(sync_content).find('h3 span'),
1322				remained 	= typeof $remained !== null && $remained.length ? $remained.text() : 15;
1323			//console.log( 'remained = ', remained, typeof $remained, $remained );
1324
1325			function start() {
1326				//console.log( $remained, remained  );
1327				
1328				function doit() {
1329					_timer = setTimeout( function() {
1330
1331						//console.log( _timer, remained  );
1332
1333						if ( remained ) {
1334							remained--;
1335							$remained.html( remained );
1336							doit();
1337						}
1338						else {
1339							stop();
1340							window.location.reload();
1341						}
1342
1343					}, 1000 );
1344				}
1345				doit();
1346			}
1347
1348			function stop() {
1349				clearTimeout( _timer );
1350				_timer = null;
1351			}
1352
1353			return {
1354				'start' : start,
1355				'stop' 	: stop
1356			}
1357		};
1358
1359		function set_operation_msg( msg, where ) {
1360			var where = where || 'prepend',
1361				opmsg = [];
1362
1363			if ( ! $(sync_debug).length ) {
1364				return false;
1365			}
1366
1367			opmsg.push( '<tr>' );
1368			opmsg.push( 	'<td>' + (new Date).toTimeString().slice(0,8) + '</td>' );
1369			opmsg.push(		'<td>' + msg + '</td>' );
1370			opmsg.push(	'</tr>' );
1371			opmsg = opmsg.join('');
1372
1373			if ( 'prepend' == where ) {
1374				$(sync_debug).find('table tbody').prepend( opmsg );
1375			}
1376			else {
1377				$(sync_debug).find('table tbody').append( opmsg );
1378			}
1379			$(sync_debug).show();
1380
1381			return opmsg;
1382		}
1383
1384		function set_operation_time() {
1385			if ( ! $(sync_debug).length ) {
1386				return false;
1387			}
1388
1389			var rows_upd = $(sync_debug).find('table tbody tr.wzsync-update-time');
1390			rows_upd.find('td:first').html( (new Date).toTimeString().slice(0,8) );
1391			rows_upd.removeClass('wzsync-update-time');
1392		}
1393
1394		function set_operation_product_info() {
1395			//var prodinfo = [];
1396			//prodinfo.push( 'product #ID: ' + sync_params.product_id );
1397			//prodinfo.push( 'product asin: ' + sync_params.asin );
1398			//prodinfo.push( 'product type: ' + sync_params.product_type );
1399			//set_operation_msg( prodinfo.join('<br />'), 'append' );
1400		}
1401		
1402		// external usage
1403		return {
1404			'init' : init
1405		};
1406	};
1407		
1408		
1409	//====================================================
1410	//== :: UTILS
1411
1412
1413
1414	//====================================================
1415	//== :: MISC
1416	var misc = {
1417	
1418		hasOwnProperty: function(obj, prop) {
1419			var proto = obj.__proto__ || obj.constructor.prototype;
1420			return (prop in obj) &&
1421			(!(prop in proto) || proto[prop] !== obj[prop]);
1422		}
1423	};
1424
1425	/*function async_product_exist( data )
1426	{
1427		product_country_check.async_product_exist( data );
1428	}*/
1429
1430	// external usage
1431	return {
1432		'popup'				: popup
1433		//'async_product_exist': async_product_exist
1434	}
1435})(jQuery);
1436
1437/*function check_product_asin( data )
1438{
1439	WooZone.async_product_exist( data );
1440}*/

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.