|
15 | 15 | </nav> |
16 | 16 | </div> |
17 | 17 |
|
18 | | -<link rel="stylesheet" type="text/css" href="/static/stylesheets/search-pages.css"> |
19 | | - |
20 | 18 | <div class="home-group-orgs-container container mx-auto p-gutter search-buttons-container"> |
21 | 19 | <div class="mt-gutter" id="datavejviser-container" style="margin-top: 0px !important;"> |
22 | 20 | <a href="/search"> |
|
49 | 47 |
|
50 | 48 | let params = new URLSearchParams(location.search); |
51 | 49 | let regExp = /(?:[^\s"]+|"[^"]*")+/g; |
52 | | - let qAll = params.get('q').match(regExp); |
53 | 50 |
|
54 | | - for (qPart of qAll) { |
55 | | - qTerm = (qTerm + " " + qPart).trim(); |
56 | | - }; |
57 | | - |
58 | | - $("#search-content-input").val(qTerm); |
| 51 | + if (params.get('q')) { |
| 52 | + let qAll = params.get('q').match(regExp); |
| 53 | + |
| 54 | + for (qPart of qAll) { |
| 55 | + qTerm = (qTerm + " " + qPart).trim(); |
| 56 | + }; |
59 | 57 |
|
60 | | - // capture search term changes |
61 | | - $("#search-content-input").on('input', function (event) { |
62 | | - qTerm = $(this).val(); |
63 | | - }); |
| 58 | + $("#search-content-input").val(qTerm); |
64 | 59 |
|
65 | | - // click on button event |
66 | | - var searchBtn = document.getElementById("search-button"); |
| 60 | + // capture search term changes |
| 61 | + $("#search-content-input").on('input', function (event) { |
| 62 | + qTerm = $(this).val(); |
| 63 | + }); |
67 | 64 |
|
68 | | - searchBtn.onclick = function(event) { |
69 | | - window.location.href = window.location.origin + "/search/content?q=" + qTerm; |
70 | | - }; |
| 65 | + // click on button event |
| 66 | + var searchBtn = document.getElementById("search-button"); |
71 | 67 |
|
72 | | - // press on Enter event |
73 | | - $("#search-content-input").on('keyup', function (event) { |
74 | | - if (event.originalEvent.code === "Enter") { |
| 68 | + searchBtn.onclick = function(event) { |
75 | 69 | window.location.href = window.location.origin + "/search/content?q=" + qTerm; |
76 | | - } |
77 | | - }); |
| 70 | + }; |
| 71 | + |
| 72 | + // press on Enter event |
| 73 | + $("#search-content-input").on('keyup', function (event) { |
| 74 | + if (event.originalEvent.code === "Enter") { |
| 75 | + window.location.href = window.location.origin + "/search/content?q=" + qTerm; |
| 76 | + } |
| 77 | + }); |
| 78 | + } |
78 | 79 |
|
79 | 80 | </script> |
80 | 81 | {% endblock %} |
0 commit comments