calculate a baseurl
This commit is contained in:
parent
f3d3e77f0f
commit
e78ccc9758
1 changed files with 8 additions and 6 deletions
|
|
@ -9,12 +9,15 @@
|
||||||
console.log("butter-dir-listing.js loaded!");
|
console.log("butter-dir-listing.js loaded!");
|
||||||
|
|
||||||
const supported_extensions = [".apk"];
|
const supported_extensions = [".apk"];
|
||||||
|
const usbRoot = "/usb-butter/";
|
||||||
|
const inferredBaseURL = window.location.pathname.split("/usb-butter/")[0] + "/";
|
||||||
|
console.log("Inferred Base URL:", inferredBaseURL);
|
||||||
|
|
||||||
const getFolderDivHTML = (directory_name, number_of_items, href) => {
|
const getFolderDivHTML = (directory_name, number_of_items, href) => {
|
||||||
return `
|
return `
|
||||||
<a class="container" href="${href}">
|
<a class="container" href="${href}">
|
||||||
<div class="logo-container">
|
<div class="logo-container">
|
||||||
<img src="/assets/images/directory.svg" alt="directory">
|
<img src="${inferredBaseURL}assets/images/directory.svg" alt="directory">
|
||||||
</div>
|
</div>
|
||||||
<div class="text-container">
|
<div class="text-container">
|
||||||
<div class="upper-text">${directory_name}</div>
|
<div class="upper-text">${directory_name}</div>
|
||||||
|
|
@ -33,7 +36,7 @@ const getFileDivHTML = (file_name, size, date, href) => {
|
||||||
return `
|
return `
|
||||||
<a class="container" href="${href}">
|
<a class="container" href="${href}">
|
||||||
<div class="logo-container">
|
<div class="logo-container">
|
||||||
<img src="/assets/images/${icon}" alt="directory">
|
<img src="${inferredBaseURL}assets/images/${icon}" alt="directory">
|
||||||
</div>
|
</div>
|
||||||
<div class="text-container">
|
<div class="text-container">
|
||||||
<div class="upper-text">${file_name}</div>
|
<div class="upper-text">${file_name}</div>
|
||||||
|
|
@ -99,7 +102,6 @@ window.onload = function () {
|
||||||
const listDiv = document.querySelector('div.list');
|
const listDiv = document.querySelector('div.list');
|
||||||
|
|
||||||
// Header with breadcrumbs
|
// Header with breadcrumbs
|
||||||
const usbRoot = "/usb-butter/";
|
|
||||||
const h2Path = document.querySelector('h2').textContent;
|
const h2Path = document.querySelector('h2').textContent;
|
||||||
console.log("H2 Path:", h2Path);
|
console.log("H2 Path:", h2Path);
|
||||||
const path = h2Path.replace('Index of ', '').replace(usbRoot, '');
|
const path = h2Path.replace('Index of ', '').replace(usbRoot, '');
|
||||||
|
|
@ -108,8 +110,8 @@ window.onload = function () {
|
||||||
const breadcrumbs = document.createElement("div");
|
const breadcrumbs = document.createElement("div");
|
||||||
breadcrumbs.classList.add('breadcrumbs');
|
breadcrumbs.classList.add('breadcrumbs');
|
||||||
let breadcrumbHTML = `
|
let breadcrumbHTML = `
|
||||||
<a href="/"><img class="home-icon" src="/assets/images/home.svg" alt="home"></a>
|
<a href="/"><img class="home-icon" src="${inferredBaseURL}assets/images/home.svg" alt="home"></a>
|
||||||
<a href="${usbRoot}" class="crumb"><img class="path-next" src="/assets/images/next.svg">Explore</a>
|
<a href="${usbRoot}" class="crumb"><img class="path-next" src="${inferredBaseURL}assets/images/next.svg">Explore</a>
|
||||||
`;
|
`;
|
||||||
pathSteps = path.split('/');
|
pathSteps = path.split('/');
|
||||||
let pathToHere = usbRoot;
|
let pathToHere = usbRoot;
|
||||||
|
|
@ -117,7 +119,7 @@ window.onload = function () {
|
||||||
pathToHere += step + '/';
|
pathToHere += step + '/';
|
||||||
if (step !== "") {
|
if (step !== "") {
|
||||||
breadcrumbHTML += `
|
breadcrumbHTML += `
|
||||||
<a href="${pathToHere}" class="crumb"><img class="path-next" src="/assets/images/next.svg">${step}</a>`;
|
<a href="${pathToHere}" class="crumb"><img class="path-next" src="${inferredBaseURL}assets/images/next.svg">${step}</a>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
breadcrumbs.innerHTML = breadcrumbHTML;
|
breadcrumbs.innerHTML = breadcrumbHTML;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue