PageSourceSearch

https://www.leicesterunion.com/pagestylesheet/search/scripts.js?v=12

js leicesterunion.com collected 2026-10-02 14:47:39 UTC 3,294 bytes, 102 lines download raw bytes

1$('document').ready(function(){
2    
3    // Results filter
4    var filter = $('#results-filter');
5    var category = $('#search_main h2');
6    
7    category.each(function(){
8        var label = $(this).text();
9        var liClass = label.toLowerCase().trim().replace(/\s+/g, '-');
10        var li = $('<li class="active ' + liClass + '">' + label + '</li>');
11        
12        li.appendTo(filter);
13    });
14    
15    function showResults() {
16        
17        // Organisations filter
18        if ($('.organisations.active').length){
19            $('.search_groupings').show();
20        } else {
21            $('.search_groupings').hide();
22        }
23        
24        // Pages filter
25        if ($('.site-content.active').length){
26            $('.search_pages').show();
27        } else {
28            $('.search_pages').hide();
29        }
30        
31        // Events filter
32        if ($('.events.active').length){
33            $('.search_events').show();
34        } else {
35            $('.search_events').hide();
36        }
37        
38        // News filter
39        if ($('.news.active').length){
40            $('.search_news').show();
41        } else {
42            $('.search_news').hide();
43        }
44        
45        // Resources filter
46        if ($('.resources.active').length){
47            $('.search_resources').show();
48        } else {
49            $('.search_resources').hide();
50        }
51    }
52    
53    showResults();
54    
55    var filterItem = $('#results-filter li');
56    
57    filterItem.on('click',function(){
58        $(this).toggleClass('active');
59        showResults();
60    });
61    
62    // Pair each dt and dd together for groupings
63    var searchTitle = $('.search_groupings dt, .search_pages dt');
64    searchTitle.each(function(){
65        var searchPair = $(this).next('dd');
66        $(this).add(searchPair).wrapAll($('<div class="search_item"/>'));
67    });
68    
69    // If result contains search term, put it first
70    var searchItem = $('.search_item');
71    searchItem.each(function(){
72        var $this = $(this);
73        var searchResult = $this.find($('.highlight'));
74        if (searchResult.length) {
75            $this.addClass('contains-result');
76        }
77    });
78    
79    // Wrap all news results for grid display
80    var newsItem = $('.search_news .news_item');
81    newsItem.wrapAll($('<div class="news_wrap"/>'));
82    
83    // Remove forced width and height from images
84    var forcedImg = $('.news_image img, .search_events img');
85    forcedImg.each(function(){
86        var imgSrc = $(this).attr('src');
87        var newImgSrc = imgSrc.slice(0, imgSrc.indexOf('?'))+ "?thumbnail_width=360&thumbnail_height=200&resize_type=CropToFit";
88        $(this).attr('src',newImgSrc);
89    });
90    
91    // Replace site page description with URL (desc gets cut off in weird places, bad for accessibility and experience)
92    var pageItem = $('.search_pages .search_item');
93    pageItem.each(function(){
94        var pageDesc = $(this).find($('dd'));
95        var pageURL = $(this).find($('a')).attr('href');
96        pageDesc.text(pageURL);
97    });
98    
99    // Replace search button value 
100    var searchButton = $('.section-wrapper #ctl00_ctl41_btnSubmit');
101    searchButton.prop('value','👀 Search');
102});

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.