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;
|
var JukeboxMorph;
|
||||||
|
|
||||||
// Get the full url without "snap.html"
|
// Get the full url without "snap.html"
|
||||||
var baseUrl = document.URL.split('/');
|
var baseURL = (function getPath(location) {
|
||||||
baseUrl.pop(baseUrl.length - 1);
|
var origin, path, slash;
|
||||||
baseUrl = baseUrl.join('/') + '/';
|
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 ///////////////////////////////////////////////////////////
|
// IDE_Morph ///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -2497,10 +2503,10 @@ IDE_Morph.prototype.projectMenu = function () {
|
||||||
function () {
|
function () {
|
||||||
// read a list of libraries from an external file,
|
// read a list of libraries from an external file,
|
||||||
var libMenu = new MenuMorph(this, 'Import library'),
|
var libMenu = new MenuMorph(this, 'Import library'),
|
||||||
libUrl = baseUrl + 'libraries/' + 'LIBRARIES';
|
libUrl = baseURL + 'libraries/' + 'LIBRARIES';
|
||||||
|
|
||||||
function loadLib(name) {
|
function loadLib(name) {
|
||||||
var url = baseUrl + 'libraries/' + name + '.xml';
|
var url = baseURL + 'libraries/' + name + '.xml';
|
||||||
myself.droppedText(myself.getURL(url), name);
|
myself.droppedText(myself.getURL(url), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4219,7 +4225,7 @@ IDE_Morph.prototype.getURLsbeOrRelative = function (url) {
|
||||||
var request = new XMLHttpRequest(),
|
var request = new XMLHttpRequest(),
|
||||||
myself = this;
|
myself = this;
|
||||||
try {
|
try {
|
||||||
request.open('GET', baseUrl + url, false);
|
request.open('GET', baseURL + url, false);
|
||||||
request.send();
|
request.send();
|
||||||
if (request.status === 200) {
|
if (request.status === 200) {
|
||||||
return request.responseText;
|
return request.responseText;
|
||||||
|
@ -4660,7 +4666,7 @@ ProjectDialogMorph.prototype.setSource = function (source) {
|
||||||
myself.nameField.setContents(item.name || '');
|
myself.nameField.setContents(item.name || '');
|
||||||
}
|
}
|
||||||
src = myself.ide.getURL(
|
src = myself.ide.getURL(
|
||||||
baseUrl + 'Examples/' + item.name + '.xml'
|
baseURL + 'Examples/' + item.name + '.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
xml = myself.ide.serializer.parse(src);
|
xml = myself.ide.serializer.parse(src);
|
||||||
|
@ -4714,9 +4720,9 @@ ProjectDialogMorph.prototype.getLocalProjectList = function () {
|
||||||
ProjectDialogMorph.prototype.getExamplesProjectList = function () {
|
ProjectDialogMorph.prototype.getExamplesProjectList = function () {
|
||||||
var dir,
|
var dir,
|
||||||
projects = [];
|
projects = [];
|
||||||
//alert(baseUrl);
|
//alert(baseURL);
|
||||||
|
|
||||||
dir = this.ide.getURL(baseUrl + 'Examples/');
|
dir = this.ide.getURL(baseURL + 'Examples/');
|
||||||
dir.split('\n').forEach(
|
dir.split('\n').forEach(
|
||||||
function (line) {
|
function (line) {
|
||||||
var startIdx = line.search(new RegExp('href=".*xml"')),
|
var startIdx = line.search(new RegExp('href=".*xml"')),
|
||||||
|
@ -4835,7 +4841,7 @@ ProjectDialogMorph.prototype.openProject = function () {
|
||||||
if (this.source === 'cloud') {
|
if (this.source === 'cloud') {
|
||||||
this.openCloudProject(proj);
|
this.openCloudProject(proj);
|
||||||
} else if (this.source === 'examples') {
|
} 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.ide.openProjectString(src);
|
||||||
this.destroy();
|
this.destroy();
|
||||||
} else { // 'local'
|
} else { // 'local'
|
||||||
|
|
Ładowanie…
Reference in New Issue