forked from enviPath/enviPy
feat: working search redirect
This commit is contained in:
@ -145,6 +145,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Global keyboard shortcut for search (Cmd+K on Mac, Ctrl+K on Windows/Linux)
|
||||||
|
document.addEventListener('keydown', function(event) {
|
||||||
|
// Check if user is typing in an input field
|
||||||
|
const activeElement = document.activeElement;
|
||||||
|
const isInputField = activeElement && (
|
||||||
|
activeElement.tagName === 'INPUT' ||
|
||||||
|
activeElement.tagName === 'TEXTAREA' ||
|
||||||
|
activeElement.contentEditable === 'true'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isInputField) {
|
||||||
|
return; // Don't trigger shortcut when typing in input fields
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for Cmd+K (Mac) or Ctrl+K (Windows/Linux)
|
||||||
|
const isMac = /Mac/.test(navigator.platform);
|
||||||
|
const isCorrectModifier = isMac ? event.metaKey : event.ctrlKey;
|
||||||
|
|
||||||
|
if (isCorrectModifier && event.key === 'k') {
|
||||||
|
event.preventDefault();
|
||||||
|
window.location.href = '/search';
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -27,7 +27,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
<button type="button" class="inline-flex items-center gap-1 rounded-full bg-gray-950/2 px-2 py-1 inset-ring inset-ring-gray-950/8 dark:bg-white/5 dark:inset-ring-white/2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="-ml-0.5 size-4 fill-gray-600 dark:fill-gray-500"><path fill-rule="evenodd" d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z" clip-rule="evenodd"></path></svg><kbd class="hidden font-sans text-xs/4 text-gray-500 dark:text-gray-400 [.os-macos_&]:block">⌘K</kbd><kbd class="hidden font-sans text-xs/4 text-gray-500 not-[.os-macos_&]:block dark:text-gray-400">Ctrl K</kbd></button>
|
<a href="/search" role="button" >
|
||||||
|
<div class="flex items-center badge badge-dash space-x-1 bg-base-200 text-base-content/50 p-2 m-1">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-search-icon lucide-search"><path d="m21 21-4.34-4.34"/><circle cx="11" cy="11" r="8"/></svg>
|
||||||
|
<span id="search-shortcut">⌘K</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
{% if meta.user.username == 'anonymous' %}
|
{% if meta.user.username == 'anonymous' %}
|
||||||
<li><a href="{% url 'login' %}" id="loginButton">Login</a></li>
|
<li><a href="{% url 'login' %}" id="loginButton">Login</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -43,3 +48,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// OS-aware search shortcut display
|
||||||
|
(function() {
|
||||||
|
const isMac = /Mac/.test(navigator.platform);
|
||||||
|
const shortcutElement = document.getElementById('search-shortcut');
|
||||||
|
if (shortcutElement) {
|
||||||
|
shortcutElement.textContent = isMac ? '⌘K' : 'Ctrl+K';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user