Verified Commit 854a2bf1 authored by Jakob Moser's avatar Jakob Moser
Browse files

Automatically prefill search with selection

parent 2b9b4eb8
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ get_header();

                if(event.key === "/") {
                    const isEnglish = document.querySelector("html").lang.startsWith("en")
                    showSearchModal(isEnglish)
                    showSearchModal(isEnglish, document.getSelection()?.toString())
                    event.preventDefault()
                }
            })
@@ -69,10 +69,13 @@ get_header();
                <input type="search" name="s" placeholder="Suchen..."><button>🔍</button>
            </form>
            <script>
                function showSearchModal(isEnglish) {
                function showSearchModal(isEnglish, value) {
                    const searchModal = document.querySelector("#search-modal")
                    searchModal.querySelector("form").action = isEnglish ? "/en/" : "/"
                    searchModal.querySelector("input[type='search']").placeholder = isEnglish ? "Search..." : "Suchen..."

                    const searchInput = searchModal.querySelector("input[type='search']")
                    searchInput.placeholder = isEnglish ? "Search..." : "Suchen..."
                    if(value) searchInput.value = value

                    searchModal.showModal()
                }
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * Author: personads :: Maximilian Müller-Eberstein (ursprüngliche Version und Design); Jakob Moser
 * Author URI: https://personads.me/
 *
 * Version: 2.17.3-alpha
 * Version: 2.17.3
 * Requires PHP: 8.0
 *
 * License: GNU General Public License v3.0