PageSourceSearch

https://essays.discount/wp-content/plugins/listingpro-plugin/assets/js/submit-listing.js

js essays.discount collected 2026-10-06 13:17:05 UTC 11,281 bytes, 280 lines download raw bytes

1var widgetsubmit;
2
3
4/**
5 * detect IE
6 * returns version of IE or false, if browser is not Internet Explorer
7 */
8function detectIE() {
9    var ua = window.navigator.userAgent;
10
11    var msie = ua.indexOf('MSIE ');
12    if (msie > 0) {
13        // IE 10 or older => return version number
14        return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
15    }
16
17    var trident = ua.indexOf('Trident/');
18    if (trident > 0) {
19        // IE 11 => return version number
20        var rv = ua.indexOf('rv:');
21        return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
22    }
23
24    var edge = ua.indexOf('Edge/');
25    if (edge > 0) {
26       // Edge (IE 12+) => return version number
27       return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
28    }
29
30    // other browser
31    return false;
32}
33
34function recaptchaCallbackk() {
35    if (jQuery('#recaptcha-securet').length) {
36        var sitekey = jQuery('#recaptcha-securet').data('sitekey');
37        widgetsubmit = grecaptcha.render(document.getElementById('recaptcha-securet'), {
38            'sitekey': sitekey
39        })
40    }
41}
42window.onload = recaptchaCallbackk;
43jQuery(document).on('submit', '#lp-submit-form', function(e) {
44    jQuery('.error_box').hide('');
45    jQuery('.error_box').html('');
46    jQuery('.error_box').text('');
47    jQuery('.username-invalid-error').html('');
48    jQuery('.username-invalid-error').text('');
49    var $this = jQuery(this);
50    jQuery('span.email-exist-error').remove();
51    jQuery('input').removeClass('error-msg');
52    jQuery('textarea').removeClass('error-msg');
53    $this.find('.preview-section .fa-angle-right').removeClass('fa-angle-right');
54    $this.find('.preview-section .fa').addClass('fa-spinner fa-spin');
55    jQuery('.bottomofbutton.lpsubmitloading').addClass('fa-spinner fa-spin');
56	jQuery('.loaderoneditbutton.lpsubmitloading').addClass('fa-spinner fa-spin');
57    var fd = new FormData(this);
58	
59	$maxAlloedSize = jQuery('#lp-submit-form').data('imgsize');
60	$totalAlloedImgs = jQuery('#lp-submit-form').data('imgcount');
61	
62	if(detectIE() == false){
63		
64		var $fullbrowserdet = navigator.sayswho;
65		var $browserArray = $fullbrowserdet.split(" ");// outputs: `Chrome 62`
66		if($browserArray[0]=="Safari"){
67			if($browserArray[1] >= 12){
68				fd.delete('listingfiles[]');
69				fd.delete('lp-featuredimage[]');
70				fd.delete('business_logo[]');
71			}
72			
73		}else{
74			
75			fd.delete('listingfiles[]');
76			fd.delete('lp-featuredimage[]');
77			fd.delete('business_logo[]');
78			
79		}
80		
81		
82	}
83	$totalfilesize = 0;
84	var lpcount = 0;
85	var lpcountsize = 0;
86	$totalfilesize = jQuery('.lplistgallery').attr('data-savedgallweight');
87   
88	$selectedImagesCount = jQuery('.lplistgallery').attr('data-savedgallerysize');
89    if (jQuery("input[name='listingfiles[]']").length){
90        
91        jQuery.each(jQuery("input[name='listingfiles[]']"), function(k, files) {
92            jQuery.each(jQuery("input[name='listingfiles[]']")[k].files, function(i, file) {
93                if(file.size > 1 || file.fileSize > 1) {
94					$totalfilesize = parseInt($totalfilesize) + parseInt(file.size);
95                    fd.append('listingfiles[' + lpcount + ']', file);
96                    lpcount++;
97					
98                }
99            });
100        });
101    }
102
103	lpcount = parseInt(lpcount) + parseInt($selectedImagesCount);
104    $AlloedSize = true;
105    $Alloedimgcount = true;
106	if(!isNaN($totalfilesize)){
107		if($totalfilesize > $maxAlloedSize){
108			msgf = jQuery('#lp-submit-form').data('sizenotice');
109			var resError = {response : 'fail', msg : msgf};
110			listing_ajax_response_notice(resError);
111			$this.find('.preview-section').addClass('fa-angle-right');
112			jQuery('.lpsubmitloading').addClass('fa-angle-right');
113			$this.find('.preview-section .fa').removeClass('fa-spinner fa-spin');
114			jQuery('.bottomofbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
115			jQuery('.loaderoneditbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
116			$AlloedSize = false;
117		}
118	}
119	if(lpcount > $totalAlloedImgs){        
120		msgf = jQuery('#lp-submit-form').data('countnotice');
121		var resError = {response : 'fail', msg : msgf};
122		listing_ajax_response_notice(resError);
123		jQuery('.lpsubmitloading').addClass('fa-angle-right');
124		$this.find('.preview-section').addClass('fa-angle-right');
125		$this.find('.preview-section .fa').removeClass('fa-spinner fa-spin');
126		jQuery('.bottomofbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
127		jQuery('.loaderoneditbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
128        $Alloedimgcount = false;
129	}else{
130	
131	
132
133			if (jQuery("input[name='business_logo[]']").length){
134				fd.append('business_logo[]', jQuery("input[name='business_logo[]']")[0].files[0]);
135			}
136
137			if (jQuery("input[name='lp-featuredimage[]']").length){
138				fd.append('lp-featuredimage[]', jQuery("input[name='lp-featuredimage[]']")[0].files[0]);
139			}
140			jQuery("#listingsubmitBTN").prop('disabled', !0);
141			fd.append('action', 'listingpro_submit_listing_ajax');
142			if (jQuery('#already-account').is(':checked')) {
143				fd.append('processLogin', 'yes')
144			} else {
145				fd.append('processLogin', 'no')
146			}
147			var postContent = tinymce.editors.inputDescription.getContent();
148			if (postContent != '' || postContent != null || postContent != !1) {
149				fd.append('postContent', postContent)
150			} else {
151				fd.append('postContent', '')
152			}
153        if($Alloedimgcount == true){
154            fd.append('imageCount', lpcount)
155        }
156			jQuery.ajax({
157				type: 'POST',
158				url: ajax_listingpro_submit_object.ajaxurl,
159				data: fd,
160				contentType: !1,
161				processData: !1,
162				success: function(res) {
163					if (jQuery('#recaptcha-securet').length) {
164						lp_reset_grecaptcha()
165					}
166					var resp = jQuery.parseJSON(res);
167					listing_ajax_response_notice(resp);
168					if (resp.response === "fail") {
169						jQuery("#listingsubmitBTN").prop('disabled', !1);
170						jQuery.each(resp.status, function(k, v) {
171							if (k === "postTitle") {
172								jQuery("input:text[name='postTitle']").addClass('error-msg')
173							} else if (k === "gAddress") {
174								jQuery("input:text[name='gAddress']").addClass('error-msg')
175							} else if (k === "category") {
176								jQuery("#inputCategory_chosen").find('a.chosen-single').addClass('error-msg');
177								jQuery("#inputCategory").next('.select2-container').find('.selection').find('.select2-selection--single').addClass('error-msg');
178								jQuery("#inputCategory").next('.select2-container').find('.selection').find('.select2-selection--multiple').addClass('error-msg')
179							} else if (k === "location") {
180								jQuery("#inputCity_chosen").find('a.chosen-single').addClass('error-msg');
181								jQuery("#inputCity").next('.select2-container').find('.selection').find('.select2-selection--single').addClass('error-msg');
182								jQuery("#inputCity").next('.select2-container').find('.selection').find('.select2-selection--multiple').addClass('error-msg')
183							} else if (k === "postContent") {
184								jQuery("textarea[name='postContent']").addClass('error-msg');
185								jQuery("#lp-submit-form .wp-editor-container").addClass('error-msg')
186							} else if (k === "email") {
187								jQuery("input#inputEmail").addClass('error-msg')
188							} else if (k === "inputUsername") {
189								jQuery("input#inputUsername").addClass('error-msg')
190							} else if (k === "inputUserpass") {
191								jQuery("input#inputUserpass").addClass('error-msg')
192							}
193						});
194						var errorrmsg = jQuery("input[name='errorrmsg']").val();
195						$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
196						$this.find('.preview-section .fa').addClass('fa-times');
197						$this.find('.preview-section').find('.error_box').text(errorrmsg).show();
198						jQuery('.bottomofbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
199						jQuery('.bottomofbutton.lpsubmitloading').addClass('fa-times');
200						jQuery('.loaderoneditbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
201					   jQuery('.loaderoneditbutton.lpsubmitloading').addClass('fa-times');
202					} else if (resp.response === "failure") {
203						if (jQuery('#already-account').is(':checked')) {
204							jQuery('.lp-submit-have-account').append(resp.status)
205						} else {
206							jQuery("input#inputEmail").after(resp.status);
207							jQuery("div#inputEmail").after(resp.status)
208						}
209						$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
210						$this.find('.preview-section .fa').addClass('fa-angle-right');
211						jQuery("#listingsubmitBTN").prop('disabled', !1);
212						jQuery('.bottomofbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
213						jQuery('.bottomofbutton.lpsubmitloading').addClass('fa-times');
214						jQuery('.loaderoneditbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
215					   jQuery('.loaderoneditbutton.lpsubmitloading').addClass('fa-times');
216					} else if (resp.response === "success") {
217						$this.find('.preview-section .fa-spinner').removeClass('fa-times');
218						$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
219						$this.find('.preview-section .fa').addClass('fa-check');
220						jQuery('.bottomofbutton.lpsubmitloading').removeClass('fa-times');
221						jQuery('.bottomofbutton.lpsubmitloading').addClass('fa-check');
222						jQuery('.loaderoneditbutton.lpsubmitloading').removeClass('fa-spinner fa-spin');
223						jQuery('.loaderoneditbutton.lpsubmitloading').removeClass('fa-angle-right');
224						jQuery('.loaderoneditbutton.lpsubmitloading').addClass('fa-check');
225						var redURL = resp.status;
226
227						function redirectPageNow() {
228							window.location.href = redURL
229						}
230						setTimeout(redirectPageNow, 1000)
231					}
232				},
233				error: function(request, error) {
234					if (!jQuery('#recaptcha-securet').length === 0) {
235						lp_reset_grecaptcha()
236					}
237					$this.find('.preview-section .fa-spinner').removeClass('fa-times');
238					$this.find('.preview-section .fa-spinner').removeClass('fa-spinner fa-spin');
239					$this.find('.preview-section .fa').addClass('fa-times');
240					alert(error)
241				}
242			});
243	}
244    e.preventDefault()
245});
246
247
248
249function listing_ajax_response_notice(res){
250   if( res.response == 'success' ){
251       jQuery('.lp-notifaction-area').find('h4').text(res.msg);
252       jQuery('.lp-notifaction-area').removeClass('lp-notifaction-error').addClass('lp-notifaction-success');
253       jQuery('.lp-notifaction-area').addClass('active-wrap');
254
255   }
256   if ( res.response == 'fail' || res.response == 'failure' ){
257       jQuery('.lp-notifaction-area').find('h4').text(res.msg);
258       jQuery('.lp-notifaction-area').removeClass('lp-notifaction-success').addClass('lp-notifaction-error');
259       jQuery('.lp-notifaction-area').addClass('active-wrap');
260   }
261}
262
263//check browser code
264
265navigator.sayswho= (function(){
266	var ua= navigator.userAgent, tem, 
267	M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
268	if(/trident/i.test(M[1])){
269		tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];
270		return 'IE '+(tem[1] || '');
271	}
272	if(M[1]=== 'Chrome'){
273		tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
274		if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
275	}
276	M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
277	if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
278	return M.join(' ');
279})();
280

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.