Make ctrl+tab work a little better

Hopefully I'll stop getting ideas soon..
This commit is contained in:
2024-08-10 20:14:05 +02:00
parent b291fec8a0
commit e0eb7f9748

View File

@@ -6,6 +6,8 @@
import * as srouter from "svelte-spa-router";
import { location } from "svelte-spa-router";
const energyLocRegex = /^\/(?:Energy)?(?!Weight)/;
const weightLocRegex = /^\/(?:Weight)(?!Energy)/;
function keyDown(event: KeyboardEvent) {
if (event.ctrlKey && event.key == "r") {
window.location.reload();
@@ -14,10 +16,10 @@
Close();
}
if (event.ctrlKey && event.key == "Tab") {
if ($location == "/") {
srouter.replace("/Weight");
} else if ($location == "/Weight") {
srouter.replace("/");
if (energyLocRegex.test($location)) {
srouter.replace($location.replace(energyLocRegex, "/Weight"));
} else if (weightLocRegex.test($location)) {
srouter.replace($location.replace(weightLocRegex, "/Energy"));
}
}
}