PageSourceSearch

https://poonch.nic.in/wp-content/plugins/common_utility/js/common.js

js poonch.nic.in collected 2026-10-02 22:26:20 UTC 20,369 bytes, 560 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3    $('body').on('focus', '.enter-captcha', function () {
4        $(this).attr('autocomplete', 'off');
5    });
6
7    function validateEmail(email) {
8        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
9        return re.test(email);
10    }
11
12    function validatePhone(phone) {
13        var re = new RegExp("^(?:(?:\\+|0{0,2})91([\\-])?|[0]?)?[789]\\d{9}$", "g");
14        return re.test(phone);
15    }
16
17    $('.select-lang li a').on('click', function () {
18      var getDropdownLang = $(this).text().trim();
19      if (confirm("This will lead you to " + getDropdownLang + " language")) {
20          return true;
21      }
22      return false;
23    });    
24
25    $('script,style').each(function () {
26
27        var attr = $(this).attr('type');
28        if (typeof attr !== typeof undefined && attr !== false) {
29            $(this).removeAttr('type');
30        }
31    });
32
33    $('#SkipContent').attr('tabindex', '-1');
34    $('iframe').each(function () {
35        $(this).removeAttr('frameborder');
36        $(this).removeAttr('width');
37    });
38
39    /* Where To Stay Ajax Load*/
40
41    jQuery.ajaxSetup({ cache: false });
42
43    jQuery('.festivalLoadDom').on('change', '.wts-filter', function (event) {
44
45        event.preventDefault();
46
47        var data = {};
48        var $this = $(this);
49        var parents = $(this).parents('.wts-filter-hold');
50        var isSelectParentTerm = $(this).attr('data-parent');
51        var action = "where_to_stay_ajax";
52        var foundPosts = 0;
53        data.filterTermId = parseInt($this.val());
54
55        $.post({
56            //url:AwaasData.ajaxUrl + '? = ' + new Date().getTime(),
57            url: AwaasData.ajaxUrl,
58            method: 'POST',
59            dataType: 'JSON',
60            data: { data: data, action: action },
61            beforeSend: function () {
62
63                $this.parents('.festivalLoadDom').find('.festivalcontainer').attr('data-filter-term-id', data.filterTermId);
64                $this.parents('.festivalLoadDom').find('.festivalcontainer').attr('data-current-page', 1);
65                parents.data('ajaxRunning', true);
66                $('.loader').show();
67            },
68            success: function (responseResults, status, xhr) {
69
70                $this.parents('.festivalLoadDom').find('.festivalcontainer').html(responseResults.html);
71                parents.data('ajaxRunning', false);
72                if (responseResults.found_posts > 1) {
73
74                    if (typeof isSelectParentTerm !== typeof undefined && isSelectParentTerm !== false) {
75
76
77                        parents.find('.wts-child-filter').off().attr('disabled', 'disabled');
78                        // parents.find('.wts-child-filter').html('<option value="0">All</option>');
79
80                        if (parseInt($this.val()) !== 0) {
81
82                            $.post({
83                                url: AwaasData.ajaxUrl,
84                                method: 'POST',
85                                dataType: 'JSON',
86                                data: { data: data, action: 'where_to_stay_child_term_ajax' },
87                                beforeSend: function () {
88
89                                    $this.parents('.festivalLoadDom').find('.festivalcontainer').attr('data-filter-term-id', data.filterTermId);
90                                    parents.data('ajaxRunning', true);
91
92                                },
93                                success: function (responseTemrs) {
94
95                                    parents.find('.wts-child-filter').removeAttr('disabled').html(responseTemrs.html);
96                                    parents.data('ajaxRunning', false);
97                                    $('.loader').hide();
98                                }
99
100
101                            })
102                        } else {
103                            $('.loader').hide();
104                        }
105
106                    } else {
107                        $('.loader').hide();
108                    }
109                } else {
110                    $('.loader').hide();
111                    if (typeof isSelectParentTerm !== typeof undefined && isSelectParentTerm !== false) {
112                        parents.find('.wts-child-filter').attr('disabled', 'disabled');
113                        //parents.find('.wts-child-filter').html('<option value="0">All</option>');
114                    }
115                }
116            }
117
118        })
119
120
121
122    })
123
124    jQuery('.festivalLoadDom').on('click', '.festivalLoad .pegination li a', function (event) {
125
126        event.preventDefault();
127        var data = {};
128        var $this = $(this);
129        var parentUl = $this.parents('ul');
130        var link = $this.attr('href');
131
132        var action = "where_to_stay_ajax";
133        data.loadAction = 'page';
134        data.paginateAction = $this.attr('data-action');
135        data.filterTermId = parseInt($this.parents('.festivalLoadDom').find('.festivalcontainer').attr('data-filter-term-id'));
136        data.currentPage = parseInt($this.parents('.festivalLoadDom').find('.festivalcontainer').attr('data-current-page'));
137
138        if (parentUl.data('ajaxRunning')) {
139            return;
140        }
141
142        $.post({
143            url: AwaasData.ajaxUrl,
144            method: 'POST',
145            dataType: 'JSON',
146            data: { data: data, action: action },
147            beforeSend: function () {
148
149                parentUl.data('ajaxRunning', true);
150                $('.loader').show();
151
152            },
153            success: function (response, status, xhr) {
154
155                $this.parents('.festivalLoadDom').find('.festivalcontainer').html(response.html);
156                $('.festivalcontainer').attr('data-current-page', response.current);
157                parentUl.data('ajaxRunning', false);
158                $('.loader').hide();
159                $('html, body').animate({ scrollTop: $('.festivalLoadDom').offset().top }, 800);
160
161            }
162
163        });
164    });
165
166    /*Gallery flexslider*/
167    var getGridSize = function () {
168        return (window.innerWidth < 600) ? 1 :
169            (window.innerWidth < 900) ? 3 : 4;
170    }
171    jQuery('.prdc-glery-large').flexslider({
172        animation: "slide",
173        controlNav: false,
174        animationLoop: true,
175        slideshow: false,
176        itemWidth: 200,
177        //itemMargin: 5,
178        minItems: getGridSize(), // use function to pull in initial value
179        maxItems: getGridSize() // use function to pull in initial value
180    });
181
182    // Feedback Form Js
183
184    if (jQuery(".wpcf7-form").length > 0) {
185
186        jQuery(".wpcf7-form span.wpcf7-form-control-wrap input,.wpcf7-form span.wpcf7-form-control-wrap textarea,.wpcf7-form span.wpcf7-form-control-wrap select").each(function () {
187            var name = $(this).attr('name');
188
189            $(this).attr('id', name);
190            $(this).parent('span').prevAll('label:first').attr('for', name);
191
192        })
193
194        $('img.siwp_img').attr('tabindex', '0').attr('aria-label', 'CAPTCHA Image');
195
196        jQuery("form.wpcf7-form input#your-name").on('keyup blur', function () {
197
198            var name = $(this);
199            var errorMsg = '';
200            var nameregex = new RegExp("^[A-Za-z ]+$");
201            var ariaRequired = name.attr('aria-required');
202
203            if (
204                typeof ariaRequired !== typeof undefined
205                && ariaRequired !== false
206                && name.val().trim() == ''
207            ) {
208                errorMsg = S3WaaSAccessibilityParams.nameIsRequired;
209                $(this).data("error", true);
210
211            } else if ($('body').hasClass('lang-en') && (name.val() != '' && !nameregex.test(name.val()))) {
212
213                errorMsg = S3WaaSAccessibilityParams.nameInvalidError;
214                $(this).data("error", true);
215            }
216
217            if (errorMsg !== '') {
218
219                name.css('border', '2px solid #ff0000');
220                if (name.parent().find(".wpcf7-not-valid-tip").length == 0) {
221                    $('<span role="alert" class="wpcf7-not-valid-tip" aria-label="' + errorMsg + '">' + errorMsg + '</span>').insertAfter(name);
222                } else {
223                    name.parent().find(".wpcf7-not-valid-tip").text(errorMsg);
224                }
225
226            } else {
227                $(this).data("error", false);
228                name.parent().find(".wpcf7-not-valid-tip").remove();
229                name.css('border', '1px solid #e1e1e1');
230            }
231
232        })
233
234        jQuery("form.wpcf7-form input#your-email").on('keyup blur', function () {
235
236            var email = $(this);
237            var errorMsg = '';
238            var ariaRequired = email.attr('aria-required');
239
240            if (
241                typeof ariaRequired !== typeof undefined
242                && ariaRequired !== false
243                && email.val().trim() == ''
244            ) {
245
246                errorMsg = S3WaaSAccessibilityParams.emailRequired;
247                $(this).data("error", true);
248
249            } else if (!validateEmail(email.val())) {
250
251                errorMsg = S3WaaSAccessibilityParams.emailInvalidError;
252                $(this).data("error", true);
253            }
254
255            if (errorMsg !== '') {
256                email.css('border', '2px solid #ff0000');
257                if (email.parent().find(".wpcf7-not-valid-tip").length == 0) {
258                    $('<span role="alert" class="wpcf7-not-valid-tip" aria-label="' + errorMsg + '">' + errorMsg + '</span>').insertAfter(email);
259                } else {
260                    email.parent().find(".wpcf7-not-valid-tip").text(errorMsg);
261                }
262            } else {
263                $(this).data("error", false);
264                email.parent().find(".wpcf7-not-valid-tip").remove();
265                email.css('border', '1px solid #e1e1e1');
266            }
267
268        })
269
270        jQuery("form.wpcf7-form input#your-mobile").on('keyup blur', function () {
271
272            var mobile = $(this);
273            var errorMsg = '';
274            var ariaRequired = mobile.attr('aria-required');
275
276            if (
277                typeof ariaRequired !== typeof undefined
278                && ariaRequired !== false
279                && mobile.val().trim() == ''
280            ) {
281
282                errorMsg = 'The telephone number is required.';
283                $(this).data("error", true);
284
285            } else if (mobile.val() !== '' && !validatePhone(mobile.val())) {
286
287                errorMsg = 'The telephone number is invalid.';
288                $(this).data("error", true);
289            }
290
291            if (errorMsg !== '') {
292
293                mobile.css('border', '2px solid #ff0000');
294                if (mobile.parent().find(".wpcf7-not-valid-tip").length == 0) {
295                    $('<span role="alert" class="wpcf7-not-valid-tip" aria-label="' + errorMsg + '">' + errorMsg + '</span>').insertAfter(mobile);
296                } else {
297                    mobile.parent().find(".wpcf7-not-valid-tip").text(errorMsg);
298                }
299
300            } else {
301                $(this).data("error", false);
302                mobile.parent().find(".wpcf7-not-valid-tip").remove();
303                mobile.css('border', '1px solid #e1e1e1');
304            }
305
306        })
307
308        jQuery("form.wpcf7-form input#your-subject").on('keyup blur', function () {
309
310
311            var subject = $(this);
312            var errorMsg = '';
313            var subregex = new RegExp("^[A-Za-z0-9- ]+$");
314
315            var ariaRequired = subject.attr('aria-required');
316
317            if (
318                typeof ariaRequired !== typeof undefined
319                && ariaRequired !== false
320                && subject.val().trim() == ''
321            ) {
322
323                errorMsg = S3WaaSAccessibilityParams.subjectRequired;
324                $(this).data("error", true);
325
326            } else if (subject.val() !== '' && $('body').hasClass('lang-en') && !subregex.test(subject.val())) {
327                errorMsg = 'Subject is invalid';
328                $(this).data("error", true);
329            }
330
331            if (errorMsg !== '') {
332                subject.css('border', '2px solid #ff0000');
333                if (subject.parent().find(".wpcf7-not-valid-tip").length == 0) {
334                    $('<span role="alert" class="wpcf7-not-valid-tip" aria-label="' + errorMsg + '">' + errorMsg + '</span>').insertAfter(subject);
335                } else {
336                    subject.parent().find(".wpcf7-not-valid-tip").text(errorMsg);
337                }
338            } else {
339                $(this).data("error", false);
340                subject.parent().find(".wpcf7-not-valid-tip").remove();
341                subject.css('border', '1px solid #e1e1e1');
342            }
343
344        })
345
346        jQuery("form.wpcf7-form textarea#your-message").on('keyup blur', function () {
347
348
349            var message = $(this);
350            var errorMsg = '';
351            var ariaRequired = message.attr('aria-required');
352
353            if (
354                typeof ariaRequired !== typeof undefined
355                && ariaRequired !== false
356                && message.val().trim() == ''
357            ) {
358
359                errorMsg = S3WaaSAccessibilityParams.messageRequired;
360                $(this).data("error", true);
361
362            }
363
364            if (errorMsg !== '') {
365
366                message.css('border', '2px solid #ff0000');
367                if (message.parent().find(".wpcf7-not-valid-tip").length == 0) {
368                    $('<span role="alert" class="wpcf7-not-valid-tip" aria-label="' + errorMsg + '">' + errorMsg + '</span>').insertAfter(message);
369                } else {
370                    message.parent().find(".wpcf7-not-valid-tip").text(errorMsg);
371                }
372
373            } else {
374                $(this).data("error", false);
375                message.parent().find(".wpcf7-not-valid-tip").remove();
376                message.css('border', '1px solid #e1e1e1');
377            }
378
379        })
380
381        jQuery("form.wpcf7-form input[name=\"siwp_captcha_value\"]").on('keyup blur', function () {
382
383
384            var captcha = $(this);
385            var errorMsg = '';
386
387            if (captcha.val().trim() == '') {
388                errorMsg = S3WaaSAccessibilityParams.captchaRequired;
389                $(this).data("error", true);
390            }
391
392            if (errorMsg !== '') {
393
394                if (captcha.parent().find(".wpcf7-not-valid-tip").length == 0) {
395                    $('<span role="alert" class="wpcf7-not-valid-tip" aria-label="' + errorMsg + '">' + errorMsg + '</span>').insertAfter(captcha);
396                } else {
397                    captcha.parent().find(".wpcf7-not-valid-tip").text(errorMsg);
398                }
399
400            } else {
401                $(this).data("error", false);
402                captcha.parent().find(".wpcf7-not-valid-tip").remove();
403                captcha.css('border', '1px solid #e1e1e1');
404            }
405
406        })
407
408        // jQuery("form.wpcf7-form").on('submit', function () {
409
410        //     var offset = 250;
411        //     var error = false;
412
413        //     error = jQuery("form.wpcf7-form input#your-name").trigger('keyup').data('error');
414
415        //     if (!error) {
416        //         error = jQuery("form.wpcf7-form input#your-email").trigger('keyup').data('error');
417        //     }
418        //     if (!error) {
419        //         error = jQuery("form.wpcf7-form input#your-mobile").trigger('keyup').data('error');
420        //     }
421        //     if (!error) {
422        //         error = jQuery("form.wpcf7-form input#your-subject").trigger('keyup').data('error');
423        //     }
424        //     if (!error) {
425        //         error = jQuery("form.wpcf7-form textarea#your-message").trigger('keyup').data('error');
426        //     }
427        //     if (!error) {
428        //         error = jQuery("form.wpcf7-form input[name=\"siwp_captcha_value\"]").trigger('keyup').data('error');
429        //     }
430
431        //     if (error) {
432
433        //         $('html, body').animate({
434        //             scrollTop: ($('span.wpcf7-not-valid-tip').first().offset().top - offset)
435        //         }, 1500);
436        //         setTimeout(function () {
437        //             $('span.wpcf7-not-valid-tip').first().focus();
438        //         }, 1400)
439        //         return false;
440        //     }
441        // })
442
443        jQuery("form.wpcf7-form").on("submit", function(event) {
444            const form = jQuery(this);
445            const fields = [
446            form.find("input#your-name"),
447            form.find("input#your-email"),
448            form.find("input#your-subject"),
449            form.find("textarea#your-message"),
450            form.find("input[name='siwp_captcha_value']")
451            ];
452
453            let firstInvalidField = null;
454
455            fields.forEach(field => {
456            field.trigger("blur");
457            if (field.data("error") && !firstInvalidField) {
458                firstInvalidField = field;
459            }
460            });
461
462            if (firstInvalidField) {
463                event.preventDefault();
464                const offset = AwaasData.isUserLoggedIn ? 150 : 65;
465                jQuery("html, body").animate(
466                    { scrollTop: firstInvalidField.offset().top - offset },
467                    1500
468                );
469                setTimeout(() => {
470                    firstInvalidField.focus();
471                    if (firstInvalidField.is("input, textarea")) {
472                    firstInvalidField[0].setSelectionRange?.(firstInvalidField.val().length, firstInvalidField.val().length);
473                    }
474                }, 1500);
475                return false;
476            }
477        });
478
479        jQuery(document).ready(function($) {
480            $('input[name="your-name"]').attr('autocomplete', 'name');
481            $('input[name="your-email"]').attr('autocomplete', 'email');
482            $('input[name="your-subject"]').attr('autocomplete', 'subject');
483            $('textarea[name="your-message"]').attr('autocomplete', 'on');
484        });
485        
486        $('span.wpcf7-form-control-wrap').each(function (i, element) {
487            var ariaLabel = '';
488            if ($(this).find('input').length > 0) {
489                ariaLabel = $(this).find('input').attr('name') + ' ';
490            }
491
492            ariaLabel += $(this).find('span.wpcf7-not-valid-tip').text();
493
494            $(this).find('span.wpcf7-not-valid-tip')
495                .attr('tabindex', '0')
496                .attr('aria-label', ariaLabel);
497        })
498    }
499
500    $('img').each(function () {
501        if (typeof $(this).attr('alt') === "undefined") {
502            $(this).attr('alt', '');
503        }
504    });
505
506    // Tabs
507    jQuery('.tabs-menu li').click(function () {
508        var index = $(this).index();
509        jQuery('.tabs-menu li').removeClass('active');
510        jQuery(this).addClass('active');
511        jQuery('.panes').hide();
512        jQuery('.panes').eq(index).show();
513        return false
514    });
515
516    $('body').on('click', '.clickToCopy', function () {
517        let $this = $(this);
518        let text = $(this).text().replaceAll("[at]", "@").replaceAll("[dot]", ".");
519        $this.css('cursor','wait');
520        setTimeout(function(){
521            navigator.clipboard.writeText(text).then(() => {
522                $this.css('cursor','pointer');
523            }).catch((error) => {
524                console.error(`Could not copy text: ${error}`);
525            });
526        },500);
527    });
528
529});
530const uA = navigator.userAgent;
531const vendor = navigator.vendor;
532if (/Safari/i.test(uA) && /Apple Computer/.test(vendor) && !/Mobi|Android/i.test(uA)) {
533    jQuery('.searchbox').on('click', function () {
534        jQuery('.goiSearch').css("visibility", "visible");
535    })
536    jQuery(document).mouseup(function (e) {
537
538        var container = jQuery(".goiSearch");
539        if (!container.is(e.target) && container.has(e.target).length === 0) {
540            container.css("visibility", "hidden");
541        }
542    });
543}
544
545jQuery(document).ready(function ($) {
546  $(".goiSearch form, .search-area form, .header-middle form").on("submit", function (e) {
547    let search = $(this).find("#search");
548    if (search.val() == "" || search.val().length < 3) {
549      alert("Search text should be minimum 3 characters long!");
550      search.focus();
551      e.preventDefault();
552    }
553  });
554});
555
556jQuery(document).ready(function ($) {
557  setTimeout(function () {
558      $('.captcha-refresh-btn').trigger('click');
559  }, 500);
560});

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.