Skip to content

Commit

Permalink
Fixed instant search when pressing some function keys and some other …
Browse files Browse the repository at this point in the history
…shortcut keys + brought back the codriver badge
  • Loading branch information
RickyDane committed Aug 24, 2024
1 parent 47f4077 commit fd10da5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# cargo-features = ["profile-rustflags"]
[package]
name = "CoDriver"
version = "0.4.831"
version = "0.4.832"
description = "A simple file explorer"
authors = ["Ricky Dane Perlick"]
license = "none"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "CoDriver",
"version": "0.4.831"
"version": "0.4.832"
},
"tauri": {
"updater": {
Expand Down
4 changes: 4 additions & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
</div>
</div>
<div class="popup-background"></div>

<!-- :instant-search | Instant Search -->
<input class="instant-search-input text-input" type="text" placeholder="Start typing ..." disabled/>

<div style="display: flex; width: 100%; height: 100vh;">
<div data-tauri-drag-region class="site-nav-bar">
<div class="codriver-name">CoDriver</div>
Expand Down
78 changes: 57 additions & 21 deletions ui/main_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,14 @@ document.addEventListener("keydown", async (e) => {
}
if (IsInputFocused === false &&
IsPopUpOpen === false &&
e.key !== "Escape" &&
e.key !== "ArrowLeft" &&
e.key !== "ArrowRight" &&
e.key !== "ArrowUp" &&
e.key !== "ArrowDown" &&
e.key !== "Enter" &&
e.key !== "Backspace" &&
e.key !== "Delete" &&
e.key !== "CapsLock" &&
e.key !== "Shift" &&
e.key !== "Control" &&
e.key !== "Alt" &&
e.key !== "Meta" &&
e.key !== "Tab" &&
e.key !== " " &&
!e.metaKey &&
!e.ctrlKey &&
!e.altKey &&
!e.shiftKey &&
IsMetaDown === false &&
IsCtrlDown === false &&
IsShiftDown === false
IsShiftDown === false &&
isShortcut(e.key) === false
) {
CurrentQuickSearch += e.key;
$(".instant-search-input").css("display", "block");
$(".instant-search-input").val(CurrentQuickSearch);
await searchFor(CurrentQuickSearch, 9999999, 1, true);
setTimeout(() => {
if (IsDualPaneEnabled === true) {
Expand All @@ -252,6 +236,8 @@ function resetQuickSearch() {
clearInterval(CurrentQuickSearchTimer);
CurrentQuickSearchTime = TIMETORESET;
CurrentQuickSearch = "";
$(".instant-search-input").val("");
$(".instant-search-input").css("display", "none");
} else {
CurrentQuickSearchTime -= 50;
}
Expand Down Expand Up @@ -410,6 +396,56 @@ function positionContextMenu(e) {

/* :shortcuts Shortcuts configuration */

function isShortcut(key) {
if (key == "Meta" ||
key == "Control" ||
key == "Shift" ||
key == "Alt" ||
key == "CapsLock" ||
key == "Enter" ||
key == "Backspace" ||
key == "Delete" ||
key == "ArrowLeft" ||
key == "ArrowRight" ||
key == "ArrowUp" ||
key == "ArrowDown" ||
key == "Escape" ||
key == "Tab" ||
key == "F1" ||
key == "F2" ||
key == "F3" ||
key == "F4" ||
key == "F5" ||
key == "F6" ||
key == "F7" ||
key == "F8" ||
key == "F9" ||
key == "F10" ||
key == "F11" ||
key == "F12" ||
key == "F13" ||
key == "Home" ||
key == "End" ||
key == "PageUp" ||
key == "PageDown" ||
key == "PrintScreen" ||
key == "Insert" ||
key == "Pause" ||
key == "Help" ||
key == "NumLock" ||
key == "Clear" ||
key == "ScrollLock" ||
key == "+" ||
key == "-" ||
key == "*" ||
key == "/" ||
key == ",") {
return true;
} else {
return false;
}
}

document.onkeydown = async (e) => {
if (IsDisableShortcuts === false) {
// Shortcut for jumping to configured directory
Expand Down Expand Up @@ -4019,7 +4055,7 @@ async function getDir(number) {

async function insertSiteNavButtons() {
for (let children of document.querySelector(".site-nav-bar").children) {
if (!children.classList.contains("active-actions-container")) {
if (!children.classList.contains("active-actions-container") && !children.classList.contains("codriver-name")) {
children.remove();
}
}
Expand Down
19 changes: 19 additions & 0 deletions ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2115,4 +2115,23 @@ button > svg {
}
.c-item-custom:hover {
background-color: var(--transparentColorActive);
}

.instant-search-input {
display: none;
position: fixed;
left: 0;
right: 0;
bottom: 100px;
margin: auto;
border: 1px solid var(--tertiaryColor);
border-radius: 10px;
padding: 5px;
background-color: var(--transparentColor);
backdrop-filter: blur(2px);
-webkit-backdrop-filter: blur(2px);
color: var(--textColor);
font-size: var(--fontSize);
width: 200px;
z-index: 5;
}

0 comments on commit fd10da5

Please sign in to comment.