From 2b530f82dfd2d2bd23a660db616936e259e653a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Guill=C3=A9n=20i=20Pelegay?= Date: Thu, 13 May 2021 16:15:11 +0200 Subject: [PATCH 1/2] Fixing 'lang' flag and anchor launcher --- src/gui.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gui.js b/src/gui.js index bd10eb4a..12613fc4 100644 --- a/src/gui.js +++ b/src/gui.js @@ -364,9 +364,6 @@ IDE_Morph.prototype.openIn = function (world) { if (dict.noExitWarning) { window.onbeforeunload = nop; } - if (dict.lang) { - myself.setLanguage(dict.lang, null, true); // don't persist - } // only force my world to get focus if I'm not in embed mode // to prevent the iFrame from involuntarily scrolling into view @@ -606,16 +603,33 @@ IDE_Morph.prototype.openIn = function (world) { this.cloudError() ); } else if (location.hash.substr(0, 6) === '#lang:') { - urlLanguage = location.hash.substr(6); - this.setLanguage(urlLanguage, null, true); // don't persist - this.loadNewProject = true; + dict = myself.cloud.parseDict(location.hash.substr(6)); + applyFlags(dict); } else if (location.hash.substr(0, 7) === '#signup') { this.createCloudAccount(); } this.loadNewProject = false; } - if (this.userLanguage) { + function launcherLangSetting() { + var langSetting = null; + if (location.hash.substr(0, 6) === '#lang:') { + if (location.hash.charAt(8) === '_') { + langSetting = location.hash.slice(6,11); + } else { + langSetting = location.hash.slice(6,8); + } + } + // lang-flag wins lang-anchor setting + langSetting = myself.cloud.parseDict(location.hash).lang || langSetting; + return langSetting; + } + + if (launcherLangSetting()) { + // launch with this non-persisten lang setting + this.loadNewProject = true; + this.setLanguage(launcherLangSetting(), interpretUrlAnchors, true); + } else if (this.userLanguage) { this.loadNewProject = true; this.setLanguage(this.userLanguage, interpretUrlAnchors); } else { From fe55a1763be1e51da3e59a40fd6016ddf49dc99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Guill=C3=A9n=20i=20Pelegay?= Date: Fri, 14 May 2021 11:48:28 +0200 Subject: [PATCH 2/2] Fixing #run: anchor launcher --- src/gui.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/gui.js b/src/gui.js index 12613fc4..3c6359a6 100644 --- a/src/gui.js +++ b/src/gui.js @@ -457,26 +457,38 @@ IDE_Morph.prototype.openIn = function (world) { } ); } - } else if (location.hash.substr(0, 5) === '#run:') { + } else if (location.hash.substr(0, 5) === '#run:') { + dict = ''; hash = location.hash.substr(5); - idx = hash.indexOf("&"); - if (idx > 0) { - hash = hash.slice(0, idx); - } + + //decoding if hash is an encoded URI if (hash.charAt(0) === '%' || hash.search(/\%(?:[0-9a-f]{2})/i) > -1) { hash = decodeURIComponent(hash); } - if (hash.substr(0, 8) === '') { - this.rawOpenProjectString(hash); - applyFlags(myself.cloud.parseDict(location.hash.substr(5))); + idx = hash.indexOf("&"); + + // supporting three URL cases + + // xml project + if (hash.substr(0, 8) === '') + 10)); + applyFlags(myself.cloud.parseDict(hash.substr(hash.indexOf('') + 10))); + // no project, only flags + } else if (idx == 0){ + applyFlags(myself.cloud.parseDict(hash)); + // xml file path + // three path types allowed: absolute (http...) , relative to site ("/path") or relative to folder ("path") } else { this.shield = new Morph(); this.shield.alpha = 0; this.shield.setExtent(this.parent.extent()); this.parent.add(this.shield); this.showMessage('Fetching project...'); - + if (idx > 0) { + dict = myself.cloud.parseDict(hash.substr(idx)); + hash = hash.slice(0,idx); + } this.getURL( hash, projectData => { @@ -498,11 +510,7 @@ IDE_Morph.prototype.openIn = function (world) { this.shield = null; msg.destroy(); // this.toggleAppMode(true); - applyFlags( - this.cloud.parseDict( - location.hash.substr(5) - ) - ); + applyFlags(dict); } ]); }