blob: 2bf4f8079f9d0926162509dbc01d336fa0414eeb [file] [log] [blame]
Nils Diewald2329e1d2014-06-12 16:07:57 +00001% if (param 'q') {
Nils Diewald4af3f0b2014-06-25 01:43:17 +00002% content 'main' => begin
Nils Diewald4af3f0b2014-06-25 01:43:17 +00003% unless (param 'snippet') {
Nils Diewald5d1ffb42014-05-21 17:45:34 +00004<div style="clear: both">
Nils Diewald4af3f0b2014-06-25 01:43:17 +00005% my $url = url_with->query(['p' => '{page}']);
Nils Diewald2fef6c62014-11-11 17:48:59 +00006% my $pages;
7% $pages = stash('search.totalResults') == -1 ? -1 : (stash('search.totalResults') / (stash('search.itemsPerPage') || 1));
Nils Diewald44a72782014-06-20 16:03:21 +00008 <div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div>
9 <p class="found">Found
Nils Diewald432356a2014-11-11 12:52:13 +000010% my $found = stash('search.totalResults');
11% if ($found == -1) {
12% $found = 'unknown amount of';
13% } elsif (stash('search.timeExceeded')) {
14% $found = 'more than ' . $found;
15% };
16 <span id="total-results"><%= $found %> matches</span>
Nils Diewald2ef057e2014-11-04 16:04:17 +000017 <% if (stash 'search.benchmark') { %> in <%= stash 'search.benchmark' %><% } %>
Nils Diewald2329e1d2014-06-12 16:07:57 +000018 </p>
Nils Diewald5d1ffb42014-05-21 17:45:34 +000019</div>
Nils Diewald02df9912014-06-03 16:08:07 +000020%= include 'query'
Nils Diewald1d2903f2014-11-03 22:31:20 +000021%= include 'api-communication'
Nils Diewald4af3f0b2014-06-25 01:43:17 +000022% };
Nils Diewald5d1ffb42014-05-21 17:45:34 +000023
Nils Diewald432356a2014-11-11 12:52:13 +000024% if (stash('search.totalResults') != 0 && scalar @{stash('search.hits')}) {
Nils Diewald4af3f0b2014-06-25 01:43:17 +000025<div id="search">
Nils Diewalde99d9042014-11-20 23:36:54 +000026<ol class="align-left">
Nils Diewald4af3f0b2014-06-25 01:43:17 +000027%= search_hits begin
28%= include 'match', match => $_
29% end
Nils Diewald5d1ffb42014-05-21 17:45:34 +000030</ol>
Nils Diewald4af3f0b2014-06-25 01:43:17 +000031</div>
Nils Diewald7cad8402014-07-08 17:06:56 +000032% };
Nils Diewald5d1ffb42014-05-21 17:45:34 +000033% end
Nils Diewald44a72782014-06-20 16:03:21 +000034
Nils Diewald4af3f0b2014-06-25 01:43:17 +000035% content 'javascript' => begin
36%= javascript begin
37
Nils Diewalde99d9042014-11-20 23:36:54 +000038var openLi = function (e) {
39 this.classList.add("active");
Nils Diewald4af3f0b2014-06-25 01:43:17 +000040 e.stopPropagation();
Nils Diewalde99d9042014-11-20 23:36:54 +000041};
Nils Diewald4af3f0b2014-06-25 01:43:17 +000042
Nils Diewalde99d9042014-11-20 23:36:54 +000043var closeLi = function (e) {
44 this.parentNode.parentNode.classList.remove("active");
Nils Diewald4af3f0b2014-06-25 01:43:17 +000045 e.stopPropagation();
Nils Diewalde99d9042014-11-20 23:36:54 +000046};
47
48var inactiveLi = document.querySelectorAll("#search > ol > li:not(.active)");
49for (var i = 0; i < inactiveLi.length; i++) {
50 inactiveLi[i].addEventListener("click", openLi, false);
51 inactiveLi[i].getElementsByClassName("close")[0].addEventListener("click", closeLi, false);
52};
Nils Diewald4af3f0b2014-06-25 01:43:17 +000053
54% end
55% end
Nils Diewald1eba6572014-06-17 19:49:53 +000056% };