first try at sharing

This commit is contained in:
2023-08-23 17:50:58 +02:00
parent 547eaaefd5
commit f3564e0c9c

View File

@ -572,13 +572,12 @@ export class Editor {
}); });
// Loading from URL bar // Loading from URL bar
// let url = new URLSearchParams(window.location.search).toString(); let url = new URLSearchParams(window.location.search);
// const queryString = url.split("universe="); if (url === null) {
// console.log(queryString); let new_universe = JSON.parse(url.get("universe"));
// const encodedData = queryString.split("=")[1]; console.log((this.universes["imported"] = new_universe));
// const decodedData = decodeURIComponent(queryString); this.loadUniverse("imported");
// console.log(decodedData); }
// console.log(decodedData);
} }
get note_buffer() { get note_buffer() {
@ -608,9 +607,9 @@ export class Editor {
}; };
share() { share() {
const hashed_table = JSON.stringify( const hashed_table = JSON.stringify({
this.settings.universes[this.selected_universe] universe: this.settings.universes[this.selected_universe],
); });
const url = new URL(window.location.href); const url = new URL(window.location.href);
url.searchParams.set("universe", hashed_table); url.searchParams.set("universe", hashed_table);
window.history.replaceState({}, "", url.toString()); window.history.replaceState({}, "", url.toString());