some fun functions

This commit is contained in:
2023-08-23 15:48:49 +02:00
parent e5dd7194ba
commit 2ca6e8ee31
3 changed files with 77 additions and 55 deletions

View File

@ -570,6 +570,15 @@ export class Editor {
Object.entries(this.api).forEach(([name, value]) => {
(globalThis as Record<string, any>)[name] = value;
});
// Loading from URL bar
// let url = new URLSearchParams(window.location.search).toString();
// const queryString = url.split("universe=");
// console.log(queryString);
// const encodedData = queryString.split("=")[1];
// const decodedData = decodeURIComponent(queryString);
// console.log(decodedData);
// console.log(decodedData);
}
get note_buffer() {
@ -594,15 +603,16 @@ export class Editor {
window.history.replaceState({}, document.title, "/");
};
parseHash = (hash: string) => {
return JSON.parse(atob(hash));
};
share() {
const hashed_table = JSON.stringify(
this.settings.universes[this.selected_universe]
);
const url = new URL(window.location.href);
url.searchParams.set(
"universe",
this.selected_universe + "-" + hashed_table
);
url.searchParams.set("universe", hashed_table);
window.history.replaceState({}, "", url.toString());
}