PageSourceSearch

https://neot-semadar.com/store/wp-content/plugins/woocommerce-simple-auctions/js/simple-auction-frontend.js

js neot-semadar.com collected 2026-10-02 12:26:07 UTC 12,747 bytes, 374 lines download raw bytes

1(function($){
2	"use strict";
3
4	var running = false;
5	var saajaxurl = SA_Ajax.ajaxurl;
6	var SA_last_activity = SA_Ajax.last_activity;
7	var window_focus = true;
8	var refreshIntervalId = '';
9
10	jQuery(document).ready(function($){
11		if(data.interval){
12
13			if(SA_Ajax.focus == 'yes'){
14				$(window).focus(function(){
15					window_focus = true;
16				});
17				$(window).blur(function(){
18					window_focus = false;
19				});
20			}
21		   refreshIntervalId =  setInterval(function(){
22				if(window_focus == true){
23				   getPriceAuction();
24				}
25			}, data.interval*1000);
26
27		}
28
29		$( ".auction-time-countdown" ).each(function( index ) {
30			var time 	= $(this).data('time');
31			var format 	= $(this).data('format');
32			var compact = false;
33			if(format == ''){
34				format = 'yowdHMS';
35			}
36			if(data.compact_counter == 'yes' || $(this).data('compact') == true ){
37
38				compact	 = true;
39			} else{
40				compact	 = false;
41			}
42			var etext ='';
43			if($(this).hasClass('future') ){
44				var etext = '<div class="started">'+data.started+'</div>';
45			} else{
46				var etext = '<div class="over">'+data.checking+'</div>';
47			}
48
49			if ( ! $(' body' ).hasClass('logged-in') ) {
50				time = $.SAcountdown.UTCDate(-(new Date().getTimezoneOffset()),new Date(time*1000));
51			}
52
53			$(this).SAcountdown({
54				until: time,
55				format: format,
56				compact:  compact,
57
58				onExpiry: closeAuction,
59				expiryText: etext
60			});
61
62		});
63
64		$( ".auction-time-countdown-compact" ).each(function( index , element) {
65			var time 	= $(this).data('time');
66			var format 	= $(this).data('format');
67			var compact = true;
68			var $element = jQuery(element);
69			var $placeh = $element.siblings('.recent-bids-list-item-datum-inner-placeholder');
70
71			if(format == ''){
72				format = 'yowdHMS';
73			}
74
75			var etext ='';
76			if($(this).hasClass('future') ){
77				var etext = '<div class="started">'+data.started+'</div>';
78			} else{
79				var etext = '<div class="over">'+data.checking+'</div>';
80			}
81
82			if ( ! $(' body' ).hasClass('logged-in') ) {
83				time = $.SAcountdown.UTCDate(-(new Date().getTimezoneOffset()),new Date(time*1000));
84			}
85
86			$(this).SAcountdown({
87				until: time,
88				format: format,
89				compact:  compact,
90
91				onExpiry: closeAuction,
92				expiryText: etext,
93			});
94
95		});
96
97		$('form.cart').submit(function() {
98			clearInterval(refreshIntervalId);
99
100		});
101
102		$( "input[name=bid_value]" ).on('changein', function( event ) {
103			$(this).addClass('changein');
104		});
105
106		$( ".sealed-text a" ).on('click', function(e){
107			e.preventDefault();
108			$('.sealed-bid-desc').slideToggle('fast');
109		});
110
111
112
113		$( ".sa-watchlist-action" ).on('click', watchlist);
114
115		function watchlist( event ) {
116			var auction_id = jQuery(this).data('auction-id');
117					var currentelement  =  $(this);
118					event.preventDefault();
119					jQuery.ajax({
120					 type : "get",
121					 url : SA_Ajax.ajaxurl,
122					 data : { post_id : auction_id, 'wsa-ajax' : "watchlist"},
123					 success: function(response) {
124								var parent = currentelement.parent().replaceWith(response);
125								 $( ".sa-watchlist-action" ).off('click').on('click', watchlist);
126								 jQuery( document.body).trigger('sa-wachlist-action',[response,auction_id] );
127						}
128					});
129		}
130	if (jQuery().autoNumeric) {
131		var bid_valu = $('.auction_form .qty').autoNumeric('init', {
132			unformatOnSubmit: true,
133			digitGroupSeparator: autoNumericdata.digitGroupSeparator,
134			decimalCharacter: autoNumericdata.decimalCharacter,
135			currencySymbol: autoNumericdata.currencySymbol,
136			currencySymbolPlacement: autoNumericdata.currencySymbolPlacement,
137			decimalPlacesOverride: autoNumericdata.decimalPlacesOverride,
138			showWarnings: false,
139		});
140		jQuery('.auction_form div.quantity.buttons_added').off("click"); //flatsome bug
141
142		jQuery(document).on("click", ".auction_form .plus-bid,.auction_form .minus-bid", function() {
143         console.log('clcik')
144			var t = jQuery(this).closest(".quantity").find("input[name=bid_value]"),
145				a = parseFloat( jQuery(this).parents('.auction_form').find('.qty').autoNumeric('get') ),
146				n = parseNumber( t.attr("max") ) ,
147				s = parseNumber( t.attr("min") ) ,
148				vb = '',
149				e = t.attr("step");
150				a && "" !== a && "NaN" !== a || (a = 0), ("" === n || "NaN" === n) && (n = ""), ("" === s || "NaN" === s) && (s = 0), ("any" === e || "" === e || void 0 === e || "NaN" === parseFloat(e)) && (e = 1),
151				jQuery(this).is(".plus-bid") ? t.val(number_format(n && (n == a || a > n) ? n : a + parseFloat(e) )) : s && (s == a || s >
151 a) ? t.val(number_format( s ) ) : a > 0 && t.val( number_format (a - parseFloat(e) ) ),
152				t.trigger("change"),
153				$('.auction_form .qty').autoNumeric('update');
154
155
156
157
158
159		});
160
161	}
162
163	 $(document).on('touchend', '.recent-bids-list-item a', function (event) {
164		$(this).data('touched', true);
165		}).on('mouseenter', '.recent-bids-list-item', function (event) {
166			var $this = $(this);
167			if (!$this.find('a').data('touched')) {
168				$('.recent-bids-list-item').removeClass('recent-bids-list-item-active');
169				$this.addClass('recent-bids-list-item-active');
170				var auction_id = $(this).data('auction_id');
171				var $image = $('.recent-bids-image-link[data-auction_id="' + auction_id + '"]').remove().prependTo('.recent-bids-image-links').show();
172			}
173
174		});
175	});
176
177	function closeAuction(){
178			var auctionid = jQuery(this).data('auctionid');
179			var future = jQuery(this).hasClass('future') ? 'true' : 'false';
180			var ajaxcontainer = jQuery(this).parent().next('.auction-ajax-change');
181			if ( ajaxcontainer.length == 0 ){
182				ajaxcontainer = jQuery(".auction_form[data-product_id='" + auctionid + "']");
183			}
184			ajaxcontainer.hide();
185			jQuery( '<div class="ajax-working"></div>' ).insertBefore(ajaxcontainer);
186			ajaxcontainer.parent().children('form.buy-now').hide();
187
188			var ajaxurl = saajaxurl+'=finish_auction';
189
190			jQuery( document.body).trigger('sa-close-auction',[auctionid]);
191			var request =  jQuery.ajax({
192			 type : "post",
193			 url : ajaxurl,
194			 cache : false,
195			 data : {action: "finish_auction", post_id : auctionid, ret: ajaxcontainer.length, future: future},
196			 success: function(response) {
197					if ( response ) {
198						if (response.status == 'closed' ){
199							ajaxcontainer.parent().children('form.buy-now').remove();
200							jQuery('.auction-time-countdown[data-auctionid='+auctionid+']').parent().remove();
201							if ( response.message ){
202								jQuery('.ajax-working').remove();
203								jQuery('.main-auction.auction-time-countdown[data-auctionid='+auctionid+']').parent().remove();
204								ajaxcontainer.empty().prepend(response.message).wrap( "<div></div>" );
205								ajaxcontainer.show();
206								 jQuery( document.body).trigger('sa-action-closed',[auctionid]);
207							}
208						} else if (response.status == 'running') {
209							getPriceAuction();
210							jQuery('.ajax-working').remove();
211							ajaxcontainer.show();
212							ajaxcontainer.parent().children('form.buy-now').show();
213						} else {
214							location.reload();
215						}
216					} else {
217						location.reload();
218					}
219
220				},
221			error: function(){
222				location.reload();
223			},
224			});
225
226	}
227
228
229
230	function getPriceAuction(){
231		var auction, time;
232
233		if(jQuery('.auction-price').length<1){
234			return;
235		}
236
237		if (running == true){
238			return;
239		}
240
241		running = true;
242
243		var ajaxurl = saajaxurl+'=get_price_for_auctions';
244
245		jQuery.ajax({
246
247			type : "post",
248			encoding:"UTF-8",
249			url : ajaxurl,
250			dataType: 'json',
251			data : {action: "get_price_for_auctions", "last_activity" : SA_last_activity},
252			success: function(response) {
253
254				if(response != null ) {
255					if (typeof response.last_activity != 'undefined') {
256						SA_last_activity = response.last_activity;
257					}
258					jQuery.each( response, function( key, value ) {
259						auction = jQuery("body").find(".auction-price[data-auction-id='" + key + "']");
260						auction.replaceWith(value.curent_bid);
261						jQuery("body").find("[data-auction-id='" + key + "']").addClass('changed blink').fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100, function(){jQuery(this).removeClass('blink');});
262
263						if (typeof value.timer != 'undefined') {
264							var curenttimer = jQuery("body").find(".auction-time-countdown[data-auctionid='" + key + "']");
265							if(curenttimer.attr('data-time') != value.timer){
266								curenttimer.attr('data-time',value.timer );
267								if ( ! jQuery(' body' ).hasClass('logged-in') ) {
268									time = jQuery.SAcountdown.UTCDate(-(new Date().getTimezoneOffset()),new Date(value.timer*1000));
269								} else {
270									time = value.timer
271								}
272								curenttimer.SAcountdown('option',  'until', time );
273								curenttimer.addClass('changed blink').fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100, function(){jQuery(this).removeClass('blink');});
274							}
275						}
276						if (typeof value.curent_bider != 'undefined' ) {
277							var curentuser = jQuery("input[name=user_id]");
278							var mainauction = jQuery("input[name=place-bid]").val();
279							if (curentuser.length){
280								if(value.curent_bider != curentuser.val() && mainauction == key ){
281									jQuery('.woocommerce-message:contains("'+  data.no_need  +'")').replaceWith(data.outbid_message );
282									jQuery('.wc-block-components-notice-banner:contains("'+  data.no_need  +'")').replaceWith(data.outbid_message );
283									jQuery( ".reserve_not_meet[data-auction-id='"+key+"']" ).parent().remove();
284
285								}
286							}
287							if(jQuery( "span.winning[data-auction_id='"+key+"']" ).attr('data-user_id') != value.curent_bider){
288								jQuery( document.body).trigger('sa-action-removing-winning-badge',[ jQuery( "span.winning[data-auction_id='"+key+"']" ), key, value ] );
289								jQuery( "span.winning[data-auction_id='"+key+"']" ).remove();
290							}
291
292
293						}
294
295						if (typeof value.bid_value != 'undefined' ) {
296							if(!jQuery( "input[name=bid_value][data-auction-id='"+key+"']" ).hasClass('changedin')){
297								jQuery( "input[name=bid_value][data-auction-id='"+key+"']" ).val(value.bid_value).attr('value', value.bid_value).removeClass('changedin');
298								jQuery("input[name=bid_value][data-auction-id='"+key+"']").autoNumeric('set', value.bid_value);
299							}
300						}
301
302						if (typeof value.reserve != 'undefined' ) {
303
304							jQuery( ".auction-ajax-change .reserve[data-auction-id='"+key+"']" ).text(value.reserve);
305
306						}
307
308						if (typeof value.activity != 'undefined' ) {
309
310							jQuery("#auction-history-table-" + key +" tbody > tr:first" ).before(value.activity);
311							jQuery("#auction-history-table-" + key +" tbody > tr:first" ).addClass('changed blink').fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100, function(){jQuery(this).removeClass('blink');})
312
313						}
314
315						if (typeof value.add_to_cart_text != 'undefined' ) {
316
317							jQuery( "a.button.product_type_auction[data-product_id='"+key+"']" ).text(value.add_to_cart_text);
318
319						}
320
321						jQuery( document.body).trigger('sa-action-price-changed',[key, value]);
322
323					});
324
325				//console.log(response);
326			 }
327			 jQuery( document.body).trigger('sa-action-price-respons', response);
328			 running = false;
329		 },
330		 error: function() {
331			running = false;
332		 }
333		});
334
335	}
336	function number_format (number , decimals = autoNumericdata.decimalPlacesOverride, dec_point = autoNumericdata.decimalCharacter, thousands_sep = autoNumericdata.digitGroupSeparator) {
337		// Strip all characters but numerical ones.
338		number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
339
340		var n = !isFinite(+number) ? 0 : +number,
341			prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
342			sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
343			dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
344			s = '',
345			toFixedFix = function (n, prec) {
346				var k = Math.pow(10, prec);
347				return '' + Math.round(n * k) / k;
348			};
349		// Fix for IE parseFloat(0.55).toFixed(0) = 0;
350		s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
351		if (s[0].length > 3) {
352			s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
353		}
354		if ((s[1] || '').length < prec) {
355			s[1] = s[1] || '';
356			s[1] += new Array(prec - s[1].length + 1).join('0');
357		}
358
359		return s.join(dec);
360	}
361
362	function parseNumber(strg, dec_point = autoNumericdata.decimalCharacter) {
363		var strg = strg || "";
364		var decimal = dec_point;
365		strg = strg.replace(/[^0-9$.,]/g, '');
366		if(strg.indexOf(',') > strg.indexOf('.')) decimal = ',';
367		if((strg.match(new RegExp("\\" + decimal,"g")) || []).length > 1) decimal="";
368		if (decimal != "" && (strg.length - strg.indexOf(decimal) - 1 == 3) && strg.indexOf("0" + decimal)!==0) decimal = "";
369		strg = strg.replace(new RegExp("[^0-9$" + decimal + "]","g"), "");
370		strg = strg.replace(',', '.');
371		return parseFloat(strg);
372	}
373
374})(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.