From ce7f681c55bebff231867d8f3cd67e31daa644b9 Mon Sep 17 00:00:00 2001 From: brianharvey Date: Fri, 11 Jul 2014 08:52:30 -0700 Subject: Improve sbe-or-relative to generalize New method GetURLsbeOrRelative(url) takes a relative URL and tries it first on s.b.e and if that fails as a relative url. --- gui.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gui.js') diff --git a/gui.js b/gui.js index e209d4b..1d3c134 100644 --- a/gui.js +++ b/gui.js @@ -2349,9 +2349,8 @@ IDE_Morph.prototype.projectMenu = function () { 'Import tools', function () { myself.droppedText( - myself.getURL2( - 'tools.xml', - 'http://snap.berkeley.edu/snapsource/tools.xml' + myself.getURLsbeOrRelative( + 'tools.xml' ), 'tools' ); @@ -4036,16 +4035,17 @@ IDE_Morph.prototype.getURL = function (url) { } }; -IDE_Morph.prototype.getURL2 = function (url, url2) { +IDE_Morph.prototype.getURLsbeOrRelative = function (url) { var request = new XMLHttpRequest(), myself = this; try { - request.open('GET', url, false); + request.open('GET', 'http://snap.berkeley.edu/snapsource/' + + url, false); request.send(); if (request.status === 200) { return request.responseText; } - return myself.getURL(url2); + return myself.getURL(url); } catch (err) { myself.showMessage(err); return; -- cgit v1.3.1