improve search result display

This commit is contained in:
quenousimporte 2024-10-22 09:29:46 +02:00
parent 0b10cefced
commit afc839bee1
1 changed files with 7 additions and 2 deletions

View File

@ -58,9 +58,9 @@
<div> <div>
<a href="note.php?new" class="grey" accesskey="n">new</a> <a href="note.php?new" class="grey" accesskey="n">new</a>
<a href="index.php?download" class="grey" accesskey="d">download</a> <a href="index.php?download" class="grey" accesskey="d">download</a>
<input form="home" placeholder="filter..." autofocus autocomplete="off" class="title" name="filter" value="<?php echo $filter; ?>" form="home">
<form action="index.php" method="GET" id="home"> <form action="index.php" method="GET" id="home">
<input hidden type="submit"> <input hidden type="submit">
<input placeholder="filter..." autofocus autocomplete="off" class="title" name="filter" value="<?php echo $filter; ?>" form="home">
</form> </form>
</div> </div>
@ -94,7 +94,12 @@
if ($filter && str_contains(cleanstring($content), cleanstring($filter))) if ($filter && str_contains(cleanstring($content), cleanstring($filter)))
{ {
$pos = strpos(cleanstring($content), cleanstring($filter)); $pos = strpos(cleanstring($content), cleanstring($filter));
echo '<span class="grey"> ' . $filter . substr($content, $pos + strlen($filter), 42) . '</span>'; $start = max($pos - 21, 0);
echo '<span class="grey">&nbsp;';
echo substr($content, $start, min(21, $pos));
echo '<b>' . $filter . '</b>';
echo substr($content, $pos + strlen($filter), 21);
echo '</span>';
} }
echo'</div>'; echo'</div>';
} }