mirror of
https://github.com/nuttylmao/nutty.gg.git
synced 2026-09-19 04:00:59 -04:00
Updated to new Settings page
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
let settingsContainer = document.getElementById('settings-container');
|
||||
settingsContainer.src = `../../.utilities/settings-page-builder?settingsJson=${window.location.href}/settings.json`
|
||||
console.log(settingsContainer.src);
|
||||
const widgetContainer = document.getElementById('widgetContainer');
|
||||
|
||||
function reloadWidget(data) {
|
||||
const settingsPageURL = '../../.utilities/settings-page-builder';
|
||||
|
||||
const currentURL = window.location.href;
|
||||
|
||||
let settingsJSON;
|
||||
let baseURL = currentURL;
|
||||
|
||||
if (baseURL.endsWith("index.html"))
|
||||
baseURL = baseURL.replace("index.html", "");
|
||||
|
||||
settingsJSON = "?settingsJson=" + baseURL + "settings.json";
|
||||
|
||||
const lastSlashIndex = baseURL.lastIndexOf("/");
|
||||
let widgetURL = "&widgetURL=" + baseURL.replace("/settings", "");
|
||||
|
||||
console.debug("Window Ref: " + window.location.href);
|
||||
console.debug("Base URL: " + baseURL);
|
||||
console.debug("Settings JSON: " + settingsJSON);
|
||||
console.debug("Widget URL: " + widgetURL);
|
||||
|
||||
widgetContainer.src = settingsPageURL + settingsJSON + widgetURL;
|
||||
|
||||
function callFunction(functionName) {
|
||||
console.debug(`Calling ${functionName}`);
|
||||
let widget = document.getElementById("widget");
|
||||
widget.src = `${getParentUrl()}?${data}`;
|
||||
}
|
||||
|
||||
function getParentUrl() {
|
||||
const currentUrl = window.location.href;
|
||||
const urlParts = currentUrl.split('/');
|
||||
|
||||
// Remove the last part of the URL (the current page/file)
|
||||
urlParts.pop();
|
||||
|
||||
// Remove the last part again to go one directory up
|
||||
urlParts.pop();
|
||||
|
||||
// Reconstruct the URL
|
||||
const parentUrl = urlParts.join('/');
|
||||
|
||||
// Ensure there's a trailing slash if necessary (if it was a directory)
|
||||
if (urlParts.length > 2 && !parentUrl.endsWith('/')) {
|
||||
return parentUrl + '/';
|
||||
}
|
||||
|
||||
return parentUrl;
|
||||
widget.contentWindow[functionName]();
|
||||
}
|
||||
Reference in New Issue
Block a user