Merge pull request #2020 from cycomachead/master

Fix the MOTD feature.
upd4.2
Jens Mönig 2018-02-15 15:10:09 +01:00 zatwierdzone przez GitHub
commit 7fa9f2ef59
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 9 dodań i 24 usunięć

1
.gitignore vendored
Wyświetl plik

@ -1,3 +1,4 @@
.DS_Store .DS_Store
*.swp *.swp
.tern-port .tern-port
motd.txt

30
gui.js
Wyświetl plik

@ -310,21 +310,6 @@ IDE_Morph.prototype.openIn = function (world) {
this.reactToWorldResize(world.bounds); this.reactToWorldResize(world.bounds);
function getURL(url) {
try {
var request = new XMLHttpRequest();
request.open('GET', url, false);
request.send();
if (request.status === 200) {
return request.responseText;
}
throw new Error('unable to retrieve ' + url);
} catch (err) {
myself.showMessage('unable to retrieve project');
return '';
}
}
function applyFlags(dict) { function applyFlags(dict) {
if (dict.embedMode) { if (dict.embedMode) {
myself.setEmbedMode(); myself.setEmbedMode();
@ -347,14 +332,11 @@ IDE_Morph.prototype.openIn = function (world) {
} }
// dynamic notifications from non-source text files // dynamic notifications from non-source text files
// has some issues, commented out for now this.getURL('motd.txt', function (text, request) {
/* if (text && request.status == 200) {
this.cloudMsg = getURL('http://snap.berkeley.edu/cloudmsg.txt'); this.inform('Snap!', text);
motd = getURL('http://snap.berkeley.edu/motd.txt');
if (motd) {
this.inform('Snap!', motd);
} }
*/ });
function interpretUrlAnchors() { function interpretUrlAnchors() {
var dict, idx; var dict, idx;
@ -5576,7 +5558,8 @@ IDE_Morph.prototype.getURL = function (url, callback) {
if (request.responseText) { if (request.responseText) {
callback.call( callback.call(
myself, myself,
request.responseText request.responseText,
request
); );
} else { } else {
throw new Error('unable to retrieve ' + url); throw new Error('unable to retrieve ' + url);
@ -5592,6 +5575,7 @@ IDE_Morph.prototype.getURL = function (url, callback) {
throw new Error('unable to retrieve ' + url); throw new Error('unable to retrieve ' + url);
} }
} catch (err) { } catch (err) {
alert('CATCHING ERROR', err)
myself.showMessage(err.toString()); myself.showMessage(err.toString());
if (async) { if (async) {
callback.call(this); callback.call(this);