From c965d45259f077863132f7651309bdb63d488524 Mon Sep 17 00:00:00 2001 From: brianharvey Date: Fri, 11 Jul 2014 08:28:48 -0700 Subject: 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. --- gui.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'gui.js') 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) { -- cgit v1.3.1