This commit is contained in:
2023-08-25 19:26:40 +02:00
parent 953626303d
commit 3f6fd7ac44
2 changed files with 20 additions and 17 deletions

View File

@ -166,12 +166,14 @@ Array.prototype.repeatOdd = function <T>(this: T[], amount: number) {
return this; return this;
}; };
// @ts-ignore
Array.prototype.palindrome = function <T>() { Array.prototype.palindrome = function <T>() {
let left_to_right = Array.from(this); let left_to_right = Array.from(this);
let right_to_left = Array.from(this.reverse()); let right_to_left = Array.from(this.reverse());
return left_to_right.concat(right_to_left); return left_to_right.concat(right_to_left);
}; };
// @ts-ignore
Array.prototype.random = function <T>(this: T[], index: number): T { Array.prototype.random = function <T>(this: T[], index: number): T {
return this[Math.floor(Math.random() * this.length)]; return this[Math.floor(Math.random() * this.length)];
}; };
@ -180,6 +182,7 @@ Array.prototype.loop = function <T>(this: T[], index: number): T {
return this[index % this.length]; return this[index % this.length];
}; };
// @ts-ignore
Array.prototype.random = function (index) { Array.prototype.random = function (index) {
return this[Math.floor(Math.random() * this.length)]; return this[Math.floor(Math.random() * this.length)];
}; };

View File

@ -559,23 +559,6 @@ export class Editor {
(globalThis as Record<string, any>)[name] = value; (globalThis as Record<string, any>)[name] = value;
}); });
// Loading from URL bar
let url = new URLSearchParams(window.location.search);
if (url !== undefined) {
let new_universe;
if (url !== null) {
const universeParam = url.get("universe");
if (universeParam !== null) {
new_universe = JSON.parse(atob(universeParam));
const randomName: string = uniqueNamesGenerator({
dictionaries: [adjectives, colors, animals],
});
this.loadUniverse(randomName, new_universe["universe"]);
this.emptyUrl();
}
}
}
this.state = EditorState.create({ this.state = EditorState.create({
extensions: [ extensions: [
...this.editorExtensions, ...this.editorExtensions,
@ -602,6 +585,23 @@ export class Editor {
}); });
this.changeModeFromInterface("global"); this.changeModeFromInterface("global");
// Loading from URL bar
let url = new URLSearchParams(window.location.search);
if (url !== undefined) {
let new_universe;
if (url !== null) {
const universeParam = url.get("universe");
if (universeParam !== null) {
new_universe = JSON.parse(atob(universeParam));
const randomName: string = uniqueNamesGenerator({
dictionaries: [adjectives, colors, animals],
});
this.loadUniverse(randomName, new_universe["universe"]);
this.emptyUrl();
}
}
}
} }
get note_buffer() { get note_buffer() {