randomize shared universe names

This commit is contained in:
2023-08-24 00:08:00 +02:00
parent c6a2f5f1a8
commit c28463b06d
3 changed files with 23 additions and 7 deletions

View File

@ -36,6 +36,7 @@
"tailwind-highlightjs": "^2.0.1",
"tailwindcss": "^3.3.3",
"tone": "^14.8.49",
"unique-names-generator": "^4.7.1",
"vite-plugin-markdown": "^2.1.0",
"zifferjs": "^0.0.12",
"zzfx": "^1.2.0"

View File

@ -1,3 +1,10 @@
import {
uniqueNamesGenerator,
Config,
adjectives,
colors,
animals,
} from "unique-names-generator";
import { EditorState, Compartment } from "@codemirror/state";
import { ViewUpdate, lineNumbers, keymap } from "@codemirror/view";
import { javascript } from "@codemirror/lang-javascript";
@ -579,13 +586,14 @@ export class Editor {
const universeParam = url.get("universe");
if (universeParam !== null) {
new_universe = JSON.parse(atob(universeParam));
this.loadUniverse("imported", new_universe["universe"]);
const randomName: string = uniqueNamesGenerator({
dictionaries: [adjectives, colors, animals],
});
this.loadUniverse(randomName, new_universe["universe"]);
this.emptyUrl();
}
}
}
console.log(this.universes[this.selected_universe]);
console.log(this.universes["imported"]);
}
get note_buffer() {
@ -615,14 +623,16 @@ export class Editor {
};
share() {
const hashed_table = btoa(JSON.stringify(
{
const hashed_table = btoa(
JSON.stringify({
universe: this.settings.universes[this.selected_universe],
}
));
})
);
const url = new URL(window.location.href);
url.searchParams.set("universe", hashed_table);
window.history.replaceState({}, "", url.toString());
// Copy the text inside the text field
navigator.clipboard.writeText(url.toString());
}
showDocumentation() {

View File

@ -1380,6 +1380,11 @@ uc.micro@^1.0.1, uc.micro@^1.0.5:
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
unique-names-generator@^4.7.1:
version "4.7.1"
resolved "https://registry.yarnpkg.com/unique-names-generator/-/unique-names-generator-4.7.1.tgz#966407b12ba97f618928f77322cfac8c80df5597"
integrity sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==
update-browserslist-db@^1.0.11:
version "1.0.11"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz#9a2a641ad2907ae7b3616506f4b977851db5b940"