mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
move global search input to a general location
- create a global search store - create a half-baked context menu store -
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import perks from "./perks";
|
||||
|
||||
export default function normalizeContextMenu(x, y) {
|
||||
const app_dom = perks.getElem("app", "id");
|
||||
const context_menu = perks.getElem("context-menu-visible", "class");
|
||||
|
||||
const { left: scopeOffsetX, top: scopeOffsetY } =
|
||||
app_dom.getBoundingClientRect();
|
||||
|
||||
const scopeX = x - scopeOffsetX;
|
||||
const scopeY = y - scopeOffsetY;
|
||||
|
||||
const outOfBoundsX = scopeX + context_menu.clientHeight > app_dom.clientWidth;
|
||||
const outOfBoundsY =
|
||||
scopeY + context_menu.clientHeight > app_dom.clientHeight;
|
||||
|
||||
let normalizedX = x;
|
||||
let normalizedY = y;
|
||||
|
||||
if (outOfBoundsX) {
|
||||
normalizedX =
|
||||
scopeOffsetX + app_dom.clientWidth - context_menu.clientHeight;
|
||||
}
|
||||
|
||||
if (outOfBoundsY) {
|
||||
normalizedY =
|
||||
scopeOffsetY + app_dom.clientHeight - context_menu.clientHeight;
|
||||
}
|
||||
|
||||
return {
|
||||
normalizedX,
|
||||
normalizedY,
|
||||
};
|
||||
}
|
||||
@@ -212,6 +212,8 @@ window.addEventListener("keyup", () => {
|
||||
key_down_fired = false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
function formatSeconds(seconds) {
|
||||
// check if there are arguments
|
||||
|
||||
@@ -258,6 +260,7 @@ export default {
|
||||
focusCurrent,
|
||||
updateQueue,
|
||||
formatSeconds,
|
||||
getElem,
|
||||
current,
|
||||
queue,
|
||||
next,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import state from "./state.js";
|
||||
|
||||
const base_url = "http://0.0.0.0:9876/search?q=";
|
||||
const base_url = `${state.settings.uri}/search?q=`;
|
||||
|
||||
async function search(query) {
|
||||
state.loading.value = true;
|
||||
const url = base_url + encodeURIComponent(query);
|
||||
const url = base_url + encodeURIComponent(query.trim());
|
||||
|
||||
const res = await fetch(url);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user