Allow loading tools.xml from mirror *or* s.b.e

Using full http://s.b.e/snapsource/tools.xml disallows local repository.
Using relative tools.xml disallows running from local disk but getting tools from s.b.e.
So we try both.
pull/3/merge
brianharvey 2014-07-11 08:28:48 -07:00
rodzic f27e72e2b2
commit c965d45259
1 zmienionych plików z 19 dodań i 2 usunięć

21
gui.js
Wyświetl plik

@ -2349,8 +2349,9 @@ IDE_Morph.prototype.projectMenu = function () {
'Import tools',
function () {
myself.droppedText(
myself.getURL(
'tools.xml'
myself.getURL2(
'tools.xml',
'http://snap.berkeley.edu/snapsource/tools.xml'
),
'tools'
);
@ -4035,6 +4036,22 @@ IDE_Morph.prototype.getURL = function (url) {
}
};
IDE_Morph.prototype.getURL2 = function (url, url2) {
var request = new XMLHttpRequest(),
myself = this;
try {
request.open('GET', url, false);
request.send();
if (request.status === 200) {
return request.responseText;
}
return myself.getURL(url2);
} catch (err) {
myself.showMessage(err);
return;
}
};
// IDE_Morph user dialog shortcuts
IDE_Morph.prototype.showMessage = function (message, secs) {