Skip to content

Commit

Permalink
Merge pull request #2023 from jmoenig/revert-2020-master
Browse files Browse the repository at this point in the history
Revert "Fix the MOTD feature."
  • Loading branch information
jmoenig committed Feb 15, 2018
2 parents c6bf4ad + d4bf6dd commit 272d986
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
*.swp
.tern-port
motd.txt
32 changes: 24 additions & 8 deletions gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ IDE_Morph.prototype.openIn = function (world) {

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) {
if (dict.embedMode) {
myself.setEmbedMode();
Expand All @@ -332,11 +347,14 @@ IDE_Morph.prototype.openIn = function (world) {
}

// dynamic notifications from non-source text files
this.getURL('motd.txt', function (text, request) {
if (text && request.status == 200) {
this.inform('Snap!', text);
}
});
// has some issues, commented out for now
/*
this.cloudMsg = getURL('http://snap.berkeley.edu/cloudmsg.txt');
motd = getURL('http://snap.berkeley.edu/motd.txt');
if (motd) {
this.inform('Snap!', motd);
}
*/

function interpretUrlAnchors() {
var dict, idx;
Expand Down Expand Up @@ -5558,8 +5576,7 @@ IDE_Morph.prototype.getURL = function (url, callback) {
if (request.responseText) {
callback.call(
myself,
request.responseText,
request
request.responseText
);
} else {
throw new Error('unable to retrieve ' + url);
Expand All @@ -5575,7 +5592,6 @@ IDE_Morph.prototype.getURL = function (url, callback) {
throw new Error('unable to retrieve ' + url);
}
} catch (err) {
alert('CATCHING ERROR', err)
myself.showMessage(err.toString());
if (async) {
callback.call(this);
Expand Down

0 comments on commit 272d986

Please sign in to comment.