Nils Diewald | 2329e1d | 2014-06-12 16:07:57 +0000 | [diff] [blame] | 1 | % if (param 'q') { |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 2 | % content 'main' => begin |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 3 | % unless (param 'snippet') { |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 4 | <div style="clear: both"> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 5 | % my $url = url_with->query(['p' => '{page}']); |
Nils Diewald | 8f4b5da | 2014-12-03 22:13:39 +0000 | [diff] [blame] | 6 | % my $pages = search->total_pages; |
| 7 | <div id="pagination"><%= pagination(search->start_page, $pages, $url) =%></div> |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 8 | <p class="found">Found |
Nils Diewald | 8f4b5da | 2014-12-03 22:13:39 +0000 | [diff] [blame] | 9 | % my $found = search->total_results; |
Nils Diewald | 432356a | 2014-11-11 12:52:13 +0000 | [diff] [blame] | 10 | % if ($found == -1) { |
| 11 | % $found = 'unknown amount of'; |
Nils Diewald | 0a3f5f9 | 2014-12-21 04:25:53 +0000 | [diff] [blame] | 12 | % } elsif (search->time_exceeded) { |
Nils Diewald | 432356a | 2014-11-11 12:52:13 +0000 | [diff] [blame] | 13 | % $found = 'more than ' . $found; |
| 14 | % }; |
| 15 | <span id="total-results"><%= $found %> matches</span> |
Nils Diewald | 8f4b5da | 2014-12-03 22:13:39 +0000 | [diff] [blame] | 16 | <% if (search->benchmark) { %> in <%= search->benchmark %><% } %> |
Nils Diewald | 2329e1d | 2014-06-12 16:07:57 +0000 | [diff] [blame] | 17 | </p> |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 18 | </div> |
Nils Diewald | 02df991 | 2014-06-03 16:08:07 +0000 | [diff] [blame] | 19 | %= include 'query' |
Nils Diewald | 1d2903f | 2014-11-03 22:31:20 +0000 | [diff] [blame] | 20 | %= include 'api-communication' |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 21 | % }; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 22 | |
Nils Diewald | 8f4b5da | 2014-12-03 22:13:39 +0000 | [diff] [blame] | 23 | % if (search->total_results != 0 && search->results->size) { |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 24 | <div id="search"> |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 25 | <ol class="align-left"> |
Nils Diewald | 8f4b5da | 2014-12-03 22:13:39 +0000 | [diff] [blame] | 26 | %= search_results begin |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 27 | %= include 'match', match => $_ |
| 28 | % end |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 29 | </ol> |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 30 | </div> |
Nils Diewald | 7cad840 | 2014-07-08 17:06:56 +0000 | [diff] [blame] | 31 | % }; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 32 | % end |
Nils Diewald | 44a7278 | 2014-06-20 16:03:21 +0000 | [diff] [blame] | 33 | |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 34 | % content 'javascript' => begin |
| 35 | %= javascript begin |
| 36 | |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 37 | var openLi = function (e) { |
| 38 | this.classList.add("active"); |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 39 | e.stopPropagation(); |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 40 | }; |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 41 | |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 42 | var closeLi = function (e) { |
| 43 | this.parentNode.parentNode.classList.remove("active"); |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 44 | e.stopPropagation(); |
Nils Diewald | e99d904 | 2014-11-20 23:36:54 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | var inactiveLi = document.querySelectorAll("#search > ol > li:not(.active)"); |
| 48 | for (var i = 0; i < inactiveLi.length; i++) { |
| 49 | inactiveLi[i].addEventListener("click", openLi, false); |
| 50 | inactiveLi[i].getElementsByClassName("close")[0].addEventListener("click", closeLi, false); |
| 51 | }; |
Nils Diewald | 4af3f0b | 2014-06-25 01:43:17 +0000 | [diff] [blame] | 52 | |
| 53 | % end |
| 54 | % end |
Nils Diewald | 1eba657 | 2014-06-17 19:49:53 +0000 | [diff] [blame] | 55 | % }; |