summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorbrianharvey <bh@cs.berkeley.edu>2014-07-11 08:28:48 -0700
committerbrianharvey <bh@cs.berkeley.edu>2014-07-11 08:28:48 -0700
commitc965d45259f077863132f7651309bdb63d488524 (patch)
tree58fd1682025f75194066e6d77d0c47357f3cface /gui.js
parentf27e72e2b2005f96d680e12efb59aa146969d0ec (diff)
downloadsnap-yow-c965d45259f077863132f7651309bdb63d488524.tar.gz
snap-yow-c965d45259f077863132f7651309bdb63d488524.zip
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.
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/gui.js b/gui.js
index 23a2250..e209d4b 100644
--- a/gui.js
+++ b/gui.js
@@ -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) {