PageSourceSearch

https://www.helmholtz-hiri.de/_assets/6187d03d8e9590bcc0b3368700c86825/JavaScript/Main.js?1790318294

js helmholtz-hiri.de collected 2026-10-02 05:34:28 UTC 7,748 bytes, 190 lines download raw bytes

1var clickedByLoadMore = false;
2
3$(document).ready(function () {
4
5    var startYear = $('#startYear');
6
7    $("form.publication").submit(function (event) {
8        event.preventDefault();
9        if (clickedByLoadMore === false) {
10            // If form is submitted by search button
11            var loadMore = $("#loadMore");
12            loadMore.css('display', '')
13            $('#startYear').val($('#year').children("option:selected").val());
14            if (yearsWithResults[yearsWithResults.length - 1] === $('#year').children("option:selected").val()) {
15                loadMore.attr('disabled', 'disabled');
16            } else {
17                loadMore.removeAttr('disabled');
18            }
19        }
20
21        var form = $(this);
22        var action = form.attr("action"),
23            method = form.attr("method"),
24            data = form.serialize();
25
26        $.ajax({
27            url: action,
28            type: method,
29            data: data
30        }).done(function (data) {
31            changeHtml(data);
32            clickedByLoadMore = false;
33        }).fail(function () {
34            console.log('Publications Transfer Failed');
35        });
36    });
37
38    $("#loadMore:not([disabled])").click(function () {
39        if (startYear.val() !== yearsWithResults[yearsWithResults.length - 1]) {
40            if (startYear.val()) {
41                for (var i = loadMoreNumberOfYears; i  > 0; i--) {
42                    $nextYear = Object.values(yearsWithResults).indexOf(startYear.val()) + i;
43                    if (yearsWithResults[$nextYear]) {
44                        break;
45                    }
46                }
47            } else {
48                $nextYear = Object.values(yearsWithResults).indexOf(startYear.val()) + 2;
49            }
50
51            startYear.val(yearsWithResults[$nextYear]);
52
53            if (!yearsWithResults[$nextYear + 1]) {
54                $(this).attr('disabled', 'disabled');
55            }
56            clickedByLoadMore = true;
57            $("#submit").trigger('click');
58        } else {
59            $(this).attr('disabled', 'disabled');
60        }
61    });
62});
63
64function changeHtml(data) {
65    changeResults(data.groups, data.settings.showDoi, data.settings.linkTitleToDoi);
66    changeSelectOptions(data);
67    $('#startYear').val(data.startYear);
68    yearsWithResults = data.yearsWithResults;
69}
70
71var filter;
72
73function changeSelectOptions(data) {
74
75    years = data.newSelectValues.years;
76
77    filter = data.selectedValues;
78    var groupSelect = $("#group");
79    var firstOption = groupSelect.find("option:first-child");
80    groupSelect.empty().append(firstOption);
81
82    Object.values(data.newSelectValues.groups).forEach(function (option) {
83        if (data.selectedValues.group === option.value) {
84            groupSelect.append('<option name="' + option.title + '" value="' + option.value + '" selected>' + option.title + '</option>');
85        } else {
86            groupSelect.append('<option name="' + option.title + '" value="' + option.value + '">' + option.title + '</option>');
87        }
88    });
89
90    var typeSelect = $("#type");
91    firstOption = typeSelect.find("option:first-child");
92    typeSelect.empty().append(firstOption);
93    data.newSelectValues.types.forEach(function (option) {
94        if (data.selectedValues.type === option) {
95            typeSelect.append('<option name="' + option + '" value="' + option + '" selected>' + option + '</option>');
96        } else {
97            typeSelect.append('<option name="' + option + '" value="' + option + '">' + option + '</option>');
98        }
99    });
100
101    var yearSelect = $("#year");
102    firstOption = yearSelect.find("option:first-child");
103    yearSelect
104        .find('option')
105        .remove();
106    yearSelect.append(firstOption);
107    if (!data.selectedValues.year) {
108        yearSelect.val("0");
109    }
110    data.newSelectValues.years.forEach(function (option) {
111        if (data.selectedValues.year === option) {
112            yearSelect.append('<option name="' + option + '" value="' + option + '" selected>' + option + '</option>');
113        } else {
114            yearSelect.append('<option name="' + option + '" value="' + option + '">' + option + '</option>');
115        }
116    });
117}
118
119function changeResults(groups, showDoi, linkTitleToDoi) {
120    document.getElementById("results").innerHTML = '';
121    var resultsWrap = '',
122        years = Object.keys(groups).sort().reverse();
123
124    if (groups.length < 1) {
125        document.getElementById("results").innerHTML = 'No publications foun
125d<br /><br />';
126        $("#loadMore").attr('disabled', 'disabled');
127    }
128
129    for (var i = 0, maxi = years.length; i < maxi; i++) {
130        var year = years[i],
131            group = groups[year],
132            publications = [];
133
134        if (typeof group !== 'undefined') {
135            publications = group;
136
137            /**
138             *
139             * @param pubs
140             * @param showDoi
141             * @param linkTitleToDoi
142             * @returns {string}
143             */
144            function getResults(pubs, showDoi, linkTitleToDoi)
145            {
146                var results = [];
147                pubs.forEach(function (publicationField) {
148
149                    var values = {
150                        abbrevation: publicationField.abbreviation_stringS !== '' ? '<b>' + publicationField.abbreviation_stringS + '</b>' : '',
151                        volume: publicationField.volume_stringS !== '' ? ' ' + publicationField.volume_stringS : '',
152                        issue: publicationField.issue_stringS !== '' ? ' (' + publicationField.issue_stringS + ')' : '',
153                        pageRange: publicationField.pageRange_stringS !== '' ? ': ' + publicationField.pageRange_stringS : '',
154                        doi: (publicationField.doi_stringS !== '' && showDoi) ? '<span class="c-publications__item-doi">DOI: <a target="_blank" href="https://doi.org/' + publicationField.doi_stringS + '">' + publicationField.doi_stringS + '</a></span>' : '',
155                        title: (publicationField.doi_stringS !== '' && linkTitleToDoi) ? '<a target="_blank" href="https://doi.org/' + publicationField.doi_stringS + '">' +  publicationField.title_textS + '</a>' : publicationField.title_textS
156                    };
157
158                    results +=
159                        '<div class="c-multicol__content--col-2">' +
160                            '<div class="c-publications__item">' +
161                                '<h3 class="c-publications__item-header">' + values.title + '</h3>' +
162                                '<p class="c-publications__item-txt">' + publicationField.combinedAuthors + ' (' + publicationField.date_stringS + ')' + '</p>' +
163                                '<p class="c-publications__item-txt">' +
164                                    values.abbrevation +
165                                    values.volume +
166                                    values.issue +
167                                    values.pageRange +
168                                    values.doi +
169                                '</p>' +
170                            '</div>' +
171                        '</div>';
172                });
173
174                return results;
175            }
176
177            resultsWrap =
178                '<div class="u-spacing--padding-y c-multicol">' +
179                    '<div class="c-multicol__container--wide u-align__left">' +
180                        '<h2 class="c-publications__group-header">' + year + '</h2>' +
181                        '<div class="c-multicol__row--last-col-left">' +
182                            getResults(publications, showDoi, linkTitleToDoi) +
183                        '</div>' +
184                    '</div>' +
185                '</div>';
186
187            document.getElementById("results").innerHTML += resultsWrap;
188        }
189    }
190}

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.