├── .gitignore ├── CHANGELOG.md ├── Jakefile.js ├── LICENSE ├── README.md ├── docs ├── generate.sh ├── generated │ ├── files.html │ ├── index.html │ └── symbols │ │ ├── UndoManager.CircularStack.html │ │ ├── UndoManager.html │ │ ├── _global_.html │ │ ├── mindmaps.ApplicationController.html │ │ ├── mindmaps.CanvasContainer.Event.html │ │ ├── mindmaps.CanvasContainer.html │ │ ├── mindmaps.CanvasPresenter.html │ │ ├── mindmaps.CanvasView.html │ │ ├── mindmaps.ClipboardController.html │ │ ├── mindmaps.CloseDocumentCommand.html │ │ ├── mindmaps.Command.Event.html │ │ ├── mindmaps.Command.html │ │ ├── mindmaps.CommandRegistry.html │ │ ├── mindmaps.CopyNodeCommand.html │ │ ├── mindmaps.CreateNodeCommand.html │ │ ├── mindmaps.CutNodeCommand.html │ │ ├── mindmaps.DefaultCanvasView-CaptionEditor.html │ │ ├── mindmaps.DefaultCanvasView-Creator.html │ │ ├── mindmaps.DefaultCanvasView-TextMetrics.html │ │ ├── mindmaps.DefaultCanvasView.html │ │ ├── mindmaps.DeleteNodeCommand.html │ │ ├── mindmaps.Document.html │ │ ├── mindmaps.EditNodeCaptionCommand.html │ │ ├── mindmaps.Event.html │ │ ├── mindmaps.EventBus.html │ │ ├── mindmaps.FloatPanel.html │ │ ├── mindmaps.FloatPanelFactory.html │ │ ├── mindmaps.HelpCommand.html │ │ ├── mindmaps.HelpController.html │ │ ├── mindmaps.InspectorPresenter.html │ │ ├── mindmaps.InspectorView.html │ │ ├── mindmaps.LocalDocumentStorage.html │ │ ├── mindmaps.MainViewController.html │ │ ├── mindmaps.MindMap.html │ │ ├── mindmaps.MindMapModel.html │ │ ├── mindmaps.NavigatorPresenter.html │ │ ├── mindmaps.NavigatorView.html │ │ ├── mindmaps.NewDocumentCommand.html │ │ ├── mindmaps.NewDocumentPresenter.html │ │ ├── mindmaps.NewDocumentView.html │ │ ├── mindmaps.Node.html │ │ ├── mindmaps.NodeMap.html │ │ ├── mindmaps.Notification.html │ │ ├── mindmaps.OpenDocumentCommand.html │ │ ├── mindmaps.OpenDocumentPresenter.html │ │ ├── mindmaps.OpenDocumentView.html │ │ ├── mindmaps.PasteNodeCommand.html │ │ ├── mindmaps.Point.html │ │ ├── mindmaps.RedoCommand.html │ │ ├── mindmaps.SaveDocumentCommand.html │ │ ├── mindmaps.SaveDocumentPresenter.html │ │ ├── mindmaps.SaveDocumentView.html │ │ ├── mindmaps.ShortcutController.html │ │ ├── mindmaps.StatusBarPresenter.html │ │ ├── mindmaps.StatusBarView.html │ │ ├── mindmaps.StatusNotificationController.html │ │ ├── mindmaps.ToggleNodeFoldedCommand.html │ │ ├── mindmaps.ToolBarButton.html │ │ ├── mindmaps.ToolBarMenu.html │ │ ├── mindmaps.ToolBarPresenter.html │ │ ├── mindmaps.ToolBarView.html │ │ ├── mindmaps.UndoCommand.html │ │ ├── mindmaps.UndoController.html │ │ ├── mindmaps.Util.html │ │ ├── mindmaps.ZoomController.html │ │ ├── mindmaps.action.Action.html │ │ ├── mindmaps.action.ChangeNodeCaptionAction.html │ │ ├── mindmaps.action.ChangeNodeFontSizeAction.html │ │ ├── mindmaps.action.CloseNodeAction.html │ │ ├── mindmaps.action.CreateAutoPositionedNodeAction.html │ │ ├── mindmaps.action.CreateNodeAction.html │ │ ├── mindmaps.action.DecreaseNodeFontSizeAction.html │ │ ├── mindmaps.action.DeleteNodeAction.html │ │ ├── mindmaps.action.IncreaseNodeFontSizeAction.html │ │ ├── mindmaps.action.MoveNodeAction.html │ │ ├── mindmaps.action.OpenNodeAction.html │ │ ├── mindmaps.action.SetBranchColorAction.html │ │ ├── mindmaps.action.SetFontColorAction.html │ │ ├── mindmaps.action.SetFontDecorationAction.html │ │ ├── mindmaps.action.SetFontStyleAction.html │ │ ├── mindmaps.action.SetFontWeightAction.html │ │ ├── mindmaps.action.ToggleNodeFoldAction.html │ │ ├── mindmaps.action.html │ │ ├── mindmaps.html │ │ └── src │ │ ├── src_js_Action.js.html │ │ ├── src_js_ApplicationController.js.html │ │ ├── src_js_CanvasPresenter.js.html │ │ ├── src_js_CanvasView.js.html │ │ ├── src_js_ClipboardController.js.html │ │ ├── src_js_Command.js.html │ │ ├── src_js_CommandRegistry.js.html │ │ ├── src_js_Document.js.html │ │ ├── src_js_Event.js.html │ │ ├── src_js_FloatPanel.js.html │ │ ├── src_js_HelpController.js.html │ │ ├── src_js_Inspector.js.html │ │ ├── src_js_MainViewController.js.html │ │ ├── src_js_MindMap.js.html │ │ ├── src_js_MindMapModel.js.html │ │ ├── src_js_MindMaps.js.html │ │ ├── src_js_Navigator.js.html │ │ ├── src_js_NewDocument.js.html │ │ ├── src_js_Node.js.html │ │ ├── src_js_NodeMap.js.html │ │ ├── src_js_Notification.js.html │ │ ├── src_js_OpenDocument.js.html │ │ ├── src_js_Point.js.html │ │ ├── src_js_SaveDocument.js.html │ │ ├── src_js_ShortcutController.js.html │ │ ├── src_js_StatusBar.js.html │ │ ├── src_js_Storage.js.html │ │ ├── src_js_ToolBar.js.html │ │ ├── src_js_UndoController.js.html │ │ ├── src_js_UndoManager.js.html │ │ ├── src_js_Util.js.html │ │ └── src_js_ZoomController.js.html └── node-jsdoc-toolkit │ ├── README.txt │ ├── app │ ├── frame.js │ ├── frame │ │ ├── Chain.js │ │ ├── Dumper.js │ │ ├── Hash.js │ │ ├── Link.js │ │ ├── Namespace.js │ │ ├── Opt.js │ │ ├── Reflection.js │ │ ├── String.js │ │ └── Testrun.js │ ├── handlers │ │ ├── FOODOC.js │ │ ├── XMLDOC.js │ │ └── XMLDOC │ │ │ ├── DomReader.js │ │ │ ├── XMLDoc.js │ │ │ └── XMLParse.js │ ├── lib │ │ ├── JSDOC.js │ │ └── JSDOC │ │ │ ├── DocComment.js │ │ │ ├── DocTag.js │ │ │ ├── JsDoc.js │ │ │ ├── JsPlate.js │ │ │ ├── Lang.js │ │ │ ├── Parser.js │ │ │ ├── PluginManager.js │ │ │ ├── Symbol.js │ │ │ ├── SymbolSet.js │ │ │ ├── TextStream.js │ │ │ ├── Token.js │ │ │ ├── TokenReader.js │ │ │ ├── TokenStream.js │ │ │ ├── Util.js │ │ │ └── Walker.js │ ├── main.js │ ├── plugins │ │ ├── commentSrcJson.js │ │ ├── frameworkPrototype.js │ │ ├── functionCall.js │ │ ├── publishSrcHilite.js │ │ ├── symbolLink.js │ │ ├── tagParamConfig.js │ │ └── tagSynonyms.js │ ├── run.js │ ├── t │ │ ├── TestDoc.js │ │ └── runner.js │ ├── test.js │ └── test │ │ ├── addon.js │ │ ├── anon_inner.js │ │ ├── augments.js │ │ ├── augments2.js │ │ ├── borrows.js │ │ ├── borrows2.js │ │ ├── config.js │ │ ├── constructs.js │ │ ├── encoding.js │ │ ├── encoding_other.js │ │ ├── event.js │ │ ├── exports.js │ │ ├── functions_anon.js │ │ ├── functions_nested.js │ │ ├── global.js │ │ ├── globals.js │ │ ├── ignore.js │ │ ├── inner.js │ │ ├── jsdoc_test.js │ │ ├── lend.js │ │ ├── memberof.js │ │ ├── memberof2.js │ │ ├── memberof3.js │ │ ├── memberof_constructor.js │ │ ├── module.js │ │ ├── multi_methods.js │ │ ├── name.js │ │ ├── namespace_nested.js │ │ ├── nocode.js │ │ ├── oblit_anon.js │ │ ├── overview.js │ │ ├── param_inline.js │ │ ├── params_optional.js │ │ ├── prototype.js │ │ ├── prototype_nested.js │ │ ├── prototype_oblit.js │ │ ├── prototype_oblit_constructor.js │ │ ├── public.js │ │ ├── scripts │ │ ├── code.js │ │ └── notcode.txt │ │ ├── shared.js │ │ ├── shared2.js │ │ ├── shortcuts.js │ │ ├── static_this.js │ │ ├── synonyms.js │ │ ├── tosource.js │ │ └── variable_redefine.js │ ├── changes.txt │ ├── conf │ └── default.conf │ └── templates │ └── jsdoc │ ├── allclasses.tmpl │ ├── allfiles.tmpl │ ├── class.tmpl │ ├── index.tmpl │ ├── publish.js │ ├── static │ ├── default.css │ ├── header.html │ └── index.html │ └── symbol.tmpl ├── package-lock.json ├── package.json ├── psd ├── creator-nub.psd ├── favicon.psd └── plus-minus.psd ├── src ├── about.html ├── cache.appcache ├── css │ ├── Aristo │ │ ├── images │ │ │ ├── bg_fallback.png │ │ │ ├── icon_sprite.png │ │ │ ├── progress_bar.gif │ │ │ ├── slider_handles.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ └── ui-icons_454545_256x240.png │ │ └── jquery-ui-1.8.7.custom.css │ ├── about.css │ ├── app.css │ ├── common.css │ └── minicolors │ │ ├── images │ │ ├── circle.gif │ │ ├── gradient.png │ │ ├── line.gif │ │ ├── rainbow.png │ │ └── trigger.png │ │ └── jquery.miniColors.css ├── img │ ├── ajax-loader.gif │ ├── closedhand.png │ ├── creator-nub-sprite.png │ ├── favicon.png │ ├── grid.gif │ ├── openhand.png │ └── plus-minus.png ├── index.html └── js │ ├── Action.js │ ├── ApplicationController.js │ ├── AutoSaveController.js │ ├── CanvasDrawingTools.js │ ├── CanvasPresenter.js │ ├── CanvasView.js │ ├── ClipboardController.js │ ├── Command.js │ ├── CommandRegistry.js │ ├── Document.js │ ├── Event.js │ ├── ExportMap.js │ ├── FilePicker.js │ ├── FloatPanel.js │ ├── HelpController.js │ ├── Inspector.js │ ├── MainViewController.js │ ├── MindMap.js │ ├── MindMapModel.js │ ├── MindMaps.js │ ├── Navigator.js │ ├── NewDocument.js │ ├── Node.js │ ├── NodeMap.js │ ├── Notification.js │ ├── OpenDocument.js │ ├── Point.js │ ├── PrintController.js │ ├── SaveDocument.js │ ├── ShortcutController.js │ ├── StaticCanvas.js │ ├── StatusBar.js │ ├── Storage.js │ ├── ToolBar.js │ ├── UndoController.js │ ├── UndoManager.js │ ├── Util.js │ ├── ZoomController.js │ └── libs │ ├── dragscrollable.js │ ├── events.js │ ├── jquery-ui-1.8.11.custom.complete.min.js │ ├── jquery-ui-1.8.11.custom.min.js │ ├── jquery.hotkeys.js │ ├── jquery.minicolors.js │ ├── jquery.mousewheel.js │ └── jquery.tmpl.js └── test ├── jasmine ├── CommandSpec.js ├── DocumentSpec.js ├── IntegrationTestSpec.js ├── MindMapSpec.js ├── NodeMapSpec.js ├── NodeSpec.js ├── PointSpec.js ├── SpecHelper.js ├── SpecRunner.html ├── StorageSpec.js ├── UndoManagerSpec.js └── jasmine-1.1.0 │ ├── MIT.LICENSE │ ├── jasmine-html.js │ ├── jasmine.css │ ├── jasmine.js │ └── jasmine_favicon.png └── selenium ├── dependencies.txt └── src ├── helper └── SeleniumHelper.java └── tests ├── BaseMindMapsTestCase.java ├── BasicFunctions.java └── LoadTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | .settings/ 2 | .project 3 | .classpath 4 | dist/ 5 | node_modules/ 6 | .idea 7 | .vscode/ -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2012-06-24 4 | - Added integration with Dropbox and other cloud storage services (finally!) 5 | 6 | ## 2012-04-25 7 | - Added feature to set the branch color of all children to the parent's color 8 | - Branch and font color changes now happen on-the-fly when using the colorpicker 9 | 10 | ## 2012-02-13 11 | - Added auto save feature for LocalStorage 12 | 13 | ## 2012-01-21 14 | - Added Shortcuts for Mac OSX users 15 | 16 | ## 2011-08-09 17 | - Implemented PNG export 18 | - Added support for printing the mind map 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSA: This project is not actively maintained. I consider it feature complete for what it set out to do. I'll fix critical bugs should they pop up but I won't be adding new features. 2 | 3 | 4 | # mindmaps 5 | mindmaps is a HTML5 based mind mapping application. It lets you create neat looking mind maps in the browser. 6 | 7 | This project started in 2011 as an exploration into what's possible to do in browsers using modern APIs. Nowadays, most of this stuff is pretty common and the code base is a bit outdated. This was way before React, ES6, webpack. Heck, it doesn't even use Backbone. 8 | 9 | However, there is no reason to change any of that and it makes the code base quite easy to grok. There is no compilation step, no babel plugins, no frameworks. Just a JavaScript application and a very simple Model-View-Presenter pattern. 10 | 11 | ## HTML5 stuff which was cool in 2011 12 | - 100% offline capable via ApplicationCache 13 | - Stores mind maps in LocalStorage 14 | - FileReader API reads stored mind maps from the hard drive 15 | - Canvas API draws the mind map 16 | 17 | ## Try it out 18 | The latest stable build is hosted [here](https://www.mindmaps.app). 19 | 20 | ## Build 21 | * First run `npm install` to install required dependencies 22 | * Run `npm run start` to launch a local dev server. The app will be hosted at [http://localhost:3000](http://localhost:3000). 23 | * Run `npm run build` to compile the production bundle. The artifacts will be located in `/dist`. 24 | 25 | 26 | ## Host yourself 27 | All you need is a web server for static files. After building, copy all files from /dist into your web directory and launch the app with index.html. 28 | Make sure your web server serves .appcache files with the mime type `text/cache-manifest` for the application to 29 | be accessible offline. 30 | 31 | In Apache add the following line to your .htaccess: 32 | 33 | ``` 34 | AddType text/cache-manifest .appcache 35 | ``` 36 | 37 | In nginx add this to conf/mime.types: 38 | 39 | ``` 40 | text/cache-manifest appcache; 41 | ``` 42 | 43 | Alternatively, you can launch a local debug server with `npm start` which starts a server on localhost:8080. 44 | 45 | ## License 46 | mindmaps is licensed under AGPL V3, see LICENSE for more information. 47 | -------------------------------------------------------------------------------- /docs/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Generating project documentation..." 4 | script_dir=$(dirname $0) 5 | 6 | cd $script_dir/node-jsdoc-toolkit 7 | node app/run.js -c=conf/default.conf 8 | 9 | -------------------------------------------------------------------------------- /docs/generated/symbols/src/src_js_NewDocument.js.html: -------------------------------------------------------------------------------- 1 |
  1 /**
 9 |   2  * Unused for now.
10 |   3  * 
11 |   4  * @constructor
12 |   5  */
13 |   6 mindmaps.NewDocumentView = function() {
14 |   7 
15 |   8 };
16 |   9 
17 |  10 /**
18 |  11  * Creates a new NewDocumentPresenter. This presenter has no view associated
19 |  12  * with it for now. It simply creates a new document. It could in the future
20 |  13  * display a dialog where the user could chose options like document title and
21 |  14  * such.
22 |  15  * 
23 |  16  * @constructor
24 |  17  */
25 |  18 mindmaps.NewDocumentPresenter = function(eventBus, mindmapModel, view) {
26 |  19 
27 |  20 	this.go = function() {
28 |  21 		var doc = new mindmaps.Document();
29 |  22 		mindmapModel.setDocument(doc);
30 |  23 	};
31 |  24 };
-------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/README.txt: -------------------------------------------------------------------------------- 1 | ====================================================================== 2 | 3 | DESCRIPTION: 4 | 5 | This is the source code for JsDoc Toolkit, an automatic documentation 6 | generation tool for JavaScript. It is written in JavaScript and is run 7 | from a command line (or terminal) using the Node.JS JavaScript runtime 8 | engine. 9 | 10 | Using this tool you can automatically turn JavaDoc-like comments in 11 | your JavaScript source code into published output files, such as HTML 12 | or XML. 13 | 14 | For more information, to report a bug, or to browse the technical 15 | documentation for this tool please visit the official JsDoc Toolkit 16 | project homepage at http://code.google.com/p/jsdoc-toolkit/ 17 | 18 | For the most up-to-date documentation on JsDoc Toolkit see the 19 | official wiki at http://code.google.com/p/jsdoc-toolkit/w/list 20 | 21 | ====================================================================== 22 | 23 | REQUIREMENTS: 24 | 25 | Node.JS interpreter http://nodejs.org 26 | 27 | ====================================================================== 28 | 29 | USAGE: 30 | 31 | Before running the JsDoc Toolkit app you should change your current 32 | working directory to the jsdoc-toolkit folder. Then follow the 33 | examples below, or as shown on the project wiki. 34 | 35 | On Mac OS X or Linux the command would look like this: 36 | 37 | $ app/run.js -a -t=templates/jsdoc mycode.js 38 | 39 | The above assumes your current working directory contains the "app" 40 | and "templates" subdirectories from the standard JsDoc Toolkit 41 | distribution and that the relative path to the code you wish to 42 | document is "mycode.js". 43 | 44 | The output documentation files will be saved to a new directory named 45 | "out" (by default) in the current directory, or if you specify a 46 | -d=somewhere_else option, to the somewhere_else directory. 47 | 48 | For help (usage notes) enter this on the command line: 49 | 50 | $ app/run.js --help 51 | 52 | More information about the various command line options used by JsDoc 53 | Toolkit are available on the project wiki. 54 | 55 | ====================================================================== 56 | 57 | TESTING: 58 | 59 | To run the suite of unit tests included with JsDoc Toolkit enter this 60 | on the command line: 61 | 62 | $ app/run.js -T 63 | 64 | To see a dump of the internal data structure that JsDoc Toolkit has 65 | built from your source files use this command: 66 | 67 | $ app/run.js mycode.js -Z 68 | 69 | ====================================================================== 70 | 71 | LICENSE: 72 | 73 | JSDoc.pm 74 | 75 | This project is based on the JSDoc.pm tool, created by Michael 76 | Mathews and Gabriel Reid. More information on JsDoc.pm can 77 | be found on the JSDoc.pm homepage: http://jsdoc.sourceforge.net/ 78 | 79 | Complete documentation on JsDoc Toolkit can be found on the project 80 | wiki at http://code.google.com/p/jsdoc-toolkit/w/list 81 | 82 | JsDoc Toolkit 83 | 84 | All code specific to JsDoc Toolkit are free, open source and licensed 85 | for use under the X11/MIT License. 86 | 87 | JsDoc Toolkit is Copyright (c)2009 Michael Mathews 88 | Additional portions are Copyright (c)2010 Aaron Wirtz 89 | 90 | This program is free software; you can redistribute it and/or 91 | modify it under the terms below. 92 | 93 | Permission is hereby granted, free of charge, to any person obtaining 94 | a copy of this software and associated documentation files (the 95 | "Software"), to deal in the Software without restriction, including 96 | without limitation the rights to use, copy, modify, merge, publish, 97 | distribute, sublicense, and/or sell copies of the Software, and to 98 | permit persons to whom the Software is furnished to do so, subject to 99 | the following conditions: The above copyright notice and this 100 | permission notice must be included in all copies or substantial 101 | portions of the Software. 102 | 103 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 104 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 105 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 106 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 107 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 108 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 109 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 110 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame.js: -------------------------------------------------------------------------------- 1 | IO.include("frame/Opt.js"); 2 | IO.include("frame/Chain.js"); 3 | IO.include("frame/Link.js"); 4 | IO.include("frame/String.js"); 5 | IO.include("frame/Hash.js"); 6 | IO.include("frame/Namespace.js"); 7 | //IO.include("frame/Reflection.js"); 8 | 9 | /** A few helper functions to make life a little easier. */ 10 | 11 | function defined(o) { 12 | return (o !== undefined); 13 | } 14 | 15 | function copy(o) { // todo check for circular refs 16 | if (o == null || typeof(o) != 'object') return o; 17 | var c = new o.constructor(); 18 | for(var p in o) c[p] = copy(o[p]); 19 | return c; 20 | } 21 | 22 | function isUnique(arr) { 23 | var l = arr.length; 24 | for(var i = 0; i < l; i++ ) { 25 | if (arr.lastIndexOf(arr[i]) > i) return false; 26 | } 27 | return true; 28 | } 29 | 30 | /** Returns the given string with all regex meta characters backslashed. */ 31 | RegExp.escapeMeta = function(str) { 32 | return str.replace(/([$^\\\/()|?+*\[\]{}.-])/g, "\\$1"); 33 | } 34 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/Chain.js: -------------------------------------------------------------------------------- 1 | /**@constructor*/ 2 | function ChainNode(object, link) { 3 | this.value = object; 4 | this.link = link; // describes this node's relationship to the previous node 5 | } 6 | 7 | /**@constructor*/ 8 | function Chain(valueLinks) { 9 | this.nodes = []; 10 | this.cursor = -1; 11 | 12 | if (valueLinks && valueLinks.length > 0) { 13 | this.push(valueLinks[0], "//"); 14 | for (var i = 1, l = valueLinks.length; i < l; i+=2) { 15 | this.push(valueLinks[i+1], valueLinks[i]); 16 | } 17 | } 18 | } 19 | 20 | Chain.prototype.push = function(o, link) { 21 | if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link)); 22 | else this.nodes.push(new ChainNode(o)); 23 | } 24 | 25 | Chain.prototype.unshift = function(o, link) { 26 | if (this.nodes.length > 0 && link) this.nodes[0].link = link; 27 | this.nodes.unshift(new ChainNode(o)); 28 | this.cursor++; 29 | } 30 | 31 | Chain.prototype.get = function() { 32 | if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null; 33 | return this.nodes[this.cursor]; 34 | } 35 | 36 | Chain.prototype.first = function() { 37 | this.cursor = 0; 38 | return this.get(); 39 | } 40 | 41 | Chain.prototype.last = function() { 42 | this.cursor = this.nodes.length-1; 43 | return this.get(); 44 | } 45 | 46 | Chain.prototype.next = function() { 47 | this.cursor++; 48 | return this.get(); 49 | } 50 | 51 | Chain.prototype.prev = function() { 52 | this.cursor--; 53 | return this.get(); 54 | } 55 | 56 | Chain.prototype.toString = function() { 57 | var string = ""; 58 | for (var i = 0, l = this.nodes.length; i < l; i++) { 59 | if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> "; 60 | string += this.nodes[i].value.toString(); 61 | } 62 | return string; 63 | } 64 | 65 | Chain.prototype.joinLeft = function() { 66 | var result = ""; 67 | for (var i = 0, l = this.cursor; i < l; i++) { 68 | if (result && this.nodes[i].link) result += this.nodes[i].link; 69 | result += this.nodes[i].value.toString(); 70 | } 71 | return result; 72 | } 73 | 74 | 75 | /* USAGE: 76 | 77 | var path = "one/two/three.four/five-six"; 78 | var pathChain = new Chain(path.split(/([\/.-])/)); 79 | print(pathChain); 80 | 81 | var lineage = new Chain(); 82 | lineage.push("Port"); 83 | lineage.push("Les", "son"); 84 | lineage.push("Dawn", "daughter"); 85 | lineage.unshift("Purdie", "son"); 86 | 87 | print(lineage); 88 | 89 | // walk left 90 | for (var node = lineage.last(); node !== null; node = lineage.prev()) { 91 | print("< "+node.value); 92 | } 93 | 94 | // walk right 95 | var node = lineage.first() 96 | while (node !== null) { 97 | print(node.value); 98 | node = lineage.next(); 99 | if (node && node.link) print("had a "+node.link+" named"); 100 | } 101 | 102 | */ -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/Dumper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 |
  4 | This is a lightly modified version of Kevin Jones' JavaScript
  5 | library Data.Dump. To download the original visit:
  6 |     http://openjsan.org/doc/k/ke/kevinj/Data/Dump/
  7 | 
  8 | AUTHORS
  9 | 
 10 | The Data.Dump JavaScript module is written by Kevin Jones 
 11 | (kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
 12 | based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
 13 | 
 14 | COPYRIGHT
 15 | 
 16 | Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
 17 | Copyright 1996-1998 Gurusamy Sarathy.
 18 | 
 19 | This program is free software; you can redistribute it and/or modify
 20 | it under the terms of the Perl Artistic License
 21 | 
 22 | See http://www.perl.com/perl/misc/Artistic.html
 23 | 
24 | * @static 25 | */ 26 | Dumper = { 27 | /** @param [...] The objects to dump. */ 28 | dump: function () { 29 | if (arguments.length > 1) 30 | return this._dump(arguments); 31 | else if (arguments.length == 1) 32 | return this._dump(arguments[0]); 33 | else 34 | return "()"; 35 | }, 36 | 37 | _dump: function (obj) { 38 | if (typeof obj == 'undefined') return 'undefined'; 39 | var out; 40 | if (obj.serialize) { return obj.serialize(); } 41 | var type = this._typeof(obj); 42 | if (obj.circularReference) obj.circularReference++; 43 | switch (type) { 44 | case 'circular': 45 | out = "{ //circularReference\n}"; 46 | break; 47 | case 'object': 48 | var pairs = new Array; 49 | 50 | for (var prop in obj) { 51 | if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties 52 | pairs.push(prop + ': ' + this._dump(obj[prop])); 53 | } 54 | } 55 | 56 | out = '{' + this._format_list(pairs) + '}'; 57 | break; 58 | 59 | case 'string': 60 | for (var prop in Dumper.ESC) { 61 | if (Dumper.ESC.hasOwnProperty(prop)) { 62 | obj = obj.replace(prop, Dumper.ESC[prop]); 63 | } 64 | } 65 | 66 | // Escape UTF-8 Strings 67 | if (obj.match(/^[\x00-\x7f]*$/)) { 68 | out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"'; 69 | } 70 | else { 71 | out = "unescape('"+escape(obj)+"')"; 72 | } 73 | break; 74 | 75 | case 'array': 76 | var elems = new Array; 77 | 78 | for (var i=0; i 60 ? '\n' : ' '; 109 | return nl + list.join(',' + nl) + nl; 110 | }, 111 | 112 | _typeof: function (obj) { 113 | if (obj && obj.circularReference && obj.circularReference > 1) return 'circular'; 114 | if (Array.prototype.isPrototypeOf(obj)) return 'array'; 115 | if (Date.prototype.isPrototypeOf(obj)) return 'date'; 116 | if (typeof obj.nodeType != 'undefined') return 'element'; 117 | return typeof(obj); 118 | }, 119 | 120 | _dump_dom: function (obj) { 121 | return '"' + Dumper.nodeTypes[obj.nodeType] + '"'; 122 | } 123 | }; 124 | 125 | Dumper.ESC = { 126 | "\t": "\\t", 127 | "\n": "\\n", 128 | "\f": "\\f" 129 | }; 130 | 131 | Dumper.nodeTypes = { 132 | 1: "ELEMENT_NODE", 133 | 2: "ATTRIBUTE_NODE", 134 | 3: "TEXT_NODE", 135 | 4: "CDATA_SECTION_NODE", 136 | 5: "ENTITY_REFERENCE_NODE", 137 | 6: "ENTITY_NODE", 138 | 7: "PROCESSING_INSTRUCTION_NODE", 139 | 8: "COMMENT_NODE", 140 | 9: "DOCUMENT_NODE", 141 | 10: "DOCUMENT_TYPE_NODE", 142 | 11: "DOCUMENT_FRAGMENT_NODE", 143 | 12: "NOTATION_NODE" 144 | }; -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/Hash.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | @example 4 | var _index = new Hash(); 5 | _index.set("a", "apple"); 6 | _index.set("b", "blue"); 7 | _index.set("c", "coffee"); 8 | 9 | for (var p = _index.first(); p; p = _index.next()) { 10 | print(p.key+" is for "+p.value); 11 | } 12 | 13 | */ 14 | var Hash = function() { 15 | this._map = {}; 16 | this._keys = []; 17 | this._vals = []; 18 | this.reset(); 19 | } 20 | 21 | Hash.prototype.set = function(k, v) { 22 | if (k != "") { 23 | this._keys.push(k); 24 | this._map["="+k] = this._vals.length; 25 | this._vals.push(v); 26 | } 27 | } 28 | 29 | Hash.prototype.replace = function(k, k2, v) { 30 | if (k == k2) return; 31 | 32 | var offset = this._map["="+k]; 33 | this._keys[offset] = k2; 34 | if (typeof v != "undefined") this._vals[offset] = v; 35 | this._map["="+k2] = offset; 36 | delete(this._map["="+k]); 37 | } 38 | 39 | Hash.prototype.drop = function(k) { 40 | if (k != "") { 41 | var offset = this._map["="+k]; 42 | this._keys.splice(offset, 1); 43 | this._vals.splice(offset, 1); 44 | delete(this._map["="+k]); 45 | for (var p in this._map) { 46 | if (this._map[p] >= offset) this._map[p]--; 47 | } 48 | if (this._cursor >= offset && this._cursor > 0) this._cursor--; 49 | } 50 | } 51 | 52 | Hash.prototype.get = function(k) { 53 | if (k != "") { 54 | return this._vals[this._map["="+k]]; 55 | } 56 | } 57 | 58 | Hash.prototype.keys = function() { 59 | return this._keys; 60 | } 61 | 62 | Hash.prototype.hasKey = function(k) { 63 | if (k != "") { 64 | return (typeof this._map["="+k] != "undefined"); 65 | } 66 | } 67 | 68 | Hash.prototype.values = function() { 69 | return this._vals; 70 | } 71 | 72 | Hash.prototype.reset = function() { 73 | this._cursor = 0; 74 | } 75 | 76 | Hash.prototype.first = function() { 77 | this.reset(); 78 | return this.next(); 79 | } 80 | 81 | Hash.prototype.next = function() { 82 | if (this._cursor++ < this._keys.length) 83 | return {key: this._keys[this._cursor-1], value: this._vals[this._cursor-1]}; 84 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/Namespace.js: -------------------------------------------------------------------------------- 1 | _global_ = this; 2 | 3 | function Namespace(name, f) { 4 | var n = name.split("."); 5 | for (var o = _global_, i = 0, l = n.length; i < l; i++) { 6 | o = o[n[i]] = o[n[i]] || {}; 7 | } 8 | 9 | if (f) f(); 10 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/Opt.js: -------------------------------------------------------------------------------- 1 | /** @namespace */ 2 | Opt = { 3 | /** 4 | * Get commandline option values. 5 | * @param {Array} args Commandline arguments. Like ["-a=xml", "-b", "--class=new", "--debug"] 6 | * @param {object} optNames Map short names to long names. Like {a:"accept", b:"backtrace", c:"class", d:"debug"}. 7 | * @return {object} Short names and values. Like {a:"xml", b:true, c:"new", d:true} 8 | */ 9 | get: function(args, optNames) { 10 | var opt = {"_": []}; // the unnamed option allows multiple values 11 | for (var i = 0; i < args.length; i++) { 12 | var arg = new String(args[i]); 13 | var name; 14 | var value; 15 | if (arg.charAt(0) == "-") { 16 | if (arg.charAt(1) == "-") { // it's a longname like --foo 17 | arg = arg.substring(2); 18 | var m = arg.split("="); 19 | name = m.shift(); 20 | value = m.shift(); 21 | if (typeof value == "undefined") value = true; 22 | 23 | for (var n in optNames) { // convert it to a shortname 24 | if (name == optNames[n]) { 25 | name = n; 26 | } 27 | } 28 | } 29 | else { // it's a shortname like -f 30 | arg = arg.substring(1); 31 | var m = arg.split("="); 32 | name = m.shift(); 33 | value = m.shift(); 34 | if (typeof value == "undefined") value = true; 35 | 36 | for (var n in optNames) { // find the matching key 37 | if (name == n || name+'[]' == n) { 38 | name = n; 39 | break; 40 | } 41 | } 42 | } 43 | if (name.match(/(.+)\[\]$/)) { // it's an array type like n[] 44 | name = RegExp.$1; 45 | if (!opt[name]) opt[name] = []; 46 | } 47 | 48 | if (opt[name] && opt[name].push) { 49 | opt[name].push(value); 50 | } 51 | else { 52 | opt[name] = value; 53 | } 54 | } 55 | else { // not associated with any optname 56 | opt._.push(args[i]); 57 | } 58 | } 59 | return opt; 60 | } 61 | } 62 | 63 | /*t: 64 | plan(11, "Testing Opt."); 65 | 66 | is( 67 | typeof Opt, 68 | "object", 69 | "Opt is an object." 70 | ); 71 | 72 | is( 73 | typeof Opt.get, 74 | "function", 75 | "Opt.get is a function." 76 | ); 77 | 78 | var optNames = {a:"accept", b:"backtrace", c:"class", d:"debug", "e[]":"exceptions"}; 79 | var t_options = Opt.get(["-a=xml", "-b", "--class=new", "--debug", "-e=one", "-e=two", "foo", "bar"], optNames); 80 | 81 | is( 82 | t_options.a, 83 | "xml", 84 | "an option defined with a short name can be accessed by its short name." 85 | ); 86 | 87 | is( 88 | t_options.b, 89 | true, 90 | "an option defined with a short name and no value are true." 91 | ); 92 | 93 | is( 94 | t_options.c, 95 | "new", 96 | "an option defined with a long name can be accessed by its short name." 97 | ); 98 | 99 | is( 100 | t_options.d, 101 | true, 102 | "an option defined with a long name and no value are true." 103 | ); 104 | 105 | is( 106 | typeof t_options.e, 107 | "object", 108 | "an option that can accept multiple values is defined." 109 | ); 110 | 111 | is( 112 | t_options.e.length, 113 | 2, 114 | "an option that can accept multiple values can have more than one value." 115 | ); 116 | 117 | is( 118 | t_options.e[1], 119 | "two", 120 | "an option that can accept multiple values can be accessed as an array." 121 | ); 122 | 123 | is( 124 | typeof t_options._, 125 | "object", 126 | "the property '_' is defined for unnamed options." 127 | ); 128 | 129 | is( 130 | t_options._[0], 131 | "foo", 132 | "the property '_' can be accessed as an array." 133 | ); 134 | */ -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/Reflection.js: -------------------------------------------------------------------------------- 1 | /**@constructor*/ 2 | function Reflection(obj) { 3 | this.obj = obj; 4 | } 5 | 6 | Reflection.prototype.getConstructorName = function() { 7 | if (this.obj.constructor.name) return this.obj.constructor.name; 8 | var src = this.obj.constructor.toSource(); 9 | var name = src.substring(name.indexOf("function")+8, src.indexOf('(')).replace(/ /g,''); 10 | return name; 11 | } 12 | 13 | Reflection.prototype.getMethod = function(name) { 14 | for (var p in this.obj) { 15 | if (p == name && typeof(this.obj[p]) == "function") return this.obj[p]; 16 | } 17 | return null; 18 | } 19 | 20 | Reflection.prototype.getParameterNames = function() { 21 | var src = this.obj.toSource(); 22 | src = src.substring( 23 | src.indexOf("(", 8)+1, src.indexOf(")") 24 | ); 25 | return src.split(/, ?/); 26 | } 27 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/frame/String.js: -------------------------------------------------------------------------------- 1 | /** 2 | @name String 3 | @class Additions to the core string object. 4 | */ 5 | 6 | /** @author Steven Levithan, released as public domain. */ 7 | String.prototype.trim = function() { 8 | var str = this.replace(/^\s+/, ''); 9 | for (var i = str.length - 1; i >= 0; i--) { 10 | if (/\S/.test(str.charAt(i))) { 11 | str = str.substring(0, i + 1); 12 | break; 13 | } 14 | } 15 | return str; 16 | } 17 | /*t: 18 | plan(6, "Testing String.prototype.trim."); 19 | 20 | var s = " a bc ".trim(); 21 | is(s, "a bc", "multiple spaces front and back are trimmed."); 22 | 23 | s = "a bc\n\n".trim(); 24 | is(s, "a bc", "newlines only in back are trimmed."); 25 | 26 | s = "\ta bc".trim(); 27 | is(s, "a bc", "tabs only in front are trimmed."); 28 | 29 | s = "\n \t".trim(); 30 | is(s, "", "an all-space string is trimmed to empty."); 31 | 32 | s = "a b\nc".trim(); 33 | is(s, "a b\nc", "a string with no spaces in front or back is trimmed to itself."); 34 | 35 | s = "".trim(); 36 | is(s, "", "an empty string is trimmed to empty."); 37 | 38 | */ 39 | 40 | String.prototype.balance = function(open, close) { 41 | var i = 0; 42 | while (this.charAt(i) != open) { 43 | if (i == this.length) return [-1, -1]; 44 | i++; 45 | } 46 | 47 | var j = i+1; 48 | var balance = 1; 49 | while (j < this.length) { 50 | if (this.charAt(j) == open) balance++; 51 | if (this.charAt(j) == close) balance--; 52 | if (balance == 0) break; 53 | j++; 54 | if (j == this.length) return [-1, -1]; 55 | } 56 | 57 | return [i, j]; 58 | } 59 | /*t: 60 | plan(16, "Testing String.prototype.balance."); 61 | 62 | var s = "{abc}".balance("{","}"); 63 | is(s[0], 0, "opener in first is found."); 64 | is(s[1], 4, "closer in last is found."); 65 | 66 | s = "ab{c}de".balance("{","}"); 67 | is(s[0], 2, "opener in middle is found."); 68 | is(s[1], 4, "closer in middle is found."); 69 | 70 | s = "a{b{c}de}f".balance("{","}"); 71 | is(s[0], 1, "nested opener is found."); 72 | is(s[1], 8, "nested closer is found."); 73 | 74 | s = "{}".balance("{","}"); 75 | is(s[0], 0, "opener with no content is found."); 76 | is(s[1], 1, "closer with no content is found."); 77 | 78 | s = "".balance("{","}"); 79 | is(s[0], -1, "empty string opener is -1."); 80 | is(s[1], -1, "empty string closer is -1."); 81 | 82 | s = "{abc".balance("{","}"); 83 | is(s[0], -1, "opener with no closer returns -1."); 84 | is(s[1], -1, "no closer returns -1."); 85 | 86 | s = "abc".balance("{","}"); 87 | is(s[0], -1, "no opener or closer returns -1 for opener."); 88 | is(s[1], -1, "no opener or closer returns -1 for closer."); 89 | 90 | s = "aX11/MIT License 8 | * (See the accompanying README file for full details.) 9 | */ 10 | 11 | /** 12 | Yet another unit testing tool for JavaScript. 13 | @author Michael Mathews micmath@gmail.com 14 | @param {object} testCases Properties are testcase names, values are functions to execute as tests. 15 | */ 16 | function testrun(testCases) { 17 | var ran = 0; 18 | for (t in testCases) { 19 | var result = testCases[t](); 20 | ran++; 21 | } 22 | 23 | return testrun.reportOut+"-------------------------------\n"+((testrun.fails>0)? ":( Failed "+testrun.fails+"/" : ":) Passed all ")+testrun.count+" test"+((testrun.count == 1)? "":"s")+".\n"; 24 | } 25 | 26 | 27 | testrun.count = 0; 28 | testrun.current = null; 29 | testrun.passes = 0; 30 | testrun.fails = 0; 31 | testrun.reportOut = ""; 32 | 33 | /** @private */ 34 | testrun.report = function(text) { 35 | testrun.reportOut += text+"\n"; 36 | } 37 | 38 | /** 39 | Check if test evaluates to true. 40 | @param {string} test To be evaluated. 41 | @param {string} message Optional. To be displayed in the report. 42 | @return {boolean} True if the string test evaluates to true. 43 | */ 44 | ok = function(test, message) { 45 | testrun.count++; 46 | 47 | var result; 48 | try { 49 | result = eval(test); 50 | 51 | if (result) { 52 | testrun.passes++; 53 | testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); 54 | } 55 | else { 56 | testrun.fails++; 57 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 58 | } 59 | } 60 | catch(e) { 61 | testrun.fails++ 62 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 63 | 64 | } 65 | } 66 | 67 | /** 68 | Check if test is same as expected. 69 | @param {string} test To be evaluated. 70 | @param {string} expected 71 | @param {string} message Optional. To be displayed in the report. 72 | @return {boolean} True if (test == expected). Note that the comparison is not a strict equality check. 73 | */ 74 | is = function(test, expected, message) { 75 | testrun.count++; 76 | 77 | var result; 78 | try { 79 | result = eval(test); 80 | 81 | if (result == expected) { 82 | testrun.passes++ 83 | testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); 84 | } 85 | else { 86 | testrun.fails++ 87 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 88 | testrun.report("expected: "+expected); 89 | testrun.report(" got: "+result); 90 | } 91 | } 92 | catch(e) { 93 | testrun.fails++ 94 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 95 | testrun.report("expected: "+expected); 96 | testrun.report(" got: "+result);} 97 | } 98 | 99 | /** 100 | Check if test matches pattern. 101 | @param {string} test To be evaluated. 102 | @param {string} pattern Used to create a RegExp. 103 | @param {string} message Optional. To be displayed in the report. 104 | @return {boolean} True if test matches pattern. 105 | */ 106 | like = function(test, pattern, message) { 107 | testrun.count++; 108 | 109 | var result; 110 | try { 111 | result = eval(test); 112 | var rgx = new RegExp(pattern); 113 | 114 | if (rgx.test(result)) { 115 | testrun.passes++ 116 | testrun.report(" OK "+testrun.count+" - "+((message != null)? message : "")); 117 | } 118 | else { 119 | testrun.fails++ 120 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 121 | testrun.report(" this: "+result); 122 | testrun.report("is not like: "+pattern); 123 | } 124 | } 125 | catch(e) { 126 | testrun.fails++ 127 | testrun.report("NOT OK "+testrun.count+" - "+((message != null)? message : "")); 128 | } 129 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/handlers/FOODOC.js: -------------------------------------------------------------------------------- 1 | /** 2 | This is the main container for the FOODOC handler. 3 | @namespace 4 | */ 5 | FOODOC = { 6 | }; 7 | 8 | /** The current version string of this application. */ 9 | FOODOC.VERSION = "1.0"; 10 | 11 | FOODOC.handle = function(srcFile, src) { 12 | LOG.inform("Handling file '" + srcFile + "'"); 13 | 14 | return [ 15 | new JSDOC.Symbol( 16 | "foo", 17 | [], 18 | "VIRTUAL", 19 | new JSDOC.DocComment("/** This is a foo. */") 20 | ) 21 | ]; 22 | }; 23 | 24 | FOODOC.publish = function(symbolgroup) { 25 | LOG.inform("Publishing symbolgroup."); 26 | }; 27 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/handlers/XMLDOC.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This is the main container for the XMLDOC handler. 3 | * @namespace 4 | * @author Brett Fattori (bfattori@fry.com) 5 | * @version $Revision: 498 $ 6 | */ 7 | XMLDOC = { 8 | 9 | }; 10 | 11 | /** The current version string of this application. */ 12 | XMLDOC.VERSION = "1.0"; 13 | 14 | /** Include the library necessary to handle XML files */ 15 | IO.includeDir("handlers/XMLDOC/"); 16 | 17 | /** 18 | * @type Symbol[] 19 | */ 20 | XMLDOC.handle = function(srcFile, src) { 21 | 22 | }; 23 | 24 | XMLDOC.publish = function(symbolgroup) { 25 | 26 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js: -------------------------------------------------------------------------------- 1 | LOG.inform("XMLDOC.DomReader loaded"); 2 | 3 | XMLDOC.DomReader = function(root) { 4 | 5 | this.dom = root; 6 | 7 | /** 8 | * The current node the reader is on 9 | */ 10 | this.node = root; 11 | 12 | /** 13 | * Get the current node the reader is on 14 | * @type XMLDOC.Parser.node 15 | */ 16 | XMLDOC.DomReader.prototype.getNode = function() { 17 | return this.node; 18 | }; 19 | 20 | /** 21 | * Set the node the reader should be positioned on. 22 | * @param node {XMLDOC.Parser.node} 23 | */ 24 | XMLDOC.DomReader.prototype.setNode = function(node) { 25 | this.node = node; 26 | }; 27 | 28 | /** 29 | * A helper method to make sure the current node will 30 | * never return null, unless null is passed as the root. 31 | * @param step {String} An expression to evaluate - should return a node or null 32 | */ 33 | XMLDOC.DomReader.prototype.navigate = function(step) { 34 | var n; 35 | if ((n = step) != null) 36 | { 37 | this.node = n; 38 | return this.node; 39 | } 40 | return null; 41 | }; 42 | 43 | /** 44 | * Get the root node of the current node's document. 45 | */ 46 | XMLDOC.DomReader.prototype.root = function() { 47 | this.navigate(this.dom); 48 | }; 49 | 50 | /** 51 | * Get the parent of the current node. 52 | */ 53 | XMLDOC.DomReader.prototype.parent = function() { 54 | return this.navigate(this.node.parentNode()); 55 | }; 56 | 57 | /** 58 | * Get the first child of the current node. 59 | */ 60 | XMLDOC.DomReader.prototype.firstChild = function() { 61 | return this.navigate(this.node.firstChild()); 62 | }; 63 | 64 | /** 65 | * Get the last child of the current node. 66 | */ 67 | XMLDOC.DomReader.prototype.lastChild = function() { 68 | return this.navigate(this.node.lastChild()); 69 | }; 70 | 71 | /** 72 | * Get the next sibling of the current node. 73 | */ 74 | XMLDOC.DomReader.prototype.nextSibling = function() { 75 | return this.navigate(this.node.nextSibling()); 76 | }; 77 | 78 | /** 79 | * Get the previous sibling of the current node. 80 | */ 81 | XMLDOC.DomReader.prototype.prevSibling = function() { 82 | return this.navigate(this.node.prevSibling()); 83 | }; 84 | 85 | //=============================================================================================== 86 | // Support methods 87 | 88 | /** 89 | * Walk the tree starting with the current node, calling the plug-in for 90 | * each node visited. Each time the plug-in is called, the DomReader 91 | * is passed as the only parameter. Use the {@link XMLDOC.DomReader#getNode} method 92 | * to access the current node. This method uses a depth first traversal pattern. 93 | * 94 | * @param srcFile {String} The source file being evaluated 95 | */ 96 | XMLDOC.DomReader.prototype.getSymbols = function(srcFile) 97 | { 98 | XMLDOC.DomReader.symbols = []; 99 | XMLDOC.DomReader.currentFile = srcFile; 100 | JSDOC.Symbol.srcFile = (srcFile || ""); 101 | 102 | if (defined(JSDOC.PluginManager)) { 103 | JSDOC.PluginManager.run("onDomGetSymbols", this); 104 | } 105 | 106 | return XMLDOC.DomReader.symbols; 107 | }; 108 | 109 | /** 110 | * Find the node with the given name using a depth first traversal. 111 | * Does not modify the DomReader's current node. 112 | * 113 | * @param name {String} The name of the node to find 114 | * @return the node that was found, or null if not found 115 | */ 116 | XMLDOC.DomReader.prototype.findNode = function(name) 117 | { 118 | var findNode = null; 119 | 120 | // Start at the current node and move into the subtree, 121 | // looking for the node with the given name 122 | function deeper(node, find) 123 | { 124 | var look = null; 125 | 126 | if (node) { 127 | if (node.name == find) 128 | { 129 | return node; 130 | } 131 | 132 | if (node.firstChild()) 133 | { 134 | look = deeper(node.firstChild(), find); 135 | } 136 | 137 | if (!look && node.nextSibling()) 138 | { 139 | look = deeper(node.nextSibling(), find); 140 | } 141 | } 142 | 143 | return look; 144 | } 145 | 146 | return deeper(this.getNode().firstChild(), name); 147 | }; 148 | 149 | /** 150 | * Find the next node with the given name using a depth first traversal. 151 | * 152 | * @param name {String} The name of the node to find 153 | */ 154 | XMLDOC.DomReader.prototype.findPreviousNode = function(name) 155 | { 156 | }; 157 | 158 | }; 159 | 160 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js: -------------------------------------------------------------------------------- 1 | LOG.inform("XMLDOC.symbolize loaded"); 2 | 3 | /** 4 | * Convert the source file to a set of symbols 5 | */ 6 | XMLDOC.symbolize = function(srcFile, src) { 7 | 8 | LOG.inform("Symbolizing file '" + srcFile + "'"); 9 | 10 | // XML files already have a defined structure, so we don't need to 11 | // do anything but parse them. The DOM reader can create a symbol 12 | // table from the parsed XML. 13 | var dr = new XMLDOC.DomReader(XMLDOC.Parser.parse(src)); 14 | return dr.getSymbols(srcFile); 15 | 16 | }; 17 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC.js: -------------------------------------------------------------------------------- 1 | /** 2 | @overview 3 | @date $Date: 2010-06-13 22:02:44 +0100 (Sun, 13 Jun 2010) $ 4 | @version $Revision: 837 $ 5 | @location $HeadURL: https://jsdoc-toolkit.googlecode.com/svn/tags/jsdoc_toolkit-2.4.0/jsdoc-toolkit/app/lib/JSDOC.js $ 6 | @name JSDOC.js 7 | */ 8 | 9 | /** 10 | This is the main container for the JSDOC application. 11 | @namespace 12 | */ 13 | JSDOC = { 14 | }; 15 | 16 | /** 17 | @requires Opt 18 | */ 19 | if (typeof arguments == "undefined") arguments = []; 20 | JSDOC.opt = Opt.get( 21 | arguments, 22 | { 23 | a: "allfunctions", 24 | c: "conf", 25 | d: "directory", 26 | "D[]": "define", 27 | e: "encoding", 28 | "E[]": "exclude", 29 | h: "help", 30 | m: "multiple", 31 | n: "nocode", 32 | o: "out", 33 | p: "private", 34 | q: "quiet", 35 | r: "recurse", 36 | S: "securemodules", 37 | s: "suppress", 38 | t: "template", 39 | T: "testmode", 40 | u: "unique", 41 | v: "verbose", 42 | x: "ext" 43 | } 44 | ); 45 | 46 | /** The current version string of this application. */ 47 | JSDOC.VERSION = "2.4.0"; 48 | 49 | /** Print out usage information and quit. */ 50 | JSDOC.usage = function() { 51 | print("USAGE: java -jar jsrun.jar app/run.js [OPTIONS] ..."); 52 | print(""); 53 | print("OPTIONS:"); 54 | print(" -a or --allfunctions\n Include all functions, even undocumented ones.\n"); 55 | print(" -c or --conf\n Load a configuration file.\n"); 56 | print(" -d= or --directory=\n Output to this directory (defaults to \"out\").\n"); 57 | print(" -D=\"myVar:My value\" or --define=\"myVar:My value\"\n Multiple. Define a variable, available in JsDoc as JSDOC.opt.D.myVar.\n"); 58 | print(" -e= or --encoding=\n Use this encoding to read and write files.\n"); 59 | print(" -E=\"REGEX\" or --exclude=\"REGEX\"\n Multiple. Exclude files based on the supplied regex.\n"); 60 | print(" -h or --help\n Show this message and exit.\n"); 61 | print(" -m or --multiples\n Don't warn about symbols being documented more than once.\n"); 62 | print(" -n or --nocode\n Ignore all code, only document comments with @name tags.\n"); 63 | print(" -o= or --out=\n Print log messages to a file (defaults to stdout).\n"); 64 | print(" -p or --private\n Include symbols tagged as private, underscored and inner symbols.\n"); 65 | print(" -q or --quiet\n Do not output any messages, not even warnings.\n"); 66 | print(" -r= or --recurse=\n Descend into src directories.\n"); 67 | print(" -s or --suppress\n Suppress source code output.\n"); 68 | print(" -S or --securemodules\n Use Secure Modules mode to parse source code.\n"); 69 | print(" -t= or --template=\n Required. Use this template to format the output.\n"); 70 | print(" -T or --test\n Run all unit tests and exit.\n"); 71 | print(" -u or --unique\n Force file names to be unique, but not based on symbol names.\n"); 72 | print(" -v or --verbose\n Provide verbose feedback about what is happening.\n"); 73 | print(" -x=[,EXT]... or --ext=[,EXT]...\n Scan source files with the given extension/s (defaults to js).\n"); 74 | 75 | quit(); 76 | } 77 | 78 | /*t: 79 | plan(4, "Testing JSDOC namespace."); 80 | 81 | is( 82 | typeof JSDOC, 83 | "object", 84 | "JSDOC.usage is a function." 85 | ); 86 | 87 | is( 88 | typeof JSDOC.VERSION, 89 | "string", 90 | "JSDOC.VERSION is a string." 91 | ); 92 | 93 | is( 94 | typeof JSDOC.usage, 95 | "function", 96 | "JSDOC.usage is a function." 97 | ); 98 | 99 | is( 100 | typeof JSDOC.opt, 101 | "object", 102 | "JSDOC.opt is a object." 103 | ); 104 | */ 105 | 106 | if (this.IO) IO.includeDir("lib/JSDOC/"); 107 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/JsDoc.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | @param [opt] Used to override the commandline options. Useful for testing. 4 | @version $Id: JsDoc.js 831 2010-03-09 14:24:56Z micmath $ 5 | */ 6 | JSDOC.JsDoc = function(/**object*/ opt) { 7 | if (opt) { 8 | JSDOC.opt = opt; 9 | } 10 | 11 | if (JSDOC.opt.h) { 12 | JSDOC.usage(); 13 | quit(); 14 | } 15 | 16 | // defend against options that are not sane 17 | if (JSDOC.opt._.length == 0) { 18 | LOG.warn("No source files to work on. Nothing to do."); 19 | quit(); 20 | } 21 | if (JSDOC.opt.t === true || JSDOC.opt.d === true) { 22 | JSDOC.usage(); 23 | } 24 | 25 | if (typeof JSDOC.opt.d == "string") { 26 | if (!JSDOC.opt.d.charAt(JSDOC.opt.d.length-1).match(/[\\\/]/)) { 27 | JSDOC.opt.d = JSDOC.opt.d+"/"; 28 | } 29 | LOG.inform("Output directory set to '"+JSDOC.opt.d+"'."); 30 | IO.mkPath(JSDOC.opt.d); 31 | } 32 | if (JSDOC.opt.e) IO.setEncoding(JSDOC.opt.e); 33 | 34 | // the -r option: scan source directories recursively 35 | if (typeof JSDOC.opt.r == "boolean") JSDOC.opt.r = 10; 36 | else if (!isNaN(parseInt(JSDOC.opt.r))) JSDOC.opt.r = parseInt(JSDOC.opt.r); 37 | else JSDOC.opt.r = 1; 38 | 39 | // the -D option: define user variables 40 | var D = {}; 41 | if (JSDOC.opt.D) { 42 | for (var i = 0; i < JSDOC.opt.D.length; i++) { 43 | var param = JSDOC.opt.D[i]; 44 | // remove first and last character if both == " 45 | if ( 46 | param.length > 1 47 | && param.charAt(0) == '"' 48 | && param.charAt(param.length-1) == '"' 49 | ) { 50 | param = param.substr(1, param.length-2); 51 | } 52 | var defineParts = param.split(":"); 53 | if (defineParts && defineParts.length > 1) { 54 | for ( var dpIdx = 2; dpIdx < defineParts.length; dpIdx++ ) { 55 | defineParts[1] += ':' + defineParts[dpIdx]; 56 | } 57 | D[defineParts[0]] = defineParts[1]; 58 | } 59 | } 60 | } 61 | JSDOC.opt.D = D; 62 | // combine any conf file D options with the commandline D options 63 | if (defined(JSDOC.conf)) for (var c in JSDOC.conf.D) { 64 | if (!defined(JSDOC.opt.D[c])) { 65 | JSDOC.opt.D[c] = JSDOC.conf.D[c]; 66 | } 67 | } 68 | 69 | // Give plugins a chance to initialize 70 | if (defined(JSDOC.PluginManager)) { 71 | JSDOC.PluginManager.run("onInit", JSDOC.opt); 72 | } 73 | 74 | JSDOC.opt.srcFiles = JSDOC.JsDoc._getSrcFiles(); 75 | JSDOC.JsDoc._parseSrcFiles(); 76 | JSDOC.JsDoc.symbolSet = JSDOC.Parser.symbols; 77 | } 78 | 79 | /** 80 | Retrieve source file list. 81 | @returns {String[]} The pathnames of the files to be parsed. 82 | */ 83 | JSDOC.JsDoc._getSrcFiles = function() { 84 | JSDOC.JsDoc.srcFiles = []; 85 | 86 | var ext = ["js"]; 87 | if (JSDOC.opt.x) { 88 | ext = JSDOC.opt.x.split(",").map(function($) {return $.toLowerCase()}); 89 | } 90 | 91 | for (var i = 0; i < JSDOC.opt._.length; i++) { 92 | JSDOC.JsDoc.srcFiles = JSDOC.JsDoc.srcFiles.concat( 93 | IO.ls(JSDOC.opt._[i], JSDOC.opt.r).filter( 94 | function($) { 95 | var thisExt = $.split(".").pop().toLowerCase(); 96 | 97 | if (JSDOC.opt.E) { 98 | for(var n = 0; n < JSDOC.opt.E.length; n++) { 99 | if ($.match(new RegExp(JSDOC.opt.E[n]))) { 100 | LOG.inform("Excluding " + $); 101 | return false; // if the file matches the regex then it's excluded. 102 | } 103 | } 104 | } 105 | 106 | return (ext.indexOf(thisExt) > -1); // we're only interested in files with certain extensions 107 | } 108 | ) 109 | ); 110 | } 111 | 112 | return JSDOC.JsDoc.srcFiles; 113 | } 114 | 115 | JSDOC.JsDoc._parseSrcFiles = function() { 116 | JSDOC.Parser.init(); 117 | for (var i = 0, l = JSDOC.JsDoc.srcFiles.length; i < l; i++) { 118 | var srcFile = JSDOC.JsDoc.srcFiles[i]; 119 | 120 | if (JSDOC.opt.v) LOG.inform("Parsing file: " + srcFile); 121 | 122 | try { 123 | var src = IO.readFile(srcFile); 124 | } 125 | catch(e) { 126 | LOG.warn("Can't read source file '"+srcFile+"': "+e.message); 127 | } 128 | 129 | var tr = new JSDOC.TokenReader(); 130 | var ts = new JSDOC.TokenStream(tr.tokenize(new JSDOC.TextStream(src))); 131 | 132 | JSDOC.Parser.parse(ts, srcFile); 133 | 134 | } 135 | JSDOC.Parser.finish(); 136 | 137 | if (JSDOC.PluginManager) { 138 | JSDOC.PluginManager.run("onFinishedParsing", JSDOC.Parser.symbols); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/JsPlate.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | JSDOC.JsPlate = function(templateFile) { 5 | if (templateFile) this.template = IO.readFile(templateFile); 6 | 7 | this.templateFile = templateFile; 8 | this.code = ""; 9 | this.parse(); 10 | } 11 | 12 | JSDOC.JsPlate.prototype.parse = function() { 13 | this.template = this.template.replace(/\{#[\s\S]+?#\}/gi, ""); 14 | this.code = "var output=\u001e"+this.template; 15 | 16 | this.code = this.code.replace( 17 | //gi, 18 | function (match, eachName, inName) { 19 | return "\u001e;\rvar $"+eachName+"_keys = keys("+inName+");\rfor(var $"+eachName+"_i = 0; $"+eachName+"_i < $"+eachName+"_keys.length; $"+eachName+"_i++) {\rvar $"+eachName+"_last = ($"+eachName+"_i == $"+eachName+"_keys.length-1);\rvar $"+eachName+"_key = $"+eachName+"_keys[$"+eachName+"_i];\rvar "+eachName+" = "+inName+"[$"+eachName+"_key];\routput+=\u001e"; 20 | } 21 | ); 22 | this.code = this.code.replace(//g, "\u001e;\rif ($1) { output+=\u001e"); 23 | this.code = this.code.replace(//g, "\u001e;}\relse if ($1) { output+=\u001e"); 24 | this.code = this.code.replace(//g, "\u001e;}\relse { output+=\u001e"); 25 | this.code = this.code.replace(/<\/(if|for)>/g, "\u001e;\r};\routput+=\u001e"); 26 | this.code = this.code.replace( 27 | /\{\+\s*([\s\S]+?)\s*\+\}/gi, 28 | function (match, code) { 29 | code = code.replace(/"/g, "\u001e"); // prevent qoute-escaping of inline code 30 | code = code.replace(/(\r?\n)/g, " "); 31 | return "\u001e+ ("+code+") +\u001e"; 32 | } 33 | ); 34 | this.code = this.code.replace( 35 | /\{!\s*([\s\S]+?)\s*!\}/gi, 36 | function (match, code) { 37 | code = code.replace(/"/g, "\u001e"); // prevent qoute-escaping of inline code 38 | code = code.replace(/(\n)/g, " "); 39 | return "\u001e; "+code+";\routput+=\u001e"; 40 | } 41 | ); 42 | this.code = this.code+"\u001e;"; 43 | 44 | this.code = this.code.replace(/(\r?\n)/g, "\\n"); 45 | this.code = this.code.replace(/"/g, "\\\""); 46 | this.code = this.code.replace(/\u001e/g, "\""); 47 | } 48 | 49 | JSDOC.JsPlate.prototype.toCode = function() { 50 | return this.code; 51 | } 52 | 53 | JSDOC.JsPlate.keys = function(obj) { 54 | var keys = []; 55 | if (obj.constructor.toString().indexOf("Array") > -1) { 56 | for (var i = 0; i < obj.length; i++) { 57 | keys.push(i); 58 | } 59 | } 60 | else { 61 | for (var i in obj) { 62 | keys.push(i); 63 | } 64 | } 65 | return keys; 66 | }; 67 | 68 | JSDOC.JsPlate.values = function(obj) { 69 | var values = []; 70 | if (obj.constructor.toString().indexOf("Array") > -1) { 71 | for (var i = 0; i < obj.length; i++) { 72 | values.push(obj[i]); 73 | } 74 | } 75 | else { 76 | for (var i in obj) { 77 | values.push(obj[i]); 78 | } 79 | } 80 | return values; 81 | }; 82 | 83 | JSDOC.JsPlate.prototype.process = function(data, compact) { 84 | var keys = JSDOC.JsPlate.keys; 85 | var values = JSDOC.JsPlate.values; 86 | 87 | try { 88 | eval(this.code); 89 | } 90 | catch (e) { 91 | print(">> There was an error evaluating the compiled code from template: "+this.templateFile); 92 | print(" The error was on line "+e.lineNumber+" "+e.name+": "+e.message); 93 | var lines = this.code.split("\r"); 94 | if (e.lineNumber-2 >= 0) print("line "+(e.lineNumber-1)+": "+lines[e.lineNumber-2]); 95 | print("line "+e.lineNumber+": "+lines[e.lineNumber-1]); 96 | print(""); 97 | } 98 | 99 | if (compact) { // patch by mcbain.asm 100 | // Remove lines that contain only space-characters, usually left by lines in the template 101 | // which originally only contained JSPlate tags or code. This makes it easier to write 102 | // non-tricky templates which still put out nice code (not bloated with extra lines). 103 | // Lines purposely left blank (just a line ending) are left alone. 104 | output = output.replace(/\s+?(\r?)\n/g, "$1\n"); 105 | } 106 | 107 | /*debug*///print(this.code); 108 | return output; 109 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/Lang.js: -------------------------------------------------------------------------------- 1 | /** 2 | @namespace 3 | */ 4 | JSDOC.Lang = { 5 | } 6 | 7 | JSDOC.Lang.isBuiltin = function(name) { 8 | return (JSDOC.Lang.isBuiltin.coreObjects.indexOf(name) > -1); 9 | } 10 | JSDOC.Lang.isBuiltin.coreObjects = ['_global_', 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', 'RegExp', 'String']; 11 | 12 | JSDOC.Lang.whitespace = function(ch) { 13 | return JSDOC.Lang.whitespace.names[ch]; 14 | } 15 | JSDOC.Lang.whitespace.names = { 16 | " ": "SPACE", 17 | "\f": "FORMFEED", 18 | "\t": "TAB", 19 | "\u0009": "UNICODE_TAB", 20 | "\u000A": "UNICODE_NBR", 21 | "\u0008": "VERTICAL_TAB" 22 | }; 23 | 24 | JSDOC.Lang.newline = function(ch) { 25 | return JSDOC.Lang.newline.names[ch]; 26 | } 27 | JSDOC.Lang.newline.names = { 28 | "\n": "NEWLINE", 29 | "\r": "RETURN", 30 | "\u000A": "UNICODE_LF", 31 | "\u000D": "UNICODE_CR", 32 | "\u2029": "UNICODE_PS", 33 | "\u2028": "UNICODE_LS" 34 | }; 35 | 36 | JSDOC.Lang.keyword = function(word) { 37 | return JSDOC.Lang.keyword.names["="+word]; 38 | } 39 | JSDOC.Lang.keyword.names = { 40 | "=break": "BREAK", 41 | "=case": "CASE", 42 | "=catch": "CATCH", 43 | "=const": "VAR", 44 | "=continue": "CONTINUE", 45 | "=default": "DEFAULT", 46 | "=delete": "DELETE", 47 | "=do": "DO", 48 | "=else": "ELSE", 49 | "=false": "FALSE", 50 | "=finally": "FINALLY", 51 | "=for": "FOR", 52 | "=function": "FUNCTION", 53 | "=if": "IF", 54 | "=in": "IN", 55 | "=instanceof": "INSTANCEOF", 56 | "=new": "NEW", 57 | "=null": "NULL", 58 | "=return": "RETURN", 59 | "=switch": "SWITCH", 60 | "=this": "THIS", 61 | "=throw": "THROW", 62 | "=true": "TRUE", 63 | "=try": "TRY", 64 | "=typeof": "TYPEOF", 65 | "=void": "VOID", 66 | "=while": "WHILE", 67 | "=with": "WITH", 68 | "=var": "VAR" 69 | }; 70 | 71 | JSDOC.Lang.punc = function(ch) { 72 | return JSDOC.Lang.punc.names[ch]; 73 | } 74 | JSDOC.Lang.punc.names = { 75 | ";": "SEMICOLON", 76 | ",": "COMMA", 77 | "?": "HOOK", 78 | ":": "COLON", 79 | "||": "OR", 80 | "&&": "AND", 81 | "|": "BITWISE_OR", 82 | "^": "BITWISE_XOR", 83 | "&": "BITWISE_AND", 84 | "===": "STRICT_EQ", 85 | "==": "EQ", 86 | "=": "ASSIGN", 87 | "!==": "STRICT_NE", 88 | "!=": "NE", 89 | "<<": "LSH", 90 | "<=": "LE", 91 | "<": "LT", 92 | ">>>": "URSH", 93 | ">>": "RSH", 94 | ">=": "GE", 95 | ">": "GT", 96 | "++": "INCREMENT", 97 | "--": "DECREMENT", 98 | "+": "PLUS", 99 | "-": "MINUS", 100 | "*": "MUL", 101 | "/": "DIV", 102 | "%": "MOD", 103 | "!": "NOT", 104 | "~": "BITWISE_NOT", 105 | ".": "DOT", 106 | "[": "LEFT_BRACKET", 107 | "]": "RIGHT_BRACKET", 108 | "{": "LEFT_CURLY", 109 | "}": "RIGHT_CURLY", 110 | "(": "LEFT_PAREN", 111 | ")": "RIGHT_PAREN" 112 | }; 113 | 114 | JSDOC.Lang.matching = function(name) { 115 | return JSDOC.Lang.matching.names[name]; 116 | } 117 | JSDOC.Lang.matching.names = { 118 | "LEFT_PAREN": "RIGHT_PAREN", 119 | "RIGHT_PAREN": "LEFT_PAREN", 120 | "LEFT_CURLY": "RIGHT_CURLY", 121 | "RIGHT_CURLY": "LEFT_CURLY", 122 | "LEFT_BRACE": "RIGHT_BRACE", 123 | "RIGHT_BRACE": "LEFT_BRACE" 124 | } 125 | 126 | JSDOC.Lang.isNumber = function(str) { 127 | return /^(\.[0-9]|[0-9]+\.|[0-9])[0-9]*([eE][+-][0-9]+)?$/i.test(str); 128 | } 129 | 130 | JSDOC.Lang.isHexDec = function(str) { 131 | return /^0x[0-9A-F]+$/i.test(str); 132 | } 133 | 134 | JSDOC.Lang.isWordChar = function(str) { 135 | return /^[a-zA-Z0-9$_.]+$/.test(str); 136 | } 137 | 138 | JSDOC.Lang.isSpace = function(str) { 139 | return (typeof JSDOC.Lang.whitespace(str) != "undefined"); 140 | } 141 | 142 | JSDOC.Lang.isNewline = function(str) { 143 | return (typeof JSDOC.Lang.newline(str) != "undefined"); 144 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/PluginManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | @namespace Holds functionality related to running plugins. 3 | */ 4 | JSDOC.PluginManager = { 5 | } 6 | 7 | /** 8 | @param name A unique name that identifies that plugin. 9 | @param handlers A collection of named functions. The names correspond to hooks in the core code. 10 | */ 11 | JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) { 12 | if (!defined(JSDOC.PluginManager.plugins)) 13 | /** The collection of all plugins. Requires a unique name for each. 14 | */ 15 | JSDOC.PluginManager.plugins = {}; 16 | 17 | 18 | JSDOC.PluginManager.plugins[name] = handlers; 19 | } 20 | 21 | /** 22 | @param hook The name of the hook that is being caught. 23 | @param target Any object. This will be passed as the only argument to the handler whose 24 | name matches the hook name. Handlers cannot return a value, so must modify the target 25 | object to have an effect. 26 | */ 27 | JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) { 28 | for (var name in JSDOC.PluginManager.plugins) { 29 | if (defined(JSDOC.PluginManager.plugins[name][hook])) { 30 | JSDOC.PluginManager.plugins[name][hook](target); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/TextStream.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | @constructor 4 | */ 5 | JSDOC.TextStream = function(text) { 6 | if (typeof(text) == "undefined") text = ""; 7 | text = ""+text; 8 | this.text = text; 9 | this.cursor = 0; 10 | } 11 | 12 | JSDOC.TextStream.prototype.look = function(n) { 13 | if (typeof n == "undefined") n = 0; 14 | 15 | if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { 16 | var result = new String(""); 17 | result.eof = true; 18 | return result; 19 | } 20 | return this.text.charAt(this.cursor+n); 21 | } 22 | 23 | JSDOC.TextStream.prototype.next = function(n) { 24 | if (typeof n == "undefined") n = 1; 25 | if (n < 1) return null; 26 | 27 | var pulled = ""; 28 | for (var i = 0; i < n; i++) { 29 | if (this.cursor+i < this.text.length) { 30 | pulled += this.text.charAt(this.cursor+i); 31 | } 32 | else { 33 | var result = new String(""); 34 | result.eof = true; 35 | return result; 36 | } 37 | } 38 | 39 | this.cursor += n; 40 | return pulled; 41 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/Token.js: -------------------------------------------------------------------------------- 1 | if (typeof JSDOC == "undefined") JSDOC = {}; 2 | 3 | /** 4 | @constructor 5 | */ 6 | JSDOC.Token = function(data, type, name) { 7 | this.data = data; 8 | this.type = type; 9 | this.name = name; 10 | } 11 | 12 | JSDOC.Token.prototype.toString = function() { 13 | return "<"+this.type+" name=\""+this.name+"\">"+this.data+""; 14 | } 15 | 16 | JSDOC.Token.prototype.is = function(what) { 17 | return this.name === what || this.type === what; 18 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/TokenStream.js: -------------------------------------------------------------------------------- 1 | if (typeof JSDOC == "undefined") JSDOC = {}; 2 | 3 | /** 4 | @constructor 5 | */ 6 | JSDOC.TokenStream = function(tokens) { 7 | this.tokens = (tokens || []); 8 | this.rewind(); 9 | } 10 | 11 | /** 12 | @constructor 13 | @private 14 | */ 15 | function VoidToken(/**String*/type) { 16 | this.toString = function() {return ""}; 17 | this.is = function(){return false;} 18 | } 19 | 20 | JSDOC.TokenStream.prototype.rewind = function() { 21 | this.cursor = -1; 22 | } 23 | 24 | /** 25 | @type JSDOC.Token 26 | */ 27 | JSDOC.TokenStream.prototype.look = function(/**Number*/n, /**Boolean*/considerWhitespace) { 28 | if (typeof n == "undefined") n = 0; 29 | 30 | if (considerWhitespace == true) { 31 | if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {}; 32 | return this.tokens[this.cursor+n]; 33 | } 34 | else { 35 | var count = 0; 36 | var i = this.cursor; 37 | 38 | while (true) { 39 | if (i < 0) return new JSDOC.Token("", "VOID", "START_OF_STREAM"); 40 | else if (i > this.tokens.length) return new JSDOC.Token("", "VOID", "END_OF_STREAM"); 41 | 42 | if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT"))) { 43 | if (n < 0) i--; else i++; 44 | continue; 45 | } 46 | 47 | if (count == Math.abs(n)) { 48 | return this.tokens[i]; 49 | } 50 | count++; 51 | (n < 0)? i-- : i++; 52 | } 53 | 54 | return new JSDOC.Token("", "VOID", "STREAM_ERROR"); // because null isn't an object and caller always expects an object 55 | } 56 | } 57 | 58 | /** 59 | @type JSDOC.Token|JSDOC.Token[] 60 | */ 61 | JSDOC.TokenStream.prototype.next = function(/**Number*/howMany) { 62 | if (typeof howMany == "undefined") howMany = 1; 63 | if (howMany < 1) return null; 64 | var got = []; 65 | 66 | for (var i = 1; i <= howMany; i++) { 67 | if (this.cursor+i >= this.tokens.length) { 68 | return null; 69 | } 70 | got.push(this.tokens[this.cursor+i]); 71 | } 72 | this.cursor += howMany; 73 | 74 | if (howMany == 1) { 75 | return got[0]; 76 | } 77 | else return got; 78 | } 79 | 80 | /** 81 | @type JSDOC.Token[] 82 | */ 83 | JSDOC.TokenStream.prototype.balance = function(/**String*/start, /**String*/stop) { 84 | if (!stop) stop = JSDOC.Lang.matching(start); 85 | 86 | var depth = 0; 87 | var got = []; 88 | var started = false; 89 | 90 | while ((token = this.look())) { 91 | if (token.is(start)) { 92 | depth++; 93 | started = true; 94 | } 95 | 96 | if (started) { 97 | got.push(token); 98 | } 99 | 100 | if (token.is(stop)) { 101 | depth--; 102 | if (depth == 0) return got; 103 | } 104 | if (!this.next()) break; 105 | } 106 | } 107 | 108 | JSDOC.TokenStream.prototype.getMatchingToken = function(/**String*/start, /**String*/stop) { 109 | var depth = 0; 110 | var cursor = this.cursor; 111 | 112 | if (!start) { 113 | start = JSDOC.Lang.matching(stop); 114 | depth = 1; 115 | } 116 | if (!stop) stop = JSDOC.Lang.matching(start); 117 | 118 | while ((token = this.tokens[cursor])) { 119 | if (token.is(start)) { 120 | depth++; 121 | } 122 | 123 | if (token.is(stop) && cursor) { 124 | depth--; 125 | if (depth == 0) return this.tokens[cursor]; 126 | } 127 | cursor++; 128 | } 129 | } 130 | 131 | JSDOC.TokenStream.prototype.insertAhead = function(/**JSDOC.Token*/token) { 132 | this.tokens.splice(this.cursor+1, 0, token); 133 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/lib/JSDOC/Util.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @namespace 3 | * @deprecated Use {@link FilePath} instead. 4 | */ 5 | JSDOC.Util = { 6 | } 7 | 8 | /** 9 | * @deprecated Use {@link FilePath.fileName} instead. 10 | */ 11 | JSDOC.Util.fileName = function(path) { 12 | LOG.warn("JSDOC.Util.fileName is deprecated. Use FilePath.fileName instead."); 13 | var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); 14 | return path.substring(nameStart); 15 | } 16 | 17 | /** 18 | * @deprecated Use {@link FilePath.fileExtension} instead. 19 | */ 20 | JSDOC.Util.fileExtension = function(filename) { 21 | LOG.warn("JSDOC.Util.fileExtension is deprecated. Use FilePath.fileExtension instead."); 22 | return filename.split(".").pop().toLowerCase(); 23 | }; 24 | 25 | /** 26 | * @deprecated Use {@link FilePath.dir} instead. 27 | */ 28 | JSDOC.Util.dir = function(path) { 29 | LOG.warn("JSDOC.Util.dir is deprecated. Use FilePath.dir instead."); 30 | var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); 31 | return path.substring(0, nameStart-1); 32 | } 33 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @version $Id: main.js 818 2009-11-08 14:51:41Z micmath $ 3 | */ 4 | 5 | function main() { 6 | IO.include("lib/JSDOC.js"); 7 | IO.includeDir("plugins/"); 8 | 9 | // process the options 10 | 11 | // the -c option: options are defined in a configuration file 12 | if (JSDOC.opt.c) { 13 | eval("JSDOC.conf = " + IO.readFile(JSDOC.opt.c)); 14 | 15 | LOG.inform("Using configuration file at '"+JSDOC.opt.c+"'."); 16 | 17 | for (var c in JSDOC.conf) { 18 | if (c !== "D" && !defined(JSDOC.opt[c])) { // commandline overrules config file 19 | JSDOC.opt[c] = JSDOC.conf[c]; 20 | } 21 | } 22 | 23 | if (typeof JSDOC.conf["_"] != "undefined") { 24 | JSDOC.opt["_"] = JSDOC.opt["_"].concat(JSDOC.conf["_"]); 25 | } 26 | 27 | LOG.inform("With configuration: "); 28 | for (var o in JSDOC.opt) { 29 | LOG.inform(" "+o+": "+JSDOC.opt[o]); 30 | } 31 | } 32 | 33 | // be verbose 34 | if (JSDOC.opt.v) LOG.verbose = true; 35 | 36 | // send log messages to a file 37 | if (JSDOC.opt.o) LOG.out = IO.open(JSDOC.opt.o); 38 | 39 | // run the unit tests 40 | if (JSDOC.opt.T) { 41 | LOG.inform("JsDoc Toolkit running in test mode at "+new Date()+"."); 42 | IO.include("frame/Testrun.js"); 43 | IO.include("test.js"); 44 | } 45 | else { 46 | // a template must be defined and must be a directory path 47 | if (!JSDOC.opt.t && System.getProperty("jsdoc.template.dir")) { 48 | JSDOC.opt.t = System.getProperty("jsdoc.template.dir"); 49 | } 50 | if (JSDOC.opt.t && SYS.slash != JSDOC.opt.t.slice(-1)) { 51 | JSDOC.opt.t += SYS.slash; 52 | } 53 | 54 | // verbose messages about the options we were given 55 | LOG.inform("JsDoc Toolkit main() running at "+new Date()+"."); 56 | LOG.inform("With options: "); 57 | for (var o in JSDOC.opt) { 58 | LOG.inform(" "+o+": "+JSDOC.opt[o]); 59 | } 60 | 61 | // initialize and build a symbolSet from your code 62 | JSDOC.JsDoc(); 63 | 64 | // debugger's option: dump the entire symbolSet produced from your code 65 | if (JSDOC.opt.Z) { 66 | LOG.warn("So you want to see the data structure, eh? This might hang if you have circular refs..."); 67 | IO.include("frame/Dumper.js"); 68 | var symbols = JSDOC.JsDoc.symbolSet.toArray(); 69 | for (var i = 0, l = symbols.length; i < l; i++) { 70 | var symbol = symbols[i]; 71 | print("// symbol: " + symbol.alias); 72 | print(symbol.serialize()); 73 | } 74 | } 75 | else { 76 | if (typeof JSDOC.opt.t != "undefined") { 77 | try { 78 | // a file named "publish.js" must exist in the template directory 79 | load(JSDOC.opt.t+"publish.js"); 80 | 81 | // and must define a function named "publish" 82 | if (!publish) { 83 | LOG.warn("No publish() function is defined in that template so nothing to do."); 84 | } 85 | else { 86 | // which will be called with the symbolSet produced from your code 87 | publish(JSDOC.JsDoc.symbolSet); 88 | } 89 | } 90 | catch(e) { 91 | LOG.warn("Sorry, that doesn't seem to be a valid template: "+JSDOC.opt.t+"publish.js : "+e); 92 | } 93 | } 94 | else { 95 | LOG.warn("No template given. Might as well read the usage notes."); 96 | JSDOC.usage(); 97 | } 98 | } 99 | } 100 | 101 | // notify of any warnings 102 | if (!JSDOC.opt.q && LOG.warnings.length) { 103 | print(LOG.warnings.length+" warning"+(LOG.warnings.length != 1? "s":"")+"."); 104 | } 105 | 106 | // stop sending log messages to a file 107 | if (LOG.out) { 108 | LOG.out.flush(); 109 | LOG.out.close(); 110 | } 111 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/commentSrcJson.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.commentSrcJson", 3 | { 4 | onDocCommentSrc: function(comment) { 5 | var json; 6 | if (/^\s*@json\b/.test(comment)) { 7 | comment.src = new String(comment.src).replace("@json", ""); 8 | 9 | eval("json = "+comment.src); 10 | var tagged = ""; 11 | for (var i in json) { 12 | var tag = json[i]; 13 | // todo handle cases where tag is an object 14 | tagged += "@"+i+" "+tag+"\n"; 15 | } 16 | comment.src = tagged; 17 | } 18 | } 19 | } 20 | ); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/frameworkPrototype.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.frameworkPrototype", 3 | { 4 | onPrototypeClassCreate: function(classCreator) { 5 | var desc = ""; 6 | if (classCreator.comment) { 7 | desc = classCreator.comment; 8 | } 9 | var insert = desc+"/** @name "+classCreator.name+"\n@constructor\n@scope "+classCreator.name+".prototype */" 10 | 11 | insert = insert.replace(/\*\/\/\*\*/g, "\n"); 12 | /*DEBUG*///print("insert is "+insert); 13 | classCreator.addComment.data = insert; 14 | } 15 | } 16 | ); 17 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/functionCall.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.functionCall", 3 | { 4 | onFunctionCall: function(functionCall) { 5 | if (functionCall.name == "dojo.define" && functionCall.arg1) { 6 | functionCall.doc = "/** @lends "+eval(functionCall.arg1)+".prototype */"; 7 | } 8 | } 9 | } 10 | ); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/publishSrcHilite.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.publishSrcHilite", 3 | { 4 | onPublishSrc: function(src) { 5 | if (src.path in JsHilite.cache) { 6 | return; // already generated src code 7 | } 8 | else JsHilite.cache[src.path] = true; 9 | 10 | try { 11 | var sourceCode = IO.readFile(src.path); 12 | } 13 | catch(e) { 14 | print(e.message); 15 | quit(); 16 | } 17 | 18 | var hiliter = new JsHilite(sourceCode, src.charset); 19 | src.hilited = hiliter.hilite(); 20 | } 21 | } 22 | ); 23 | 24 | function JsHilite(src, charset) { 25 | 26 | var tr = new JSDOC.TokenReader(); 27 | 28 | tr.keepComments = true; 29 | tr.keepDocs = true; 30 | tr.keepWhite = true; 31 | 32 | this.tokens = tr.tokenize(new JSDOC.TextStream(src)); 33 | 34 | // TODO is redefining toString() the best way? 35 | JSDOC.Token.prototype.toString = function() { 36 | return ""+this.data.replace(/"; 37 | } 38 | 39 | if (!charset) charset = "utf-8"; 40 | 41 | this.header = ' '+ 42 | "
";
50 | 	this.footer = "
"; 51 | this.showLinenumbers = true; 52 | } 53 | 54 | JsHilite.cache = {}; 55 | 56 | JsHilite.prototype.hilite = function() { 57 | var hilited = this.tokens.join(""); 58 | var line = 1; 59 | if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+""+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+" "}); 60 | 61 | return this.header+hilited+this.footer; 62 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/symbolLink.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.symbolLink", 3 | { 4 | onSymbolLink: function(link) { 5 | // modify link.linkPath (the href part of the link) 6 | // or link.linkText (the text displayed) 7 | // or link.linkInner (the #name part of the link) 8 | } 9 | } 10 | ); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/tagParamConfig.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.tagParamConfig", 3 | { 4 | onDocCommentTags: function(comment) { 5 | var currentParam = null; 6 | var tags = comment.tags; 7 | for (var i = 0, l = tags.length; i < l; i++) { 8 | 9 | if (tags[i].title == "param") { 10 | if (tags[i].name.indexOf(".") == -1) { 11 | currentParam = i; 12 | } 13 | } 14 | else if (tags[i].title == "config") { 15 | tags[i].title = "param"; 16 | if (currentParam == null) { 17 | tags[i].name = "arguments"+"."+tags[i].name; 18 | } 19 | else if (tags[i].name.indexOf(tags[currentParam].name+".") != 0) { 20 | tags[i].name = tags[currentParam].name+"."+tags[i].name; 21 | } 22 | currentParam != null 23 | //tags[currentParam].properties.push(tags[i]); 24 | } 25 | else { 26 | currentParam = null; 27 | } 28 | } 29 | } 30 | } 31 | ); 32 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/plugins/tagSynonyms.js: -------------------------------------------------------------------------------- 1 | JSDOC.PluginManager.registerPlugin( 2 | "JSDOC.tagSynonyms", 3 | { 4 | onDocCommentSrc: function(comment) { 5 | comment.src = comment.src.replace(/@methodOf\b/i, "@function\n@memberOf"); 6 | comment.src = comment.src.replace(/@fieldOf\b/i, "@field\n@memberOf"); 7 | }, 8 | 9 | onDocCommentTags: function(comment) { 10 | for (var i = 0, l = comment.tags.length; i < l; i++) { 11 | var title = comment.tags[i].title.toLowerCase(); 12 | var syn; 13 | if ((syn = JSDOC.tagSynonyms.synonyms["="+title])) { 14 | comment.tags[i].title = syn; 15 | } 16 | } 17 | } 18 | } 19 | ); 20 | 21 | new Namespace( 22 | "JSDOC.tagSynonyms", 23 | function() { 24 | JSDOC.tagSynonyms.synonyms = { 25 | "=member": "memberOf", 26 | "=memberof": "memberOf", 27 | "=description": "desc", 28 | "=exception": "throws", 29 | "=argument": "param", 30 | "=returns": "return", 31 | "=classdescription": "class", 32 | "=fileoverview": "overview", 33 | "=extends": "augments", 34 | "=base": "augments", 35 | "=projectdescription": "overview", 36 | "=classdescription": "class", 37 | "=link": "see", 38 | "=borrows": "inherits", 39 | "=scope": "lends", 40 | "=construct": "constructor" 41 | } 42 | } 43 | ); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/t/TestDoc.js: -------------------------------------------------------------------------------- 1 | var TestDoc = { 2 | fails: 0, 3 | plans: 0, 4 | passes: 0, 5 | results: [] 6 | }; 7 | 8 | TestDoc.record = function(result) { 9 | TestDoc.results.push(result); 10 | if (typeof result.verdict == "boolean") { 11 | if (result.verdict === false) TestDoc.fails++; 12 | if (result.verdict === true) TestDoc.passes++; 13 | } 14 | } 15 | 16 | TestDoc.prove = function(filePath) { 17 | if (typeof document != "undefined" && typeof document.write != "undefined") { 18 | if (TestDoc.console) print = function(s) { TestDoc.console.appendChild(document.createTextNode(s+"\n")); } 19 | else print = function(s) { document.write(s+"
"); } 20 | } 21 | TestDoc.run(TestDoc.readFile(filePath)); 22 | } 23 | 24 | TestDoc.run = function(src) { 25 | try { eval(src); } catch(e) { print("# ERROR! "+e); } 26 | 27 | var chunks = src.split(/\/\*t:/); 28 | 29 | var run = function(chunk) { 30 | // local shortcuts 31 | var is = TestDoc.assertEquals; 32 | var isnt = TestDoc.assertNotEquals; 33 | var plan = TestDoc.plan; 34 | var requires = TestDoc.requires; 35 | 36 | try { eval(chunk); } catch(e) { print("# ERROR! "+e); } 37 | } 38 | for (var start = -1, end = 0; (start = src.indexOf("/*t:", end)) > end; start = end) { 39 | run( 40 | src.substring( 41 | start+4, 42 | (end = src.indexOf("*/", start)) 43 | ) 44 | ); 45 | } 46 | } 47 | 48 | TestDoc.Result = function(verdict, message) { 49 | this.verdict = verdict; 50 | this.message = message; 51 | } 52 | 53 | TestDoc.Result.prototype.toString = function() { 54 | if (typeof this.verdict == "boolean") { 55 | return (this.verdict? "ok" : "not ok") + " " + (++TestDoc.report.counter) + " - " + this.message; 56 | } 57 | 58 | return "# " + this.message; 59 | } 60 | 61 | TestDoc.requires = function(file) { 62 | if (!TestDoc.requires.loaded[file]) { 63 | load(file); 64 | TestDoc.requires.loaded[file] = true; 65 | } 66 | } 67 | TestDoc.requires.loaded = {}; 68 | 69 | TestDoc.report = function() { 70 | TestDoc.report.counter = 0; 71 | print("1.."+TestDoc.plans); 72 | for (var i = 0; i < TestDoc.results.length; i++) { 73 | print(TestDoc.results[i]); 74 | } 75 | print("----------------------------------------"); 76 | if (TestDoc.fails == 0 && TestDoc.passes == TestDoc.plans) { 77 | print("All tests successful."); 78 | } 79 | else { 80 | print("Failed " + TestDoc.fails + "/" + TestDoc.plans + " tests, "+((TestDoc.plans == 0)? 0 : Math.round(TestDoc.passes/(TestDoc.passes+TestDoc.fails)*10000)/100)+"% okay. Planned to run "+TestDoc.plans+", did run "+(TestDoc.passes+TestDoc.fails)+".") 81 | } 82 | } 83 | 84 | TestDoc.plan = function(n, message) { 85 | TestDoc.plans += n; 86 | TestDoc.record(new TestDoc.Result(null, message+" ("+n+" tests)")); 87 | } 88 | 89 | TestDoc.assertEquals = function(a, b, message) { 90 | var result = (a == b); 91 | if (!result) message += "\n#\n# " + a + " does not equal " + b + "\n#"; 92 | TestDoc.record(new TestDoc.Result(result, message)); 93 | } 94 | 95 | TestDoc.assertNotEquals = function(a, b, message) { 96 | var result = (a != b); 97 | if (!result) message += "\n#\n# " + a + " equals " + b + "\n#"; 98 | TestDoc.record(new TestDoc.Result(result, message)); 99 | } 100 | 101 | TestDoc.readFile = (function(){ 102 | // rhino 103 | if (typeof readFile == "function") { 104 | return function(url) { 105 | var text = readFile(url); 106 | return text || ""; 107 | } 108 | } 109 | 110 | // a web browser 111 | else { 112 | return function(url) { 113 | var httpRequest; 114 | 115 | if (window.XMLHttpRequest) { // Mozilla, Safari, etc 116 | httpRequest = new XMLHttpRequest(); 117 | } 118 | else if (window.ActiveXObject) { // IE 119 | try { 120 | httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 121 | } 122 | catch (e) { 123 | try { 124 | httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 125 | } 126 | catch (e) { 127 | } 128 | } 129 | } 130 | 131 | if (!httpRequest) { throw "Cannot create HTTP Request."; } 132 | 133 | httpRequest.open('GET', url, false); 134 | httpRequest.send(''); 135 | if (httpRequest.readyState == 4) { 136 | if (httpRequest.status >= 400) { 137 | throw "The HTTP Request returned an error code: "+httpRequest.status; 138 | } 139 | } 140 | 141 | return httpRequest.responseText || ""; 142 | } 143 | } 144 | })(); 145 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/t/runner.js: -------------------------------------------------------------------------------- 1 | // try: java -jar ../../jsrun.jar runner.js 2 | 3 | load("TestDoc.js"); 4 | 5 | TestDoc.prove("../frame/Opt.js"); 6 | TestDoc.prove("../lib/JSDOC.js"); 7 | TestDoc.prove("../frame/String.js"); 8 | TestDoc.prove("../lib/JSDOC/DocTag.js"); 9 | TestDoc.prove("../lib/JSDOC/DocComment.js"); 10 | TestDoc.prove("../lib/JSDOC/TokenReader.js"); 11 | TestDoc.prove("../lib/JSDOC/Symbol.js"); 12 | 13 | TestDoc.report(); 14 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/addon.js: -------------------------------------------------------------------------------- 1 | String.prototype.reverse = function() { 2 | } 3 | 4 | String.prototype.reverse.utf8 = function() { 5 | } 6 | 7 | Function.count = function() { 8 | } 9 | 10 | /** @memberOf Function */ 11 | Function.count.reset = function() { 12 | } 13 | 14 | /** @memberOf Function */ 15 | count.getValue = function() { 16 | } 17 | 18 | /** @memberOf Function.prototype */ 19 | getSig = function() { 20 | } 21 | 22 | /** @memberOf Function.prototype */ 23 | Function.prototype.getProps = function() { 24 | } 25 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/anon_inner.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name bar 3 | * @namespace 4 | */ 5 | 6 | new function() { 7 | /** 8 | * @name bar-foo 9 | * @function 10 | * @param {number} x 11 | */ 12 | function foo(x) { 13 | } 14 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/augments.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | function Layout(p) { 5 | this.init = function(p) { 6 | } 7 | 8 | this.getId = function() { 9 | } 10 | 11 | /** @type Page */ 12 | this.orientation = "landscape"; 13 | } 14 | 15 | /** 16 | @constructor 17 | @augments Layout 18 | */ 19 | function Page() { 20 | this.reset = function(b) { 21 | } 22 | } 23 | 24 | /** 25 | @extends Page 26 | @constructor 27 | */ 28 | function ThreeColumnPage() { 29 | this.init = function(resetCode) { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/augments2.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | function LibraryItem() { 5 | this.reserve = function() { 6 | } 7 | } 8 | 9 | /** 10 | @constructor 11 | */ 12 | function Junkmail() { 13 | this.annoy = function() { 14 | } 15 | } 16 | 17 | /** 18 | @inherits Junkmail.prototype.annoy as pester 19 | @augments ThreeColumnPage 20 | @augments LibraryItem 21 | @constructor 22 | */ 23 | function NewsletterPage() { 24 | this.getHeadline = function() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/borrows.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | */ 4 | function Layout(p) { 5 | /** initilize 1 */ 6 | this.init = function(p) { 7 | } 8 | 9 | /** get the id */ 10 | this.getId = function() { 11 | } 12 | 13 | /** @type string */ 14 | this.orientation = "landscape"; 15 | 16 | function getInnerElements(elementSecretId){ 17 | } 18 | } 19 | 20 | /** A static method. */ 21 | Layout.units = function() { 22 | } 23 | 24 | /** 25 | @constructor 26 | @borrows Layout#orientation 27 | @borrows Layout-getInnerElements 28 | @borrows Layout.units 29 | */ 30 | function Page() { 31 | /** reset the page */ 32 | this.reset = function(b) { 33 | } 34 | } 35 | 36 | /** 37 | @constructor 38 | @borrows Layout.prototype.orientation as this.orientation 39 | @borrows Layout.prototype.init as #init 40 | @inherits Page.prototype.reset as #reset 41 | */ 42 | function ThreeColumnPage() { 43 | /** initilize 2 */ 44 | this.init = function(p) { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/borrows2.js: -------------------------------------------------------------------------------- 1 | // testing circular borrows 2 | 3 | /** 4 | @class 5 | @borrows Bar#zop as this.my_zop 6 | */ 7 | function Foo() { 8 | /** this is a zip. */ 9 | this.zip = function() {} 10 | 11 | this.my_zop = new Bar().zop; 12 | } 13 | 14 | /** 15 | @class 16 | @borrows Foo#zip as this.my_zip 17 | */ 18 | function Bar() { 19 | /** this is a zop. */ 20 | this.zop = function() {} 21 | 22 | this.my_zip = new Foo().zip; 23 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | * @param person The person. 4 | * @param {string} person.name The person's name. 5 | * @config {integer} age The person's age. 6 | * @config [id=1] Optional id number to use. 7 | * @param connection 8 | */ 9 | function Contact(person, connection) { 10 | 11 | } 12 | 13 | /** 14 | * @constructor 15 | * @param persons 16 | * @config {string} Father The paternal person. 17 | * @config {string} Mother The maternal person. 18 | * @config {string[]} Children And the rest. 19 | */ 20 | function Family(/**Object*/persons) { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/constructs.js: -------------------------------------------------------------------------------- 1 | var Person = makeClass( 2 | /** 3 | @scope Person 4 | */ 5 | { 6 | /** 7 | This is just another way to define a constructor. 8 | @constructs 9 | @param {string} name The name of the person. 10 | */ 11 | initialize: function(name) { 12 | this.name = name; 13 | }, 14 | say: function(message) { 15 | return this.name + " says: " + message; 16 | } 17 | } 18 | ); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/encoding.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @Constructor 4 | * @desc 配置文件 5 | * @class 什么也不返回 6 | */ 7 | function Test(conf) { 8 | // do something; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/encoding_other.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/docs/node-jsdoc-toolkit/app/test/encoding_other.js -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name Kitchen 3 | * @constructor 4 | * @fires Bakery#event:donutOrdered 5 | */ 6 | 7 | /** 8 | * Fired when some cake is eaten. 9 | * @name Kitchen#event:cakeEaten 10 | * @function 11 | * @param {Number} pieces The number of pieces eaten. 12 | */ 13 | 14 | /** 15 | * Find out if cake was eaten. 16 | * @name Kitchen#cakeEaten 17 | * @function 18 | * @param {Boolean} wasEaten 19 | */ 20 | 21 | /** 22 | * @name getDesert 23 | * @function 24 | * @fires Kitchen#event:cakeEaten 25 | */ 26 | 27 | /** 28 | * @name Bakery 29 | * @constructor 30 | * @extends Kitchen 31 | */ 32 | 33 | /** 34 | * Fired when a donut order is made. 35 | * @name Bakery#event:donutOrdered 36 | * @event 37 | * @param {Event} e The event object. 38 | * @param {String} [e.topping] Optional sprinkles. 39 | */ 40 | 41 | /** 42 | * @constructor 43 | * @borrows Bakery#event:donutOrdered as this.event:cakeOrdered 44 | */ 45 | function CakeShop() { 46 | } 47 | 48 | /** @event */ 49 | CakeShop.prototype.icingReady = function(isPink) { 50 | } 51 | 52 | /** @event */ 53 | function amHungry(/**Boolean*/enoughToEatAHorse) { 54 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/exports.js: -------------------------------------------------------------------------------- 1 | /** @namespace */ 2 | var mxn = {}; 3 | 4 | (function(){ 5 | /** @exports Map as mxn.Map */ 6 | var Map = 7 | /** @constructor */ 8 | mxn.Map = function() { 9 | }; 10 | 11 | /** A method. */ 12 | Map.prototype.doThings = function() { 13 | }; 14 | })(); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/functions_anon.js: -------------------------------------------------------------------------------- 1 | /** an anonymous constructor executed inline */ 2 | a = new function() { 3 | /** a.b*/ 4 | this.b = 1; 5 | /** a.f */ 6 | this.f = function() { 7 | /** a.c */ 8 | this.c = 2; 9 | } 10 | } 11 | 12 | 13 | /** 14 | named function executed inline 15 | */ 16 | bar1 = function Zoola1() { 17 | /** property of global */ 18 | this.g = 1; 19 | }(); 20 | 21 | /** 22 | named constructor executed inline 23 | */ 24 | bar2 = new function Zoola2() { 25 | /** property of bar */ 26 | this.p = 1; 27 | }; 28 | 29 | /** module pattern */ 30 | module = (function () { 31 | /** won't appear in documentation */ 32 | var priv = 1; 33 | 34 | /** @scope module */ 35 | return { 36 | /** will appear as a property of module */ 37 | pub: 1 38 | } 39 | })(); 40 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/functions_nested.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Zop() { 3 | } 4 | 5 | /** 6 | @class 7 | */ 8 | Foo = function(id) { 9 | // this is a bit twisted, but if you call Foo() you will then 10 | // modify Foo(). This is kinda, sorta non-insane, because you 11 | // would have to call Foo() 100% of the time to use Foo's methods 12 | Foo.prototype.methodOne = function(bar) { 13 | alert(bar); 14 | }; 15 | 16 | // same again 17 | Foo.prototype.methodTwo = function(bar2) { 18 | alert(bar2); 19 | }; 20 | 21 | // and these are only executed if the enclosing function is actually called 22 | // and who knows if that will ever happen? 23 | Bar = function(pez) { 24 | alert(pez); 25 | }; 26 | Zop.prototype.zap = function(p){ 27 | alert(p); 28 | }; 29 | 30 | // but this is only visible inside Foo 31 | function inner() { 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/global.js: -------------------------------------------------------------------------------- 1 | /** ecks */ 2 | var x = [1, 2, 4]; 3 | 4 | var y = { 5 | foo: function(){ 6 | } 7 | } 8 | 9 | bar = function() { 10 | } 11 | 12 | function zop() { 13 | } 14 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/globals.js: -------------------------------------------------------------------------------- 1 | function example(/**Circle*/a, b) { 2 | /** a global defined in function */ 3 | var number = a; 4 | 5 | var hideNumber = function(){ 6 | } 7 | 8 | setNumber = function(){ 9 | } 10 | alert('You have chosen: ' + b); 11 | } 12 | 13 | function initPage() { 14 | var supported = document.createElement && document.getElementsByTagName; 15 | if (!supported) return; 16 | // start of DOM script 17 | var x = document.getElementById('writeroot'); 18 | // etc. 19 | } 20 | 21 | /** an example var */ 22 | var document = new Document(x, y); 23 | 24 | var getNumber = function(){ 25 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/ignore.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A test constructor. 3 | * @constructor 4 | * @ignore 5 | */ 6 | function Ignored() { 7 | /** a method */ 8 | this.bar = function() { 9 | } 10 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/inner.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | */ 4 | function Outer() { 5 | /** 6 | * @constructor 7 | */ 8 | function Inner(name) { 9 | /** The name of this. */ 10 | this.name = name; 11 | } 12 | 13 | this.open = function(name) { 14 | return (new Inner(name)); 15 | } 16 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/lend.js: -------------------------------------------------------------------------------- 1 | /** @class */ 2 | var Person = Class.create( 3 | /** 4 | @lends Person.prototype 5 | */ 6 | { 7 | initialize: function(name) { 8 | this.name = name; 9 | }, 10 | say: function(message) { 11 | return this.name + ': ' + message; 12 | } 13 | } 14 | ); 15 | 16 | /** @lends Person.prototype */ 17 | { 18 | /** like say but more musical */ 19 | sing: function(song) { 20 | } 21 | } 22 | 23 | /** @lends Person */ 24 | { 25 | getCount: function() { 26 | } 27 | } 28 | 29 | /** @lends Unknown.prototype */ 30 | { 31 | notok: function() { 32 | } 33 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/memberof.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | pack = function() { 3 | this.init = function(){} 4 | function config(){} 5 | } 6 | 7 | pack.build = function(task) {}; 8 | 9 | /** @memberOf pack */ 10 | pack.install = function() {} 11 | 12 | /** @memberOf pack */ 13 | pack.install.overwrite = function() {} 14 | 15 | /** @memberOf pack */ 16 | clean = function() {} 17 | 18 | /** @memberOf pack-config */ 19 | install = function() {}; 20 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/memberof2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | */ 4 | function Foo() { 5 | /** 6 | @memberOf Foo.prototype 7 | */ 8 | function bar(a, b) { 9 | } 10 | 11 | /** 12 | @memberOf Foo 13 | */ 14 | var zip = function(p, q) { 15 | } 16 | 17 | /** 18 | @memberOf Foo 19 | */ 20 | function zop( x,y ) { 21 | } 22 | 23 | /** 24 | @memberOf Foo 25 | @constructor 26 | */ 27 | function Fiz() { 28 | /** A method of Foo#Fiz. */ 29 | this.fipple = function(fop){} 30 | } 31 | } 32 | 33 | /** 34 | @memberOf Foo# 35 | */ 36 | var blat = function() { 37 | 38 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/memberof3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @name Foo 3 | * @class 4 | */ 5 | 6 | /**#@+ 7 | * @memberOf Foo# 8 | * @field 9 | */ 10 | 11 | /** 12 | * @name bar 13 | * @type Object[] 14 | */ 15 | 16 | /**#@-*/ 17 | 18 | /** 19 | * @name Foo2 20 | * @class 21 | */ 22 | 23 | /**#@+ 24 | * @memberOf Foo2# 25 | * @field 26 | */ 27 | 28 | /** 29 | * @name bar 30 | * @type Object[] 31 | */ 32 | 33 | /**#@-*/ -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/memberof_constructor.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Circle(){} 3 | 4 | /** 5 | @constructor 6 | @memberOf Circle# 7 | */ 8 | Circle.prototype.Tangent = function(){}; 9 | 10 | // renaming Circle#Tangent to Circle#Circle#Tangent 11 | 12 | /** 13 | @memberOf Circle#Tangent# 14 | */ 15 | Circle.prototype.Tangent.prototype.getDiameter = function(){}; 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/module.js: -------------------------------------------------------------------------------- 1 | /** @namespace */ 2 | myProject = myProject || {}; 3 | 4 | /** @namespace */ 5 | myProject.myModule = (function () { 6 | /** describe myPrivateVar here */ 7 | var myPrivateVar = ""; 8 | 9 | var myPrivateMethod = function () { 10 | } 11 | 12 | /** @scope myProject.myModule */ 13 | return { 14 | myPublicMethod: function () { 15 | } 16 | }; 17 | })(); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/multi_methods.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | Get the entire flavor. 4 | @name flavor^3 5 | @function 6 | @returns {Object} The entire flavor hash. 7 | */ 8 | /** 9 | Get a named flavor. 10 | @name flavor^2 11 | @function 12 | @param {String} name The name of the flavor to get. 13 | @returns {String} The value of that flavor. 14 | */ 15 | /** 16 | Set the flavor. 17 | @param {String} name The name of the flavor to set. 18 | @param {String} value The value of the flavor. 19 | @returns {String} The value of that flavor. 20 | */ 21 | function flavor(name, value) { 22 | if (arguments.length > 1) flavor[name] = value; 23 | else if (arguments.length == 1) return flavor[name]; 24 | else return flavor; 25 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/name.js: -------------------------------------------------------------------------------- 1 | /** 2 | @name Response 3 | @class 4 | */ 5 | 6 | Response.prototype = { 7 | /** 8 | @name Response#text 9 | @function 10 | @description 11 | Gets the body of the response as plain text 12 | @returns {String} 13 | Response as text 14 | */ 15 | 16 | text: function() { 17 | return this.nativeResponse.responseText; 18 | } 19 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/namespace_nested.js: -------------------------------------------------------------------------------- 1 | /** 2 | @namespace This is the first namespace. 3 | */ 4 | ns1 = {}; 5 | 6 | /** 7 | This is the second namespace. 8 | @namespace 9 | */ 10 | ns1.ns2 = {}; 11 | 12 | /** 13 | This part of ns1.ns2 14 | @constructor 15 | */ 16 | ns1.ns2.Function1 = function() { 17 | }; 18 | 19 | ns1.staticFunction = function() { 20 | }; 21 | 22 | /** A static field in a namespace. */ 23 | ns1.ns2.staticField = 1; 24 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/nocode.js: -------------------------------------------------------------------------------- 1 | /**#nocode+*/ 2 | /** 3 | @name star 4 | @function 5 | */ 6 | function blahblah() { 7 | 8 | } 9 | /**#nocode-*/ 10 | 11 | function yaddayadda() { 12 | 13 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/oblit_anon.js: -------------------------------------------------------------------------------- 1 | /** the options */ 2 | opt = Opt.get( 3 | arguments, 4 | { 5 | d: "directory", 6 | c: "conf", 7 | "D[]": "define" 8 | } 9 | ); 10 | 11 | /** configuration */ 12 | opt.conf = { 13 | /** keep */ 14 | keep: true, 15 | /** base */ 16 | base: getBase(this, {p: properties}) 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/overview.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @overview This "library" contains a 3 | * lot of classes and functions. 4 | * @example 5 |
 6 | 	var x (x < 1);
 7 | 	alert("This 'is' \"code\"");
 8 |  
9 | * @name My Cool Library 10 | * @author Joe Smith jsmith@company.com 11 | * @version 0.1 12 | */ 13 | 14 | /** 15 | * Gets the current foo 16 | * @param {String} fooId The unique identifier for the foo. 17 | * @return {Object} Returns the current foo. 18 | */ 19 | function getFoo(fooID){ 20 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/param_inline.js: -------------------------------------------------------------------------------- 1 | /** 2 | @constructor 3 | @param columns The number of columns. 4 | */ 5 | function Layout(/**int*/columns){ 6 | /** 7 | @param [id] The id of the element. 8 | @param elName The name of the element. 9 | */ 10 | this.getElement = function( 11 | /** string */ elName, 12 | /** number|string */ id 13 | ) { 14 | }; 15 | 16 | /** 17 | @constructor 18 | */ 19 | this.Canvas = function(top, left, /**int*/width, height) { 20 | /** Is it initiated yet? */ 21 | this.initiated = true; 22 | } 23 | 24 | this.rotate = function(/**nothing*/) { 25 | } 26 | 27 | /** 28 | @param x 29 | @param y 30 | @param {zoppler} z*/ 31 | this.init = function(x, y, /**abbler*/z) { 32 | /** The xyz. */ 33 | this.xyz = x+y+z; 34 | this.getXyz = function() { 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/params_optional.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {Page[]} pages 4 | * @param {number} [id] Specifies the id, if applicable. 5 | * @param {String} [title = This is untitled.] Specifies the title. 6 | */ 7 | function Document(pages, id, title){ 8 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/prototype.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Article() { 3 | } 4 | 5 | Article.prototype.init = function(title) { 6 | /** the instance title */ 7 | this.title = title; 8 | 9 | /** the static counter */ 10 | Article.counter = 1; 11 | } 12 | 13 | a = new Article(); 14 | a.Init("my title"); 15 | 16 | print(a.title); 17 | print(Article.counter); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/prototype_nested.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Word() { 3 | } 4 | 5 | Word.prototype.reverse = function() { 6 | } 7 | 8 | Word.prototype.reverse.utf8 = function() { 9 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/prototype_oblit.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Article() { 3 | } 4 | 5 | Article.prototype = { 6 | /** instance get title */ 7 | getTitle: function(){ 8 | } 9 | } 10 | 11 | /** static get title */ 12 | Article.getTitle = function(){ 13 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/prototype_oblit_constructor.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Article() { 3 | } 4 | 5 | Article.prototype = { 6 | /** @constructor */ 7 | Title: function(title) { 8 | /** the value of the Title instance */ 9 | this.title = title; 10 | }, 11 | 12 | init: function(pages) { 13 | /** the value of the pages of the Article instance */ 14 | this.pages = pages; 15 | } 16 | } 17 | 18 | f = new Article(); 19 | f.init("one two three"); 20 | 21 | t = new f.Title("my title"); 22 | 23 | print(f.pages); 24 | print(t.title); -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/public.js: -------------------------------------------------------------------------------- 1 | /**@constructor*/ 2 | function Foo() { 3 | /** 4 | @public 5 | @static 6 | @field 7 | */ 8 | var bar = function(x) { 9 | } 10 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/scripts/code.js: -------------------------------------------------------------------------------- 1 | /** 2 | @class 3 | */ 4 | function thisiscode() { 5 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/scripts/notcode.txt: -------------------------------------------------------------------------------- 1 | (This is not code) 2 | function foo(){{{{ 3 | ( 4 | ! 5 | @ -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/shared.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Builtin object. 4 | * @class 5 | * @name Array 6 | */ 7 | 8 | /**#@+ 9 | * Extension to builtin array. 10 | * @memberOf Array 11 | * @method 12 | */ 13 | 14 | /** 15 | * @returns Boolen if some array members... 16 | */ 17 | Array.prototype.some = function(){}; 18 | 19 | /** 20 | * Change every element of an array. 21 | * @returns Filtered array copy. 22 | */ 23 | Array.prototype.filter = function(){}; 24 | 25 | /**#@-*/ 26 | 27 | 28 | /** 29 | * A first in, first out data structure. 30 | * @constructor 31 | */ 32 | Queue = function(){}; 33 | 34 | /**#@+ 35 | * Extension to Queue. 36 | * @memberOf Queue 37 | */ 38 | 39 | rewind = function(){ 40 | } 41 | 42 | // should close automatically here. -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/shared2.js: -------------------------------------------------------------------------------- 1 | startOver = function(){ 2 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/shortcuts.js: -------------------------------------------------------------------------------- 1 | // /**#=+ 2 | // * { 3 | // * 'D': 'Date.prototype', 4 | // * '$N': 'Number' 5 | // * } 6 | // */ 7 | // var D = Date.prototype, 8 | // $N = Number; 9 | // 10 | // D.locale = function(){ 11 | // }; 12 | // 13 | // /** 14 | // @return {string} The cardinal number string. 15 | // */ 16 | // $N.nth = function(n){ 17 | // }; 18 | // 19 | // LOAD.file = function(){ 20 | // } 21 | // 22 | // /**#=-*/ -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/static_this.js: -------------------------------------------------------------------------------- 1 | /** the parent */ 2 | var box = {}; 3 | 4 | /** @namespace */ 5 | box.holder = {} 6 | 7 | box.holder.foo = function() { 8 | /** the counter */ 9 | this.counter = 1; 10 | } 11 | 12 | box.holder.foo(); 13 | print(box.holder.counter); 14 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/synonyms.js: -------------------------------------------------------------------------------- 1 | /** 2 | @class 3 | @inherits Bar#zop as #my_zop 4 | */ 5 | function Foo() { 6 | /** this is a zip. */ 7 | this.zip = function() {} 8 | 9 | /** from Bar */ 10 | this.my_zop = new Bar().zop; 11 | } 12 | 13 | /** 14 | @class 15 | @borrows Foo#zip as this.my_zip 16 | */ 17 | function Bar() { 18 | /** this is a zop. */ 19 | this.zop = function() {} 20 | 21 | /** from Foo */ 22 | this.my_zip = new Foo().zip; 23 | } 24 | 25 | /** @namespace */ 26 | var myObject = { 27 | /** 28 | @type function 29 | */ 30 | myFunc: getFunction() 31 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/tosource.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {Object} object 3 | * @return {string} 4 | */ 5 | function valueOf(object) {} 6 | 7 | /** 8 | * @param {Object} object 9 | * @return {string} 10 | */ 11 | function toString(object) {} 12 | 13 | /** 14 | * @param {Object} object 15 | * @return {string} 16 | */ 17 | function toSource(object) {} 18 | 19 | /** 20 | * @param {Object} object 21 | * @return {string} 22 | */ 23 | function constructor(object) {} -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/app/test/variable_redefine.js: -------------------------------------------------------------------------------- 1 | /** @constructor */ 2 | function Foo() { 3 | var bar = 1; 4 | bar = 2; // redefining a private 5 | 6 | this.baz = 1; 7 | baz = 2; // global 8 | 9 | /** a private */ 10 | var blap = { 11 | /** in here */ 12 | tada: 1 13 | } 14 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/conf/default.conf: -------------------------------------------------------------------------------- 1 | /* 2 | This is an example of one way you could set up a configuration file to more 3 | conveniently define some commandline options. You might like to do this if 4 | you frequently reuse the same options. Note that you don't need to define 5 | every option in this file, you can combine a configuration file with 6 | additional options on the commandline if your wish. 7 | 8 | You would include this configuration file by running JsDoc Toolkit like so: 9 | java -jar jsrun.jar app/run.js -c=conf/sample.conf 10 | 11 | */ 12 | 13 | { 14 | // source files to use 15 | _: ['../../src/js'], 16 | 17 | // document all functions, even uncommented ones 18 | a: false, 19 | 20 | // including those marked @private 21 | p: true, 22 | 23 | // some extra variables I want to include 24 | // D: {generatedBy: "Michael Mathews", copyright: "2008"}, 25 | 26 | // use this directory as the output directory 27 | d: "../generated", 28 | 29 | // use this template 30 | t: "templates/jsdoc" 31 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/allclasses.tmpl: -------------------------------------------------------------------------------- 1 |
{+new Link().toFile("index.html").withText("Class Index")+} 2 | | {+new Link().toFile("files.html").withText("File Index")+}
3 |
4 |

Classes

5 |
    6 | 7 |
  • {! 8 | if (thisClass.alias == "_global_") { 9 | output += ""+new Link().toClass(thisClass.alias)+""; 10 | } 11 | else { 12 | output += new Link().toClass(thisClass.alias); 13 | } 14 | !}
  • 15 |
    16 |
17 |
-------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/allfiles.tmpl: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | {! Link.base = ""; /* all generated links will be relative to this */ !} 7 | JsDoc Reference - File Index 8 | 9 | 10 | 13 | 14 | 15 | 16 | {+include("static/header.html")+} 17 | 18 |
19 | {+publish.classesIndex+} 20 |
21 | 22 |
23 |

File Index

24 | 25 | 26 |
27 |

{+new Link().toSrc(item.alias).withText(item.name)+}

28 | {+resolveLinks(item.desc)+} 29 |
30 | 31 |
Author:
32 |
{+item.author+}
33 |
34 | 35 |
Version:
36 |
{+item.version+}
37 |
38 | {! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !} 39 | 40 |
Location:
41 | 42 |
{+location+}
43 |
44 |
45 |
46 |
47 |
48 |
49 | 50 |
51 |
52 | ©{+JSDOC.opt.D.copyright+}
53 | Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} 54 |
55 | 56 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/index.tmpl: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | JsDoc Reference - Index 8 | 9 | 10 | 13 | 14 | 15 | 16 | {+include("static/header.html")+} 17 | 18 |
19 | {+publish.classesIndex+} 20 |
21 | 22 |
23 |

Class Index

24 | 25 | 26 |
27 |

{+(new Link().toSymbol(thisClass.alias))+}

28 | {+resolveLinks(summarize(thisClass.classDesc))+} 29 |
30 |
31 |
32 | 33 |
34 |
35 | ©{+JSDOC.opt.D.copyright+}
36 | Documentation generated by JsDoc Toolkit {+JSDOC.VERSION+} on {+new Date()+} 37 |
38 | 39 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/static/default.css: -------------------------------------------------------------------------------- 1 | /* default.css */ 2 | body 3 | { 4 | font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; 5 | width: 800px; 6 | } 7 | 8 | .header 9 | { 10 | clear: both; 11 | background-color: #ccc; 12 | padding: 8px; 13 | } 14 | 15 | h1 16 | { 17 | font-size: 150%; 18 | font-weight: bold; 19 | padding: 0; 20 | margin: 1em 0 0 .3em; 21 | } 22 | 23 | hr 24 | { 25 | border: none 0; 26 | border-top: 1px solid #7F8FB1; 27 | height: 1px; 28 | } 29 | 30 | pre.code 31 | { 32 | display: block; 33 | padding: 8px; 34 | border: 1px dashed #ccc; 35 | } 36 | 37 | #index 38 | { 39 | margin-top: 24px; 40 | float: left; 41 | width: 270px; 42 | position: absolute; 43 | left: 8px; 44 | background-color: #F3F3F3; 45 | padding: 8px; 46 | } 47 | 48 | #content 49 | { 50 | margin-left: 300px; 51 | width: 600px; 52 | } 53 | 54 | .classList 55 | { 56 | list-style-type: none; 57 | padding: 0; 58 | margin: 0 0 0 8px; 59 | font-family: arial, sans-serif; 60 | font-size: 1em; 61 | overflow: auto; 62 | } 63 | 64 | .classList li 65 | { 66 | padding: 0; 67 | margin: 0 0 8px 0; 68 | } 69 | 70 | .summaryTable { width: 100%; } 71 | 72 | h1.classTitle 73 | { 74 | font-size:170%; 75 | line-height:130%; 76 | } 77 | 78 | h2 { font-size: 110%; } 79 | caption, div.sectionTitle 80 | { 81 | background-color: #7F8FB1; 82 | color: #fff; 83 | font-size:130%; 84 | text-align: left; 85 | padding: 2px 6px 2px 6px; 86 | border: 1px #7F8FB1 solid; 87 | } 88 | 89 | div.sectionTitle { margin-bottom: 8px; } 90 | .summaryTable thead { display: none; } 91 | 92 | .summaryTable td 93 | { 94 | vertical-align: top; 95 | padding: 4px; 96 | border-bottom: 1px #7F8FB1 solid; 97 | border-right: 1px #7F8FB1 solid; 98 | } 99 | 100 | /*col#summaryAttributes {}*/ 101 | .summaryTable td.attributes 102 | { 103 | border-left: 1px #7F8FB1 solid; 104 | width: 140px; 105 | text-align: right; 106 | } 107 | 108 | td.attributes, .fixedFont 109 | { 110 | line-height: 15px; 111 | color: #002EBE; 112 | font-family: "Courier New",Courier,monospace; 113 | font-size: 13px; 114 | } 115 | 116 | .summaryTable td.nameDescription 117 | { 118 | text-align: left; 119 | font-size: 13px; 120 | line-height: 15px; 121 | } 122 | 123 | .summaryTable td.nameDescription, .description 124 | { 125 | line-height: 15px; 126 | padding: 4px; 127 | padding-left: 4px; 128 | } 129 | 130 | .summaryTable { margin-bottom: 8px; } 131 | 132 | ul.inheritsList 133 | { 134 | list-style: square; 135 | margin-left: 20px; 136 | padding-left: 0; 137 | } 138 | 139 | .detailList { 140 | margin-left: 20px; 141 | line-height: 15px; 142 | } 143 | .detailList dt { margin-left: 20px; } 144 | 145 | .detailList .heading 146 | { 147 | font-weight: bold; 148 | padding-bottom: 6px; 149 | margin-left: 0; 150 | } 151 | 152 | .light, td.attributes, .light a:link, .light a:visited 153 | { 154 | color: #777; 155 | font-style: italic; 156 | } 157 | 158 | .fineprint 159 | { 160 | text-align: right; 161 | font-size: 10px; 162 | } -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/static/header.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/static/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Generated Javascript Documentation 7 | 8 | 9 | 10 | 11 | 12 | <body> 13 | <p> 14 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 15 | </p> 16 | </body> 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/node-jsdoc-toolkit/templates/jsdoc/symbol.tmpl: -------------------------------------------------------------------------------- 1 | 2 | {+data.name+} 3 | {+data.memberOf+} 4 | {+data.isStatic+} 5 | {+data.isa+} 6 | {+data.desc+} 7 | {+data.classDesc+} 8 | 9 | 10 | 11 | {+method.name+} 12 | {+method.memberOf+} 13 | {+method.isStatic+} 14 | {+method.desc+} 15 | 16 | 17 | {+param.type+} 18 | {+param.name+} 19 | {+param.desc+} 20 | {+param.defaultValue+} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | {+property.name+} 29 | {+property.memberOf+} 30 | {+property.isStatic+} 31 | {+property.desc+} 32 | {+property.type+} 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mindmaps", 3 | "description": "mindmaps is a prototype of an HTML5 based mind mapping application. It lets you create neat looking mind maps in the browser.", 4 | "version": "0.8.0", 5 | "keywords": [ 6 | "html5", 7 | "mindmap", 8 | "offline" 9 | ], 10 | "author": "David Richard", 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/drichard/mindmaps" 14 | }, 15 | "bugs": { 16 | "url": "http://github.com/drichard/mindmaps/issues" 17 | }, 18 | "scripts": { 19 | "start": "http-server ./src -p 3000", 20 | "start:prod": "npm run build && cd bin && python -m SimpleHTTPServer 3000", 21 | "build": "jake" 22 | }, 23 | "license": { 24 | "type": "AGPL", 25 | "url": "http://github.com/drichard/mindmaps/raw/master/LICENSE" 26 | }, 27 | "engines": { 28 | "node": ">=0.6" 29 | }, 30 | "dependencies": { 31 | "jake": "^8.0.15", 32 | "uglify-js": "^3.3.27" 33 | }, 34 | "devDependencies": { 35 | "http-server": "^0.11.1" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /psd/creator-nub.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/psd/creator-nub.psd -------------------------------------------------------------------------------- /psd/favicon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/psd/favicon.psd -------------------------------------------------------------------------------- /psd/plus-minus.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/psd/plus-minus.psd -------------------------------------------------------------------------------- /src/cache.appcache: -------------------------------------------------------------------------------- 1 | CACHE MANIFEST 2 | # timestamp {{timestamp}} 3 | 4 | CACHE: 5 | index.html 6 | about.html 7 | css/Aristo/images/bg_fallback.png 8 | css/Aristo/images/icon_sprite.png 9 | css/Aristo/images/progress_bar.gif 10 | css/Aristo/images/slider_handles.png 11 | css/Aristo/images/ui-icons_222222_256x240.png 12 | css/Aristo/images/ui-icons_454545_256x240.png 13 | css/Aristo/jquery-ui-1.8.7.custom.css 14 | css/minicolors/images/circle.gif 15 | css/minicolors/images/gradient.png 16 | css/minicolors/images/line.gif 17 | css/minicolors/images/rainbow.png 18 | css/minicolors/images/trigger.png 19 | css/minicolors/jquery.miniColors.css 20 | css/common.css 21 | css/app.css 22 | css/about.css 23 | img/favicon.png 24 | img/creator-nub-sprite.png 25 | img/grid.gif 26 | img/plus-minus.png 27 | img/ajax-loader.gif 28 | js/script.js 29 | http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js 30 | 31 | NETWORK: 32 | * 33 | -------------------------------------------------------------------------------- /src/css/Aristo/images/bg_fallback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/Aristo/images/bg_fallback.png -------------------------------------------------------------------------------- /src/css/Aristo/images/icon_sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/Aristo/images/icon_sprite.png -------------------------------------------------------------------------------- /src/css/Aristo/images/progress_bar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/Aristo/images/progress_bar.gif -------------------------------------------------------------------------------- /src/css/Aristo/images/slider_handles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/Aristo/images/slider_handles.png -------------------------------------------------------------------------------- /src/css/Aristo/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/Aristo/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /src/css/Aristo/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/Aristo/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /src/css/about.css: -------------------------------------------------------------------------------- 1 | /* 2 | * USER STYLES 3 | */ 4 | html,body { 5 | height: 100% 6 | } 7 | 8 | a { 9 | color: inherit; 10 | } 11 | 12 | em { 13 | font-style: italic; 14 | } 15 | 16 | strong { 17 | font-weight: bold; 18 | } 19 | 20 | #wrap { 21 | background: #75a8c4; /* Old browsers */ 22 | background: -moz-linear-gradient(top, #75a8c4 7%, #ffffff 100%); 23 | /* FF3.6+ */ 24 | background: -webkit-gradient(linear, left top, left bottom, color-stop(7%, #75a8c4), 25 | color-stop(100%, #ffffff) ); /* Chrome,Safari4+ */ 26 | background: -webkit-linear-gradient(top, #75a8c4 7%, #ffffff 100%); 27 | /* Chrome10+,Safari5.1+ */ 28 | background: -o-linear-gradient(top, #75a8c4 7%, #ffffff 100%); 29 | /* Opera11.10+ */ 30 | background: -ms-linear-gradient(top, #75a8c4 7%, #ffffff 100%); 31 | /* IE10+ */ 32 | filter: progid : DXImageTransform.Microsoft.gradient ( 33 | 34 | startColorstr = 35 | '#75a8c4', endColorstr = '#ffffff', GradientType 36 | = 37 | 38 | 0 ); 39 | /* IE6-9 */ 40 | background: linear-gradient(top, #75a8c4 7%, #ffffff 100%); /* W3C */ 41 | height: auto !important; 42 | min-height: 100%; 43 | } 44 | 45 | #container { 46 | background-color: white; 47 | padding: 25px 25px; 48 | padding-bottom: 0px; 49 | width: 650px; 50 | margin-left: auto; 51 | margin-right: auto; 52 | box-shadow: #CCC 4px 0 10px, #CCC -4px 0 10px, #AAA 0 38px 36px -24px; 53 | border-bottom-right-radius: 2px; 54 | border-bottom-left-radius: 2px; 55 | width: 650px; 56 | } 57 | 58 | .section { 59 | padding-bottom: 15px; 60 | border-bottom: 1px dashed #CCC; 61 | margin-bottom: 15px; 62 | } 63 | 64 | .section:last-child { 65 | border-bottom: none; 66 | } 67 | 68 | #head { 69 | margin-bottom: 25px; 70 | } 71 | 72 | #head a { 73 | text-decoration: none; 74 | } 75 | 76 | h1 { 77 | font-size: 52px; 78 | font-weight: bold; 79 | font-family: sans-serif; 80 | border-bottom: 4px solid #DDDDDD; 81 | color: #1C4257; 82 | text-shadow: 2px 1px 8px #75a8c4; 83 | } 84 | 85 | h2 { 86 | font-size: 24px; 87 | font-family: sans-serif; 88 | padding-bottom: 10px; 89 | font-weight: bold; 90 | color: #1C4257; 91 | text-shadow: 1px 1px 8px #75a8c4ad; 92 | } 93 | 94 | .text { 95 | font-size: 16px; 96 | font-family: Georgia, serif; 97 | line-height: 1.4em; 98 | } 99 | 100 | .text p { 101 | margin: 5px auto; 102 | } 103 | 104 | .text .feature { 105 | text-align: center; 106 | margin: 20px auto; 107 | background-color: #F2F2F2; 108 | padding: 5px; 109 | box-shadow: 1px 1px 6px #AAA; 110 | border-radius: 2px; 111 | } 112 | 113 | .text .feature:hover { 114 | box-shadow: 1px 1px 6px #75A8C4; 115 | } 116 | 117 | #footer { 118 | position: relative; 119 | padding: 10px 0px; 120 | background: #EEE; 121 | margin-top: 35px; 122 | height: 66px; 123 | border-top: 1px solid #CCC; 124 | margin: auto -25px; 125 | } 126 | 127 | #social { 128 | position: absolute; 129 | left: 10px; 130 | } 131 | 132 | #social .button { 133 | float: left; 134 | margin-right: 5px; 135 | } 136 | 137 | #copyright { 138 | position: absolute; 139 | bottom: 10px; 140 | left: 10px; 141 | font-size: 11px; 142 | color: #888; 143 | font-family: sans-serif; 144 | left: 10px; 145 | } 146 | 147 | #html5-badge { 148 | float: right; 149 | } 150 | -------------------------------------------------------------------------------- /src/css/common.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ 2 | v2.0 | 20110126 3 | License: none (public domain) 4 | */ 5 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video 6 | { 7 | margin: 0; 8 | padding: 0; 9 | border: 0; 10 | font-size: 100%; 11 | font: inherit; 12 | vertical-align: baseline; 13 | } 14 | /* HTML5 display-role reset for older browsers */ 15 | article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section 16 | { 17 | display: block; 18 | } 19 | 20 | body { 21 | line-height: 1; 22 | } 23 | 24 | ol,ul { 25 | list-style: none; 26 | } 27 | 28 | blockquote,q { 29 | quotes: none; 30 | } 31 | 32 | blockquote:before,blockquote:after,q:before,q:after { 33 | content: ''; 34 | content: none; 35 | } 36 | 37 | table { 38 | border-collapse: collapse; 39 | border-spacing: 0; 40 | } 41 | 42 | /* 43 | USER STYLES 44 | */ 45 | button { 46 | margin: 0; 47 | } 48 | 49 | a:focus { 50 | outline: none; 51 | } 52 | 53 | /* 54 | UTIL 55 | */ 56 | .no-select { 57 | -webkit-user-select: none; 58 | -khtml-user-select: none; 59 | -moz-user-select: none; 60 | -o-user-select: none; 61 | user-select: none; 62 | } 63 | 64 | .link { 65 | text-decoration: underline; 66 | cursor: pointer; 67 | } 68 | 69 | .right { 70 | float: right; 71 | } 72 | 73 | .loading { 74 | min-width: 16px; 75 | min-height: 16px; 76 | background-image: url("../img/ajax-loader.gif"); 77 | background-repeat: no-repeat; 78 | } 79 | -------------------------------------------------------------------------------- /src/css/minicolors/images/circle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/minicolors/images/circle.gif -------------------------------------------------------------------------------- /src/css/minicolors/images/gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/minicolors/images/gradient.png -------------------------------------------------------------------------------- /src/css/minicolors/images/line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/minicolors/images/line.gif -------------------------------------------------------------------------------- /src/css/minicolors/images/rainbow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/minicolors/images/rainbow.png -------------------------------------------------------------------------------- /src/css/minicolors/images/trigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/css/minicolors/images/trigger.png -------------------------------------------------------------------------------- /src/css/minicolors/jquery.miniColors.css: -------------------------------------------------------------------------------- 1 | .miniColors-trigger { 2 | height: 22px; 3 | width: 22px; 4 | background: url("images/trigger.png") center no-repeat; 5 | vertical-align: middle; 6 | margin: 0 .25em; 7 | display: inline-block; 8 | outline: none; 9 | } 10 | 11 | .miniColors-selector { 12 | position: absolute; 13 | width: 175px; 14 | height: 150px; 15 | background: #FFF; 16 | border: solid 1px #BBB; 17 | -moz-box-shadow: 0 0 6px rgba(0, 0, 0, .25); 18 | -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, .25); 19 | box-shadow: 0 0 6px rgba(0, 0, 0, .25); 20 | -moz-border-radius: 5px; 21 | -webkit-border-radius: 5px; 22 | border-radius: 5px; 23 | padding: 5px; 24 | z-index: 999999; 25 | } 26 | 27 | .miniColors-selector.black { 28 | background: #000; 29 | border-color: #000; 30 | } 31 | 32 | .miniColors-colors { 33 | position: absolute; 34 | top: 5px; 35 | left: 5px; 36 | width: 150px; 37 | height: 150px; 38 | background: url("images/gradient.png") center no-repeat; 39 | cursor: crosshair; 40 | } 41 | 42 | .miniColors-hues { 43 | position: absolute; 44 | top: 5px; 45 | left: 160px; 46 | width: 20px; 47 | height: 150px; 48 | background: url("images/rainbow.png") center no-repeat; 49 | cursor: crosshair; 50 | } 51 | 52 | .miniColors-colorPicker { 53 | position: absolute; 54 | width: 11px; 55 | height: 11px; 56 | background: url("images/circle.gif") center no-repeat; 57 | } 58 | 59 | .miniColors-huePicker { 60 | position: absolute; 61 | left: -3px; 62 | width: 26px; 63 | height: 3px; 64 | background: url("images/line.gif") center no-repeat; 65 | } -------------------------------------------------------------------------------- /src/img/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/ajax-loader.gif -------------------------------------------------------------------------------- /src/img/closedhand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/closedhand.png -------------------------------------------------------------------------------- /src/img/creator-nub-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/creator-nub-sprite.png -------------------------------------------------------------------------------- /src/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/favicon.png -------------------------------------------------------------------------------- /src/img/grid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/grid.gif -------------------------------------------------------------------------------- /src/img/openhand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/openhand.png -------------------------------------------------------------------------------- /src/img/plus-minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drichard/mindmaps/c56f3ed3f22fc355103632393043db978f24b8d5/src/img/plus-minus.png -------------------------------------------------------------------------------- /src/js/ApplicationController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new Application Controller. 3 | * 4 | * @constructor 5 | */ 6 | mindmaps.ApplicationController = function() { 7 | var eventBus = new mindmaps.EventBus(); 8 | var shortcutController = new mindmaps.ShortcutController(); 9 | var commandRegistry = new mindmaps.CommandRegistry(shortcutController); 10 | var undoController = new mindmaps.UndoController(eventBus, commandRegistry); 11 | var mindmapModel = new mindmaps.MindMapModel(eventBus, commandRegistry, undoController); 12 | var clipboardController = new mindmaps.ClipboardController(eventBus, 13 | commandRegistry, mindmapModel); 14 | var helpController = new mindmaps.HelpController(eventBus, commandRegistry); 15 | var printController = new mindmaps.PrintController(eventBus, 16 | commandRegistry, mindmapModel); 17 | var autosaveController = new mindmaps.AutoSaveController(eventBus, mindmapModel); 18 | var filePicker = new mindmaps.FilePicker(eventBus, mindmapModel); 19 | 20 | /** 21 | * Handles the new document command. 22 | */ 23 | function doNewDocument() { 24 | // close old document first 25 | var doc = mindmapModel.getDocument(); 26 | doCloseDocument(); 27 | 28 | var presenter = new mindmaps.NewDocumentPresenter(eventBus, 29 | mindmapModel, new mindmaps.NewDocumentView()); 30 | presenter.go(); 31 | } 32 | 33 | /** 34 | * Handles the save document command. 35 | */ 36 | function doSaveDocument() { 37 | var presenter = new mindmaps.SaveDocumentPresenter(eventBus, 38 | mindmapModel, new mindmaps.SaveDocumentView(), autosaveController, filePicker); 39 | presenter.go(); 40 | } 41 | 42 | /** 43 | * Handles the close document command. 44 | */ 45 | function doCloseDocument() { 46 | var doc = mindmapModel.getDocument(); 47 | if (doc) { 48 | // TODO for now simply publish events, should be intercepted by 49 | // someone 50 | mindmapModel.setDocument(null); 51 | } 52 | } 53 | 54 | /** 55 | * Handles the open document command. 56 | */ 57 | function doOpenDocument() { 58 | var presenter = new mindmaps.OpenDocumentPresenter(eventBus, 59 | mindmapModel, new mindmaps.OpenDocumentView(), filePicker); 60 | presenter.go(); 61 | } 62 | 63 | function doExportDocument() { 64 | var presenter = new mindmaps.ExportMapPresenter(eventBus, 65 | mindmapModel, new mindmaps.ExportMapView()); 66 | presenter.go(); 67 | } 68 | 69 | /** 70 | * Initializes the controller, registers for all commands and subscribes to 71 | * event bus. 72 | */ 73 | this.init = function() { 74 | var newDocumentCommand = commandRegistry 75 | .get(mindmaps.NewDocumentCommand); 76 | newDocumentCommand.setHandler(doNewDocument); 77 | newDocumentCommand.setEnabled(true); 78 | 79 | var openDocumentCommand = commandRegistry 80 | .get(mindmaps.OpenDocumentCommand); 81 | openDocumentCommand.setHandler(doOpenDocument); 82 | openDocumentCommand.setEnabled(true); 83 | 84 | var saveDocumentCommand = commandRegistry 85 | .get(mindmaps.SaveDocumentCommand); 86 | saveDocumentCommand.setHandler(doSaveDocument); 87 | 88 | var closeDocumentCommand = commandRegistry 89 | .get(mindmaps.CloseDocumentCommand); 90 | closeDocumentCommand.setHandler(doCloseDocument); 91 | 92 | var exportCommand = commandRegistry.get(mindmaps.ExportCommand); 93 | exportCommand.setHandler(doExportDocument); 94 | 95 | eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, function() { 96 | saveDocumentCommand.setEnabled(false); 97 | closeDocumentCommand.setEnabled(false); 98 | exportCommand.setEnabled(false); 99 | }); 100 | 101 | eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, function() { 102 | saveDocumentCommand.setEnabled(true); 103 | closeDocumentCommand.setEnabled(true); 104 | exportCommand.setEnabled(true); 105 | }); 106 | }; 107 | 108 | /** 109 | * Launches the main view controller. 110 | */ 111 | this.go = function() { 112 | var viewController = new mindmaps.MainViewController(eventBus, 113 | mindmapModel, commandRegistry); 114 | viewController.go(); 115 | 116 | doNewDocument(); 117 | }; 118 | 119 | this.init(); 120 | }; 121 | -------------------------------------------------------------------------------- /src/js/AutoSaveController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new AutoSaveController. This controller is able to automatically 3 | * save the document every X minutes. This setting is global for all mindmaps. 4 | * 5 | * @constructor 6 | * @param {mindmaps.EventBus} eventBus 7 | * @param {mindmaps.MindMapModel} mindmapModel 8 | */ 9 | mindmaps.AutoSaveController = function(eventBus, mindmapModel) { 10 | var SAVE_INTERVAL = 1000 * 60; // 1 minute 11 | var timer = null; 12 | 13 | function save() { 14 | console.debug("Autosaving..."); 15 | mindmapModel.saveToLocalStorage(); 16 | } 17 | 18 | function autosave() { 19 | if (!timer) { 20 | timer = setInterval(save, SAVE_INTERVAL); 21 | } 22 | } 23 | 24 | function stopAutosave() { 25 | if (timer) { 26 | clearInterval(timer); 27 | timer = null; 28 | } 29 | } 30 | 31 | /** 32 | * Enable autosave. 33 | */ 34 | this.enable = function() { 35 | autosave(); 36 | mindmapModel.getDocument().setAutoSave(true); 37 | } 38 | 39 | /** 40 | * Disable autosave. 41 | */ 42 | this.disable = function() { 43 | stopAutosave(); 44 | mindmapModel.getDocument().setAutoSave(false); 45 | } 46 | 47 | this.isEnabled = function() { 48 | return mindmapModel.getDocument().isAutoSave(); 49 | } 50 | 51 | this.init = function() { 52 | eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, this.documentOpened 53 | .bind(this)); 54 | 55 | eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, this.documentClosed 56 | .bind(this)); 57 | } 58 | 59 | this.documentOpened = function(doc) { 60 | if (this.isEnabled()) { 61 | autosave(); 62 | } 63 | } 64 | 65 | this.documentClosed = function() { 66 | stopAutosave(); 67 | } 68 | 69 | this.init(); 70 | } 71 | -------------------------------------------------------------------------------- /src/js/ClipboardController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new ClipboardController. 3 | * Handles copy, cut and paste commands. 4 | * 5 | * @constructor 6 | * 7 | * @param {mindmaps.EventBus} eventBus 8 | * @param {mindmaps.CommandRegistry} commandRegistry 9 | * @param {mindmaps.MindMapModel} mindmapModel 10 | */ 11 | mindmaps.ClipboardController = function(eventBus, commandRegistry, mindmapModel) { 12 | var node, copyCommand, cutCommand, pasteCommand; 13 | 14 | function init() { 15 | copyCommand = commandRegistry.get(mindmaps.CopyNodeCommand); 16 | copyCommand.setHandler(doCopy); 17 | 18 | cutCommand = commandRegistry.get(mindmaps.CutNodeCommand); 19 | cutCommand.setHandler(doCut); 20 | 21 | pasteCommand = commandRegistry.get(mindmaps.PasteNodeCommand); 22 | pasteCommand.setHandler(doPaste); 23 | pasteCommand.setEnabled(false); 24 | 25 | eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, function() { 26 | copyCommand.setEnabled(false); 27 | cutCommand.setEnabled(false); 28 | pasteCommand.setEnabled(false); 29 | }); 30 | 31 | eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, function() { 32 | copyCommand.setEnabled(true); 33 | cutCommand.setEnabled(true); 34 | pasteCommand.setEnabled(node != null); 35 | }); 36 | 37 | } 38 | 39 | function copySelectedNode() { 40 | node = mindmapModel.selectedNode.clone(); 41 | pasteCommand.setEnabled(true); 42 | } 43 | 44 | function doCopy() { 45 | copySelectedNode(); 46 | } 47 | 48 | function doCut() { 49 | copySelectedNode(); 50 | mindmapModel.deleteNode(mindmapModel.selectedNode); 51 | } 52 | 53 | function doPaste() { 54 | if (!node) { 55 | return; 56 | } 57 | 58 | // send a cloned copy of our node, so we can paste multiple times 59 | mindmapModel.createNode(node.clone(), mindmapModel.selectedNode); 60 | } 61 | 62 | init(); 63 | }; 64 | -------------------------------------------------------------------------------- /src/js/CommandRegistry.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new CommandRegistry. 3 | * 4 | * @constructor 5 | * @param {mindmaps.ShortcutController} [shortcutController] 6 | */ 7 | mindmaps.CommandRegistry = function(shortcutController) { 8 | this.commands = {}; 9 | 10 | function registerShortcut(command) { 11 | if (command.shortcut && command.execute) { 12 | shortcutController.register(command.shortcut, command.execute 13 | .bind(command)); 14 | } 15 | } 16 | 17 | function unregisterShortcut(command) { 18 | if (command.shortcut) { 19 | shortcutController.unregister(command.shortcut); 20 | } 21 | } 22 | 23 | /** 24 | * Returns a command object for the given command type. 25 | * 26 | * @param commandType 27 | * @returns {mindmaps.Command} a command object. 28 | */ 29 | this.get = function(commandType) { 30 | var command = this.commands[commandType]; 31 | if (!command) { 32 | command = new commandType; 33 | this.commands[commandType] = command; 34 | 35 | if (shortcutController) { 36 | registerShortcut(command); 37 | } 38 | } 39 | return command; 40 | }; 41 | 42 | /** 43 | * Removes the command object for the given command type. 44 | * 45 | * @param commandType 46 | */ 47 | this.remove = function(commandType) { 48 | // TODO remove by object 49 | var command = this.commands[commandType]; 50 | if (!command) { 51 | return; 52 | } 53 | 54 | delete this.commands[commandType]; 55 | 56 | if (shortcutController) { 57 | unregisterShortcut(command); 58 | } 59 | }; 60 | }; 61 | -------------------------------------------------------------------------------- /src/js/Document.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new Document. 3 | * 4 | * @constructor 5 | */ 6 | mindmaps.Document = function() { 7 | this.id = mindmaps.Util.createUUID(); 8 | this.title = "New Document"; 9 | this.mindmap = new mindmaps.MindMap(); 10 | this.dates = { 11 | created : new Date(), 12 | modified : null 13 | }; 14 | 15 | this.dimensions = new mindmaps.Point(4000, 2000); 16 | this.autosave = false; 17 | }; 18 | 19 | /** 20 | * Creates a new document object from a JSON string. 21 | * 22 | * @static 23 | * @param {String} json 24 | * @returns {mindmaps.Document} 25 | */ 26 | mindmaps.Document.fromJSON = function(json) { 27 | return mindmaps.Document.fromObject(JSON.parse(json)) 28 | }; 29 | 30 | /** 31 | * Creates a new document object from a generic object. 32 | * 33 | * @static 34 | * @param {Object} json 35 | * @returns {mindmaps.Document} 36 | */ 37 | mindmaps.Document.fromObject = function(obj) { 38 | var doc = new mindmaps.Document(); 39 | doc.id = obj.id; 40 | doc.title = obj.title; 41 | doc.mindmap = mindmaps.MindMap.fromObject(obj.mindmap); 42 | doc.dates = { 43 | created : new Date(obj.dates.created), 44 | modified : obj.dates.modified ? new Date(obj.dates.modified) : null 45 | }; 46 | 47 | doc.dimensions = mindmaps.Point.fromObject(obj.dimensions); 48 | doc.autosave = obj.autosave; 49 | 50 | return doc; 51 | }; 52 | 53 | /** 54 | * Called by JSON.stringify(). 55 | * 56 | * @private 57 | */ 58 | mindmaps.Document.prototype.toJSON = function() { 59 | // store dates in milliseconds since epoch 60 | var dates = { 61 | created : this.dates.created.getTime() 62 | }; 63 | 64 | if (this.dates.modified) { 65 | dates.modified = this.dates.modified.getTime(); 66 | } 67 | 68 | return { 69 | id : this.id, 70 | title : this.title, 71 | mindmap : this.mindmap, 72 | dates : dates, 73 | dimensions : this.dimensions, 74 | autosave: this.autosave 75 | }; 76 | }; 77 | 78 | /** 79 | * Returns a JSON representation of the object. 80 | * 81 | * @returns {String} the json. 82 | */ 83 | mindmaps.Document.prototype.serialize = function() { 84 | return JSON.stringify(this); 85 | }; 86 | 87 | /** 88 | * Updates modified date and title for saving. 89 | */ 90 | mindmaps.Document.prototype.prepareSave = function() { 91 | this.dates.modified = new Date(); 92 | this.title = this.mindmap.getRoot().getCaption(); 93 | return this; 94 | }; 95 | 96 | /** 97 | * Sort function for Array.sort(). 98 | * 99 | * @static 100 | * @param {mindmaps.Document} doc1 101 | * @param {mindmaps.Document} doc2 102 | */ 103 | mindmaps.Document.sortByModifiedDateDescending = function(doc1, doc2) { 104 | if (doc1.dates.modified > doc2.dates.modified) { 105 | return -1; 106 | } 107 | if (doc1.dates.modified < doc2.dates.modified) { 108 | return 1; 109 | } 110 | return 0; 111 | }; 112 | 113 | /** 114 | * Tells whether this document considerd as "new", that is has not been saved 115 | * yet. 116 | * 117 | * @returns {Boolean} 118 | */ 119 | mindmaps.Document.prototype.isNew = function() { 120 | return this.dates.modified === null; 121 | }; 122 | 123 | /** 124 | * Returns the created date. 125 | * 126 | * @returns {Date} 127 | */ 128 | mindmaps.Document.prototype.getCreatedDate = function() { 129 | return this.dates.created; 130 | }; 131 | 132 | /** 133 | * Gets the width of the document. 134 | * 135 | * @returns {Number} 136 | */ 137 | mindmaps.Document.prototype.getWidth = function() { 138 | return this.dimensions.x; 139 | }; 140 | 141 | /** 142 | * Gets the height of the document. 143 | * 144 | * @returns {Number} 145 | */ 146 | mindmaps.Document.prototype.getHeight = function() { 147 | return this.dimensions.y; 148 | }; 149 | 150 | 151 | mindmaps.Document.prototype.isAutoSave = function() { 152 | return this.autosave; 153 | } 154 | 155 | 156 | /** 157 | * Sets autosave setting. 158 | * 159 | * @param {Boolean} 160 | */ 161 | mindmaps.Document.prototype.setAutoSave = function(autosave) { 162 | this.autosave = autosave; 163 | } 164 | -------------------------------------------------------------------------------- /src/js/Event.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Events that the event bus carries. 3 | * 4 | * @namespace 5 | */ 6 | mindmaps.Event = { 7 | /** 8 | * @event 9 | * @param {mindmaps.Document} document 10 | */ 11 | DOCUMENT_OPENED : "DocumentOpenedEvent", 12 | 13 | /** 14 | * @event 15 | * @param {mindmaps.Document} document 16 | */ 17 | DOCUMENT_SAVED : "DocumentSavedEvent", 18 | 19 | /** 20 | * @event 21 | * @param {mindmaps.Document} document 22 | */ 23 | DOCUMENT_CLOSED : "DocumentClosedEvent", 24 | 25 | /** 26 | * @event 27 | * @param {mindmaps.Node} node 28 | * @param {mindmaps.Node} oldSelectedNode 29 | */ 30 | NODE_SELECTED : "NodeSelectedEvent", 31 | 32 | /** 33 | * @event 34 | * @param {mindmaps.Node} node 35 | */ 36 | NODE_DESELECTED : "NodeDeselectedEvent", 37 | 38 | /** 39 | * @event 40 | * @param {mindmaps.Node} node 41 | */ 42 | NODE_MOVED : "NodeMovedEvent", 43 | 44 | /** 45 | * @event 46 | * @param {mindmaps.Node} node 47 | */ 48 | NODE_TEXT_CAPTION_CHANGED : "NodeTextCaptionChangedEvent", 49 | 50 | /** 51 | * Some parameter of the node font attribute has changed. 52 | * 53 | * @event 54 | * @param {mindmaps.Node} node 55 | */ 56 | NODE_FONT_CHANGED : "NodeFontChangedEvent", 57 | 58 | /** 59 | * Preview event for node font color changes. 60 | * 61 | * @event 62 | * @param {mindmaps.Node} node 63 | * @param {String} color 64 | */ 65 | NODE_FONT_COLOR_PREVIEW: "NodeFontColorPreviewEvent", 66 | 67 | /** 68 | * @event 69 | * @param {mindmaps.Node} node 70 | */ 71 | NODE_BRANCH_COLOR_CHANGED : "NodeBranchColorChangedEvent", 72 | 73 | /** 74 | * @event 75 | * @param {mindmaps.Node} node 76 | * @param {String} color 77 | */ 78 | NODE_BRANCH_COLOR_PREVIEW : "NodeBranchColorPreviewEvent", 79 | 80 | /** 81 | * @event 82 | * @param {mindmaps.Node} node 83 | */ 84 | NODE_CREATED : "NodeCreatedEvent", 85 | 86 | /** 87 | * @event 88 | * @param {mindmaps.Node} node 89 | * @param {mindmaps.Node} parent 90 | */ 91 | NODE_DELETED : "NodeDeletedEvent", 92 | 93 | /** 94 | * @event 95 | * @param {mindmaps.Node} node 96 | */ 97 | NODE_OPENED : "NodeOpenedEvent", 98 | 99 | /** 100 | * @event 101 | * @param {mindmaps.Node} node 102 | */ 103 | NODE_CLOSED : "NodeClosedEvent", 104 | 105 | /** 106 | * @event 107 | * @param {Number} zoomFactor 108 | */ 109 | ZOOM_CHANGED : "ZoomChangedEvent", 110 | 111 | /** 112 | * @event 113 | * @param {String} message 114 | */ 115 | NOTIFICATION_INFO: "NotificationInfoEvent", 116 | 117 | /** 118 | * @event 119 | * @param {String} message 120 | */ 121 | NOTIFICATION_WARN: "NotificationWarnEvent", 122 | 123 | /** 124 | * @event 125 | * @param {String} message 126 | */ 127 | NOTIFICATION_ERROR: "NotificationErrorEvent" 128 | }; 129 | 130 | /** 131 | * Simple Event bus powered by EventEmitter. 132 | * 133 | * @constructor 134 | * @augments EventEmitter 135 | * 136 | */ 137 | mindmaps.EventBus = EventEmitter; 138 | 139 | if (mindmaps.DEBUG) { 140 | // overwrite publish func and display amount of listeners 141 | var old = mindmaps.EventBus.prototype.emit; 142 | mindmaps.EventBus.prototype.publish = function(type) { 143 | var l = this.listeners(type).length; 144 | console.log("EventBus > publish: " + type, "(Listeners: " + l + ")"); 145 | 146 | old.apply(this, arguments); 147 | }; 148 | } 149 | -------------------------------------------------------------------------------- /src/js/ExportMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @constructor 4 | */ 5 | mindmaps.ExportMapView = function() { 6 | var self = this; 7 | 8 | // create dialog 9 | var $dialog = $("#template-export-map").tmpl().dialog({ 10 | autoOpen : false, 11 | modal : true, 12 | zIndex : 5000, 13 | width : "auto", 14 | height : "auto", 15 | close : function() { 16 | $(this).dialog("destroy"); 17 | $(this).remove(); 18 | }, 19 | open : function() { 20 | $(this).css({ 21 | "max-width" : $(window).width() * 0.9, 22 | "max-height" : $(window).height() * 0.8 23 | }); 24 | $dialog.dialog("option", "position", "center"); 25 | }, 26 | buttons : { 27 | "Ok" : function() { 28 | $(this).dialog("close"); 29 | } 30 | } 31 | }); 32 | 33 | /** 34 | * Shows the dialog. 35 | * 36 | */ 37 | this.showDialog = function() { 38 | $dialog.dialog("open"); 39 | }; 40 | 41 | /** 42 | * Hides the dialog. 43 | */ 44 | this.hideDialog = function() { 45 | $dialog.dialog("close"); 46 | }; 47 | 48 | this.setImage = function($img) { 49 | $("#export-preview").html($img); 50 | }; 51 | }; 52 | 53 | /** 54 | * 55 | * @constructor 56 | * @param {mindmaps.EventBus} eventBus 57 | * @param {mindmaps.MindMapModel} mindmapModel 58 | * @param {mindmaps.ExportMapView} view 59 | */ 60 | mindmaps.ExportMapPresenter = function(eventBus, mindmapModel, view) { 61 | var renderer = new mindmaps.StaticCanvasRenderer(); 62 | 63 | this.go = function() { 64 | var $img = renderer.renderAsPNG(mindmapModel.getDocument()); 65 | view.setImage($img); 66 | 67 | // slightly delay showing the dialog. otherwise dialog is not correctly 68 | // centered, because the image is inserted too late 69 | setTimeout(function() { 70 | view.showDialog(); 71 | }, 30); 72 | }; 73 | }; 74 | -------------------------------------------------------------------------------- /src/js/FilePicker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class for interaction with the filepicker API. Provides open and save 3 | * from/to cloud storages. 4 | * 5 | * @constructor 6 | */ 7 | mindmaps.FilePicker = function(eventBus, mindmapModel) { 8 | 9 | // filepicker is not defined when we are offline 10 | if (window.filepicker) { 11 | var filepicker = window.filepicker; 12 | filepicker.setKey('P9tQ4bicRwyIe8ZUsny5'); 13 | } 14 | 15 | var mimetype = "application/json"; 16 | 17 | /** 18 | * Shows the open dialog and tries to open a mindmap. 19 | */ 20 | this.open = function(options) { 21 | options = options || {}; 22 | 23 | if (!filepicker || !navigator.onLine) { 24 | options.error && options.error("Cannot access cloud, it appears you are offline."); 25 | return; 26 | } 27 | 28 | // load callback 29 | options.load && options.load(); 30 | 31 | function onSuccess(blob) { 32 | // load mindmap 33 | $.ajax({ 34 | url: blob.url, 35 | success: function(data) { 36 | 37 | try { 38 | // convert to object first if response is a string 39 | if (Object.prototype.toString.call(data) == '[object String]') { 40 | data = JSON.parse(data); 41 | } 42 | 43 | var doc = mindmaps.Document.fromObject(data); 44 | } catch (e) { 45 | eventBus.publish(mindmaps.Event.NOTIFICATION_ERROR, 'File is not a valid mind map!'); 46 | throw new Error('Error while parsing map from cloud', e); 47 | } 48 | 49 | mindmapModel.setDocument(doc); 50 | 51 | // execute callback 52 | if (options.success) { 53 | options.success(doc); 54 | } 55 | }, 56 | error: function(jqXHR, textStatus, errorThrown) { 57 | if (options.error) { 58 | options.error("Error: Could not open mind map!"); 59 | } 60 | throw new Error('Error while loading map from filepicker. ' + textStatus + ' ' + errorThrown); 61 | } 62 | }); 63 | } 64 | 65 | function onError(e) { 66 | if (e.code === 101) { 67 | // 101 - The user closed the dialog without picking a file. 68 | options.cancel && options.cancel(); 69 | } else { 70 | throw new Error(e); 71 | } 72 | } 73 | 74 | filepicker.pick({ 75 | mimetype: mimetype, 76 | container: 'modal', 77 | openTo: 'DROPBOX', 78 | services: ['COMPUTER', 'GOOGLE_DRIVE', 'DROPBOX', 'BOX', 'SKYDRIVE'] 79 | }, onSuccess, onError); 80 | }; 81 | 82 | /** 83 | * Shows the save dialog where the user can save the current mindmap. 84 | */ 85 | this.save = function(options) { 86 | options = options || {}; 87 | 88 | if (!filepicker || !navigator.onLine) { 89 | options.error && options.error("Cannot access cloud, it appears you are offline."); 90 | return; 91 | } 92 | 93 | // load callback 94 | options.load && options.load(); 95 | 96 | var doc = mindmapModel.getDocument().prepareSave(); 97 | var data = doc.serialize(); 98 | 99 | function onSuccess(blob) { 100 | eventBus.publish(mindmaps.Event.DOCUMENT_SAVED, doc); 101 | 102 | if (options.success) { 103 | options.success(); 104 | } 105 | } 106 | 107 | function onError(e) { 108 | if (e.code === 131) { 109 | // 131 - The user closed the save dialog without picking a file. 110 | options.cancel && options.cancel(); 111 | } else { 112 | throw new Error(e); 113 | } 114 | } 115 | 116 | var blob = new Blob([data], {type: 'application/json'}); 117 | 118 | filepicker.store(blob, function (storedBlob) { 119 | filepicker.exportFile(storedBlob.url, { 120 | mimetype: mimetype, 121 | suggestedFilename: doc.title, 122 | container: 'modal', 123 | openTo: 'DROPBOX', 124 | services: ['DROPBOX', 'BOX', 'SKYDRIVE', 'GOOGLE_DRIVE'] 125 | }, onSuccess, onError); 126 | }); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/js/MindMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Creates a new mind map. 4 | * 5 | * @constructor 6 | * @param {mindmaps.Node} [root] 7 | */ 8 | mindmaps.MindMap = function(root) { 9 | /** 10 | * nodes is only used for quick lookup of a node by id. Each node must be 11 | * registered in this map via createNode() or addNode(node). 12 | */ 13 | this.nodes = new mindmaps.NodeMap(); 14 | 15 | if (root) { 16 | this.root = root; 17 | } else { 18 | this.root = new mindmaps.Node(); 19 | this.root.text.font.size = 20; 20 | this.root.text.font.weight = "bold"; 21 | this.root.text.caption = "Central Idea"; 22 | } 23 | 24 | this.addNode(this.root); 25 | }; 26 | 27 | /** 28 | * Creates a new mind map object from JSON String. 29 | * 30 | * @static 31 | * @param {String} json 32 | * @returns {mindmaps.MindMap} 33 | */ 34 | mindmaps.MindMap.fromJSON = function(json) { 35 | return mindmaps.MindMap.fromObject(JSON.parse(json)); 36 | }; 37 | 38 | /** 39 | * Creates a new mind map object from generic object. 40 | * 41 | * @static 42 | * @param {Object} obj 43 | * @returns {mindmaps.MindMap} 44 | */ 45 | mindmaps.MindMap.fromObject = function(obj) { 46 | var root = mindmaps.Node.fromObject(obj.root); 47 | var mm = new mindmaps.MindMap(root); 48 | 49 | // register all nodes in the map 50 | root.forEachDescendant(function(descendant) { 51 | mm.addNode(descendant); 52 | }); 53 | 54 | return mm; 55 | }; 56 | 57 | /** 58 | * Called by JSON.stringify(). 59 | * 60 | * @private 61 | * 62 | */ 63 | mindmaps.MindMap.prototype.toJSON = function() { 64 | var obj = { 65 | root : this.root 66 | }; 67 | return obj; 68 | }; 69 | 70 | /** 71 | * Creates a JSON representation of the mind map. 72 | * 73 | * @returns {String} 74 | */ 75 | mindmaps.MindMap.prototype.serialize = function() { 76 | return JSON.stringify(this); 77 | }; 78 | 79 | /** 80 | * Create a node and add to nodes map. 81 | * 82 | * @returns {mindmaps.Node} 83 | */ 84 | mindmaps.MindMap.prototype.createNode = function() { 85 | var node = new mindmaps.Node(); 86 | this.addNode(node); 87 | return node; 88 | }; 89 | 90 | /** 91 | * Adds an existing node and all its children to the nodes map. 92 | * 93 | * @param {mindmaps.Node} node 94 | */ 95 | mindmaps.MindMap.prototype.addNode = function(node) { 96 | this.nodes.add(node); 97 | 98 | // add all children 99 | var self = this; 100 | node.forEachDescendant(function(descendant) { 101 | self.nodes.add(descendant); 102 | }); 103 | }; 104 | 105 | /** 106 | * Removes a node from the mind map. Severs tie to the parent. 107 | * 108 | * @param {mindmaps.Node} node 109 | */ 110 | mindmaps.MindMap.prototype.removeNode = function(node) { 111 | // detach node from parent 112 | var parent = node.parent; 113 | parent.removeChild(node); 114 | 115 | // clear nodes table: remove node and its children 116 | var self = this; 117 | node.forEachDescendant(function(descendant) { 118 | self.nodes.remove(descendant); 119 | }); 120 | 121 | this.nodes.remove(node); 122 | }; 123 | 124 | /** 125 | * Get the root of the mind map. 126 | * 127 | * @returns {mindmaps.Node} 128 | */ 129 | mindmaps.MindMap.prototype.getRoot = function() { 130 | return this.root; 131 | }; 132 | -------------------------------------------------------------------------------- /src/js/NewDocument.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Unused for now. 3 | * 4 | * @constructor 5 | */ 6 | mindmaps.NewDocumentView = function() { 7 | 8 | }; 9 | 10 | /** 11 | * Creates a new NewDocumentPresenter. This presenter has no view associated 12 | * with it for now. It simply creates a new document. It could in the future 13 | * display a dialog where the user could chose options like document title and 14 | * such. 15 | * 16 | * @constructor 17 | */ 18 | mindmaps.NewDocumentPresenter = function(eventBus, mindmapModel, view) { 19 | 20 | this.go = function() { 21 | var doc = new mindmaps.Document(); 22 | mindmapModel.setDocument(doc); 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /src/js/NodeMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new NodeMap object. Map implementation for nodes. The key is 3 | * automatically set to the node id. 4 | * 5 | * @constructor 6 | */ 7 | mindmaps.NodeMap = function() { 8 | this.nodes = {}; 9 | this.count = 0; 10 | }; 11 | 12 | /** 13 | * Return a node by its ID. 14 | * 15 | * @param {String} nodeId 16 | * @returns {mindmaps.Node} 17 | */ 18 | mindmaps.NodeMap.prototype.get = function(nodeId) { 19 | return this.nodes[nodeId]; 20 | }; 21 | 22 | /** 23 | * Adds a node to the map if it hasn't been added before. 24 | * 25 | * @param {mindmaps.Node} node 26 | * @returns {Boolean} true if added, false otherwise. 27 | */ 28 | mindmaps.NodeMap.prototype.add = function(node) { 29 | if (!this.nodes.hasOwnProperty(node.id)) { 30 | this.nodes[node.id] = node; 31 | this.count++; 32 | return true; 33 | } 34 | return false; 35 | }; 36 | 37 | /** 38 | * Removes a node from the map. 39 | * 40 | * @param {mindmaps.Node} node 41 | * @returns {Boolean} true if removed, false otherwise. 42 | */ 43 | mindmaps.NodeMap.prototype.remove = function(node) { 44 | if (this.nodes.hasOwnProperty(node.id)) { 45 | delete this.nodes[node.id]; 46 | this.count--; 47 | return true; 48 | } 49 | return false; 50 | }; 51 | 52 | /** 53 | * Returns the number of nodes in the map. 54 | * 55 | * @returns {Number} 56 | */ 57 | mindmaps.NodeMap.prototype.size = function() { 58 | return this.count; 59 | }; 60 | 61 | /** 62 | * Returns all nodes in the map. 63 | * 64 | * @returns {Array} 65 | */ 66 | mindmaps.NodeMap.prototype.values = function() { 67 | return Object.keys(this.nodes).map(function(key) { 68 | return this.nodes[key]; 69 | }, this); 70 | }; 71 | 72 | /** 73 | * Iterator for nodes. 74 | * 75 | * @param {Function} callback, first argument should be the node. 76 | */ 77 | mindmaps.NodeMap.prototype.each = function(callback) { 78 | for ( var id in this.nodes) { 79 | callback(this.nodes[id]); 80 | } 81 | }; 82 | -------------------------------------------------------------------------------- /src/js/Point.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Point class. 3 | * 4 | * @constructor 5 | * @param {Number} [x=0] 6 | * @param {Number} [y=0] 7 | */ 8 | mindmaps.Point = function(x, y) { 9 | this.x = x || 0; 10 | this.y = y || 0; 11 | }; 12 | 13 | /** 14 | * Returns a new point object from generic obj. 15 | * 16 | * @static 17 | * @param obj 18 | * @returns {mindmaps.Point} 19 | */ 20 | mindmaps.Point.fromObject = function(obj) { 21 | return new mindmaps.Point(obj.x, obj.y); 22 | }; 23 | 24 | /** 25 | * Clones a the point. 26 | * 27 | * @returns {mindmaps.Point} 28 | */ 29 | mindmaps.Point.prototype.clone = function() { 30 | return new mindmaps.Point(this.x, this.y); 31 | }; 32 | 33 | /** 34 | * Adds a point to the point. 35 | * @param {mindmaps.Point} point 36 | */ 37 | mindmaps.Point.prototype.add = function(point) { 38 | this.x += point.x; 39 | this.y += point.y; 40 | }; 41 | 42 | /** 43 | * Returns a String representation. 44 | * @returns {String} 45 | */ 46 | mindmaps.Point.prototype.toString = function() { 47 | return "{x: " + this.x + " y: " + this.y + "}"; 48 | }; 49 | -------------------------------------------------------------------------------- /src/js/PrintController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | * @param {mindmaps.EventBus} eventBus 4 | * @param {mindmaps.CommandRegistry} commandRegistry 5 | * @param {mindmaps.MindMapModel} mindmapModel 6 | */ 7 | mindmaps.PrintController = function(eventBus, commandRegistry, mindmapModel) { 8 | var printCommand = commandRegistry.get(mindmaps.PrintCommand); 9 | printCommand.setHandler(doPrintDocument); 10 | 11 | var renderer = new mindmaps.StaticCanvasRenderer(); 12 | 13 | function doPrintDocument() { 14 | var $img = renderer.renderAsPNG(mindmapModel.getDocument()); 15 | $("#print-area").html($img); 16 | window.print(); 17 | 18 | // TODO chrome only: after print() opens a new tab, and one switches 19 | // back to the old tab the canvas container has scrolled top-left. 20 | } 21 | 22 | eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, function() { 23 | printCommand.setEnabled(false); 24 | }); 25 | 26 | eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, function() { 27 | printCommand.setEnabled(true); 28 | }); 29 | }; 30 | -------------------------------------------------------------------------------- /src/js/SaveDocument.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new SaveDocumentView. This view renders a dialog where the user can 3 | * save the mind map. 4 | * 5 | * @constructor 6 | */ 7 | mindmaps.SaveDocumentView = function() { 8 | var self = this; 9 | 10 | var $dialog = $("#template-save").tmpl().dialog({ 11 | autoOpen : false, 12 | modal : true, 13 | zIndex : 5000, 14 | width : 550, 15 | close : function() { 16 | // remove dialog from DOM 17 | $(this).dialog("destroy"); 18 | $(this).remove(); 19 | } 20 | }); 21 | 22 | 23 | var $saveCloudStorageButton = $("#button-save-cloudstorage").button().click( 24 | function() { 25 | if (self.cloudStorageButtonClicked) { 26 | self.cloudStorageButtonClicked(); 27 | } 28 | }); 29 | 30 | var $localSorageButton = $("#button-save-localstorage").button().click( 31 | function() { 32 | if (self.localStorageButtonClicked) { 33 | self.localStorageButtonClicked(); 34 | } 35 | }); 36 | 37 | var $autoSaveCheckbox = $("#checkbox-autosave-localstorage").click( 38 | function() { 39 | if (self.autoSaveCheckboxClicked) { 40 | self.autoSaveCheckboxClicked($(this).prop("checked")); 41 | } 42 | }); 43 | 44 | var $hddSaveButton = $("#button-save-hdd").button().click( 45 | function () { 46 | if (self.hddSaveButtonClicked) { 47 | self.hddSaveButtonClicked(); 48 | } 49 | }); 50 | 51 | this.setAutoSaveCheckboxState = function(checked) { 52 | $autoSaveCheckbox.prop("checked", checked); 53 | }; 54 | 55 | this.showSaveDialog = function() { 56 | $dialog.dialog("open"); 57 | }; 58 | 59 | this.hideSaveDialog = function() { 60 | $dialog.dialog("close"); 61 | }; 62 | 63 | this.showCloudError = function(msg) { 64 | $dialog.find('.cloud-loading').removeClass('loading'); 65 | $dialog.find('.cloud-error').text(msg); 66 | }; 67 | 68 | this.showCloudLoading = function() { 69 | $dialog.find('.cloud-error').text(''); 70 | $dialog.find('.cloud-loading').addClass('loading'); 71 | }; 72 | 73 | this.hideCloudLoading = function() { 74 | $dialog.find('.cloud-loading').removeClass('loading'); 75 | }; 76 | }; 77 | 78 | /** 79 | * Creates a new SaveDocumentPresenter. The presenter can store documents in the 80 | * local storage or to a hard disk. 81 | * 82 | * @constructor 83 | * @param {mindmaps.EventBus} eventBus 84 | * @param {mindmaps.MindMapModel} mindmapModel 85 | * @param {mindmaps.SaveDocumentView} view 86 | * @param {mindmaps.AutoSaveController} autosaveController 87 | * @param {mindmaps.FilePicker} filePicker 88 | */ 89 | mindmaps.SaveDocumentPresenter = function(eventBus, mindmapModel, view, autosaveController, filePicker) { 90 | 91 | /** 92 | * Save in cloud button was clicked. 93 | */ 94 | view.cloudStorageButtonClicked = function() { 95 | mindmaps.Util.trackEvent("Clicks", "cloud-save"); 96 | mindmaps.Util.trackEvent("CloudSave", "click"); 97 | 98 | filePicker.save({ 99 | load: function() { 100 | view.showCloudLoading(); 101 | }, 102 | cancel: function () { 103 | view.hideCloudLoading(); 104 | mindmaps.Util.trackEvent("CloudSave", "cancel"); 105 | }, 106 | success: function() { 107 | view.hideSaveDialog(); 108 | mindmaps.Util.trackEvent("CloudSave", "success"); 109 | }, 110 | error: function(msg) { 111 | view.showCloudError(msg); 112 | mindmaps.Util.trackEvent("CloudSave", "error", msg); 113 | } 114 | }); 115 | }; 116 | 117 | /** 118 | * View callback when local storage button was clicked. Saves the document 119 | * in the local storage. 120 | * 121 | * @ignore 122 | */ 123 | view.localStorageButtonClicked = function() { 124 | mindmaps.Util.trackEvent("Clicks", "localstorage-save"); 125 | 126 | var success = mindmapModel.saveToLocalStorage(); 127 | if (success) { 128 | view.hideSaveDialog(); 129 | } else { 130 | eventBus.publish(mindmaps.Event.NOTIFICATION_ERROR, "Error while saving to local storage"); 131 | } 132 | }; 133 | 134 | 135 | /** 136 | * View callback: Enables or disables the autosave function for localstorage. 137 | * 138 | * @ignore 139 | */ 140 | view.autoSaveCheckboxClicked = function(checked) { 141 | if (checked) { 142 | autosaveController.enable(); 143 | } else { 144 | autosaveController.disable(); 145 | } 146 | }; 147 | 148 | view.hddSaveButtonClicked = function() { 149 | mindmaps.Util.trackEvent("Clicks", "hdd-save"); 150 | 151 | var filename = mindmapModel.getMindMap().getRoot().getCaption() + ".json"; 152 | var content = mindmapModel.getDocument().prepareSave().serialize(); 153 | var blob = new Blob([content], {type: "text/plain;charset=utf-8"}); 154 | window.saveAs(blob, filename); 155 | 156 | var doc = mindmapModel.getDocument(); 157 | eventBus.publish(mindmaps.Event.DOCUMENT_SAVED, doc); 158 | view.hideSaveDialog(); 159 | }; 160 | 161 | this.go = function() { 162 | view.setAutoSaveCheckboxState(autosaveController.isEnabled()); 163 | view.showSaveDialog(); 164 | }; 165 | }; 166 | -------------------------------------------------------------------------------- /src/js/ShortcutController.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a new ShortcutController. This object takes care of all keyboard 3 | * shortcuts. 4 | * 5 | * @constructor 6 | */ 7 | mindmaps.ShortcutController = function() { 8 | // set to save shortcuts in 9 | /** 10 | * @private 11 | */ 12 | this.shortcuts = {}; 13 | 14 | /** 15 | * Set the event type and add namespace for later removal. 16 | * 17 | * @param {String} shortcut the key combination 18 | * @param {String} [type="keydown"] 19 | * @returns {String} 20 | */ 21 | function getType(shortcut, type) { 22 | type = type || "keydown"; 23 | return type + "." + shortcut; 24 | } 25 | 26 | /** 27 | * Registers a new application wide shortcut. shortcuts can be 28 | * either a string or an array containing multiple possible 29 | * shortcuts for the same action. 30 | * 31 | * @param {String|Array} shortcuts 32 | * @param {Function} handler 33 | * @param {String} [type="keydown"] 34 | */ 35 | this.register = function(shortcuts, handler, type) { 36 | if (!Array.isArray(shortcuts)) { 37 | shortcuts = [shortcuts]; 38 | } 39 | 40 | var self = this; 41 | shortcuts.forEach(function(shortcut) { 42 | type = getType(shortcut, type); 43 | $(document).bind(type, shortcut, function(e) { 44 | // try best to cancel default actions on shortcuts like ctrl+n 45 | e.stopImmediatePropagation(); 46 | e.stopPropagation(); 47 | e.preventDefault(); 48 | handler(); 49 | return false; 50 | self.shortcut[type] = true 51 | }); 52 | }); 53 | }; 54 | 55 | /** 56 | * Unregisters a application shortcut. 57 | * 58 | * @param {String} shortcut 59 | * @param {String} [type="keydown"] 60 | */ 61 | this.unregister = function(shortcut, type) { 62 | type = getType(shortcut, type); 63 | $(document).unbind(type); 64 | delete this.shortcuts[type]; 65 | }; 66 | 67 | /** 68 | * Removes all shortcuts. 69 | */ 70 | this.unregisterAll = function() { 71 | for ( var shortcut in shortcuts) { 72 | $(document).unbind(shortcut); 73 | } 74 | }; 75 | }; 76 | -------------------------------------------------------------------------------- /src/js/StatusBar.js: -------------------------------------------------------------------------------- 1 | // TODO Rename those objects to TaskBar* 2 | 3 | /** 4 | * Creates a new StatusBarView. 5 | * 6 | * @constructor 7 | */ 8 | mindmaps.StatusBarView = function() { 9 | var self = this; 10 | var $statusbar = $("#statusbar"); 11 | 12 | this.init = function() { 13 | }; 14 | 15 | /** 16 | * Creates and adds a new button to the stats baar. 17 | * 18 | * @param {String} id 19 | * @param {String} text 20 | * @returns {jQuery} 21 | */ 22 | this.createButton = function(id, text) { 23 | return $("