kopia lustrzana https://github.com/backface/turtlestitch
rodzic
53068ea259
commit
1fc6cd7910
26
gui.js
26
gui.js
|
@ -83,9 +83,15 @@ var SoundIconMorph;
|
|||
var JukeboxMorph;
|
||||
|
||||
// Get the full url without "snap.html"
|
||||
var baseUrl = document.URL.split('/');
|
||||
baseUrl.pop(baseUrl.length - 1);
|
||||
baseUrl = baseUrl.join('/') + '/';
|
||||
var baseURL = (function getPath(location) {
|
||||
var origin, path, slash;
|
||||
path = location.pathname; // starts with a /
|
||||
origin = location.origin; // has no trailing /
|
||||
slash = path.lastIndexOf('/');
|
||||
path = path.slice(0, slash); // keep a trailing /
|
||||
return origin + path;
|
||||
}(window.location));
|
||||
|
||||
|
||||
// IDE_Morph ///////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -2497,10 +2503,10 @@ IDE_Morph.prototype.projectMenu = function () {
|
|||
function () {
|
||||
// read a list of libraries from an external file,
|
||||
var libMenu = new MenuMorph(this, 'Import library'),
|
||||
libUrl = baseUrl + 'libraries/' + 'LIBRARIES';
|
||||
libUrl = baseURL + 'libraries/' + 'LIBRARIES';
|
||||
|
||||
function loadLib(name) {
|
||||
var url = baseUrl + 'libraries/' + name + '.xml';
|
||||
var url = baseURL + 'libraries/' + name + '.xml';
|
||||
myself.droppedText(myself.getURL(url), name);
|
||||
}
|
||||
|
||||
|
@ -4219,7 +4225,7 @@ IDE_Morph.prototype.getURLsbeOrRelative = function (url) {
|
|||
var request = new XMLHttpRequest(),
|
||||
myself = this;
|
||||
try {
|
||||
request.open('GET', baseUrl + url, false);
|
||||
request.open('GET', baseURL + url, false);
|
||||
request.send();
|
||||
if (request.status === 200) {
|
||||
return request.responseText;
|
||||
|
@ -4660,7 +4666,7 @@ ProjectDialogMorph.prototype.setSource = function (source) {
|
|||
myself.nameField.setContents(item.name || '');
|
||||
}
|
||||
src = myself.ide.getURL(
|
||||
baseUrl + 'Examples/' + item.name + '.xml'
|
||||
baseURL + 'Examples/' + item.name + '.xml'
|
||||
);
|
||||
|
||||
xml = myself.ide.serializer.parse(src);
|
||||
|
@ -4714,9 +4720,9 @@ ProjectDialogMorph.prototype.getLocalProjectList = function () {
|
|||
ProjectDialogMorph.prototype.getExamplesProjectList = function () {
|
||||
var dir,
|
||||
projects = [];
|
||||
//alert(baseUrl);
|
||||
//alert(baseURL);
|
||||
|
||||
dir = this.ide.getURL(baseUrl + 'Examples/');
|
||||
dir = this.ide.getURL(baseURL + 'Examples/');
|
||||
dir.split('\n').forEach(
|
||||
function (line) {
|
||||
var startIdx = line.search(new RegExp('href=".*xml"')),
|
||||
|
@ -4835,7 +4841,7 @@ ProjectDialogMorph.prototype.openProject = function () {
|
|||
if (this.source === 'cloud') {
|
||||
this.openCloudProject(proj);
|
||||
} else if (this.source === 'examples') {
|
||||
src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml');
|
||||
src = this.ide.getURL(baseURL + 'Examples/' + proj.name + '.xml');
|
||||
this.ide.openProjectString(src);
|
||||
this.destroy();
|
||||
} else { // 'local'
|
||||
|
|
Ładowanie…
Reference in New Issue