blob: ee24e79705423d63c138c1d1f2012c3ce8cc28f5 [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 Diewald8f4b5da2014-12-03 22:13:39 +00006% my $pages = search->total_pages;
7 <div id="pagination"><%= pagination(search->start_page, $pages, $url) =%></div>
Nils Diewald44a72782014-06-20 16:03:21 +00008 <p class="found">Found
Nils Diewald8f4b5da2014-12-03 22:13:39 +00009% my $found = search->total_results;
Nils Diewald432356a2014-11-11 12:52:13 +000010% if ($found == -1) {
11% $found = 'unknown amount of';
Nils Diewald8f4b5da2014-12-03 22:13:39 +000012% } elsif (search->timeExceeded) {
Nils Diewald432356a2014-11-11 12:52:13 +000013% $found = 'more than ' . $found;
14% };
15 <span id="total-results"><%= $found %> matches</span>
Nils Diewald8f4b5da2014-12-03 22:13:39 +000016 <% if (search->benchmark) { %> in <%= search->benchmark %><% } %>
Nils Diewald2329e1d2014-06-12 16:07:57 +000017 </p>
Nils Diewald5d1ffb42014-05-21 17:45:34 +000018</div>
Nils Diewald02df9912014-06-03 16:08:07 +000019%= include 'query'
Nils Diewald1d2903f2014-11-03 22:31:20 +000020%= include 'api-communication'
Nils Diewald4af3f0b2014-06-25 01:43:17 +000021% };
Nils Diewald5d1ffb42014-05-21 17:45:34 +000022
Nils Diewald8f4b5da2014-12-03 22:13:39 +000023% if (search->total_results != 0 && search->results->size) {
Nils Diewald4af3f0b2014-06-25 01:43:17 +000024<div id="search">
Nils Diewalde99d9042014-11-20 23:36:54 +000025<ol class="align-left">
Nils Diewald8f4b5da2014-12-03 22:13:39 +000026%= search_results begin
Nils Diewald4af3f0b2014-06-25 01:43:17 +000027%= include 'match', match => $_
28% end
Nils Diewald5d1ffb42014-05-21 17:45:34 +000029</ol>
Nils Diewald4af3f0b2014-06-25 01:43:17 +000030</div>
Nils Diewald7cad8402014-07-08 17:06:56 +000031% };
Nils Diewald5d1ffb42014-05-21 17:45:34 +000032% end
Nils Diewald44a72782014-06-20 16:03:21 +000033
Nils Diewald4af3f0b2014-06-25 01:43:17 +000034% content 'javascript' => begin
35%= javascript begin
36
Nils Diewalde99d9042014-11-20 23:36:54 +000037var openLi = function (e) {
38 this.classList.add("active");
Nils Diewald4af3f0b2014-06-25 01:43:17 +000039 e.stopPropagation();
Nils Diewalde99d9042014-11-20 23:36:54 +000040};
Nils Diewald4af3f0b2014-06-25 01:43:17 +000041
Nils Diewalde99d9042014-11-20 23:36:54 +000042var closeLi = function (e) {
43 this.parentNode.parentNode.classList.remove("active");
Nils Diewald4af3f0b2014-06-25 01:43:17 +000044 e.stopPropagation();
Nils Diewalde99d9042014-11-20 23:36:54 +000045};
46
47var inactiveLi = document.querySelectorAll("#search > ol > li:not(.active)");
48for (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 Diewald4af3f0b2014-06-25 01:43:17 +000052
53% end
54% end
Nils Diewald1eba6572014-06-17 19:49:53 +000055% };