summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/index.php b/index.php
index 7ef5fb6..dc8ee35 100644
--- a/index.php
+++ b/index.php
@@ -48,8 +48,8 @@ foreach ($index_files as $file) {
}
}
$q = $_GET['q'] ?: "";
-$more = 1;
-$autofocus = ' autofocus';
+$more = 0;
+$autofocus = 'autofocus ';
if ($_GET['more']) {
$more = (int)($_GET['more']);
$autofocus = '';
@@ -105,15 +105,17 @@ $max_more = 10;
<ol>
<?php
$depth = 0;
+ $count = 0;
$anchor = '';
- find_expr($selected_index, $q, function($score, $text) use (&$depth, &$anchor, $more) {
+ find_expr($selected_index, $q, function($score, $text) use (&$depth, &$count, &$anchor, $more, $max_more) {
if ($score == '#') {
$depth++;
if ($depth == $more) {
$anchor .= ' id="more"';
}
- return $depth > $more;
+ return $depth > $more && ($count > 0 || $depth > $max_more);
}
+ $count++;
?>
<li class="match" value="<?=(int)(float)($score)?>"<?=$anchor?>><?=htmlspecialchars($text)?></li>
<?php
@@ -126,7 +128,7 @@ $max_more = 10;
?>
</ol>
<?php
- if ($depth > $more && $more != $max_more) {
+ if ($depth > $more && $depth <= $max_more) {
?>
<a<?=$anchor?> class="more" href="?<?=http_build_query([
'idx' => index_name($selected_index),