PageSourceSearch

https://www.amgeniss.com/-/media/Themes/CorporateAffairs/amgeniss-…/Scripts/cl-search-resultsISS.js

js amgeniss.com collected 2026-10-05 08:49:29 UTC 40,221 bytes, 842 lines download raw bytes

1/**
2 * @description: returns the param value from a URL string
3 * @param {string} str denotes URL String
4 * @param {string} sParam denotes Param name
5 */
6 var getUrlParameter = function getUrlParameter(str, sParam) {
7	 str = sanitizeinput(str);
8    var firstOccurence = str.indexOf('?')
9    var sPageURL = str.substring(firstOccurence + 1),
10        sURLVariables = sPageURL.split('&'),
11        sParameterName,
12        i;
13
14    for (i = 0; i < sURLVariables.length; i++) {
15        sParameterName = sURLVariables[i].split('=');
16
17        if (sParameterName[0] === sParam) {
18            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
19        }
20    }
21};
22
23
24
25
26
27
28
29// Removed extra search related options such as sorting select, radio buttons etc
30function clearSearchExtras() {
31    $('.quantum-search-result-ul').empty();
32    $('.quantum-search-noresult').hide();
33    $('.quantum-search-results-count').empty();
34    $('#search-Container .sort').hide();
35    // Remove Sortion option in mobile-view
36    $('.main-container-wrapper#search-Container .mobile-sort').hide();
37}
38
39// Removes the radio buttons
40/*function clearRadioButtons() {
41    $('#search-Container .radiocontainer').hide();
42}*/
43
44/**
45 * @description: Removes the HTML Tag from a html string
46 * @param {*} text is the html string
47 * @param {*} selector is the html tag to be removed
48 */
49var removeElements = function(text, selector) {
50    var wrapped = $(text);
51    wrapped.find(selector).remove();
52    return wrapped.html();
53}
54
55// removes the custom selected tab
56function removeSelectedTab() {
57    $('#search-Container .search-custom-tab-select-container .search-custom-tab-label.selected').
58    removeClass('selected');
59}
60
61/**
62 * @description: removes special character from string if the string is not enclosed withing quotes
63 * @param {string} str 
64 */
65function removeSpecialCharacters(str) {
66    if (str.startsWith('"') && str.endsWith('"')) {
67        return str;
68    } else return str.replace(/[^a-zA-Z0-9 ]/g, "");
69}
70
71
72// returns the value of paramaters from the window URL
73function getUrlHashVars() {
74    var vars = [],
75        hash;
76    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
77    for (var i = 0; i < hashes.length; i++) {
78        hash = hashes[i].split('=');
79        vars.push(hash[0]);
80        vars[hash[0]] = decodeURIComponent(hash[1]);
81    }
82    return vars;
83}
84
85// Hides the search results
86function hideSearchRelated() {
87    $('.quantum-search-results-count').hide();
88    $('.main-container-wrapper#search-Container .quantum-search-result').hide();
89}
90
91// Show search results
92function showSearchRelated() {
93    $('.quantum-search-results-count').show();
94    $('.main-container-wrapper#search-Container .quantum-search-result').show();
95}
96
97$(document).ready(function() {
98///$("#searchTextBox-main").attr("disabled", "disabled");
99   // $("#searchSubmitBtn").attr("disabled", "disabled");
100
101    $('#search-Container .sort').hide();
102    $('#search-Container .radiocontainer').hide();
103
104    var NumberofResults = 0;
105
106    $("#sort-by-ddl option").eq(0).before($("<option selected></option>").val("Relevance").text("Relevance"));
107
108    // Check for search keyword from window URL and query into search string
109    if (window.location.pathname === '/search-results') {
110        var str = getUrlHashVars()["q"];
111        if (str == undefined) {
112            $(".main-container-wrapper#search-Container .quantum-search-result").hide()
113        } else {
114            var searchText = str.split('+').join(' ');
115            var updatedText = '';
116            var resultsUrl = "/MyApi/Custom/SearchCl/results?q=" + removeSpecialCharacters(str) + "&rowCount=25&startValue=0";
117            Search();
118        }
119    }
120
121
122    /**
123     * @description: Changes the category of search results
124     * @param {} obj denotes select box or input button for categories
125     */
126    function categoryToggle(obj) {
127        selectedradio = obj.val();
128        // Get sorting param value
129        var sort = getUrlParameter(resultsUrl, 'sort');
130        resultsUrl = "/MyApi/Custom/SearchCl/results?q=";
131        resultsUrl += (updatedText == '') ? removeSpecialCharacters(getUrlHashVars()["q"]) : removeSpecialCharacters(updatedText);
132        if (obj.val() !== "ALL") { // Any category except 'ALL' is selected
133            resultsUrl += "&tag=" + obj.val(); // Add corresponding tag
134        }
135        resultsUrl += "&rowCount=25&startValue=0";
136        // Check if any sorting was applied
137        if (sort != undefined && sort !== '') resultsUrl += '&sort=' + sort;
138        Search();
139    }
140
141    /**
142     * @description: Toggle the Sort by relevavnce-date
143     * @param {*} obj denotes $(this) object. For this function, it would be the select to toggle sorting options
144     */
145    function toggleSortBy(obj) {
146        $('.quantum-search-result-ul').empty();
147        $('.quantum-search-noresult').hide();
148        $('.quantum-search-results-count').empty();
149        $('.pagination').hide();
150        // Get category param value
151        var category = getUrlParameter(resultsUrl, 'tag');
152        resultsUrl = "/MyApi/Custom/SearchCl/results?q=";
153        resultsUrl += (updatedText == '') ? removeSpecialCharacters($('#searchTextBox-main').val()) : removeSpecialCharacters(updatedText);
154        if (obj.val() !== "Relevance") { // Any Sorting Parameter Except Relevance is Selected
155            resultsUrl += "&sort=" + obj.val(); // Add corresponding sorting option
156        }
157        resultsUrl += "&rowCount=25&startValue=0";
158        // Check if any category was applied
159        if (category != undefined && category !== '') resultsUrl += '&tag=' + category;
160        Search();
161    }
162
163    // Cube tournant
164    var showresultsMessage = 'yes';
165    var selectedradio = 'ALL';
166    var resultsCountHtml = $('.quantum-search-results-count').html();
167
168    // Search functionality
169    function Search() {
170        console.log(resultsUrl);
171
172        $('.pagination').hide();
173        // hide search results while loading spinner shows
174        hideSearchRelated();
175        // Remove padding
176        $('.quantum-search-results-count').addClass('pt-0');
177
178        var spinnerHtml = '<div id="loading" class="clearfix"><div class="spinner">' +
179            '<div class="cube1"></div><div class="cube2"></div></div></div>';
180        $('#search-Container').after(spinnerHtml);
181
182        jQuery.getJSON(resultsUrl, function(json) {
183            var SpellCheckSuggestions = json.SpellCheckSuggestions;
184            $('#loading').remove();
185            //$('.radiocontainer').remove();
186            // Remove custom tabs
187            $('#search-Container .search-custom-tab-select-container').remove();
188            // Show search results
189            showSearchRelated();
190            $('.quantum-search-result-ul').empty();
191            $('.quantum-search-noresult').hide();
192            $('.quantum-search-results-count').empty();
193            $('.quantum-search-results-count').html(resultsCountHtml);
194            // Add padding
195            $('.quantum-search-results-count.pt-0').removeClass('pt-0');
196            NumberofResults = json.NumberOfRecordsFound;
197            var gtmSearchWord = getUrlParameter(resultsUrl, 'q');
198            dataLayer.push({
199                'event': 'e_searchResults',
200                'searchTerm': gtmSearchWord,
201                'searchResults': NumberofResults
202
203            });
204            $('.quantum-search-results-count').each(function() {
205
206                if (SpellCheckSuggestions != null) {
207                    $('.quantum-search-noresult').hide();
208                    resultsUrl = "/MyApi/Custom/SearchCl/results?q=" + SpellCheckSuggestions[0] + "&rowCount=25&startValue=0";
209                    showresultsMessage = 'no';
210                    updatedText = SpellCheckSuggestions[0];
211                    Search();
212                    return;
213                }
214
215                if (SpellCheckSuggestions == null && updatedText !== '') {
216                    $('.quantum-search-count-message').
217                    after('<div class="suggestion-instead">Searching ' +
218                        updatedText + ' instead of ' +
219                        $('#searchTextBox-main').val() + '</div>');
220                    searchText = updatedText;
221                    updatedText = '';
222                    var refresh = window.location.protocol + "//" +
223                        window.location.host + window.location.pathname +
224                        '?q=' + searchText;
225                    window.history.replaceState({ path: refresh }, '', refresh);
226                } else if (SpellCheckSuggestions == null && updatedText == '') {
227                    var refresh = window.location.protocol + "//" +
228                        window.location.host + window.location.pathname +
229                        '?q=' + searchText;
230                    window.history.replaceState({ path: refresh }, '', refresh);
231                } else {
232                    $('.suggestion-instead').hide();
233                }
234
235                var text = $(this).html().replace('[--resultskeyword--]', searchText);
236                $('.quantum-search-results-count').hide();
237
238                // Add custom tab-select container
239                var customTabPanelStructure =
240                    '<div class="search-custom-tab-select-container"> ' +
241                    ' <div class="search-custom-tab">' +
242                    '   <div class="search-custom-tab-labels"> ' +
243                    '       <ul class="search-custom-tab-labels-list"> ' +
244                    '           <li class="search-custom-tab-label"><a>ALL</a></li>' +
245                    '       </ul>' +
246                    '   </div> ' +
247                    ' </div>' +
248                    ' <div class="search-custom-select"> ' +
249                    '   <label>Sort by</label>' +
250                    '  <select id="search-custom-select">' +
251                    '  </select> ' +
252                    ' </div>' +
253                    '</div>';
254                $(".main-container-wrapper#search-Container .search").after(customTabPanelStructure);
255
256                // Add all sort options available
257                $('#sort-by-ddl option').each(function() {
258                    $('#search-custom-select').append(
259                        '<option value=' + $(this).attr('value') + '>' + $(this).html() + '</option>'
260                    );
261                });
262
263                // Highlight Correct Selected option
264                var selectedOption = $('#sort-by-ddl').val();
265                $('#search-custom-select').val(selectedOption);
266
267                if (json.Count === 0) {
268                    $('#search-Container .search .radiocontainer').hide();
269                    $('#search-Container .search-custom-tab-select-container').hide();
270                    
271                }
272
273                if (json.Count > 0) {
274
275                    var facetValues = json.FacetValues;
276                    var checkedPro = "";
277                    if (selectedradio == "ALL") checkedPro = "checked";
278                    var facetPresent = false;
279             
280
281                    var htmlCon = " <div class='radiocontainer'>" +
282                        "<h3 class='categories'>Categories</h3>" +
283                        "<p><input type='radio' id='_all' name='myRadio' " +
284                        checkedPro + " value='ALL' checked/> <label id='FirstAll' for='_all'>All</label></p>" +
285
286                        "<p><input type='radio' id='_newsReleases' name='myRadio' value='_newsReleases'/> <label for='_newsReleases'>News Releases</label></p>" +
287
288                        "<p><input type='radio' id='_featuredNews' name='myRadio' value='_featuredNews'/> <label for='_featuredNews'>Featured News</label></p>";
289
290                    var checkForAll = true; // helps in checking whether any tab selected or not, if not will select default tab
291                    for (var key in facetValues) {
292                        if (Number(facetValues[key]) >= 0) {
293                            facetPresent = true;
294                            var checkedPro = "";
295                            if (selectedradio == key) checkedPro = "checked";
296                            htmlCon +=
297                                " <p><input type='radio' name='myRadio' value='" +
298                                key + "' " + checkedPro + " /> " + key + "</p>";
299
300                            // Add Custom Tabs
301                            if (selectedradio == key) {
302                                $('#search-Container .search-custom-tab-select-container .search-custom-tab-labels-list').
303                                append(
304                                    '<li class="search-custom-tab-label selected"><a>' + key + '</a></li>'
305                                )
306                                checkForAll = false;
307                            } else {
308                                $('#search-Container .search-custom-tab-select-container  .search-custom-tab-labels-list').
309                                append(
310                                    '<li class="search-custom-tab-label"><a>' + key + '</a></li>'
311                                )
312                            }
313                        }
314                    }
315                    if (checkForAll) {
316                        $('#search-Container .search-custom-tab-select-container .search-custom-tab-label:first-child').
317                        addClass('selected');
318                    }
319
320                    htmlCon += "</div>";
321
322                    if ($(window).width() < 1023) {
323                        // Remove custom tab and selects in mobile view
324                        $('#search-Container .search-custom-tab-select-container').remove();
325
326                        var htmlCon = " <div class='radiocontainer'>" +
327                            "<h3 class='categories'>Category</h3> " +
328                            "<select id='categories_list'>" +
329                            "<option  value='ALL'>All</option>";
330                        for (var key in facetValues) {
331                            if (Number(facetValues[key]) >= 0) {
332                                facetPresent = true;
333                                var checkedPro = "";
334                                if (selectedradio == key)
335                                    checkedPro = "selected";
336                                htmlCon += " <option " + checkedPro +
337                                    " value='" + key + "'>" + key + "</option>";
338                            }
339                        }
340                        htmlCon += "</select></div>";
341                        // Add Sort for mobile view
342                        if ($('#search-Container .mobile-sort').length == 0) {
343                            var sortHtml =
344                                '<div class="mobile-sort">' +
345                                '<h3>Sort By</h3>' +
346                                '   <select>' +
347                                '   </select>' +
348                                '<div>';
349
350                            htmlCon += sortHtml;
351                        }
352                    }
353
354
355                    $('.main-container-wrapper#search-Container .search-result-box').
356                    after(htmlCon);
357
358                    // Add all sort options available in mobile view
359                    if ($('#search-Container .mobile-sort select option').length != $('#sort-by-ddl option').length) {
360                        $('#sort-by-ddl option').each(function() {
361                            $('#search-Container .mobile-sort select').append(
362                                '<option value=' + $(this).attr('value') + '>' + $(this).html() + '</option>'
363                            );
364                        });
365                    }
366
367                    $('.main-container-wrapper#search-Container .mobile-sort').show();
368
369                    /**                   All Event Listeners for category and sort toggling starts                   */
370
371                    // Category Toggle Functionality - Internal one which is coming from component
372                    $("input[name='myRadio']").click(function() {
373                        clearSearchExtras();
374                        $('.quantum-search-result-ul').empty();
375                        $('.quantum-search-noresult').hide();
376                        $('.quantum-search-results-count').empty();
377                        $('.pagination').hide();
378                        categoryToggle($(this));
379                    });
380
381                    // Toggle Tabs by adding Click functionality
382                    $('#search-Container .search-custom-tab-select-container .search-custom-tab-label').
383                    click(function() {
384                        var selectedOption = removeElements($(this).html());
385                        var selectedTabSelector =
386                            '#search-Container .radiocontainer input[name="myRadio"][value="' +
387                            selectedOption +
388                            '"';
389                        removeSelectedTab();
390                        $(selectedTabSelector).click();
391                    });
392
393                    // Category Toggle Functionality on mobile
394                    $('#categories_list').on('change', function() {
395                        categoryToggle($(this));
396                    });
397
398                    // Sort Functionality on Desktop
399                    $('#search-Container #search-custom-select').
400                    change(function() {
401                        $('#sort-by-ddl').val($(this).val());
402                        toggleSortBy($('#sort-by-ddl'));
403                    });
404
405                    // Sort Functionality on Mobile
406                    $('#search-Container .mobile-sort select').
407                    off('change').on('change', function() {
408                        $('#sort-by-ddl').val($(this).val());
409                        toggleSortBy($('#sort-by-ddl'));
410                    });
411                    /**                   All Event Listeners for category and s
411ort toggling ends                   */
412                    showresultsMessage = 'yes';
413                    text = text.replace('[--resultscount--]', json.NumberOfRecordsFound);
414                    text = text.replace('[--Notext--]', '');
415                    if (typeof(Storage) !== "undefined") {
416
417                        searchtype = sessionStorage.getItem("key_searchtype");
418                    }
419                    sessionStorage.removeItem("key_searchtype");
420                } else {
421                    text = text.replace('[--resultscount--]', 0);
422                    text = text.replace('[--Notext--]', 'NO');
423                    //$('#search-Container .search-custom-tab-select-container').hide();
424                    $('.quantum-search-noresult').show();
425                }
426                text = text.replace("#", "");
427                $(this).html(text);
428            });
429
430            $('.quantum-search-results-count').show();
431
432            if (showresultsMessage == 'yes') {
433                $('.quantum-search-count-message').removeClass('d-none');
434            }
435
436            if (json.Count > 0) {
437
438                var dataName = $('.quantum-search-result-ul').data('name');
439                var dataNameWithUrl = $('.quantum-search-result-ul').data('namewithurl');
440                var dataNavTitleUrl = $('.quantum-search-result-ul').data('navtitle');
441                var dataUrl = $('.quantum-search-result-ul').data('url');
442                var dataNumbering = $('.quantum-search-result-ul').data('numbering');
443                var linkWithText = $('.quantum-search-result-ul').data('linkwithtext');
444                var linkText = $('.quantum-search-result-ul').data('linktext');
445
446
447                for (var i = 0; i < json.Results.length; i++) {
448
449                    var li;
450                    var date = new Date(json.Results[i].ItemUpdatedDate.split(" ")[0]);
451                    var yyyy = date.getFullYear();
452                    var dd = date.getDate();
453
454                    var monthNames = ["Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"];
455                    var monthIndex = date.getMonth();
456
457                    //return monthNames[monthIndex] + ' ' + day + ', ' + year;
458
459                    /*var mm = date.getMonth() + 1;
460                    if (dd < 10) {
461                        dd = '0' + dd;
462                    }
463
464                    if (mm < 10) {
465                        mm = '0' + mm;
466                    }*/
467                    li = $('<li class=\"quantum-search-list\">');
468                    li.append(
469                        '<div class="date-field">' +
470                        '   <span class="date">' + monthNames[monthIndex] + ' ' + dd + ', ' + yyyy + '</span></div>'
471                    )
472                    var new_url = json.Results[i].Url.split('?')[0];
473                    if (new_url != window.location.href.replace(/^.*\/\/[^\/]+/, '').split('?')[0]) {
474                        if (dataName == undefined && dataNameWithUrl == undefined && dataUrl == undefined) {
475                            if (json.Results[i].NavTitle) {
476                                li.append("<div class=\"quantum-spacing-div\">" +
477                                    "<a class=\"quantum-search-link\" href=\"" +
478                                    json.Results[i].Url + "\">" +
479                                    json.Results[i].NavTitle.replace(/[®]/g, '<sup>$&</sup>') + "</a></div>");
480                            } else {
481                                li.append("<div class=\"quantum-spacing-div\">" +
482                                    "<a class=\"quantum-search-link\" href=\"" +
483                                    json.Results[i].Url + "\">" +
484                                    json.Results[i].Url + "</a></div>");
485                            }
486                        }
487                        if (dataName == 'True' && json.Results[i].NavTitle) {
488                            if (dataNumbering == 'True') {
489
490                                li.append("<div class=\"quantum-spacing-div\">" +
491                                    "<a class=\"quantum-search-link\" href=\"" +
492                                    json.Results[i].Url + "\">" +
493                                    json.Results[i].NavTitle +
494                                    "</a></div>");
495                            } else {
496                                li.append("<div class=\"quantum-spacing-div\">" +
497                                    "<a class=\"quantum-search-link\" href=\"" +
498                                    json.Results[i].Url + "\">" +
499                                    json.Results[i].NavTitle + "</a></div>");
500                            }
501
502                        }
503                        if (dataNameWithUrl == 'True') {
504                            if (json.Results[i].NavTitle) {
505                                li.append("<div class=\"quantum-spacing-div\">" +
506                                    "<a class=\"quantum-search-link\" href=\"" +
507                                    json.Results[i].Url + "\">" +
508                                    json.Results[i].NavTitle.replace(/[®]/g, '<sup>$&</sup>') + "</a></div>");
509                            } else {
510                                li.append("<div class=\"quantum-spacing-div\">" +
511                                    "<a class=\"quantum-search-link\" href=\"" +
512                                    json.Results[i].Url + "\">" +
513                                    json.Results[i].Url + "</a></div>");
514                            }
515                        }
516
517                        li.append("<div class=\"quantum-search-content\"><span>" +
518                            json.Results[i].Html.replace(/[®]/g, '<sup>$&</sup>') + "</span></div>");
519
520                        if (linkWithText == 'True') {
521                            if (linkText !== "") {
522                                li.append("<div class=\"quantum-spacing-div\">" +
523                                    "<a class=\"quantum-search-link\" href=\"" +
524                                    json.Results[i].Url + "\">" + linkText + "</a></div>");
525
526                            } else {
527                                //Do not change this value
528                                li.append("<div class=\"quantum-spacing-div\">" +
529                                    "<a class=\"quantum-search-link\" href=\"" +
530                                    json.Results[i].Url + "\">" + "View Page" +
531                                    "</a></div>");
532
533                            }
534                        }
535                        li.append('</div></li>');
536                        $('.quantum-search-result-ul').append(li);
537                    }
538                }
539
540                // Arrow Click functionality - Will redirect to correct article
541                $('#search-Container .quantum-search-list .date-field img').click(function() {
542                    var newPageUrl = $($(this).parent().parent().find('a.quantum-search-link')).attr('href');
543                    window.location.pathname = newPageUrl;
544                })
545
546                // Pagination Code
547                var previousButtonHTML = '<li id="prev-page"><a href="javascript:void(0)"' +
548                    ' aria-label="Previous"><span aria-hidden="true">' +
549                    'prev</span></a></li>';
550
551                var nextButtonHTML = "<li id=\"next-page\"><a href=\"javascript:void(0);\" " +
552                    "aria-label=\"Next\"><span aria-hidden=\"true\">next</span></a></li>";
553
554                var firstButtonHTML = "<li class=\"current-page\">" +
555                    "<a href=\"javascript:void(0);\" filterApplied=\"pagination\" filterValue=\"1\">" +
556                    1 +
557                    "</a></li>";
558
559                var dottedButtonHTML = "<li class=\"current-page disabled\">" +
560                    "<a filterApplied=\"pagination\" >" +
561                    "..." +
562                    "</a></li>"
563
564                /**
565                 * @description: return the HTML string for a page button
566                 * @param {number} num denotes the number of page button
567                 */
568                function paginationButtonHTML(num) {
569                    return "<li class=\"current-page\">" +
570                        "<a href=\"javascript:void(0);\" filterApplied=\"pagination\" filterValue=" +
571                        num + ">" + num + "</a></li>";
572                }
573
574
575                var dataCount = NumberofResults; //Total entries
576                var pageCount = $('.quantum-search-result-ul').data('pagecount'); // number of entries on a single page
577                var count = parseInt(pageCount); // number of entries on a single page
578                var currentPageIndex = parseInt(getUrlParameter(resultsUrl, 'startValue')) / pageCount;
579                if (count == NaN)
580                    count = 0;
581                if (count > 0) {
582                    var limitPerPage = count; //Limit number of data on single page
583                    $(".quantum-search-result-ul .quantum-search-list:gt(" + (limitPerPage - 1) + ")").hide(); // hide extra data
584                    var totalPages = Math.round(dataCount / limitPerPage); // Calculate number of pages required to store data
585                    if ((totalPages * limitPerPage) < dataCount) { //Taking the ceiling value of totalPages
586                        totalPages = totalPages + 1;
587                    }
588                    $('.pagination').empty(); // Empty the current pagination
589                    // Add Previous button
590                    $('.pagination').
591                    append(previousButtonHTML);
592                    // Add first button
593                    $('.pagination').
594                    append(firstButtonHTML);
595
596                    var currentPage = currentPageIndex + 1;
597
598                    // Add remaining buttons from page 2 to end of pages
599
600                    // Desktop View
601                    if ($(window).width() > 767) {
602                        if (totalPages > 10) {
603
604                            // Selected Page is either of 
605                            // a) First three Pages
606                            // b) Last last Pages
607                            if (currentPage < 4 || currentPage > totalPages - 3) {
608                                // Design will be like 1 2 3 4 ..... 77 78 79 80 
609
610                                // Add Pages 2 to 4
611                                for (var itr = 2; itr <= 4; ++itr) {
612                                    $('.pagination').
613                                    append(paginationButtonHTML(itr));
614                                }
615                                // Add the '...' button
616                                $('.pagination')
617                                    .append(dottedButtonHTML);
618                                // Add the remaining buttons
619                                for (var itr = totalPages - 3; itr <= totalPages; ++itr) {
620                                    $('.pagination').
621                                    append(paginationButtonHTML(itr));
622                                }
623                            }
624                            // Selected Page is some intermediate Page
625                            else {
626                                // Design will be like 1 ... 55 56 57 ... 80
627
628                                // Add the '...' button
629                                $('.pagination')
630                                    .append(dottedButtonHTML);
631
632                                // Add three intermediate page buttons
633                                var tempStart = currentPage - 1;
634                                var tempEnd = currentPage + 1;
635                                if (currentPage == 4) {
636                                    tempStart = 3;
637                                    tempEnd = 5;
638                                }
639                                if (currentPage == totalPages - 3) {
640                                    tempStart = currentPage - 1;
641                                    tempEnd = currentPage + 1;
642                                }
643                                for (var itr = tempStart; itr <= tempEnd; ++itr) {
644                                    $('.pagination').
645                                    append(paginationButtonHTML(itr));
646                                }
647                                // Add the '...' button
648                                $('.pagination')
649                                    .append(dottedButtonHTML);
650                                // Add the last button
651                                $('.pagination').
652                                append(paginationButtonHTML(totalPages));
653
654                            }
655                        } else {
656                            // Display all the pages
657                            for (var itr = 2; itr <= totalPages; ++itr) {
658                                $('.pagination').
659                                append(paginationButtonHTML(itr));
660                            }
661
662                        }
663                    } else { // Mobile Views
664                        if (totalPages < 5) {
665                            // Display all the pages
666                            for (var itr = 2; itr <= totalPages; ++itr) {
667                                $('.pagination').
668                                append(paginationButtonHTML(itr));
669                            }
670                        } else {
671                            // Selected Page is either of 
672                            // a) First two Pages
673                            // b) Last two Pages
674                            if (currentPage < 3 || currentPage > totalPages - 2) {
675                                // Design will be like 1 2 ... 79 80 
676
677                                // Add Pages 2 
678                                $('.pagination').
679                                append(paginationButtonHTML(2));
680                                // Add the '...' button
681                                $('.pagination')
682                                    .append(dottedButtonHTML);
683                                // Add the remaining buttons
684                                for (var itr = totalPages - 1; itr <= totalPages; ++itr) {
685                                    $('.pagination').
686                                    append(paginationButtonHTML(itr));
687                                }
688                            }
689                            // Selected Page is some intermediate Page
690                            else {
691                                // Design will be like 1 ... 55 56 ... 80
692
693                                // Add the '...' button
694                                $('.pagination')
695                                    .append(dottedButtonHTML);
696
697                                // Add two intermediate page buttons
698                                var tempStart = currentPage - 1;
699                                var tempEnd = currentPage;
700                                if (tempStart == 2) {
701                                    tempStart = 3;
702                                    tempEnd = 4;
703                                }
704                                for (var itr = tempStart; itr <= tempEnd; ++itr) {
705                                    $('.pagination').
706                                    append(paginationButtonHTML(itr));
707                                }
708                                // Add the '...' button
709                                $('.pagination')
710                                    .append(dottedButtonHTML);
711                                // Add the last button
712                                $('.pagination').
713                                append(paginationButtonHTML(totalPages));
714
715                            }
716                        }
717                    }
718
719                    // Add Next Button
720                    $('.pagination').
721                    append(nextButtonHTML);
722                    $('.pagination').show();
723                } else {
724                    var limitPerPage = count;
725                    $(".quantum-search-result-ul .quantum-search-list:gt(" + (limitPerPage - 1) + ")").hide();
726                    var totalPages = 1;
727                    $('.pagination').hide();
728                }
729
730                // Add Active class on correct page
731                $('.pagination li a').each(function() {
732                    $(this).parent().removeClass('active');
733                    if (parseInt($(this).html()) === currentPageIndex + 1) $(this).parent().addClass('active');
734                })
735
736                // Disable previous page button on first page
737                if (currentPageIndex == 0) {
738                    $('#prev-page').addClass("disabled");
739                } else $('#prev-page').removeClass("disabled");
740
741                // Disable Next page button on last page
742                if (currentPageIndex + 1 === totalPages) {
743                    $('#next-page').addClass("disabled");
744                } else $('#next-page').removeClass("disabled");
745
746                /**
747                 * @description: Adjust the resultsUrl aka search query string, with correct page
748                 */
749                function pagination() {
750                    $('.quantum-search-result-ul .quantum-search-list').hide();
751
752
753                    var searchKeyword = getUrlHashVars()["q"];
754                    // Check for Categories
755                    var category = getUrlParameter(resultsUrl, 'tag');
756                    // Check for sort
757                    var sort = getUrlParameter(resultsUrl, 'sort');
758                    resultsUrl = "/MyApi/Custom/SearchCl/results?q=" +
759                        removeSpecialCharacters(searchKeyword) + "&rowCount=" +
760                        pageCount + "&startValue=" +
761                        (currentPageIndex * pageCount);
762                    if (category != undefined) resultsUrl += '&tag=' + category;
763                    if (sort != undefined) resultsUrl += '&sort=' + sort;
764                    Search();
765                }
766
767                // Page Button Click Functionality
768                $('.pagination li.current-page').on("click", function() {
769                    currentPageIndex = parseInt($(this).find('a').html()) - 1;
770                    pagination();
771                });
772
773                // Next Page Click Functionality
774                $('#next-page').on("click", function() {
775                    currentPageIndex++; //increment Page
776                    pagination();
777                });
778
779                // Previous page Click Functionality
780                $('#prev-page').on("click", function() {
781                    currentPageIndex--; //decrement page
782                    pagination();
783                });
784
785                // Next Arrow Click functionality
786                $('.main-container-wrapper#search-Container nav ul li#next-page::after').click(function() {
787                    $('#next-page').click();
788                })
789
790                // Prev arrow click functionality
791                $('.main-container-wrapper#search-Container nav ul li#prev-page a::before').click(function() {
792                    $('#prev-page').click();
793                })
794            } else {
795                if (updatedText === '') {
796                    $('.quantum-search-noresult').show();
797                    $('.pagination').hide();
798                }
799            }
800        });
801    }
802
803    $("#searchTextBox-main").on('keypress blur change', function(e) {
804        if (e.which == 13) { //Enter key pressed
805                if($("#searchTextBox-main").val() != ""){
806                var searchKeyword = $('#searchTextBox-main').val();
807				searchKeyword = sanitizeinput(searchKeyword);
808                searchText = searchKeyword;
809                resultsUrl = "/MyApi/Custom/SearchCl/results?q=" +
810                    removeSpecialCharacters(searchKeyword) +
811                    "&rowCount=25&startValue=0";
812                selectedradio = "ALL";
813                clearSearchExtras();
814                //clearRadioButtons();
815                Search();
816            }
817        }
818    });
819
820    // Search button icon in search page
821    $('#searchSubmitBtn').click(function(e) {
822        if($("#searchTextBox-main").val() != ""){
823            var searchKeyword = $('#searchTextBox-main').val();
824			searchKeyword = sanitizeinput(searchKeyword);
825            searchText = searchKeyword;
826            resultsUrl = "/MyApi/Custom/SearchCl/results?q=" +
827                removeSpecialCharacters(searchKeyword) +
828                "&rowCount=25&startValue=0";
829            selectedradio = "ALL";
830            clearSearchExtras();
831            //clearRadioButtons();
832            Search();
833        }
834    });
835
836    if ($(".search .radiocontainer")[0]){
837        $(".search .radiocontainer").next().remove();
838    } else {
839        $(".search").append('<div class="radiocontainer"><h3 class="categories">Category</h3><p><input type="radio" id="_all" name="myRadio" checked="" value="ALL"> <label id="FirstAll" for="_all">All</label></p><p><input type="radio" id="_newsReleases" name="myRadio" value="_newsReleases"> <label for="_newsReleases">News Releases</label></p><p><input type="radio" id="_featuredNews" name="myRadio" value="_featuredNews"> <label for="_featuredNews">Featured News</label></p></div>')
840    }
841   
842});

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.