From 1061fa4437884f7fca2487e5c36c717778174eb7 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 2 Jul 2013 16:51:42 +0200 Subject: GUI: import libraries feature in the project menu, libraries for * Iteration, composition, * List utilities, * Variadic reporters, * Words, sentences --- gui.js | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'gui.js') 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); }; -- cgit v1.3.1