kopia lustrzana https://github.com/backface/turtlestitch
Merge pull request #2830 from jguille2/langLauncher
Fixing 'lang' flag and anchor launcherpull/95/head
commit
8c5d981e2a
62
src/gui.js
62
src/gui.js
|
@ -364,9 +364,6 @@ IDE_Morph.prototype.openIn = function (world) {
|
||||||
if (dict.noExitWarning) {
|
if (dict.noExitWarning) {
|
||||||
window.onbeforeunload = nop;
|
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
|
// only force my world to get focus if I'm not in embed mode
|
||||||
// to prevent the iFrame from involuntarily scrolling into view
|
// to prevent the iFrame from involuntarily scrolling into view
|
||||||
|
@ -461,25 +458,37 @@ 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);
|
hash = location.hash.substr(5);
|
||||||
idx = hash.indexOf("&");
|
|
||||||
if (idx > 0) {
|
//decoding if hash is an encoded URI
|
||||||
hash = hash.slice(0, idx);
|
|
||||||
}
|
|
||||||
if (hash.charAt(0) === '%'
|
if (hash.charAt(0) === '%'
|
||||||
|| hash.search(/\%(?:[0-9a-f]{2})/i) > -1) {
|
|| hash.search(/\%(?:[0-9a-f]{2})/i) > -1) {
|
||||||
hash = decodeURIComponent(hash);
|
hash = decodeURIComponent(hash);
|
||||||
}
|
}
|
||||||
if (hash.substr(0, 8) === '<project>') {
|
idx = hash.indexOf("&");
|
||||||
this.rawOpenProjectString(hash);
|
|
||||||
applyFlags(myself.cloud.parseDict(location.hash.substr(5)));
|
// supporting three URL cases
|
||||||
|
|
||||||
|
// xml project
|
||||||
|
if (hash.substr(0, 8) === '<project') {
|
||||||
|
this.rawOpenProjectString(hash.slice(0,hash.indexOf('</project>') + 10));
|
||||||
|
applyFlags(myself.cloud.parseDict(hash.substr(hash.indexOf('</project>') + 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 {
|
} else {
|
||||||
this.shield = new Morph();
|
this.shield = new Morph();
|
||||||
this.shield.alpha = 0;
|
this.shield.alpha = 0;
|
||||||
this.shield.setExtent(this.parent.extent());
|
this.shield.setExtent(this.parent.extent());
|
||||||
this.parent.add(this.shield);
|
this.parent.add(this.shield);
|
||||||
this.showMessage('Fetching project...');
|
this.showMessage('Fetching project...');
|
||||||
|
if (idx > 0) {
|
||||||
|
dict = myself.cloud.parseDict(hash.substr(idx));
|
||||||
|
hash = hash.slice(0,idx);
|
||||||
|
}
|
||||||
this.getURL(
|
this.getURL(
|
||||||
hash,
|
hash,
|
||||||
projectData => {
|
projectData => {
|
||||||
|
@ -501,11 +510,7 @@ IDE_Morph.prototype.openIn = function (world) {
|
||||||
this.shield = null;
|
this.shield = null;
|
||||||
msg.destroy();
|
msg.destroy();
|
||||||
// this.toggleAppMode(true);
|
// this.toggleAppMode(true);
|
||||||
applyFlags(
|
applyFlags(dict);
|
||||||
this.cloud.parseDict(
|
|
||||||
location.hash.substr(5)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -606,16 +611,33 @@ IDE_Morph.prototype.openIn = function (world) {
|
||||||
this.cloudError()
|
this.cloudError()
|
||||||
);
|
);
|
||||||
} else if (location.hash.substr(0, 6) === '#lang:') {
|
} else if (location.hash.substr(0, 6) === '#lang:') {
|
||||||
urlLanguage = location.hash.substr(6);
|
dict = myself.cloud.parseDict(location.hash.substr(6));
|
||||||
this.setLanguage(urlLanguage, null, true); // don't persist
|
applyFlags(dict);
|
||||||
this.loadNewProject = true;
|
|
||||||
} else if (location.hash.substr(0, 7) === '#signup') {
|
} else if (location.hash.substr(0, 7) === '#signup') {
|
||||||
this.createCloudAccount();
|
this.createCloudAccount();
|
||||||
}
|
}
|
||||||
this.loadNewProject = false;
|
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.loadNewProject = true;
|
||||||
this.setLanguage(this.userLanguage, interpretUrlAnchors);
|
this.setLanguage(this.userLanguage, interpretUrlAnchors);
|
||||||
} else {
|
} else {
|
||||||
|
|
Ładowanie…
Reference in New Issue