summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-07-02 16:51:42 +0200
committerjmoenig <jens@moenig.org>2013-07-02 16:51:42 +0200
commit1061fa4437884f7fca2487e5c36c717778174eb7 (patch)
treec6bd02dae1f234f55651f823d062975b13c59d47 /gui.js
parent78f416be9a4d42517a4b6a5bb801394c6c3e30c1 (diff)
downloadsnap-byow-1061fa4437884f7fca2487e5c36c717778174eb7.tar.gz
snap-byow-1061fa4437884f7fca2487e5c36c717778174eb7.zip
GUI: import libraries feature
in the project menu, libraries for * Iteration, composition, * List utilities, * Variadic reporters, * Words, sentences
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js47
1 files changed, 46 insertions, 1 deletions
diff --git a/gui.js b/gui.js
index 11cecf6..6e303c5 100644
--- a/gui.js
+++ b/gui.js
@@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2013-June-28';
+modules.gui = '2013-July-02';
// Declarations
@@ -2315,6 +2315,51 @@ IDE_Morph.prototype.projectMenu = function () {
},
'load the official library of\npowerful blocks'
);
+ menu.addItem(
+ 'Libraries...',
+ function () {
+ var menu = new MenuMorph(this, 'Import library');
+
+ function loadLib(name) {
+ var url = 'http://snap.berkeley.edu/snapsource/libraries/'
+ + name
+ + '.xml',
+ request = new XMLHttpRequest();
+ request.open('GET', url, false);
+ request.send();
+ if (request.status === 200) {
+ return myself.droppedText(request.responseText, name);
+ }
+ throw new Error('unable to retrieve ' + url);
+ }
+
+ menu.addItem(
+ 'Iteration, composition...',
+ function () {
+ loadLib('iteration-composition');
+ }
+ );
+ menu.addItem(
+ 'List utilities...',
+ function () {
+ loadLib('list-utilities');
+ }
+ );
+ menu.addItem(
+ 'Variadic reporters...',
+ function () {
+ loadLib('variadic-reporters');
+ }
+ );
+ menu.addItem(
+ 'Words, sentences...',
+ function () {
+ loadLib('word-sentence');
+ }
+ );
+ menu.popup(world, pos);
+ }
+ );
menu.popup(world, pos);
};