From 3f6fd7ac440c03ed2457de19cdcd0aedbe8c5061 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Fri, 25 Aug 2023 19:26:40 +0200 Subject: [PATCH] test --- src/API.ts | 3 +++ src/main.ts | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/API.ts b/src/API.ts index 0bb91b0..8ed69f7 100644 --- a/src/API.ts +++ b/src/API.ts @@ -166,12 +166,14 @@ Array.prototype.repeatOdd = function (this: T[], amount: number) { return this; }; +// @ts-ignore Array.prototype.palindrome = function () { let left_to_right = Array.from(this); let right_to_left = Array.from(this.reverse()); return left_to_right.concat(right_to_left); }; +// @ts-ignore Array.prototype.random = function (this: T[], index: number): T { return this[Math.floor(Math.random() * this.length)]; }; @@ -180,6 +182,7 @@ Array.prototype.loop = function (this: T[], index: number): T { return this[index % this.length]; }; +// @ts-ignore Array.prototype.random = function (index) { return this[Math.floor(Math.random() * this.length)]; }; diff --git a/src/main.ts b/src/main.ts index ea93a74..c6685b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -559,23 +559,6 @@ export class Editor { (globalThis as Record)[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({ extensions: [ ...this.editorExtensions, @@ -602,6 +585,23 @@ export class Editor { }); 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() {