PageSourceSearch

https://www.nsws.gov.in/modules/custom/sws_configs/js/alterSearch.js?v=1.1

js nsws.gov.in collected 2026-10-02 05:01:19 UTC 3,399 bytes, 93 lines download raw bytes

1(function ($, Drupal, window, document, drupalSettings) {
2  "use strict";
3  Drupal.behaviors.faqs = {
4    attach: function (context, settings) {
5      // Function calls.
6
7      jQuery(document).ajaxSend(function (event, jqxhr, settings) {
8        if (settings.url.indexOf("frontpage/autocomplete/search") > -1) {
9          var approvalType = jQuery("input.approvals-search-box:focus").parents(".homepage-approvals-search").find("[data-drupal-selector='edit-select-approvals']").val();
10          settings.url = settings.url + '&approvalType=' + approvalType;
11          var urlSections = settings.url.split('&');
12          if (urlSections[0] && urlSections[1]) {
13            var newurl = urlSections[0] + '&' + urlSections[1];
14          }
15          settings.url = newurl;
16        }
17      });
18
19      // Autocomplete Redirect url
20      jQuery(".homepage-approvals-search").on('autocompleteselect', function (event, node) {
21        dataLayer.push({ 'event': 'searchSuggestedApprovals', 'Approval Name': node.item.urlTitle });
22        var url = '';
23        if (node.item.approvalType == "centralApprovals") {
24          localStorage.setItem("approvalsId", node.item.licenseId);
25          url = '/portal/approval-details/' + node.item.ministryUrlTitle + '/' + node.item.departmentUrlTitle + '/' + node.item.urlTitle;
26        }
27        if (node.item.approvalType == "stateApprovals") {
28          localStorage.setItem("approvalsId", node.item.licenseId);
29          url = '/portal/approval-details/' + node.item.stateUrlTitle + '/' + node.item.authorityUrlTitle + '/' + node.item.urlTitle;
30        }
31        if (node.item.schemeUrl) {
32          url = node.item.schemeUrl;
33        }
34        if (url) {
35          window.open(url, '_blank');
36        }
37        jQuery("input").on("keydown", function search(e) {
38          if (url && e.keyCode == 13) {
39            window.open(url, '_blank');
40            url = '';
41            jQuery('.approvals-search-box').val('');
42          }
43          if (url && e.keyCode == 8) {
44            url = '';
45            jQuery('.approvals-search-box').val('');
46          }
47        });
48      });
49
50      jQuery("input").bind('keydown', function (e) {
51        if (e.keyCode == 13) {
52          e.preventDefault();
53        }
54      });
55
56      //Direct click
57
58      jQuery('.approvals-search-box').autocomplete({
59        select: showResult,
60        change: showResult
61        });
62        function showResult(event, ui) { 
63        jQuery('.button-green').click()
64        }
65        
66
67      //added specific urls for approval types
68      jQuery('.button-green').on('click', function (e) {
69        var approvalVal = jQuery('.banner-content .approval-type').val();
70        var redirectUrl = '';
71        if(approvalVal == "centralApprovals"){
72          redirectUrl = '/portal/approvalsandregistrations';
73        }
74        else if(approvalVal == "stateApprovals"){
75          redirectUrl = '/state-list';
76        }
77        else if(approvalVal == "allSchemes"){
78          redirectUrl = '/government-schemes';
79        }
80        window.open(redirectUrl, '_blank');
81      });
82
83      jQuery("#edit-select-approvals--2").on('change', function () {
84        jQuery('.approvals-search-box').val('');
85      });
86
87      jQuery("#edit-select-approvals").on('change', function () {
88        jQuery('.approvals-search-box').val('');
89      });
90
91    },
92  };
93})(jQuery, Drupal, this, this.document, drupalSettings);

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.