From 8485264714b32585ca6ea605e77d948312551683 Mon Sep 17 00:00:00 2001
From: Erik Thuning <boooink@gmail.com>
Date: Wed, 12 Jun 2019 11:09:03 +0200
Subject: [PATCH] Searches now automatically match parts of field values, and
 the search field has autofocus

---
 html/fragments.html   | 3 ++-
 include/functions.php | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/html/fragments.html b/html/fragments.html
index 65986f7..8bb62e6 100644
--- a/html/fragments.html
+++ b/html/fragments.html
@@ -624,7 +624,8 @@
            onKeyPress="JavaScript:searchInput(event)"
            name="q"
            placeholder="Vad letar du efter?"
-           value="" />
+           value=""
+           autofocus />
     <button type="submit">
       Sök
     </button>
diff --git a/include/functions.php b/include/functions.php
index 9ef1b5a..f82ba69 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -224,7 +224,7 @@ function match($testvalues, $matchvalues) {
     }
     foreach($testvalues as $value) {
         foreach($matchvalues as $candidate) {
-            if(fnmatch($value, $candidate, FNM_CASEFOLD)) {
+            if(fnmatch('*'.$value.'*', $candidate, FNM_CASEFOLD)) {
                 return true;
             }
         }