From a67b2e238164a60988e9bb89d644b3923b0f696b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 19 Mar 2013 12:09:55 +0100 Subject: motd support On startup Snap! looks for http://snap.berkeley.edu/motd.txt, if it exists it is shown in a dialog box --- gui.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'gui.js') diff --git a/gui.js b/gui.js index 49c65bd..ae26750 100644 --- a/gui.js +++ b/gui.js @@ -149,7 +149,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { }; IDE_Morph.prototype.openIn = function (world) { - var hash, usr; + var hash, usr, motd; this.buildPanes(); world.add(this); @@ -191,13 +191,22 @@ IDE_Morph.prototype.openIn = function (world) { this.reactToWorldResize(world.bounds); function getURL(url) { - var request = new XMLHttpRequest(); - request.open('GET', url, false); - request.send(); - if (request.status === 200) { - return request.responseText; + 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) { + return; } - throw new Error('unable to retrieve ' + url); + } + + motd = getURL('http://snap.berkeley.edu/motd.txt'); + if (motd) { + this.inform('Snap!', motd); } if (location.hash.substr(0, 6) === '#open:') { -- cgit v1.3.1