diff options
| author | jmoenig <jens@moenig.org> | 2013-07-02 16:51:42 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-07-02 16:51:42 +0200 |
| commit | 1061fa4437884f7fca2487e5c36c717778174eb7 (patch) | |
| tree | c6bd02dae1f234f55651f823d062975b13c59d47 /gui.js | |
| parent | 78f416be9a4d42517a4b6a5bb801394c6c3e30c1 (diff) | |
| download | snap-1061fa4437884f7fca2487e5c36c717778174eb7.tar.gz snap-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.js | 47 |
1 files changed, 46 insertions, 1 deletions
@@ -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); }; |
