summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wallace <kevin@wallace.seattle.wa.us>2019-05-09 01:03:39 -0700
committerKevin Wallace <kevin@wallace.seattle.wa.us>2019-05-09 01:07:30 -0700
commit186d696009c380da00983539d56fbe4273e8ec4b (patch)
tree4f982761ec4c27cca5bb5efbbf6b3e25e199faf2
parentadd source link (diff)
sometimes ignore $more in an attempt to always return at least 1 result
-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),