filestash/public/assets/pages/viewerpage/common.js
2025-08-07 23:05:44 +10:00

20 lines
736 B
JavaScript

import { fromHref } from "../../lib/skeleton/router.js";
import { transition as transitionLib, slideYIn } from "../../lib/animate.js";
import { basename, forwardURLParams } from "../../lib/path.js";
export function transition($node) {
return transitionLib($node, { timeEnter: 150, enter: slideYIn(2) });
}
export function getFilename() {
return basename(getCurrentPath()) || " ";
}
export function getDownloadUrl() {
return forwardURLParams("api/files/cat?path=" + encodeURIComponent(getCurrentPath()), ["share"]);
}
export function getCurrentPath(start = "/view/") {
const fullpath = fromHref(location.pathname + location.hash);
return decodeURIComponent(fullpath.replace(new RegExp("^" + start), "/"));
}