PageSourceSearch

https://www.sgb-sg.ch/typo3conf/ext/t8_custom/Resources/Public/JS/t8_custom.js?1695305914

js sgb-sg.ch collected 2026-10-07 02:58:56 UTC 9,674 bytes, 222 lines download raw bytes

1$(document).ready(function(){
2    /* News More Link */
3    if (typeof(Storage) !== "undefined") {
4        if ($('.news-detail__backlink').length > 0) {
5            // on detailpage
6            $('.news-detail__backlink').attr('href', localStorage.getItem('backUrl'));
7            window.localStorage.setItem('fromDetailPage', true);
8        } else if ($('.news-list__link-detail').length > 0) {
9            // on a list page
10            if (localStorage.getItem('fromDetailPage') == true || localStorage.getItem('backUrl') == window.location.href) {
11                var filtered = 0;
12                if (localStorage.getItem('searchVal') != null) {
13                    $('#ke_search_sword').val(window.localStorage.getItem('searchVal'));
14                    $('[name="tx_news_pi1[overwriteDemand][possibleIdList]"]').val(window.localStorage.getItem('searchResultIds'));
15                    window.localStorage.removeItem('searchVal');
16                    window.localStorage.removeItem('searchResultIds');
17                    filtered++;
18                }
19                if (localStorage.getItem('searchedYears') != null) {
20                    var checkedYears = window.localStorage.getItem('searchedYears').split(',');
21                    for (i = 0; i < checkedYears.length; ++i) {
22                        $('[name="tx_news_pi1[overwriteDemand][yearsArray][]"][value="'+checkedYears[i]+'"]').prop('checked', true);
23                    }
24                    window.localStorage.removeItem('searchedYears');
25                    filtered++;
26                }
27                if (localStorage.getItem('searchedCategories') != null) {
28                    var checkedCategories = window.localStorage.getItem('searchedCategories').split(',');
29                    for (i = 0; i < checkedCategories.length; ++i) {
30                        $('[name="tx_news_pi1[overwriteDemand][categoriesArray][]"][value="'+checkedCategories[i]+'"]').prop('checked', true);
31                    }
32                    window.localStorage.removeItem('searchedCategories');
33                    filtered++;
34                }
35            } else {
36                window.localStorage.removeItem('searchVal');
37                window.localStorage.removeItem('searchResultIds');
38                window.localStorage.removeItem('searchedYears');
39                window.localStorage.removeItem('searchedCategories');
40            }
41
42            window.localStorage.setItem('backUrl', window.location.href);
43            window.localStorage.setItem('fromDetailPage', false);
44        } else {
45            window.localStorage.removeItem('backUrl');
46            window.localStorage.removeItem('fromDetailPage');
47
48            window.localStorage.removeItem('searchVal');
49            window.localStorage.removeItem('searchResultIds');
50            window.localStorage.removeItem('searchedYears');
51            window.localStorage.removeItem('searchedCategories');
52        }
53    } else {
54        // No web storage Support.
55    }
56
57    /* Ajax Service */
58    var resultContainer = $('[id^="news-list"]');
59    var ajaxLinkPagination = {
60        ajaxCall: function ajaxCall(data, url) {
61            $.post({
62                url: url,
63                cache: false,
64                data: data.serialize(),
65                success: function success(result) {
66                    resultContainer.children('.newspagination').remove();
67                    resultContainer.append(result);
68                    initializeAjaxLinks(resultContainer);
69                },
70                error: function error(jqXHR, textStatus, errorThrow) {
71                    resultContainer.html('Ajax request - ' + textStatus + ': ' + errorThrow).fadeIn('fast');
72                }
73            });
74        }
75    };
76    function initializeAjaxLinks(container = null) {
77        if (!container) {
78          container = $('body');
79        }
80        container.find('.ajaxpagination__button').click(function(ev) {
81            ev.preventDefault();
82            var url = $(this).attr('href');
83            resultContainer = $(this).parents('[id^="news-list"]');
84            ajaxLinkPagination.ajaxCall($(this), url);
85        });
86
87        if (container.find('.newssearchresult__message').length > 0) {
88            container.find('.message.newssearchresult__message').remove();
89            var message = container.find('.newssearchresult__message').text();
90            container.prepend('<div class="col12"><div class="message message--bad newssearchresult__message"><p>'+message+'</p></div></div>');
91        }
92
93        /* set localstorage filter vars */
94        if (typeof(Storage) !== "undefined" && $('#newsListAjaxForm').length > 0) {
95            if ($('[name="tx_news_pi1[overwriteDemand][possibleIdList]"]').length > 0 && $('[name="tx_news_pi1[overwriteDemand][possibleIdList]"]').val() != '') {
96                window.localStorage.setItem('searchVal', $('#ke_search_sword').val());
97                window.localStorage.setItem('searchResultIds', $('[name="tx_news_pi1[overwriteDemand][possibleIdList]"]').val());
98            } else {
99                window.localStorage.removeItem('searchVal');
100                window.localStorage.removeItem('searchResultIds');
101            }
102
103            var searchedYears = [];
104            $('[name="tx_news_pi1[overwriteDemand][yearsArray][]"]:checked').each(function(){
105                searchedYears.push($(this).val());
106            });
107            if (searchedYears.length > 0) {
108                window.localStorage.setItem('searchedYears', searchedYears);
109            } else {
110                window.localStorage.removeItem('searchedYears');
111            }
112
113            var searchedCategories = [];
114            $('[name="tx_news_pi1[overwriteDemand][categoriesArray][]"]:checked').each(function(){
115                searchedCategories.push($(this).val());
116            });
117            if (searchedCategories.length > 0) {
118                window.localStorage.setItem('searchedCategories', searchedCategories);
119            } else {
120                window.localStorage.removeItem('searchedCategories');
121            }
122        }
123    }
124    initializeAjaxLinks();
125
126    var form = $('#newsListAjaxForm');
127    var ajaxForm = {
128        ajaxCall: function ajaxCall(data) {
129            $.ajax({
130                url: form.attr('action'),
131                type: form.attr('method'),
132                cache: false,
133                data: data.serialize(),
134                success: function success(result) {
135                    resultContainer.html(result).css('opacity', 1);
136                    initializeAjaxLinks(resultContainer);
137                },
138                error: function error(jqXHR, textStatus, errorThrow) {
139                    resultContainer.html('Ajax request - ' + textStatus + ': ' + errorThrow).fadeIn('fast');
140                }
141            });
142        }
143    };
144    form.submit(function(ev) {
145        ev.preventDefault();
146        resultContainer = $(this).parents('.news-list__filters').siblings('[id^="news-list"]');
147        resultContainer.css('opacity', 0);
148        ajaxForm.ajaxCall($(this));
149    });
150
151
152    var newsListSearchForm = $('#newsListFiltersSearchForm');
153    var resultContainerNewsListSearch = $('#newsListFiltersSearchResult');
154    var ajaxFormNewsListSearch = {
155        ajaxCall: function ajaxCall(data) {
156            $.ajax({
157                url: newsListSearchForm.attr('action'),
158                type: newsListSearchForm.attr('method'),
159                cache: false,
160                data: data.serialize(),
161                success: function success(result) {
162                    resultContainerNewsListSearch.html(result);
163                    submitNewsFilter();
164                },
165                error: function error(jqXHR, textStatus, errorThrow) {
166                    resultContainer.html('Ajax request - ' + textStatus + ': ' + errorThrow).fadeIn('fast');
167                }
168            });
169        }
170    };
171    newsListSearchForm.submit(function(ev) {
172        ev.preventDefault();
173        ajaxFormNewsListSearch.ajaxCall($(this));
174    });
175
176    function submitNewsFilter() {
177        $('#newsListAjaxForm').submit();
178    }
179
180    $('.news-list__filters__reset').click(function(ev){
181        ev.preventDefault();
182        form[0].reset();
183        form.find('.form__multiselect__checkboxes__item .form__input').trigger('change');
184        newsListSearchForm[0].reset();
185        form.find('[name="tx_news_pi1[overwriteDemand][possibleIdList]"]').val('');
186        $('#newsListAjaxForm').submit();
187    });
188
189    // prefiltered from localstorage
190    if (filtered > 0) {
191        $('#newsListAjaxForm').submit();
192    }
193
194});
195
196/* Accordion */
197$('.accordion .accordion__head').click(function() {
198    $(this).siblings('.accordion__content').addClass('accordion__content--inprogress');
199    var closable_height = $(this).siblings('.accordion__content').children('.accordion__content__inner').outerHeight();
200    $(this).siblings('.accordion__content').css('height', closable_height);
201    $(this).toggleClass('accordion__head--open');
202    $(this).siblings('.accordion__content').toggleClass('accordion__content--closed');
203
204    var self = $(this);
205    setTimeout(function() {
206        self.siblings().removeClass('accordion__content--inprogress');
207    }, 500);
208});
209
210$('.accordion__head--open').each(function() {
211    var closable_height = $(this).siblings('.accordion__content').children('.accordion__content__inner').outerHeight();
212    $(this).siblings('.accordion__content').css('height', closable_height);
213});
214
215/* Lightbox
216// http://lokeshdhakar.com/projects/lightbox2/#options
217function applyLightboxFunctionality() {
218    lightbox.option({
219        'albumLabel': "%1 / %2"
220    });
221}
222applyLightboxFunctionality();*/

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.