diff --git a/.gitignore b/.gitignore index 4fb38028a1d..2c4be5d288a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,6 @@ Thumbs.db /Source/Shaders/*/*/*.js !/Source/Shaders/Shaders.profile.js -/Specs/SpecList.js \ No newline at end of file +/Specs/SpecList.js + +/node_modules diff --git a/.project b/.project index 137f830461e..37192d9c9a9 100644 --- a/.project +++ b/.project @@ -32,7 +32,7 @@ - 1391456479002 + 1400616658988 10 @@ -41,7 +41,7 @@ - 1391456479007 + 1400616658995 10 @@ -50,7 +50,7 @@ - 1391456479012 + 1400616658999 6 @@ -59,7 +59,7 @@ - 1391456479018 + 1400616659006 10 @@ -67,6 +67,15 @@ 1.0-name-matches-false-false-.git + + 1400616659012 + + 10 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-node_modules + + 1336749023862 Source @@ -86,7 +95,7 @@ - 1348694184349 + 1400616508068 Tools 9 @@ -94,6 +103,15 @@ 1.0-name-matches-false-false-buildTasks + + 1400616508072 + Tools + 9 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-jsdoc + + 1360870693679 Apps/Sandcastle diff --git a/.settings/com.eclipsesource.jshint.ui.prefs b/.settings/com.eclipsesource.jshint.ui.prefs index 5d8e5b1f560..42fed44e830 100644 --- a/.settings/com.eclipsesource.jshint.ui.prefs +++ b/.settings/com.eclipsesource.jshint.ui.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -excluded=Apps/Sandcastle/ThirdParty//*\:Source/ThirdParty//*\:Source/Workers/cesiumWorkerBootstrapper.js\:ThirdParty//*\:Tools/build.js +excluded=Apps/Sandcastle/ThirdParty//*\:Source/ThirdParty//*\:Source/Workers/cesiumWorkerBootstrapper.js\:ThirdParty//*\:Tools/build.js\:Tools/jsdoc//* included=//*.js projectSpecificOptions=true diff --git a/CHANGES.md b/CHANGES.md index 4981cea1498..8f9597d956f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,7 +45,8 @@ Beta Releases * `Camera.transform` now works consistently across scene modes. * Fixed a bug that prevented `sampleTerrain` from working with STK World Terrain in Firefox. * `sampleTerrain` no longer fails when used with a `TerrainProvider` that is not yet ready. -* Updated Dojo from 1.9.1 to 1.9.3. NOTE: Dojo is only used in Sandcastle and not required by Cesium. +* Upgraded JSDoc from 3.0 to 3.3.0-alpha5. The Cesium reference documentation now has a slightly different look and feel. +* Upgraded Dojo from 1.9.1 to 1.9.3. NOTE: Dojo is only used in Sandcastle and not required by Cesium. ### b28 - 2014-05-01 diff --git a/Specs/SpecRunner.js b/Specs/SpecRunner.js index a18d2750172..a8d2e338c68 100644 --- a/Specs/SpecRunner.js +++ b/Specs/SpecRunner.js @@ -35,11 +35,7 @@ var afterAll; function getQueryParameter(name) { var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); - - if (match) { - return decodeURIComponent(match[1].replace(/\+/g, ' ')); - } - return null; + return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); } // patch in beforeAll/afterAll functions diff --git a/Tools/jsdoc/cesiumTags.js b/Tools/jsdoc/cesiumTags.js new file mode 100644 index 00000000000..7f5970b051c --- /dev/null +++ b/Tools/jsdoc/cesiumTags.js @@ -0,0 +1,39 @@ +exports.defineTags = function(dictionary) { + dictionary.lookUp('class').synonym('internalConstructor'); + + dictionary.defineTag('exports', { + mustHaveValue : true, + onTagged : function(doclet, tag) { + doclet.addTag('alias', tag.value); + doclet.addTag('kind', 'module'); + doclet.longname = tag.value; + } + }).synonym('enumeration'); + + dictionary.defineTag('glsl', { + onTagged : function(doclet, tag) { + doclet.addTag('kind', 'glsl'); + doclet.filename = doclet.name; + } + }).synonym('glslStruct').synonym('glslUniform').synonym('glslConstant').synonym('glslFunction'); + + dictionary.defineTag('performance', { + mustHaveValue : true, + onTagged : function(doclet, tag) { + if (!doclet.performance) { + doclet.performance = []; + } + doclet.performance.push(tag.value); + } + }); + + dictionary.defineTag('demo', { + mustHaveValue : true, + onTagged : function(doclet, tag) { + if (!doclet.demo) { + doclet.demo = []; + } + doclet.demo.push(tag.value); + } + }); +}; \ No newline at end of file diff --git a/Tools/jsdoc/cesium_template/publish.js b/Tools/jsdoc/cesium_template/publish.js new file mode 100644 index 00000000000..057013c3d0d --- /dev/null +++ b/Tools/jsdoc/cesium_template/publish.js @@ -0,0 +1,406 @@ +/*global env: true */ +'use strict'; + +var fs = require('jsdoc/fs'); +var helper = require('jsdoc/util/templateHelper'); +var logger = require('jsdoc/util/logger'); +var path = require('jsdoc/path'); +var taffy = require('taffydb').taffy; +var template = require('jsdoc/template'); +var util = require('util'); + +var htmlsafe = helper.htmlsafe; +var linkto = helper.linkto; +var resolveAuthorLinks = helper.resolveAuthorLinks; +var scopeToPunc = helper.scopeToPunc; +var hasOwnProp = Object.prototype.hasOwnProperty; + +var data; +var view; + +var outdir = env.opts.destination; + +function find(spec) { + return helper.find(data, spec); +} + +function tutoriallink(tutorial) { + return helper.toTutorial(tutorial, null, { tag: 'em', classname: 'disabled', prefix: 'Tutorial: ' }); +} + +function getAncestorLinks(doclet) { + return helper.getAncestorLinks(data, doclet); +} + +function hashToLink(doclet, hash) { + if ( !/^(#.+)/.test(hash) ) { return hash; } + + var url = helper.createLink(doclet); + + url = url.replace(/(#.+|$)/, hash); + return '' + hash + ''; +} + +function needsSignature(doclet) { + var needsSig = false; + + // function and class definitions always get a signature + if (doclet.kind === 'function' || doclet.kind === 'class') { + needsSig = true; + } + // typedefs that contain functions get a signature, too + else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names && + doclet.type.names.length) { + for (var i = 0, l = doclet.type.names.length; i < l; i++) { + if (doclet.type.names[i].toLowerCase() === 'function') { + needsSig = true; + break; + } + } + } + + return needsSig; +} + +function addSignatureParams(f) { + var params = helper.getSignatureParams(f, 'optional'); + + f.signature = (f.signature || '') + '('+params.join(', ')+')'; +} + +function addSignatureReturns(f) { + var returnTypes = helper.getSignatureReturns(f); + + f.signature = ''+(f.signature || '') + ''; + + if (returnTypes.length) { + f.signature += ' → '+(returnTypes.length ? returnTypes.join('|') : '')+''; + } +} + +function addSignatureTypes(f) { + var types = helper.getSignatureTypes(f); + + f.signature = (f.signature || '') + ''+(types.length? ' :'+types.join('|') : '')+''; +} + +function addAttribs(f) { + var attribs = helper.getAttribs(f); + + if (attribs.length) { + f.attribs = attribs.map(function(attrib) { + return '' + htmlsafe(attrib) + ''; + }).join(''); + } +} + +function shortenPaths(files, commonPrefix) { + Object.keys(files).forEach(function(file) { + files[file].shortened = files[file].resolved.replace(commonPrefix, '') + // always use forward slashes + .replace(/\\/g, '/'); + }); + + return files; +} + +function getPathFromDoclet(doclet) { + if (!doclet.meta) { + return null; + } + + return doclet.meta.path && doclet.meta.path !== 'null' ? + path.join(doclet.meta.path, doclet.meta.filename) : + doclet.meta.filename; +} + +function generate(title, docs, filename, resolveLinks) { + resolveLinks = resolveLinks === false ? false : true; + + var docData = { + filename: filename, + title: title, + docs: docs + }; + + var outpath = path.join(outdir, filename), + html = view.render('container.tmpl', docData); + + if (resolveLinks) { + html = helper.resolveLinks(html); // turn {@link foo} into foo + } + + fs.writeFileSync(outpath, html, 'utf8'); +} + +/** + * Look for classes or functions with the same name as modules (which indicates that the module + * exports only that class or function), then attach the classes or functions to the `module` + * property of the appropriate module doclets. The name of each class or function is also updated + * for display purposes. This function mutates the original arrays. + * + * @private + * @param {Array.} doclets - The array of classes and functions to + * check. + * @param {Array.} modules - The array of module doclets to search. + */ +function attachModuleSymbols(doclets, modules) { + var symbols = {}; + + // build a lookup table + doclets.forEach(function(symbol) { + symbols[symbol.longname] = symbol; + }); + + return modules.map(function(module) { + if (symbols[module.longname]) { + module.module = symbols[module.longname]; + module.module.name = module.module.name.replace('module:', 'require("') + '")'; + } + }); +} + +/** + * Create the navigation sidebar. + * @param {object} members The members that will be used to create the sidebar. + * @param {array} members.classes + * @param {array} members.externals + * @param {array} members.globals + * @param {array} members.mixins + * @param {array} members.modules + * @param {array} members.namespaces + * @param {array} members.tutorials + * @param {array} members.events + * @return {string} The HTML for the navigation sidebar. + */ +function buildNav(members) { + var nav = '
    ', + seen = {}, + hasClassList = false, + classNav = '', + globalNav = ''; + + var items = members.modules.concat(members.classes).sort(function(a, b) { + return a.longname.toLowerCase().localeCompare(b.longname.toLowerCase()); + }); + + if (items.length) { + items.forEach(function(m) { + if ( !hasOwnProp.call(seen, m.longname) ) { + nav += '
  • ' + linkto(m.longname, m.name) + '
  • '; + } + seen[m.longname] = true; + }); + + nav += '
'; + } + + return nav; +} + +/** + @param {TAFFY} taffyData See . + @param {object} opts + @param {Tutorial} tutorials + */ +exports.publish = function(taffyData, opts, tutorials) { + data = taffyData; + + var conf = env.conf.templates || {}; + conf['default'] = conf['default'] || {}; + + var templatePath = opts.template; + view = new template.Template(templatePath + '/tmpl'); + + // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness + // doesn't try to hand them out later + var indexUrl = helper.getUniqueFilename('index'); + // don't call registerLink() on this one! 'index' is also a valid longname + + var globalUrl = helper.getUniqueFilename('global'); + helper.registerLink('global', globalUrl); + + // set up templating + view.layout = 'layout.tmpl'; + + // set up tutorials for helper + helper.setTutorials(tutorials); + + data = helper.prune(data); + data.sort('longname, version, since'); + helper.addEventListeners(data); + + var sourceFiles = {}; + var sourceFilePaths = []; + data().each(function(doclet) { + doclet.attribs = ''; + + if (doclet.examples) { + doclet.examples = doclet.examples.map(function(example) { + var caption, code; + + if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) { + caption = RegExp.$1; + code = RegExp.$3; + } + + return { + caption: caption || '', + code: code || example + }; + }); + } + if (doclet.see) { + doclet.see.forEach(function(seeItem, i) { + doclet.see[i] = hashToLink(doclet, seeItem); + }); + } + + // build a list of source files + var sourcePath; + if (doclet.meta) { + sourcePath = getPathFromDoclet(doclet); + sourceFiles[sourcePath] = { + resolved: sourcePath, + shortened: null + }; + if (sourceFilePaths.indexOf(sourcePath) === -1) { + sourceFilePaths.push(sourcePath); + } + } + }); + + // update outdir if necessary, then create outdir + var packageInfo = ( find({kind: 'package'}) || [] ) [0]; + if (packageInfo && packageInfo.name) { + outdir = path.join(outdir, packageInfo.name, packageInfo.version); + } + fs.mkPath(outdir); + + // copy the template's static files to outdir + var fromDir = path.join(templatePath, 'static'); + var staticFiles = fs.ls(fromDir, 3); + + staticFiles.forEach(function(fileName) { + var toDir = fs.toDir( fileName.replace(fromDir, outdir) ); + fs.mkPath(toDir); + fs.copyFileSync(fileName, toDir); + }); + + if (sourceFilePaths.length) { + sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) ); + } + data().each(function(doclet) { + var url = helper.createLink(doclet); + helper.registerLink(doclet.longname, url); + + // replace the filename with a shortened version of the full path + var docletPath; + if (doclet.meta) { + docletPath = getPathFromDoclet(doclet); + docletPath = sourceFiles[docletPath].shortened; + if (docletPath) { + doclet.meta.filename = docletPath; + doclet.meta.sourceUrl = conf['sourceUrl'].replace('{version}', process.env.CESIUM_VERSION).replace('{filename}', docletPath); + } + } + }); + + data().each(function(doclet) { + var url = helper.longnameToUrl[doclet.longname]; + + if (url.indexOf('#') > -1) { + doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop(); + } + else { + doclet.id = doclet.name; + } + + if ( needsSignature(doclet) ) { + addSignatureParams(doclet); + addSignatureReturns(doclet); + addAttribs(doclet); + } + }); + + // do this after the urls have all been generated + data().each(function(doclet) { + doclet.ancestors = getAncestorLinks(doclet); + + if (doclet.kind === 'member') { + addSignatureTypes(doclet); + addAttribs(doclet); + } + + if (doclet.kind === 'constant') { + addSignatureTypes(doclet); + addAttribs(doclet); + doclet.kind = 'member'; + } + }); + + var members = helper.getMembers(data); + + // add template helpers + view.find = find; + view.linkto = linkto; + view.resolveAuthorLinks = resolveAuthorLinks; + view.tutoriallink = tutoriallink; + view.htmlsafe = htmlsafe; + + // once for all + view.nav = buildNav(members); + attachModuleSymbols( find({ kind: ['class', 'function'], longname: {left: 'module:'} }), + members.modules ); + + if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); } + + // index page displays information from package.json and lists files + var files = find({kind: 'file'}), + packages = find({kind: 'package'}); + + var origLayout = view.layout; + view.layout = 'indexLayout.tmpl'; + generate('Index', + packages.concat( + [{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}] + ).concat(files), + indexUrl); + view.layout = origLayout; + + // set up the lists that we'll use to generate pages + var classes = taffy(members.classes); + var modules = taffy(members.modules); + + var typesJson = {}; + + Object.keys(helper.longnameToUrl).forEach(function(longname) { + var items = helper.find(classes, {longname: longname}); + + if (!items.length) { + items = helper.find(modules, {longname: longname}); + } + + if (items.length) { + var title = items[0].name; + var filename = helper.longnameToUrl[longname]; + generate(title, items, filename); + + var titleLower = title.toLowerCase(); + + typesJson[titleLower] = typesJson[titleLower] || []; + typesJson[titleLower].push(filename); + + var members = find({kind: ['function','member'], memberof: longname}); + members.forEach(function(member) { + member = member.id; + var memberLower = member.toLowerCase(); + + typesJson[memberLower] = typesJson[memberLower] || []; + typesJson[memberLower].push(filename + '#' + member); + }); + } + }); + + fs.writeFileSync(outdir + '/types.txt', JSON.stringify(typesJson), 'utf8'); +}; diff --git a/Tools/jsdoc3/templates/default/static/icons/home.png b/Tools/jsdoc/cesium_template/static/icons/home.png similarity index 100% rename from Tools/jsdoc3/templates/default/static/icons/home.png rename to Tools/jsdoc/cesium_template/static/icons/home.png diff --git a/Tools/jsdoc3/templates/default/static/icons/popout.png b/Tools/jsdoc/cesium_template/static/icons/popout.png similarity index 100% rename from Tools/jsdoc3/templates/default/static/icons/popout.png rename to Tools/jsdoc/cesium_template/static/icons/popout.png diff --git a/Documentation/Images/CesiumLogo.jpg b/Tools/jsdoc/cesium_template/static/images/CesiumLogo.jpg similarity index 100% rename from Documentation/Images/CesiumLogo.jpg rename to Tools/jsdoc/cesium_template/static/images/CesiumLogo.jpg diff --git a/Tools/jsdoc/cesium_template/static/javascript/cesiumDoc.js b/Tools/jsdoc/cesium_template/static/javascript/cesiumDoc.js new file mode 100644 index 00000000000..db58288b08b --- /dev/null +++ b/Tools/jsdoc/cesium_template/static/javascript/cesiumDoc.js @@ -0,0 +1,61 @@ +(function() { + + SyntaxHighlighter.all(); + + var filterType = document.getElementById('filterType'); + var classFilter = document.getElementById('ClassFilter'); + var classList = document.getElementById('ClassList'); + + function filter() { + var value = classFilter.value.toLowerCase(); + + var items = classList.getElementsByTagName('li'); + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var itemName = item.getAttribute('data-name') || ''; + itemName = itemName.toLowerCase().replace(/\s/g, ''); + if (itemName.indexOf(value) >= 0) { + item.style.display = ''; + } else { + item.style.display = 'none'; + } + } + } + classFilter.onkeyup = filter; + + function getQueryParameter(name) { + var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); + return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); + } + + var show = getQueryParameter('show'); + if (show) { + document.getElementById('filterType').value = show; + } + + var searchTerm = getQueryParameter('classFilter') || ''; + classFilter.value = searchTerm; + filter(); + + function resetFilter() { + classFilter.value = ''; + filter(); + } + + function updateMenuLinks() { + var links = classList.getElementsByTagName('a'); + var searchTerm = classFilter.value; + for (var i = 0; i < links.length; i++) { + var link = links[i]; + var prefix = link.href.split('?')[0]; + link.href = prefix + (searchTerm === '' ? '' : '?classFilter=' + searchTerm); + } + } + + var menuLinks = classList.getElementsByTagName('a'); + for (var i = 0; i < menuLinks.length; i++) { + menuLinks[i].onclick = function() { + updateMenuLinks(); + } + } +})(); \ No newline at end of file diff --git a/Tools/jsdoc/cesium_template/static/javascript/html5.js b/Tools/jsdoc/cesium_template/static/javascript/html5.js new file mode 100644 index 00000000000..448cebd79e7 --- /dev/null +++ b/Tools/jsdoc/cesium_template/static/javascript/html5.js @@ -0,0 +1,8 @@ +/* + HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); +a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; +c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| +"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f); +if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d + + + + + +
- +
-

- - - - - -

-
+
- - + +
- + + +
Example 1? 's':'' ?>
- -
- +

Extends

- +
- +

Mixes In

- +
- +

Requires

- +
- +

Classes

- +
- +

Namespaces

- +
- +

Members

- +
- +

Methods

- +
- + -

TypeDefs

- -
- -
+

Type Definitions

+ +
+ + + +
- +

Events

- +
-
+ + + diff --git a/Tools/jsdoc/cesium_template/tmpl/details.tmpl b/Tools/jsdoc/cesium_template/tmpl/details.tmpl new file mode 100644 index 00000000000..041cb0768a9 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/details.tmpl @@ -0,0 +1,115 @@ +" + data.defaultvalue + ""; + defaultObjectClass = ' class="object-value"'; +} +?> +
+ + +
Properties:
+ +
+ + + + +
Version:
+
+ + + +
Since:
+
+ + + +
Inherited From:
+
  • + +
+ + + +
Deprecated:
  • Yes
    + + + +
    Author:
    +
    +
      +
    • +
    +
    + + + + + + + + +
    License:
    +
    + + + +
    Default Value:
    + > + + + +
    Example 1? 's':'' ?>
    + + + + +
    Tutorials:
    +
    +
      +
    • +
    +
    + + + +
    Demo:
    +
      +
    • +
    + + + +
    See:
    +
      +
    • +
    + + + +
    To Do:
    +
    +
      +
    • +
    +
    + + + + + +
    diff --git a/Tools/jsdoc3/templates/default/tmpl/example.tmpl b/Tools/jsdoc/cesium_template/tmpl/example.tmpl similarity index 61% rename from Tools/jsdoc3/templates/default/tmpl/example.tmpl rename to Tools/jsdoc/cesium_template/tmpl/example.tmpl index d45b405e6d7..e87caa5b72c 100644 --- a/Tools/jsdoc3/templates/default/tmpl/example.tmpl +++ b/Tools/jsdoc/cesium_template/tmpl/example.tmpl @@ -1,2 +1,2 @@ - +
    diff --git a/Tools/jsdoc3/templates/default/tmpl/examples.tmpl b/Tools/jsdoc/cesium_template/tmpl/examples.tmpl similarity index 59% rename from Tools/jsdoc3/templates/default/tmpl/examples.tmpl rename to Tools/jsdoc/cesium_template/tmpl/examples.tmpl index 5470fa75c2d..3ff18f6fc4a 100644 --- a/Tools/jsdoc3/templates/default/tmpl/examples.tmpl +++ b/Tools/jsdoc/cesium_template/tmpl/examples.tmpl @@ -1,10 +1,13 @@

    -
    +
    \ No newline at end of file diff --git a/Tools/jsdoc/cesium_template/tmpl/exceptions.tmpl b/Tools/jsdoc/cesium_template/tmpl/exceptions.tmpl new file mode 100644 index 00000000000..c9d877bf6ca --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/exceptions.tmpl @@ -0,0 +1,16 @@ + + +
    + : +
    + +
    + + + + + +
    + diff --git a/Tools/jsdoc/cesium_template/tmpl/indexLayout.tmpl b/Tools/jsdoc/cesium_template/tmpl/indexLayout.tmpl new file mode 100644 index 00000000000..03468fd3dad --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/indexLayout.tmpl @@ -0,0 +1,59 @@ + + + + + + <?js= (title ? (title + ' - ') : '') + 'Cesium Documentation' ?> + + + + + + + + + + + + +
    + +
    + + + + + +
    + Documentation generated by JSDoc +
    +
    + +
    + +
    + + + + + + + \ No newline at end of file diff --git a/Tools/jsdoc/cesium_template/tmpl/layout.tmpl b/Tools/jsdoc/cesium_template/tmpl/layout.tmpl new file mode 100644 index 00000000000..4b80a17ab46 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/layout.tmpl @@ -0,0 +1,76 @@ + + + + + + <?js= (title ? (title + ' - ') : '') + 'Cesium Documentation' ?> + + + + + + + + + + + + +
    + + + + + +
    + +

    + + + +
    + Documentation generated by JSDoc +
    +
    + +
    + +
    + + + + + + + \ No newline at end of file diff --git a/Tools/jsdoc/cesium_template/tmpl/mainpage.tmpl b/Tools/jsdoc/cesium_template/tmpl/mainpage.tmpl new file mode 100644 index 00000000000..64e9e5943a1 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/mainpage.tmpl @@ -0,0 +1,14 @@ + + + +

    + + + +
    +
    +
    + diff --git a/Tools/jsdoc/cesium_template/tmpl/members.tmpl b/Tools/jsdoc/cesium_template/tmpl/members.tmpl new file mode 100644 index 00000000000..456b0d95143 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/members.tmpl @@ -0,0 +1,32 @@ + +
    +
    +

    + +

    + +
    + + +

    + +
    +
    + +
    + +
    + + + +
    Fires:
    +
      +
    • +
    + + + +
    diff --git a/Tools/jsdoc/cesium_template/tmpl/method.tmpl b/Tools/jsdoc/cesium_template/tmpl/method.tmpl new file mode 100644 index 00000000000..d20d084f579 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/method.tmpl @@ -0,0 +1,98 @@ + +
    +
    +

    + +

    + +
    + + +

    + +
    +
    + + +
    + +
    + + + +
    Performance:
    +

    + + + +
    Type:
    +
      +
    • + +
    • +
    + + + +
    This:
    +
    + + + + + + + +
    Requires:
    +
      +
    • +
    + + + +
    Fires:
    +
      +
    • +
    + + + +
    Listens to Events:
    +
      +
    • +
    + + + +
    Listeners of This Event:
    +
      +
    • +
    + + + +
    Returns:
    + 1) { ?>
      +
    • +
    + + + + +
    Throws:
    +
      +
    • +
    + + + +
    diff --git a/Tools/jsdoc3/templates/default/tmpl/params.tmpl b/Tools/jsdoc/cesium_template/tmpl/params.tmpl similarity index 58% rename from Tools/jsdoc3/templates/default/tmpl/params.tmpl rename to Tools/jsdoc/cesium_template/tmpl/params.tmpl index 190a53c201f..a4056559952 100644 --- a/Tools/jsdoc3/templates/default/tmpl/params.tmpl +++ b/Tools/jsdoc/cesium_template/tmpl/params.tmpl @@ -1,11 +1,11 @@ - - - Name - - - Type - - - Argument - - - - Default - - - Description - - - - - + + Name + + + Type + + + Default + + + Description + + + + + - + params.forEach(function(param) { + if (!param) { return; } + ?> + - + - - - | - - - - - - - <optional>
    - - - - <nullable>
    - - + + - + + @@ -101,13 +80,25 @@ - - -
    Properties
    + + + + + optional + + + nullable + + + + repeatable + + + - - - + + + \ No newline at end of file diff --git a/Tools/jsdoc3/templates/default/tmpl/properties.tmpl b/Tools/jsdoc/cesium_template/tmpl/properties.tmpl similarity index 68% rename from Tools/jsdoc3/templates/default/tmpl/properties.tmpl rename to Tools/jsdoc/cesium_template/tmpl/properties.tmpl index 9ec1a99742a..58f412f2dc6 100644 --- a/Tools/jsdoc3/templates/default/tmpl/properties.tmpl +++ b/Tools/jsdoc/cesium_template/tmpl/properties.tmpl @@ -1,11 +1,11 @@ - - - Name - - - Type - - - Argument - - - - Default - - - Description - - - - - + + Name + + + Type + + + Attributes + + + + Default + + + Description + + + + + - + props.forEach(function(prop) { + if (!prop) { return; } + ?> + - + - - - | - + + + - + <optional>
    - + <nullable>
    - + @@ -101,12 +96,12 @@ - +
    Properties
    - - - + + + \ No newline at end of file diff --git a/Tools/jsdoc/cesium_template/tmpl/returns.tmpl b/Tools/jsdoc/cesium_template/tmpl/returns.tmpl new file mode 100644 index 00000000000..6f850151e07 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/returns.tmpl @@ -0,0 +1,8 @@ + +
    + +
    + diff --git a/Tools/jsdoc/cesium_template/tmpl/source.tmpl b/Tools/jsdoc/cesium_template/tmpl/source.tmpl new file mode 100644 index 00000000000..e559b5d1038 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/source.tmpl @@ -0,0 +1,8 @@ + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Tools/jsdoc3/templates/default/tmpl/tutorial.tmpl b/Tools/jsdoc/cesium_template/tmpl/tutorial.tmpl similarity index 85% rename from Tools/jsdoc3/templates/default/tmpl/tutorial.tmpl rename to Tools/jsdoc/cesium_template/tmpl/tutorial.tmpl index 783a8d24cd9..88a0ad52aa2 100644 --- a/Tools/jsdoc3/templates/default/tmpl/tutorial.tmpl +++ b/Tools/jsdoc/cesium_template/tmpl/tutorial.tmpl @@ -1,19 +1,19 @@
    - +
    0) { ?>
    • -
    +

    -
    +
    -
    + diff --git a/Tools/jsdoc/cesium_template/tmpl/type.tmpl b/Tools/jsdoc/cesium_template/tmpl/type.tmpl new file mode 100644 index 00000000000..ec2c6c0df72 --- /dev/null +++ b/Tools/jsdoc/cesium_template/tmpl/type.tmpl @@ -0,0 +1,7 @@ + + +| + \ No newline at end of file diff --git a/Tools/jsdoc/conf.json b/Tools/jsdoc/conf.json new file mode 100644 index 00000000000..ea37b973f97 --- /dev/null +++ b/Tools/jsdoc/conf.json @@ -0,0 +1,24 @@ +{ + "tags": { + "allowUnknownTags": false + }, + "source": { + "include": ["Source"], + "exclude": ["Source/ThirdParty", "Source/Workers/cesiumWorkerBootstrapper.js"], + "includePattern": ".+\\.js(doc)?$", + "excludePattern": "(^|\\/|\\\\)_" + }, + "plugins": ["cesiumTags"], + "templates": { + "cleverLinks": true, + "default": { + "outputSourceFiles": false + }, + "sourceUrl": "https://github.com/AnalyticalGraphicsInc/cesium/blob/{version}/Source/{filename}" + }, + "opts": { + "destination": "Build/Documentation", + "template": "cesium_template", + "recurse": true + } +} \ No newline at end of file diff --git a/Tools/jsdoc3/.gitignore b/Tools/jsdoc3/.gitignore deleted file mode 100644 index 24ec4d0815b..00000000000 --- a/Tools/jsdoc3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build-files/java/build -jsdoc.jar -test/tutorials/out \ No newline at end of file diff --git a/Tools/jsdoc3/HOW_TO_CONTRIBUTE.md b/Tools/jsdoc3/HOW_TO_CONTRIBUTE.md deleted file mode 100644 index 992136ce53d..00000000000 --- a/Tools/jsdoc3/HOW_TO_CONTRIBUTE.md +++ /dev/null @@ -1,69 +0,0 @@ -Pull Requests -------------- - -If you're thinking about making some changes, maybe fixing a bug, or adding a -snazzy new feature, first, thank you. Contributions are very welcome. Things -need to be manageable for the maintainers, however. So below you'll find **The -fastest way to get your pull request merged in.** Some things, particularly how -you set up your branches and work with git, are just suggestions, but pretty good -ones. - -1. **Create a remote to track the base jsdoc3/jsdoc repository** - This is just a convenience to make it easier to update your `````` - (more on that shortly). You would execute something like: - - git remote add base git://github.com/jsdoc3/jsdoc.git - - Here 'base' is the name of the remote. Feel free to use whatever you want. - -2. **Set up a tracking branch for the base repository** - We're gonna call this your ``````. You will only ever update - this branch by pulling from the 'base' remote. (as opposed to 'origin') - - git branch --track pullpost base/master - git checkout pullpost - - Here 'pullpost' is the name of the branch. Fell free to use whatever you want. - -3. **Create your change branch** - Once you are in ``````, make sure it's up to date, then create - a branch for your changes off of that one. - - git branch fix-for-issue-395 - git checkout fix-for-issue-395 - - Here 'fix-for-issue-395' is the name of the branch. Feel free to use whatever - you want. We'll call this the ``````. This is the branch that - you will eventually issue your pull request from. - - The purpose of these first three steps is to make sure that your merge request - has a nice clean diff that only involves the changes related to your fix/feature. - -4. **Make your changes** - On your `````` make any changes relevant to your fix/feature. Don't - group fixes for multiple unrelated issues or multiple unrelated features together. - Create a separate branch for each unrelated changeset. For instance, if you're - fixing a bug in the parser and adding some new UI to the default template, those - should be separate branches and merge requests. - -5. **Add tests** - Add tests for your change. If you are submitting a bugfix, include a test that - verifies the existence of the bug along with your fix. If you are submitting - a new feature, include tests that verify proper feature function, if applicable. - See the readme in the 'test' directory for more information - -6. **Commit and publish** - Commit your changes and publish your branch (or push it if it's already published) - -7. **Issue your pull request** - On github.com, switch to your `````` and click the 'Pull Request' - button. Enter some meaningful information about the pull request. If it's a bugfix, - that doesn't already have an issue associated with it, provide some info on what - situations that bug occurs in and a sense of it's severity. If it does already have - an issue, make sure the include the hash and issue number (e.g. '#100') so github - links it. - - If it's a feature, provide some context about the motivations behind the feature, - why it's important/useful/cool/necessary and what it does/how it works. Don't - worry about being too verbose. Folks will be much more amenable to reading through - your code if they know what its supposed to be about. diff --git a/Tools/jsdoc3/Jake/lib/mustache.js b/Tools/jsdoc3/Jake/lib/mustache.js deleted file mode 100644 index 60687a38e46..00000000000 --- a/Tools/jsdoc3/Jake/lib/mustache.js +++ /dev/null @@ -1,335 +0,0 @@ -/* - mustache.js — Logic-less templates in JavaScript - - See http://mustache.github.com/ for more info. -*/ - -var Mustache = function() { - var Renderer = function() {}; - - Renderer.prototype = { - otag: "{{", - ctag: "}}", - pragmas: {}, - buffer: [], - pragmas_implemented: { - "IMPLICIT-ITERATOR": true, - "ARRAY-ORDINALS": true // define #first? and #last? when looping arrays - }, - context: {}, - - render: function(template, context, partials, in_recursion) { - // reset buffer & set context - if(!in_recursion) { - this.context = context; - this.buffer = []; // TODO: make this non-lazy - } - - // fail fast - if(!this.includes("", template)) { - if(in_recursion) { - return template; - } else { - this.send(template); - return; - } - } - - template = this.render_pragmas(template); - var html = this.render_section(template, context, partials); - if(in_recursion) { - return this.render_tags(html, context, partials, in_recursion); - } - - this.render_tags(html, context, partials, in_recursion); - }, - - /* - Sends parsed lines - */ - send: function(line) { - if(line != "") { - this.buffer.push(line); - } - }, - - /* - Looks for %PRAGMAS - */ - render_pragmas: function(template) { - // no pragmas - if(!this.includes("%", template)) { - return template; - } - - var that = this; - var regex = new RegExp(this.otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" + - this.ctag); - return template.replace(regex, function(match, pragma, options) { - if(!that.pragmas_implemented[pragma]) { - throw({message: - "This implementation of mustache doesn't understand the '" + - pragma + "' pragma"}); - } - that.pragmas[pragma] = {}; - if(options) { - var opts = options.split("="); - that.pragmas[pragma][opts[0]] = opts[1]; - } - return ""; - // ignore unknown pragmas silently - }); - }, - - /* - Tries to find a partial in the curent scope and render it - */ - render_partial: function(name, context, partials) { - name = this.trim(name); - if(!partials || partials[name] === undefined) { - throw({message: "unknown_partial '" + name + "'"}); - } - if(typeof(context[name]) != "object") { - return this.render(partials[name], context, partials, true); - } - return this.render(partials[name], context[name], partials, true); - }, - - /* - Renders inverted (^) and normal (#) sections - */ - render_section: function(template, context, partials) { - if(!this.includes("#", template) && !this.includes("^", template)) { - return template; - } - - var that = this; - // CSW - Added "+?" so it finds the tighest bound, not the widest - var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag + - "\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag + - "\\s*", "mg"); - - // for each {{#foo}}{{/foo}} section do... - return template.replace(regex, function(match, type, name, content) { - var value = that.find(name, context); - if(type == "^") { // inverted section - if(!value || that.is_array(value) && value.length === 0) { - // false or empty list, render it - return that.render(content, context, partials, true); - } else { - return ""; - } - } else if(type == "#") { // normal section - if(that.is_array(value)) { // Enumerable, Let's loop! - var len = value.length; - return value.map(function(row, i) { - return that.render(content, that.create_context(row, {first: i === 0, last: i === len-1}), - partials, true); - }).join(""); - } else if(that.is_object(value)) { // Object, Use it as subcontext! - return that.render(content, that.create_context(value), - partials, true); - } else if(typeof value === "function") { - // higher order section - return value.call(context, content, function(text) { - return that.render(text, context, partials, true); - }); - } else if(value) { // boolean section - return that.render(content, context, partials, true); - } else { - return ""; - } - } - }); - }, - - /* - Replace {{foo}} and friends with values from our view - */ - render_tags: function(template, context, partials, in_recursion) { - // tit for tat - var that = this; - - var new_regex = function() { - return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" + - that.ctag + "+", "g"); - }; - - var regex = new_regex(); - var tag_replace_callback = function(match, operator, name) { - switch(operator) { - case "!": // ignore comments - return ""; - case "=": // set new delimiters, rebuild the replace regexp - that.set_delimiters(name); - regex = new_regex(); - return ""; - case ">": // render partial - return that.render_partial(name, context, partials); - case "{": // the triple mustache is unescaped - return that.find(name, context); - default: // escape the value - return that.escape(that.find(name, context)); - } - }; - var lines = template.split("\n"); - for(var i = 0; i < lines.length; i++) { - lines[i] = lines[i].replace(regex, tag_replace_callback, this); - if(!in_recursion) { - this.send(lines[i]); - } - } - - if(in_recursion) { - return lines.join("\n"); - } - }, - - set_delimiters: function(delimiters) { - var dels = delimiters.split(" "); - this.otag = this.escape_regex(dels[0]); - this.ctag = this.escape_regex(dels[1]); - }, - - escape_regex: function(text) { - // thank you Simon Willison - if(!arguments.callee.sRE) { - var specials = [ - '/', '.', '*', '+', '?', '|', - '(', ')', '[', ']', '{', '}', '\\' - ]; - arguments.callee.sRE = new RegExp( - '(\\' + specials.join('|\\') + ')', 'g' - ); - } - return text.replace(arguments.callee.sRE, '\\$1'); - }, - - /* - find `name` in current `context`. That is find me a value - from the view object - */ - find: function(name, context) { - name = this.trim(name); - - // Checks whether a value is thruthy or false or 0 - function is_kinda_truthy(bool) { - return bool === false || bool === 0 || bool; - } - - var value; - if(is_kinda_truthy(context[name])) { - value = context[name]; - } else if(is_kinda_truthy(this.context[name])) { - value = this.context[name]; - } - - if(typeof value === "function") { - return value.apply(context); - } - if(value !== undefined) { - return value; - } - // silently ignore unkown variables - return ""; - }, - - // Utility methods - - /* includes tag */ - includes: function(needle, haystack) { - return haystack.indexOf(this.otag + needle) != -1; - }, - - /* - Does away with nasty characters - */ - escape: function(s) { - s = String(s === null ? "" : s); - return s.replace(/&(?!\w+;)|["'<>\\]/g, function(s) { - switch(s) { - case "&": return "&"; - case "\\": return "\\\\"; - case '"': return '"'; - case "'": return '''; - case "<": return "<"; - case ">": return ">"; - default: return s; - } - }); - }, - - // by @langalex, support for arrays of strings - create_context: function(_context, opts) { - if(this.is_object(_context)) { - if (this.pragmas["ARRAY-ORDINALS"] && opts) { - _context['first?'] = opts.first || false; - _context['last?'] = opts.last || false; - } - return _context; - } else { - var iterator = "."; - if(this.pragmas["IMPLICIT-ITERATOR"]) { - iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator; - } - var ctx = {}; - ctx[iterator] = _context; - if (this.pragmas["ARRAY-ORDINALS"] && opts){ - ctx['first?'] = opts.first || false; - ctx['last?'] = opts.last || false; - } - return ctx; - } - }, - - is_object: function(a) { - return a && typeof a == "object"; - }, - - is_array: function(a) { - return Object.prototype.toString.call(a) === '[object Array]'; - }, - - /* - Gets rid of leading and trailing whitespace - */ - trim: function(s) { - return s.replace(/^\s*|\s*$/g, ""); - }, - - /* - Why, why, why? Because IE. Cry, cry cry. - */ - map: function(array, fn) { - if (typeof array.map == "function") { - return array.map(fn); - } else { - var r = []; - var l = array.length; - for(var i = 0; i < l; i++) { - r.push(fn(array[i])); - } - return r; - } - } - }; - - return({ - name: "mustache.js", - version: "0.3.1-dev", - - /* - Turns a template and view into HTML - */ - to_html: function(template, view, partials, send_fun) { - var renderer = new Renderer(); - if(send_fun) { - renderer.send = send_fun; - } - renderer.render(template, view, partials); - if(!send_fun) { - return renderer.buffer.join("\n"); - } - } - }); -}(); \ No newline at end of file diff --git a/Tools/jsdoc3/Jake/templates/package.json.tmpl b/Tools/jsdoc3/Jake/templates/package.json.tmpl deleted file mode 100644 index 38b0ee93a8d..00000000000 --- a/Tools/jsdoc3/Jake/templates/package.json.tmpl +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "{{appname}}", - "version": "{{appversion}}", - "revision": "{{timestamp}}", - "description": "An automatic documentation generator for javascript.", - "keywords": [ "documentation", "javascript" ], - "licenses": [ - { - "type": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0" - } - ], - "repositories": [ - { - "type": "git", - "url": "https://github.com/jsdoc3/jsdoc" - } - ], - "bugs": "https://github.com/jsdoc3/jsdoc/issues", - "contributors" : [ - { - "name": "Michael Mathews", - "email": "micmath@gmail.com" - }, - { - "name": "Rafa\u0105 Wrzeszcz", - "email": "rafal.wrzeszcz@wrzasq.pl" - }, - { - "name": "Jannon Frank", - "email": "jannon@jannon.net" - } - ], - "maintainers": [ - { - "name": "Michael Mathews", - "email": "micmath@gmail.com" - }, - { - "name": "Jannon Frank", - "email": "jannon@jannon.net" - } - ] -} diff --git a/Tools/jsdoc3/Jakefile.js b/Tools/jsdoc3/Jakefile.js deleted file mode 100644 index a168e7a3280..00000000000 --- a/Tools/jsdoc3/Jakefile.js +++ /dev/null @@ -1,73 +0,0 @@ -// see: https://github.com/mde/jake - -desc('Updating package.json revision.'); -task('default', [], function(params) { - var fs = require('fs'), sys = require('sys'); - - // import the Mustache template tool - eval(fs.readFileSync('Jake/lib/mustache.js', 'utf8')); - - var templates = { - packagejson : fs.readFileSync('Jake/templates/package.json.tmpl', 'utf8') - }; - - var metadata = { - appname : 'JSDoc', - appversion : '3.0.0', - timestamp : '' + new Date().getTime() - }; - - var outdir = './'; - - var rendered = Mustache.to_html(templates.packagejson, metadata); - - fs.writeFileSync(outdir + 'package.json', rendered, 'utf8'); - - process.exit(0); - -}); - -desc('Installs a plugin/template.'); -task('install', [], function(loc) { - var fs = require('fs'), util = require('util'), path = require('path'), wrench = require('wrench/wrench'); - - if(!loc) { - fail("You must specify the location of the plugin/template."); - } - - if(!path.existsSync(loc)) { - fail("plugin/template location [" + loc + "] is not valid."); - } - - var pluginLoc = path.join(loc, "plugins"), templateLoc = path.join(loc, "templates"), jsdocLoc = process.cwd(), name, config; - - //First the plugin - if(path.existsSync(pluginLoc)) { - //copy it over - wrench.copyDirSyncRecursive(pluginLoc, path.join(jsdocLoc, "plugins"), { - preserve : true - }); - //find out what it's called - name = fs.readdirSync(pluginLoc)[0].replace(".js", ""); - //And finally edit the conf.json - try { - config = JSON.parse(fs.readFileSync(path.join(jsdocLoc, 'conf.json'), 'utf8')); - if(config.plugins.indexOf('plugins/' + name) == -1) { - config.plugins.push('plugins/' + name); - fs.writeFileSync(path.join(jsdocLoc, 'conf.json'), JSON.stringify(config, null, " "), 'utf8'); - } - } catch (e) { - fail("Could not edit the conf.json file: " + e); - } - } - - //Then the template - if(path.existsSync(pluginLoc)) { - wrench.copyDirSyncRecursive(templateLoc, path.join(jsdocLoc, "templates"), { - preserve : true - }); - } - - process.exit(0); - -}); \ No newline at end of file diff --git a/Tools/jsdoc3/LICENSE.md b/Tools/jsdoc3/LICENSE.md deleted file mode 100644 index e9244005000..00000000000 --- a/Tools/jsdoc3/LICENSE.md +++ /dev/null @@ -1,136 +0,0 @@ -License -======= - -JSDoc 3 is free software, licensed under the Apache License, -Version 2.0 (the "License"); you MAY NOT use this software except in -compliance with the License. You have permission to use it for commercial, -non-commercial, or any other purpose you like, according to the -License below. - -Copyright (c) 2011 Michael Mathews -All rights reserved. - -You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the License for the specific language governing -permissions and limitations under the License. - -You may obtain the source code for JSDoc 3 at -https://github.com/micmath/JSDoc - - -In Addition -=========== - -Third party software is included, used-by or distributed along -with JSDoc 3. Each is provided under its own license and has source -available from other locations. - - -Rhino ----- - -Rhino is open source and licensed by Mozilla under the MPL 1.1 or -later/GPL 2.0 or later licenses. - -https://developer.mozilla.org/en/Rhino_License - -You may obtain the source code for Rhino from the Mozilla web site at -http://www.mozilla.org/rhino/download.html - -markdown-js ----- - -markdown-js is released under the MIT license. You may obtain a copy of the -License at http://www.opensource.org/licenses/mit-license.php - -Copyright (c) 2009-2010 Dominic Baggott -Copyright (c) 2009-2010 Ash Berlin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -You may obtain the source code for markdown-js at -https://github.com/evilstreak/markdown-js - -sqlitejdbc (build/java/classes/sqlitejdbc-v054.jar) ----- - -Copyright (c) 2007 David Crawshaw - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -You may obtain the source code for sqlitejdbc at -https://github.com/crawshaw/sqlitejdbc - -Underscore Template ----- - -Underscore.js 1.1.4 - -Copyright (c) 2011 Jeremy Ashkenas, DocumentCloud Inc. - -Underscore is freely distributable under the MIT license. -Portions of Underscore are inspired or borrowed from Prototype, -Oliver Steele's Functional, and John Resig's Micro-Templating. - -For all details and documentation: -http://documentcloud.github.com/underscore/#template - -TaffyDB ----- - -Copyright (c) 2008 All rights reserved. - -Software License Agreement (BSD License) - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following condition is met: - -Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -You may obtain the source code for TaffyDB at -https://github.com/typicaljoe/taffydb \ No newline at end of file diff --git a/Tools/jsdoc3/README.md b/Tools/jsdoc3/README.md deleted file mode 100644 index 33ef68ed4d6..00000000000 --- a/Tools/jsdoc3/README.md +++ /dev/null @@ -1,95 +0,0 @@ -JSDoc 3 -======= - -An inline API documentation processor for JavaScript. JSDoc 3 is intended to be -an upgrade to JsDoc Toolkit (JSDoc 2). - -Notice ------- - -This is *beta software*! It is available for testing purposes and may not be -suitable for production use yet. - -Installation ------------- - -Download a copy of JSDoc 3 from the official Git Hub repository here: - - -To test that jsdoc is working, change your working directory to the jsdoc folder -and run the following command: - - java -cp lib/js.jar org.mozilla.javascript.tools.shell.Main \ - -modules node_modules -modules rhino_modules \ - jsdoc.js -T - -If you are operating on a Mac OSX or *nix platform, you can shorten that command -to this: - - ./jsdoc -T - -Usage ------ - -This example assumes that your working directory is the jsdoc application base -directory: - - ./jsdoc yourSourceCodeFile.js - -For help regarding the supported commandline options use the --help option. - - ./jsdoc --help - -Generated documentation will appear in the folder specified by the --destination -option, or in a folder named "out" by default. - -Dependencies ------------- - -JSDoc 3 utilises the Mozilla Rhino engine, which requires Java. JSDoc 3 is known -to work with version 1.6.0_24 of Java. - -JSDoc 3 uses advanced features in the Rhino application which are only -available in or after the 1.7 release 3. A copy of this version of Rhino is -included in JSDoc so this is not normally an issue that the user needs to be -concerned with. However, in rare cases, users may have their Java CLASSPATH -configured to override that included Rhino and point to some older version of -Rhino instead. If this is the case, simply correct the CLASSPATH to remove the -older Rhino. - -The version of rhino distributed with JSDoc3 can be found here: https://github.com/jannon/rhino - -Debugging ---------- - -Rhino is not always very friendly when it comes to reporting errors in -JavaScript. Luckily it comes with a full-on debugger included that can be much -more useful than a simple stack trace. To invoke JSDoc with the debugger try the -following command: - - $ java -classpath lib/js.jar \ - org.mozilla.javascript.tools.debugger.Main -debug \ - -modules node_modules -modules rhino_modules \ - jsdoc.js \ - your/script.js - -This will open a debugging window. Choose "Break on Exceptions" from the "Debug" -menu, then press the "Run" button. If there is an error, you should see exactly -where it is in the source code. - -See Also --------- - -Project Documentation: (under development) -Project Documentation Source: -JSDoc User's Group: -JSDoc3 Ant Task -Project Annoncements: - -License -------- - -JSDoc 3 is copyright (c) 2011 Michael Mathews - -See file "LICENSE.md" in this distribution for more details about -terms of use. \ No newline at end of file diff --git a/Tools/jsdoc3/changes.md b/Tools/jsdoc3/changes.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/conf.json b/Tools/jsdoc3/conf.json deleted file mode 100644 index 1a602ca0a2f..00000000000 --- a/Tools/jsdoc3/conf.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "tags": { - "allowUnknownTags": true - }, - "source": { - "includePattern": ".+\\.js(doc)?$", - "excludePattern": "(^|\\/)_" - }, - "plugins": ["plugins/customTags"], - "jsVersion": 180 -} \ No newline at end of file diff --git a/Tools/jsdoc3/conf.json.EXAMPLE b/Tools/jsdoc3/conf.json.EXAMPLE deleted file mode 100644 index 3d669f099f9..00000000000 --- a/Tools/jsdoc3/conf.json.EXAMPLE +++ /dev/null @@ -1,11 +0,0 @@ -{ - "tags": { - "allowUnknownTags": true - }, - "source": { - "includePattern": ".+\\.js(doc)?$", - "excludePattern": "(^|\\/)_" - }, - "plugins": [], - "jsVersion": 180 -} \ No newline at end of file diff --git a/Tools/jsdoc3/jsdoc b/Tools/jsdoc3/jsdoc deleted file mode 100644 index dd161e05f50..00000000000 --- a/Tools/jsdoc3/jsdoc +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# rhino discards the path to the current script file, so we must add it back -SOURCE="$0" -while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done -BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -if test $1 = "--debug" -then - echo "Running Debug" - CMD="org.mozilla.javascript.tools.debugger.Main -debug" - shift -else - CMD="org.mozilla.javascript.tools.shell.Main" -fi - -#Conditionally execute different command lines depending on whether we're running tests or not -if test $1 = "-T" -then - echo "Running Tests" - java -classpath ${BASEDIR}/lib/js.jar ${CMD} -opt -1 -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@ -else - # normal mode should be quiet - java -classpath ${BASEDIR}/lib/js.jar ${CMD} -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@ -fi - -#java -classpath ${BASEDIR}/lib/js.jar ${CMD} -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@ \ No newline at end of file diff --git a/Tools/jsdoc3/jsdoc.cmd b/Tools/jsdoc3/jsdoc.cmd deleted file mode 100644 index 0744b884e83..00000000000 --- a/Tools/jsdoc3/jsdoc.cmd +++ /dev/null @@ -1,23 +0,0 @@ -@ECHO OFF - -SETLOCAL - -REM jsdoc.js expects Unix-style paths without a trailing slash -SET _BASEPATH=%~dp0 -SET _BASEPATH=%_BASEPATH:\=/% -SET _BASEPATH=%_BASEPATH:~0,-1% - -REM for whatever reason, Rhino requires module paths to be valid URIs -SET _URLPATH=file:/%_BASEPATH% - -:ESCAPE_SPACE -SET _TRAILING=%_URLPATH:* =% -CALL SET _URLPATH=%%_URLPATH: %_TRAILING%=%% -SET _URLPATH=%_URLPATH%%%20%_TRAILING% -IF NOT "%_URLPATH%"=="%_URLPATH: =%" GOTO ESCAPE_SPACE - -java -classpath "%_BASEPATH%/lib/js.jar" org.mozilla.javascript.tools.shell.Main -modules "%_URLPATH%/node_modules" -modules "%_URLPATH%/rhino_modules" -modules "%_URLPATH%" "%_BASEPATH%/jsdoc.js" %* --dirname="%_BASEPATH%/ - -REM java -classpath "%_BASEPATH%/lib/js.jar" org.mozilla.javascript.tools.debugger.Main -debug -modules "%_URLPATH%/node_modules/" -modules "%_URLPATH%/rhino_modules/" -modules "%_URLPATH%/" "%_BASEPATH%/jsdoc.js" %* --dirname="%_BASEPATH%/ - -ENDLOCAL diff --git a/Tools/jsdoc3/jsdoc.js b/Tools/jsdoc3/jsdoc.js deleted file mode 100644 index 798b25ef9ec..00000000000 --- a/Tools/jsdoc3/jsdoc.js +++ /dev/null @@ -1,307 +0,0 @@ -/** - * @project jsdoc - * @author Michael Mathews - * @license See LICENSE.md file included in this distribution. - */ - -// try: $ java -classpath build-files/java/classes/js.jar org.mozilla.javascript.tools.shell.Main main.js `pwd` script/to/parse.js - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// - -/** The absolute path to the base directory of the jsdoc application. - @type string - @global - */ -__dirname = '.', -args = Array.prototype.slice.call(arguments, 0); - -// rhino has no native way to get the base dirname of the currently running script -// so this information must be manually passed in from the command line -for (var i = 0; i < args.length; i++) { - if ( /^--dirname(?:=(.+?)(\/|\/\.)?)?$/i.test(args[i]) ) { - if (RegExp.$1) { - __dirname = RegExp.$1; // last wins - args.splice(i--, 1); // remove --dirname opt from arguments - } - else { - __dirname = args[i + 1]; - args.splice(i--, 2); - } - } -} - -load(__dirname + '/lib/rhino-shim.js'); - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// - - -/** Data representing the environment in which this app is running. - @namespace -*/ -env = { - /** Running start and finish times. */ - run: { - start: new Date(), - finish: null - }, - - /** - The command line arguments passed into jsdoc. - @type Array - */ - args: Array.prototype.slice.call(args, 0), - - - /** - The parsed JSON data from the configuration file. - @type Object - */ - conf: {}, - - /** - The command line arguments, parsed into a key/value hash. - @type Object - @example if (env.opts.help) { print 'Helpful message.'; } - */ - opts: {} -}; - -/** - Data that must be shared across the entire application. - @namespace -*/ -app = { - jsdoc: { - scanner: new (require('jsdoc/src/scanner').Scanner)(), - parser: new (require('jsdoc/src/parser').Parser)(), - name: require('jsdoc/name') - } -} - -try { main(); } -catch(e) { - if (e.rhinoException != null) { - e.rhinoException.printStackTrace(); - } else { - throw e; - } -} -finally { env.run.finish = new Date(); } - -/** Print string/s out to the console. - @param {string} ... String/s to print out to console. - */ -function print() { - for (var i = 0, leni = arguments.length; i < leni; i++) { - java.lang.System.out.println('' + arguments[i]); - } -} - -/** - Try to recursively print out all key/values in an object. - @global - @param {Object} ... Object/s to dump out to console. - */ -function dump() { - for (var i = 0, leni = arguments.length; i < leni; i++) { - print( require('jsdoc/util/dumper').dump(arguments[i]) ); - } -} - -/** @global - @param {string} filepath The path to the script file to include (read and execute). -*/ -function include(filepath) { - try { - if (filepath.indexOf('/') === 0) { - load(filepath); - } - else { - load(__dirname + '/' + filepath); - } - } - catch (e) { - console.log('Cannot include "' + __dirname + '/' + filepath + '": '+e); - } -} - -/** - Cause the VM running jsdoc to exit running. - @param {number} [n = 0] The exit status. - */ -function exit(n) { - n = n || 0; - java.lang.System.exit(n); -} - -function installPlugins(plugins, p) { - var dictionary = require('jsdoc/tag/dictionary'), - parser = p || app.jsdoc.parser; - - // allow user-defined plugins to... - for (var i = 0, leni = plugins.length; i < leni; i++) { - var plugin = require(plugins[i]); - - //...register event handlers - if (plugin.handlers) { - for (var eventName in plugin.handlers) { - parser.on(eventName, plugin.handlers[eventName]); - } - } - - //...define tags - if (plugin.defineTags) { - plugin.defineTags(dictionary); - } - - //...add a node visitor - if (plugin.nodeVisitor) { - parser.addNodeVisitor(plugin.nodeVisitor); - } - } -} - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// - - -/** - Run the jsoc application. - */ -function main() { - var sourceFiles, - packageJson, - docs, - jsdoc = { - opts: { - parser: require('jsdoc/opts/parser'), - } - }, - resolver, - fs = require('fs'); - - env.opts = jsdoc.opts.parser.parse(env.args); - - try { - env.conf = JSON.parse( - fs.readFileSync( env.opts.configure || __dirname + '/conf.json' ) - ); - } - catch (e) { - try { - //Try to copy over the example conf - var example = fs.readFileSync(__dirname + '/conf.json.EXAMPLE', 'utf8'); - fs.writeFileSync(__dirname + '/conf.json', example, 'utf8'); - env.conf = JSON.parse(example); - } - catch(e) { - throw('Configuration file cannot be evaluated. ' + e); - } - } - - // allow to pass arguments from configuration file - if (env.conf.opts) { - for (var opt in env.conf.opts) { - // arguments passed in command are more important - if (!(opt in env.opts)) { - env.opts[opt] = env.conf.opts[opt]; - } - } - // command file list is concatenated after conf list - if( env.conf.opts._ ){ - env.opts._ = env.conf.opts._.concat( env.opts._ ); - } - } - - if (env.opts.query) { - env.opts.query = require('common/query').toObject(env.opts.query); - } - - // which version of javascript will be supported? (rhino only) - if (typeof version === 'function') { - version(env.conf.jsVersion || 180); - } - - if (env.opts.help) { - console.log( jsdoc.opts.parser.help() ); - exit(0); - } else if (env.opts.test) { - include('test/runner.js'); - exit(0); - } - - if (env.conf.plugins) { - installPlugins(env.conf.plugins); - } - - // any source file named package.json is treated special - for (var i = 0, l = env.opts._.length; i < l; i++ ) { - if (/\bpackage\.json$/i.test(env.opts._[i])) { - packageJson = require('fs').readFileSync( env.opts._[i] ); - env.opts._.splice(i--, 1); - } - } - - if (env.opts._.length > 0) { // are there any files to scan and parse? - - var includeMatch = (env.conf.source && env.conf.source.includePattern)? new RegExp(env.conf.source.includePattern) : null, - excludeMatch = (env.conf.source && env.conf.source.excludePattern)? new RegExp(env.conf.source.excludePattern) : null; - - sourceFiles = app.jsdoc.scanner.scan(env.opts._, (env.opts.recurse? 10 : undefined), includeMatch, excludeMatch); - - require('jsdoc/src/handlers').attachTo(app.jsdoc.parser); - - docs = app.jsdoc.parser.parse(sourceFiles, env.opts.encoding); - - //The files are ALWAYS useful for the templates to have - //If there is no package.json, just create an empty package - var packageDocs = new (require('jsdoc/package').Package)(packageJson); - packageDocs.files = sourceFiles || []; - docs.push(packageDocs); - - function indexAll(docs) { - var lookupTable = {}; - - docs.forEach(function(doc) { - if ( !lookupTable.hasOwnProperty(doc.longname) ) { - lookupTable[doc.longname] = []; - } - lookupTable[doc.longname].push(doc); - }); - docs.index = lookupTable; - } - - indexAll(docs); - - require('jsdoc/augment').addInherited(docs); - require('jsdoc/borrow').resolveBorrows(docs); - - if (env.opts.explain) { - console.log(docs); - exit(0); - } - - // load this module anyway to ensure root instance exists - // it's not a problem since without tutorials root node will have empty children list - resolver = require('jsdoc/tutorial/resolver'); - - if (env.opts.tutorials) { - resolver.load(env.opts.tutorials); - resolver.resolve(); - } - - env.opts.template = env.opts.template || 'templates/default'; - - // should define a global "publish" function - include(env.opts.template + '/publish.js'); - - if (typeof publish === 'function') { - publish( - new (require('typicaljoe/taffy'))(docs), - env.opts, - resolver.root - ); - } - else { // TODO throw no publish warning? - } - } -} diff --git a/Tools/jsdoc3/lib/js.jar b/Tools/jsdoc3/lib/js.jar deleted file mode 100644 index 2714a90f651..00000000000 Binary files a/Tools/jsdoc3/lib/js.jar and /dev/null differ diff --git a/Tools/jsdoc3/lib/rhino-shim.js b/Tools/jsdoc3/lib/rhino-shim.js deleted file mode 100644 index 08cdda85a8d..00000000000 --- a/Tools/jsdoc3/lib/rhino-shim.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - @overview A minimal emulation of the standard features of nodejs necessary - to get jsdoc to run. - */ - -/** - Emulate nodejs console functions. - @see http://nodejs.org/docs/v0.4.8/api/stdio.html - */ -console = { - log: function(/*...*/) { - var args = Array.prototype.slice.call(arguments, 0), - dumper = dumper || require('jsdoc/util/dumper'); - - for (var i = 0, len = args.length; i < len; i++) { - if (typeof args[i] !== 'string') { - args[i] = dumper.dump(args[i]); - } - } - - print( args.join(' ') ); - } -}; - -/** - Emulate nodejs process functions. - @see http://nodejs.org/docs/v0.4.8/api/process.html - */ -process = { - exit: function(n) { - n = n || 0; - java.lang.System.exit(n); - }, - argv: [__dirname + '/jsdoc.js'].concat(Array.prototype.slice.call(arguments, 0)) -}; diff --git a/Tools/jsdoc3/node_modules/common/args.js b/Tools/jsdoc3/node_modules/common/args.js deleted file mode 100644 index 9332dfd388f..00000000000 --- a/Tools/jsdoc3/node_modules/common/args.js +++ /dev/null @@ -1,161 +0,0 @@ -/** - Parse the command line arguments. - @module common/args - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ -(function() { - - /** - Create an instance of the parser. - @classdesc A parser to interpret the key value pairs entered on the command - line. - @constructor - */ - exports.ArgParser = function() { - this._options = []; - this._shortNameIndex = {}; - this._longNameIndex = {}; - }; - - exports.ArgParser.prototype._getOptionByShortName = function(name) { - if (this._shortNameIndex.hasOwnProperty(name)) { - return this._options[this._shortNameIndex[name]]; - } - return null; - }; - - exports.ArgParser.prototype._getOptionByLongName = function(name) { - if (this._longNameIndex.hasOwnProperty(name)) { - return this._options[this._longNameIndex[name]]; - } - return null; - }; - - /** - * Provide information about a legal option. - * @param {character} shortName The short name of the option, entered like: -T. - * @param {string} longName The equivalent long name of the option, entered like: --test. - * @param {boolean} hasValue Does this option require a value? Like: -t templatename - * @param {string} helpText - * @example - * myParser.addOption('t', 'template', true, 'The path to the template.'); - * myParser.addOption('h', 'help', false, 'Show the help message.'); - */ - exports.ArgParser.prototype.addOption = function(shortName, longName, hasValue, helpText, canHaveMultiple) { - this._options.push({shortName: shortName, longName: longName, hasValue: hasValue, helpText: helpText, canHaveMultiple: (canHaveMultiple || false)}); - if (shortName) { - this._shortNameIndex[shortName] = this._options.length - 1; - } - if (longName) { - this._longNameIndex[longName] = this._options.length - 1; - } - }; - - /** - Generate a summary of all the options with corresponding help text. - @returns {string} - */ - exports.ArgParser.prototype.help = function() { - var helpArr = ['OPTIONS:'], - option, optionHelp; - - for (var i = 0, leni = this._options.length; i < leni; i++) { - option = this._options[i]; - optionHelp = '\t'; - - if (option.shortName) { - optionHelp += '-' + option.shortName + (option.longName ? ', ' : ''); - } - - if (option.longName) { - optionHelp += '--' + option.longName; - } - - if (option.hasValue) { - optionHelp += ' '; - } - - optionHelp += '\t\t' + option.helpText; - helpArr.push(optionHelp); - } - - return helpArr.join('\n'); - }; - - /** - Get the options. - @param {Array.} args An array, like ['-x', 'hello'] - @param {Object} [defaults={}] An optional collection of default values. - @returns {Object} The keys will be the longNames, or the shortName if - no longName is defined for that option. The values will be the values - provided, or `true` if the option accepts no value. - */ - exports.ArgParser.prototype.parse = function(args, defaults) { - var util = require('common/util'), - result = defaults && util.mixin({}, defaults) || {}; - - result._ = []; - for (var i = 0, leni = args.length; i < leni; i++) { - var arg = '' + args[i], - next = (i < leni-1)? '' + args[i+1] : null, - option, - shortName = null, - longName, - name, - value = null; - - // like -t - if (arg.charAt(0) === '-') { - - // like: --template - if (arg.charAt(1) === '-') { - name = longName = arg.slice(2); - option = this._getOptionByLongName(longName); - } - else { - name = shortName = arg.slice(1); - option = this._getOptionByShortName(shortName); - } - - if (option === null) { - throw new Error( 'Unknown command line option found: ' + name ); - } - - if (option.hasValue) { - value = next; - i++; - - if (value === null || value.charAt(0) === '-') { - throw new Error( 'Command line option requires a value: ' + name ); - } - } - else { - value = true; - } - - if (option.longName && shortName) { - name = option.longName; - } - - // Allow for multiple options of the same type to be present - if (option.canHaveMultiple && result.hasOwnProperty(name)) { - var val = result[name]; - if (val instanceof Array) { - val.push(value); - } else { - result[name] = [val, value]; - } - } - else { - result[name] = value; - } - } - else { - result._.push(arg); - } - } - - return result; - }; -})(); \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/common/assert.js b/Tools/jsdoc3/node_modules/common/assert.js deleted file mode 100644 index a693dfbcc6b..00000000000 --- a/Tools/jsdoc3/node_modules/common/assert.js +++ /dev/null @@ -1,302 +0,0 @@ -// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 -// -// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! -// -// Originally from narwhal.js (http://narwhaljs.org) -// Copyright (c) 2009 Thomas Robinson <280north.com> -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the 'Software'), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -// UTILITY -var common = { util: require('common/util') };; -var pSlice = Array.prototype.slice; - -// 1. The assert module provides functions that throw -// AssertionError's when particular conditions are not met. The -// assert module must conform to the following interface. - -var assert = exports; - -// 2. The AssertionError is defined in assert. -// new assert.AssertionError({ message: message, -// actual: actual, -// expected: expected }) - -assert.AssertionError = function AssertionError(options) { - this.name = 'AssertionError'; - this.message = options.message; - this.actual = options.actual; - this.expected = options.expected; - this.operator = options.operator; - var stackStartFunction = options.stackStartFunction || fail; - - if (Error.captureStackTrace) { - Error.captureStackTrace(this, stackStartFunction); - } -}; -common.util.inherits(assert.AssertionError, Error); - -assert.AssertionError.prototype.toString = function() { - if (this.message) { - return [this.name + ':', this.message].join(' '); - } else { - return [this.name + ':', - JSON.stringify(this.expected), - this.operator, - JSON.stringify(this.actual)].join(' '); - } -}; - -// assert.AssertionError instanceof Error - -assert.AssertionError.__proto__ = Error.prototype; - -// At present only the three keys mentioned above are used and -// understood by the spec. Implementations or sub modules can pass -// other keys to the AssertionError's constructor - they will be -// ignored. - -// 3. All of the following functions must throw an AssertionError -// when a corresponding condition is not met, with a message that -// may be undefined if not provided. All assertion methods provide -// both the actual and expected values to the assertion error for -// display purposes. - -function fail(actual, expected, message, operator, stackStartFunction) { - throw new assert.AssertionError({ - message: message, - actual: actual, - expected: expected, - operator: operator, - stackStartFunction: stackStartFunction - }); -} - -// EXTENSION! allows for well behaved errors defined elsewhere. -assert.fail = fail; - -// 4. Pure assertion tests whether a value is truthy, as determined -// by !!guard. -// assert.ok(guard, message_opt); -// This statement is equivalent to assert.equal(true, guard, -// message_opt);. To test strictly for the value true, use -// assert.strictEqual(true, guard, message_opt);. - -assert.ok = function ok(value, message) { - if (!!!value) fail(value, true, message, '==', assert.ok); -}; - -// 5. The equality assertion tests shallow, coercive equality with -// ==. -// assert.equal(actual, expected, message_opt); - -assert.equal = function equal(actual, expected, message) { - if (actual != expected) fail(actual, expected, message, '==', assert.equal); -}; - -// 6. The non-equality assertion tests for whether two objects are not equal -// with != assert.notEqual(actual, expected, message_opt); - -assert.notEqual = function notEqual(actual, expected, message) { - if (actual == expected) { - fail(actual, expected, message, '!=', assert.notEqual); - } -}; - -// 7. The equivalence assertion tests a deep equality relation. -// assert.deepEqual(actual, expected, message_opt); - -assert.deepEqual = function deepEqual(actual, expected, message) { - if (!_deepEqual(actual, expected)) { - fail(actual, expected, message, 'deepEqual', assert.deepEqual); - } -}; - -function _deepEqual(actual, expected) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (this.Buffer && Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { - if (actual.length != expected.length) return false; - - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) return false; - } - - return true; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } -} - -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function objEquiv(a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return _deepEqual(a, b); - } - try { - var ka = Object.keys(a), - kb = Object.keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!_deepEqual(a[key], b[key])) return false; - } - return true; -} - -// 8. The non-equivalence assertion tests for any deep inequality. -// assert.notDeepEqual(actual, expected, message_opt); - -assert.notDeepEqual = function notDeepEqual(actual, expected, message) { - if (_deepEqual(actual, expected)) { - fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); - } -}; - -// 9. The strict equality assertion tests strict equality, as determined by ===. -// assert.strictEqual(actual, expected, message_opt); - -assert.strictEqual = function strictEqual(actual, expected, message) { - if (actual !== expected) { - fail(actual, expected, message, '===', assert.strictEqual); - } -}; - -// 10. The strict non-equality assertion tests for strict inequality, as -// determined by !==. assert.notStrictEqual(actual, expected, message_opt); - -assert.notStrictEqual = function notStrictEqual(actual, expected, message) { - if (actual === expected) { - fail(actual, expected, message, '!==', assert.notStrictEqual); - } -}; - -function expectedException(actual, expected) { - if (!actual || !expected) { - return false; - } - - if (expected instanceof RegExp) { - return expected.test(actual); - } else if (actual instanceof expected) { - return true; - } else if ( expected.call({}, actual) === true ) { - return true; - } - - return false; -} - -function _throws(shouldThrow, block, expected, message) { - var actual; - - if (typeof expected === 'string') { - message = expected; - expected = null; - } - - try { - block(); - } catch (e) { - actual = e; - } - - message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + - (message ? ' ' + message : '.'); - - if (shouldThrow && !actual) { - fail('Missing expected exception' + message); - } - - if (!shouldThrow && expectedException(actual, expected)) { - fail('Got unwanted exception' + message); - } - - if ((shouldThrow && actual && expected && - !expectedException(actual, expected)) || (!shouldThrow && actual)) { - throw actual; - } -} - -// 11. Expected to throw an error: -// assert.throws(block, Error_opt, message_opt); - -assert['throws'] = function(block, /*optional*/error, /*optional*/message) { - _throws.apply(this, [true].concat(pSlice.call(arguments))); -}; - -// EXTENSION! This is annoying to write outside this module. -assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { - _throws.apply(this, [false].concat(pSlice.call(arguments))); -}; - -assert.ifError = function(err) { if (err) {throw err;}}; \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/common/events.js b/Tools/jsdoc3/node_modules/common/events.js deleted file mode 100644 index d2e9c500e1f..00000000000 --- a/Tools/jsdoc3/node_modules/common/events.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - Functions related to events. Designed to be mixed into other classes. - @exports common/events - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. -*/ -module.exports = { - /** - @param {string} type - @param {function} handler - @returns {this} - */ - on: function(type, handler, context) { - if ( !type || !handler ) { - return; - } - if ( !context ) { context = this; } - - if ( !this.__bindings ) { this.__bindings = {}; } - // TODO check here for hasOwnProperty? - if ( !this.__bindings[type] ) { this.__bindings[type] = []; } - - var call = function(e) { - return handler.call(context, e); - }; - this.__bindings[type].push( {handler: handler, call: call} ); - - return this; // chainable - }, - - /** - @param {string} type - @param {object} [eventData] - @returns {this} - */ - fire: function(eventType, eventData) { - if ( !eventType || !this.__bindings || !this.__bindings[eventType] ) { - return; - } - - // run handlers in first-in-first-run order - for (var i = 0, leni = this.__bindings[eventType].length; i < leni; i++) { - if ( false === this.__bindings[eventType][i].call(eventData) ) { - if (eventData) { eventData.defaultPrevented = true; } - } - } - - return this; // chainable - }, - - /** - @param {string} type - @param {function} handler - */ - removeListener: function(type, handler) { - if ( !type || !handler || !this.__bindings || !this.__bindings[type] ) { - return; - } - - var i = this.__bindings[type].length; - while ( i-- ) { - if ( this.__bindings[type][i].handler === handler ) { - this.__bindings[type].splice(i, 1); - } - } - - if (this.__bindings[type].length === 0) { - delete this.__bindings[type]; - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/common/query.js b/Tools/jsdoc3/node_modules/common/query.js deleted file mode 100644 index 075f8985759..00000000000 --- a/Tools/jsdoc3/node_modules/common/query.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - @description Support parsing of command line querystrings into JS objects. - @module common/query - @example - - -q 'format=xml&root+node=documentation&publish=' - - > becomes - - { - "format": "xml", - "root node": "documentation", - "publish": true - } -*/ -(function() { - var query = module.exports = { - /** - @name module:common/query.toObject - @param {string} querystring - @returns {object} - */ - toObject: function(querystring) { - var object = {}; - - querystring.replace( - new RegExp('([^?=&]+)(?:=([^&]*))?', 'g'), - function($0, key, val) { - object[query._decode(key)] = - (typeof val !== 'undefined')? query._decode(val) : true; - } - ); - - return object; - }, - - /** @private */ - _decode: function(string) { - return decodeURIComponent( string.replace(/\+/g, ' ') ); - } - }; -})(); \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/common/sqlite.js b/Tools/jsdoc3/node_modules/common/sqlite.js deleted file mode 100644 index 7bc9f97add3..00000000000 --- a/Tools/jsdoc3/node_modules/common/sqlite.js +++ /dev/null @@ -1,55 +0,0 @@ -importPackage(java.sql); -java.lang.Class.forName('org.sqlite.JDBC'); - -var DB = exports.DB = function(dbname) { - this.dbname = dbname; -} - -DB.prototype.connect = function() { - this.conn = DriverManager.getConnection('jdbc:sqlite:' + this.dbname); - return this; -} - -DB.prototype.prepare = function(statement) { // like "insert into symbols values (?, ?, ?);" - this.prep = this.conn.prepareStatement(statement); - return this; -} - -DB.prototype.values = function() { // replaces "?" placeholders in prepared statement - for (var i = 0, leni = arguments.length; i < leni; i++) { - this.prep.setString(i+1, arguments[i]); - } - this.prep.addBatch(); - - return this; -} - -DB.prototype.commit = function() { - this.conn.setAutoCommit(false); - this.prep.executeBatch(); - this.conn.setAutoCommit(true); - - return this; -} - -DB.prototype.query = function(statement) { // like "select * from symbols;" - this.stat = this.conn.createStatement(); - this.resultSet = this.stat.executeQuery(statement); - - return this.resultSet; -} - -DB.prototype.update = function(statement) { // like "create table symbols (id, longname, kind);" - this.stat = this.conn.createStatement(); - this.resultSet = this.stat.executeUpdate(statement); - - return this; -} - -DB.prototype.close = function() { - if (this.resultSet) this.resultSet.close(); - if (this.stat) this.stat.close(); - if (this.conn) this.conn.close(); - - return this; -} diff --git a/Tools/jsdoc3/node_modules/common/util.js b/Tools/jsdoc3/node_modules/common/util.js deleted file mode 100644 index 1b57ee34926..00000000000 --- a/Tools/jsdoc3/node_modules/common/util.js +++ /dev/null @@ -1,119 +0,0 @@ -/** - @module common/util - */ - -exports.print = function() { - for (var i = 0, len = arguments.length; i < len; ++i) { - java.lang.System.out.print(String(arguments[i])); - } -}; - -exports.puts = function() { - for (var i = 0, len = arguments.length; i < len; ++i) { - java.lang.System.out.println(arguments[i] + '\n'); - } -}; - -exports.debug = function(x) { - exports.puts('DEBUG: ' + x + '\n'); -}; - -var error = exports.error = function(x) { - for (var i = 0, len = arguments.length; i < len; ++i) { - exports.puts(arguments[i] + '\n'); - } -}; - -exports.format = { - stylize: function(str, styleType) { - // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics - var styles = - { 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] }; - - var style = - { 'special': 'cyan', - 'number': 'blue', - 'boolean': 'yellow', - 'undefined': 'grey', - 'null': 'bold', - 'string': 'green', - 'date': 'magenta', - // "name": intentionally not styling - 'regexp': 'red' }[styleType]; - - if (style) { - return '\033[' + styles[style][0] + 'm' + str + - '\033[' + styles[style][1] + 'm'; - } else { - return str; - } - }, - - pad: function (n) { - return n < 10 ? '0' + n.toString(10) : n.toString(10); - } -} - -var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', - 'Oct', 'Nov', 'Dec']; - -/** - * Create a timestamp string. - * @returns {string} Like 26 Feb 2011 16:19:34 - */ -exports.timestamp = function() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); - return [d.getDate(), months[d.getMonth()], d.getFullYear(), time].join(' '); -} - -exports.log = function(msg) { - exports.puts(exports.timestamp() + ' - ' + msg.toString()); -}; - -/** - * Inherit the prototype methods from one constructor into another. - * @param {function} ctor Constructor function which needs to inherit the prototype. - * @param {function} superCtor Constructor function to inherit prototype from. - */ -exports.inherits = function(ctor, superCtor) { - ctor.super_ = superCtor; - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { value: ctor, enumerable: false } - }); -}; - -/** - * Mix in the members of a source object over a target object. - * @param {object} target - * @param {object} source - */ -exports.mixin = function(target, source /*...*/){ - var sourceProperty; - - for (var i = 1, len = arguments.length; i < len; i++) { - source = arguments[i]; - - for (sourceProperty in source) { - if( source.hasOwnProperty(sourceProperty) ) { - target[sourceProperty] = source[sourceProperty]; // overwrites target property - } - } - } - - return target; -}; \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/evilstreak/markdown.js b/Tools/jsdoc3/node_modules/evilstreak/markdown.js deleted file mode 100644 index cdfbeb654d4..00000000000 --- a/Tools/jsdoc3/node_modules/evilstreak/markdown.js +++ /dev/null @@ -1,1446 +0,0 @@ -// Released under MIT license -// Copyright (c) 2009-2010 Dominic Baggott -// Copyright (c) 2009-2010 Ash Berlin - -(function( expose ) { - -/** - * class Markdown - * - * Markdown processing in Javascript done right. We have very particular views - * on what constitutes 'right' which include: - * - * - produces well-formed HTML (this means that em and strong nesting is - * important) - * - * - has an intermediate representation to allow processing of parsed data (We - * in fact have two, both as [JsonML]: a markdown tree and an HTML tree). - * - * - is easily extensible to add new dialects without having to rewrite the - * entire parsing mechanics - * - * - has a good test suite - * - * This implementation fulfills all of these (except that the test suite could - * do with expanding to automatically run all the fixtures from other Markdown - * implementations.) - * - * ##### Intermediate Representation - * - * *TODO* Talk about this :) Its JsonML, but document the node names we use. - * - * [JsonML]: http://jsonml.org/ "JSON Markup Language" - **/ -var Markdown = expose.Markdown = function Markdown(dialect) { - switch (typeof dialect) { - case "undefined": - this.dialect = Markdown.dialects.Gruber; - break; - case "object": - this.dialect = dialect; - break; - default: - if (dialect in Markdown.dialects) { - this.dialect = Markdown.dialects[dialect]; - } - else { - throw new Error("Unknown Markdown dialect '" + String(dialect) + "'"); - } - break; - } - this.em_state = []; - this.strong_state = []; - this.debug_indent = ""; -} - -/** - * parse( markdown, [dialect] ) -> JsonML - * - markdown (String): markdown string to parse - * - dialect (String | Dialect): the dialect to use, defaults to gruber - * - * Parse `markdown` and return a markdown document as a Markdown.JsonML tree. - **/ -expose.parse = function( source, dialect ) { - // dialect will default if undefined - var md = new Markdown( dialect ); - return md.toTree( source ); -} - -/** - * toHTML( markdown ) -> String - * toHTML( md_tree ) -> String - * - markdown (String): markdown string to parse - * - md_tree (Markdown.JsonML): parsed markdown tree - * - * Take markdown (either as a string or as a JsonML tree) and run it through - * [[toHTMLTree]] then turn it into a well-formated HTML fragment. - **/ -expose.toHTML = function toHTML( source ) { - var input = expose.toHTMLTree( source ); - - return expose.renderJsonML( input ); -} - -/** - * toHTMLTree( markdown, [dialect] ) -> JsonML - * toHTMLTree( md_tree ) -> JsonML - * - markdown (String): markdown string to parse - * - dialect (String | Dialect): the dialect to use, defaults to gruber - * - md_tree (Markdown.JsonML): parsed markdown tree - * - * Turn markdown into HTML, represented as a JsonML tree. If a string is given - * to this function, it is first parsed into a markdown tree by calling - * [[parse]]. - **/ -expose.toHTMLTree = function toHTMLTree( input, dialect ) { - // convert string input to an MD tree - if ( typeof input ==="string" ) input = this.parse( input, dialect ); - - // Now convert the MD tree to an HTML tree - - // remove references from the tree - var attrs = extract_attr( input ), - refs = {}; - - if ( attrs && attrs.references ) { - refs = attrs.references; - } - - var html = convert_tree_to_html( input, refs ); - merge_text_nodes( html ); - return html; -} - -var mk_block = Markdown.mk_block = function(block, trail, line) { - // Be helpful for default case in tests. - if ( arguments.length == 1 ) trail = "\n\n"; - - var s = new String(block); - s.trailing = trail; - // To make it clear its not just a string - s.toSource = function() { - return "Markdown.mk_block( " + - uneval(block) + - ", " + - uneval(trail) + - ", " + - uneval(line) + - " )" - } - - if (line != undefined) - s.lineNumber = line; - - return s; -} - -function count_lines( str ) { - var n = 0, i = -1;; - while ( ( i = str.indexOf('\n', i+1) ) != -1) n++; - return n; -} - -// Internal - split source into rough blocks -Markdown.prototype.split_blocks = function splitBlocks( input, startLine ) { - // [\s\S] matches _anything_ (newline or space) - var re = /([\s\S]+?)($|\n(?:\s*\n|$)+)/g, - blocks = [], - m; - - var line_no = 1; - - if ( ( m = (/^(\s*\n)/)(input) ) != null ) { - // skip (but count) leading blank lines - line_no += count_lines( m[0] ); - re.lastIndex = m[0].length; - } - - while ( ( m = re(input) ) != null ) { - blocks.push( mk_block( m[1], m[2], line_no ) ); - line_no += count_lines( m[0] ); - } - - return blocks; -} - -/** - * Markdown#processBlock( block, next ) -> undefined | [ JsonML, ... ] - * - block (String): the block to process - * - next (Array): the following blocks - * - * Process `block` and return an array of JsonML nodes representing `block`. - * - * It does this by asking each block level function in the dialect to process - * the block until one can. Succesful handling is indicated by returning an - * array (with zero or more JsonML nodes), failure by a false value. - * - * Blocks handlers are responsible for calling [[Markdown#processInline]] - * themselves as appropriate. - * - * If the blocks were split incorrectly or adjacent blocks need collapsing you - * can adjust `next` in place using shift/splice etc. - * - * If any of this default behaviour is not right for the dialect, you can - * define a `__call__` method on the dialect that will get invoked to handle - * the block processing. - */ -Markdown.prototype.processBlock = function processBlock( block, next ) { - var cbs = this.dialect.block, - ord = cbs.__order__; - - if ( "__call__" in cbs ) { - return cvs.__call__.call(this, block, next); - } - - for ( var i = 0; i < ord.length; i++ ) { - //D:this.debug( "Testing", ord[i] ); - var res = cbs[ ord[i] ].call( this, block, next ); - if ( res ) { - //D:this.debug(" matched"); - if ( !res instanceof Array || ( res.length > 0 && !( res[0] instanceof Array ) ) ) - this.debug(ord[i], "didn't return a proper array"); - //D:this.debug( "" ); - return res; - } - } - - // Uhoh! no match! Should we throw an error? - return []; -} - -Markdown.prototype.processInline = function processInline( block ) { - return this.dialect.inline.__call__.call( this, String( block ) ); -} - -/** - * Markdown#toTree( source ) -> JsonML - * - source (String): markdown source to parse - * - * Parse `source` into a JsonML tree representing the markdown document. - **/ -// custom_tree means set this.tree to `custom_tree` and restore old value on return -Markdown.prototype.toTree = function toTree( source, custom_root ) { - var blocks = source instanceof Array - ? source - : this.split_blocks( source ); - - // Make tree a member variable so its easier to mess with in extensions - var old_tree = this.tree; - try { - this.tree = custom_root || this.tree || [ "markdown" ]; - - blocks: - while ( blocks.length ) { - var b = this.processBlock( blocks.shift(), blocks ); - - // Reference blocks and the like won't return any content - if ( !b.length ) continue blocks; - - this.tree.push.apply( this.tree, b ); - } - return this.tree; - } - finally { - if ( custom_root ) - this.tree = old_tree; - } - -} - -// Noop by default -Markdown.prototype.debug = function () { - var args = Array.prototype.slice.call( arguments); - args.unshift(this.debug_indent); - print.apply( print, args ); -} - -Markdown.prototype.loop_re_over_block = function( re, block, cb ) { - // Dont use /g regexps with this - var m, - b = block.valueOf(); - - while ( b.length && (m = re(b) ) != null) { - b = b.substr( m[0].length ); - cb.call(this, m); - } - return b; -} - -/** - * Markdown.dialects - * - * Namespace of built-in dialects. - **/ -Markdown.dialects = {}; - -/** - * Markdown.dialects.Gruber - * - * The default dialect that follows the rules set out by John Gruber's - * markdown.pl as closely as possible. Well actually we follow the behaviour of - * that script which in some places is not exactly what the syntax web page - * says. - **/ -Markdown.dialects.Gruber = { - block: { - atxHeader: function atxHeader( block, next ) { - var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ ); - - if ( !m ) return undefined; - - var header = [ "header", { level: m[ 1 ].length }, m[ 2 ] ]; - - if ( m[0].length < block.length ) - next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) ); - - return [ header ]; - }, - - setextHeader: function setextHeader( block, next ) { - var m = block.match( /^(.*)\n([-=])\2\2+(?:\n|$)/ ); - - if ( !m ) return undefined; - - var level = ( m[ 2 ] === "=" ) ? 1 : 2; - var header = [ "header", { level : level }, m[ 1 ] ]; - - if ( m[0].length < block.length ) - next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) ); - - return [ header ]; - }, - - code: function code( block, next ) { - // | Foo - // |bar - // should be a code block followed by a paragraph. Fun - // - // There might also be adjacent code block to merge. - - var ret = [], - re = /^(?: {0,3}\t| {4})(.*)\n?/, - lines; - - // 4 spaces + content - var m = block.match( re ); - - if ( !m ) return undefined; - - block_search: - do { - // Now pull out the rest of the lines - var b = this.loop_re_over_block( - re, block.valueOf(), function( m ) { ret.push( m[1] ) } ); - - if (b.length) { - // Case alluded to in first comment. push it back on as a new block - next.unshift( mk_block(b, block.trailing) ); - break block_search; - } - else if (next.length) { - // Check the next block - it might be code too - var m = next[0].match( re ); - - if ( !m ) break block_search; - - // Pull how how many blanks lines follow - minus two to account for .join - ret.push ( block.trailing.replace(/[^\n]/g, '').substring(2) ); - - block = next.shift(); - } - else - break block_search; - } while (true); - - return [ [ "code_block", ret.join("\n") ] ]; - }, - - horizRule: function horizRule( block, next ) { - // this needs to find any hr in the block to handle abutting blocks - var m = block.match( /^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/ ); - - if ( !m ) { - return undefined; - } - - var jsonml = [ [ "hr" ] ]; - - // if there's a leading abutting block, process it - if ( m[ 1 ] ) { - jsonml.unshift.apply( jsonml, this.processBlock( m[ 1 ], [] ) ); - } - - // if there's a trailing abutting block, stick it into next - if ( m[ 3 ] ) { - next.unshift( mk_block( m[ 3 ] ) ); - } - - return jsonml; - }, - - // There are two types of lists. Tight and loose. Tight lists have no whitespace - // between the items (and result in text just in the
  • ) and loose lists, - // which have an empty line between list items, resulting in (one or more) - // paragraphs inside the
  • . - // - // There are all sorts weird edge cases about the original markdown.pl's - // handling of lists: - // - // * Nested lists are supposed to be indented by four chars per level. But - // if they aren't, you can get a nested list by indenting by less than - // four so long as the indent doesn't match an indent of an existing list - // item in the 'nest stack'. - // - // * The type of the list (bullet or number) is controlled just by the - // first item at the indent. Subsequent changes are ignored unless they - // are for nested lists - // - lists: (function( ) { - // Use a closure to hide a few variables. - var any_list = "[*+-]|\\d\\.", - bullet_list = /[*+-]/, - number_list = /\d+\./, - // Capture leading indent as it matters for determining nested lists. - is_list_re = new RegExp( "^( {0,3})(" + any_list + ")[ \t]+" ), - indent_re = "(?: {0,3}\\t| {4})"; - - // TODO: Cache this regexp for certain depths. - // Create a regexp suitable for matching an li for a given stack depth - function regex_for_depth( depth ) { - - return new RegExp( - // m[1] = indent, m[2] = list_type - "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" + - // m[3] = cont - "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})" - ); - } - function expand_tab( input ) { - return input.replace( / {0,3}\t/g, " " ); - } - - // Add inline content `inline` to `li`. inline comes from processInline - // so is an array of content - function add(li, loose, inline, nl) { - if (loose) { - li.push( [ "para" ].concat(inline) ); - return; - } - // Hmmm, should this be any block level element or just paras? - var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para" - ? li[li.length -1] - : li; - - // If there is already some content in this list, add the new line in - if (nl && li.length > 1) inline.unshift(nl); - - for (var i=0; i < inline.length; i++) { - var what = inline[i], - is_str = typeof what == "string"; - if (is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) - { - add_to[ add_to.length-1 ] += what; - } - else { - add_to.push( what ); - } - } - } - - // contained means have an indent greater than the current one. On - // *every* line in the block - function get_contained_blocks( depth, blocks ) { - - var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ), - replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"), - ret = []; - - while ( blocks.length > 0 ) { - if ( re( blocks[0] ) ) { - var b = blocks.shift(), - // Now remove that indent - x = b.replace( replace, ""); - - ret.push( mk_block( x, b.trailing, b.lineNumber ) ); - } - break; - } - return ret; - } - - // passed to stack.forEach to turn list items up the stack into paras - function paragraphify(s, i, stack) { - var list = s.list; - var last_li = list[list.length-1]; - - if (last_li[1] instanceof Array && last_li[1][0] == "para") { - return; - } - if (i+1 == stack.length) { - // Last stack frame - // Keep the same array, but replace the contents - last_li.push( ["para"].concat( last_li.splice(1) ) ); - } - else { - var sublist = last_li.pop(); - last_li.push( ["para"].concat( last_li.splice(1) ), sublist ); - } - } - - // The matcher function - return function( block, next ) { - var m = block.match( is_list_re ); - if ( !m ) return undefined; - - function make_list( m ) { - var list = bullet_list( m[2] ) - ? ["bulletlist"] - : ["numberlist"]; - - stack.push( { list: list, indent: m[1] } ); - return list; - } - - - var stack = [], // Stack of lists for nesting. - list = make_list( m ), - last_li, - loose = false, - ret = [ stack[0].list ]; - - // Loop to search over block looking for inner block elements and loose lists - loose_search: - while( true ) { - // Split into lines preserving new lines at end of line - var lines = block.split( /(?=\n)/ ); - - // We have to grab all lines for a li and call processInline on them - // once as there are some inline things that can span lines. - var li_accumulate = ""; - - // Loop over the lines in this block looking for tight lists. - tight_search: - for (var line_no=0; line_no < lines.length; line_no++) { - var nl = "", - l = lines[line_no].replace(/^\n/, function(n) { nl = n; return "" }); - - // TODO: really should cache this - var line_re = regex_for_depth( stack.length ); - - m = l.match( line_re ); - //print( "line:", uneval(l), "\nline match:", uneval(m) ); - - // We have a list item - if ( m[1] !== undefined ) { - // Process the previous list item, if any - if ( li_accumulate.length ) { - add( last_li, loose, this.processInline( li_accumulate ), nl ); - // Loose mode will have been dealt with. Reset it - loose = false; - li_accumulate = ""; - } - - m[1] = expand_tab( m[1] ); - var wanted_depth = Math.floor(m[1].length/4)+1; - //print( "want:", wanted_depth, "stack:", stack.length); - if ( wanted_depth > stack.length ) { - // Deep enough for a nested list outright - //print ( "new nested list" ); - list = make_list( m ); - last_li.push( list ); - last_li = list[1] = [ "listitem" ]; - } - else { - // We aren't deep enough to be strictly a new level. This is - // where Md.pl goes nuts. If the indent matches a level in the - // stack, put it there, else put it one deeper then the - // wanted_depth deserves. - var found = stack.some(function(s, i) { - if ( s.indent != m[1] ) return false; - list = s.list; // Found the level we want - stack.splice(i+1); // Remove the others - //print("found"); - return true; // And stop looping - }); - - if (!found) { - //print("not found. l:", uneval(l)); - wanted_depth++; - if (wanted_depth <= stack.length) { - stack.splice(wanted_depth); - //print("Desired depth now", wanted_depth, "stack:", stack.length); - list = stack[wanted_depth-1].list; - //print("list:", uneval(list) ); - } - else { - //print ("made new stack for messy indent"); - list = make_list(m); - last_li.push(list); - } - } - - //print( uneval(list), "last", list === stack[stack.length-1].list ); - last_li = [ "listitem" ]; - list.push(last_li); - } // end depth of shenegains - nl = ""; - } - - // Add content - if (l.length > m[0].length) { - li_accumulate += nl + l.substr( m[0].length ); - } - } // tight_search - - if ( li_accumulate.length ) { - add( last_li, loose, this.processInline( li_accumulate ), nl ); - // Loose mode will have been dealt with. Reset it - loose = false; - li_accumulate = ""; - } - - // Look at the next block - we might have a loose list. Or an extra - // paragraph for the current li - var contained = get_contained_blocks( stack.length, next ); - - // Deal with code blocks or properly nested lists - if (contained.length > 0) { - // Make sure all listitems up the stack are paragraphs - stack.forEach( paragraphify, this ); - - last_li.push.apply( last_li, this.toTree( contained, [] ) ); - } - - var next_block = next[0] && next[0].valueOf() || ""; - - if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) { - block = next.shift(); - - // Check for an HR following a list: features/lists/hr_abutting - var hr = this.dialect.block.horizRule( block, next ); - - if (hr) { - ret.push.apply(ret, hr); - break; - } - - // Make sure all listitems up the stack are paragraphs - stack.forEach( paragraphify , this ); - - loose = true; - continue loose_search; - } - break; - } // loose_search - - return ret; - } - })(), - - blockquote: function blockquote( block, next ) { - if ( !block.match( /^>/m ) ) - return undefined; - - var jsonml = []; - - // separate out the leading abutting block, if any - if ( block[ 0 ] != ">" ) { - var lines = block.split( /\n/ ), - prev = []; - - // keep shifting lines until you find a crotchet - while ( lines.length && lines[ 0 ][ 0 ] != ">" ) { - prev.push( lines.shift() ); - } - - // reassemble! - block = lines.join( "\n" ); - jsonml.push.apply( jsonml, this.processBlock( prev.join( "\n" ), [] ) ); - } - - // if the next block is also a blockquote merge it in - while ( next.length && next[ 0 ][ 0 ] == ">" ) { - var b = next.shift(); - block += block.trailing + b; - block.trailing = b.trailing; - } - - // Strip off the leading "> " and re-process as a block. - var input = block.replace( /^> ?/gm, '' ), - old_tree = this.tree; - jsonml.push( this.toTree( input, [ "blockquote" ] ) ); - - return jsonml; - }, - - referenceDefn: function referenceDefn( block, next) { - var re = /^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/; - // interesting matches are [ , ref_id, url, , title, title ] - - if ( !block.match(re) ) - return undefined; - - // make an attribute node if it doesn't exist - if ( !extract_attr( this.tree ) ) { - this.tree.splice( 1, 0, {} ); - } - - var attrs = extract_attr( this.tree ); - - // make a references hash if it doesn't exist - if ( attrs.references === undefined ) { - attrs.references = {}; - } - - var b = this.loop_re_over_block(re, block, function( m ) { - - if ( m[2] && m[2][0] == '<' && m[2][m[2].length-1] == '>' ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - var ref = attrs.references[ m[1].toLowerCase() ] = { - href: m[2] - }; - - if (m[4] !== undefined) - ref.title = m[4]; - else if (m[5] !== undefined) - ref.title = m[5]; - - } ); - - if (b.length) - next.unshift( mk_block( b, block.trailing ) ); - - return []; - }, - - para: function para( block, next ) { - // everything's a para! - return [ ["para"].concat( this.processInline( block ) ) ]; - } - } -} - -Markdown.dialects.Gruber.inline = { - __call__: function inline( text, patterns ) { - // Hmmm - should this function be directly in Md#processInline, or - // conversely, should Md#processBlock be moved into block.__call__ too - var out = [ ], - m, - // Look for the next occurange of a special character/pattern - re = new RegExp( "([\\s\\S]*?)(" + (patterns.source || patterns) + ")", "g" ), - lastIndex = 0; - - //D:var self = this; - //D:self.debug("processInline:", uneval(text) ); - function add(x) { - //D:self.debug(" adding output", uneval(x)); - if (typeof x == "string" && typeof out[out.length-1] == "string") - out[ out.length-1 ] += x; - else - out.push(x); - } - - while ( ( m = re.exec(text) ) != null) { - if ( m[1] ) add( m[1] ); // Some un-interesting text matched - else m[1] = { length: 0 }; // Or there was none, but make m[1].length == 0 - - var res; - if ( m[2] in this.dialect.inline ) { - res = this.dialect.inline[ m[2] ].call( - this, - text.substr( m.index + m[1].length ), m, out ); - } - // Default for now to make dev easier. just slurp special and output it. - res = res || [ m[2].length, m[2] ]; - - var len = res.shift(); - // Update how much input was consumed - re.lastIndex += ( len - m[2].length ); - - // Add children - res.forEach(add); - - lastIndex = re.lastIndex; - } - - // Add last 'boring' chunk - if ( text.length > lastIndex ) - add( text.substr( lastIndex ) ); - - return out; - }, - - "\\": function escaped( text ) { - // [ length of input processed, node/children to add... ] - // Only esacape: \ ` * _ { } [ ] ( ) # * + - . ! - if ( text.match( /^\\[\\`\*_{}\[\]()#\+.!\-]/ ) ) - return [ 2, text[1] ]; - else - // Not an esacpe - return [ 1, "\\" ]; - }, - - "![": function image( text ) { - // ![Alt text](/path/to/img.jpg "Optional title") - // 1 2 3 4 <--- captures - var m = text.match( /^!\[(.*?)\][ \t]*\([ \t]*(\S*)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ ); - - if ( m ) { - if ( m[2] && m[2][0] == '<' && m[2][m[2].length-1] == '>' ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - m[2] == this.dialect.inline.__call__.call( this, m[2], /\\/ )[0]; - - var attrs = { alt: m[1], href: m[2] || "" }; - if ( m[4] !== undefined) - attrs.title = m[4]; - - return [ m[0].length, [ "img", attrs ] ]; - } - - // ![Alt text][id] - m = text.match( /^!\[(.*?)\][ \t]*\[(.*?)\]/ ); - - if ( m ) { - // We can't check if the reference is known here as it likely wont be - // found till after. Check it in md tree->hmtl tree conversion - return [ m[0].length, [ "img_ref", { alt: m[1], ref: m[2].toLowerCase(), text: m[0] } ] ]; - } - - // Just consume the '![' - return [ 2, "![" ]; - }, - - "[": function link( text ) { - // [link text](/path/to/img.jpg "Optional title") - // 1 2 3 4 <--- captures - var m = text.match( /^\[([\s\S]*?)\][ \t]*\([ \t]*(\S+)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ ); - - if ( m ) { - if ( m[2] && m[2][0] == '<' && m[2][m[2].length-1] == '>' ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - // Process escapes only - m[2] = this.dialect.inline.__call__.call( this, m[2], /\\/ )[0]; - - var attrs = { href: m[2] || "" }; - if ( m[4] !== undefined) - attrs.title = m[4]; - - return [ m[0].length, [ "link", attrs, m[1] ] ]; - } - - // [Alt text][id] - // [Alt text] [id] - // [id] - m = text.match( /^\[([\s\S]*?)\](?: ?\[(.*?)\])?/ ); - - if ( m ) { - // [id] case, text == id - if ( m[2] === undefined || m[2] === "" ) m[2] = m[1]; - - // We can't check if the reference is known here as it likely wont be - // found till after. Check it in md tree->hmtl tree conversion. - // Store the original so that conversion can revert if the ref isn't found. - return [ - m[ 0 ].length, - [ - "link_ref", - { - ref: m[ 2 ].toLowerCase(), - original: m[ 0 ] - }, - m[ 1 ] - ] - ]; - } - - // Just consume the '[' - return [ 1, "[" ]; - }, - - - "<": function autoLink( text ) { - var m; - - if ( ( m = text.match( /^<(?:((https?|ftp|mailto):[^>]+)|(.*?@.*?\.[a-zA-Z]+))>/ ) ) != null ) { - if ( m[3] ) { - return [ m[0].length, [ "link", { href: "mailto:" + m[3] }, m[3] ] ]; - - } - else if ( m[2] == "mailto" ) { - return [ m[0].length, [ "link", { href: m[1] }, m[1].substr("mailto:".length ) ] ]; - } - else - return [ m[0].length, [ "link", { href: m[1] }, m[1] ] ]; - } - - return [ 1, "<" ]; - }, - - "`": function inlineCode( text ) { - // Inline code block. as many backticks as you like to start it - // Always skip over the opening ticks. - var m = text.match( /(`+)(([\s\S]*?)\1)/ ); - - if ( m && m[2] ) - return [ m[1].length + m[2].length, [ "inlinecode", m[3] ] ]; - else { - // TODO: No matching end code found - warn! - return [ 1, "`" ]; - } - }, - - " \n": function lineBreak( text ) { - return [ 3, [ "linebreak" ] ]; - } - -} - -// Meta Helper/generator method for em and strong handling -function strong_em( tag, md ) { - - var state_slot = tag + "_state", - other_slot = tag == "strong" ? "em_state" : "strong_state"; - - function CloseTag(len) { - this.len_after = len; - this.name = "close_" + md; - } - - return function ( text, orig_match ) { - - if (this[state_slot][0] == md) { - // Most recent em is of this type - //D:this.debug("closing", md); - this[state_slot].shift(); - - // "Consume" everything to go back to the recrusion in the else-block below - return[ text.length, new CloseTag(text.length-md.length) ]; - } - else { - // Store a clone of the em/strong states - var other = this[other_slot].slice(), - state = this[state_slot].slice(); - - this[state_slot].unshift(md); - - //D:this.debug_indent += " "; - - // Recurse - var res = this.processInline( text.substr( md.length ) ); - //D:this.debug_indent = this.debug_indent.substr(2); - - var last = res[res.length - 1]; - - //D:this.debug("processInline from", tag + ": ", uneval( res ) ); - - var check = this[state_slot].shift(); - if (last instanceof CloseTag) { - res.pop(); - // We matched! Huzzah. - var consumed = text.length - last.len_after; - return [ consumed, [ tag ].concat(res) ]; - } - else { - // Restore the state of the other kind. We might have mistakenly closed it. - this[other_slot] = other; - this[state_slot] = state; - - // We can't reuse the processed result as it could have wrong parsing contexts in it. - return [ md.length, md ]; - } - } - } // End returned function -} - -Markdown.dialects.Gruber.inline["**"] = strong_em("strong", "**"); -Markdown.dialects.Gruber.inline["__"] = strong_em("strong", "__"); -Markdown.dialects.Gruber.inline["*"] = strong_em("em", "*"); -Markdown.dialects.Gruber.inline["_"] = strong_em("em", "_"); - - -// Build default order from insertion order. -Markdown.buildBlockOrder = function(d) { - var ord = []; - for ( var i in d ) { - if ( i == "__order__" || i == "__call__" ) continue; - ord.push( i ); - } - d.__order__ = ord; -} - -// Build patterns for inline matcher -Markdown.buildInlinePatterns = function(d) { - var patterns = []; - - for ( var i in d ) { - if (i == "__call__") continue; - var l = i.replace( /([\\.*+?|()\[\]{}])/g, "\\$1" ) - .replace( /\n/, "\\n" ); - patterns.push( i.length == 1 ? l : "(?:" + l + ")" ); - } - - patterns = patterns.join("|"); - //print("patterns:", uneval( patterns ) ); - - var fn = d.__call__; - d.__call__ = function(text, pattern) { - if (pattern != undefined) - return fn.call(this, text, pattern); - else - return fn.call(this, text, patterns); - } -} - -// Helper function to make sub-classing a dialect easier -Markdown.subclassDialect = function( d ) { - function Block() {}; - Block.prototype = d.block; - function Inline() {}; - Inline.prototype = d.inline; - - return { block: new Block(), inline: new Inline() }; -} - -Markdown.buildBlockOrder ( Markdown.dialects.Gruber.block ); -Markdown.buildInlinePatterns( Markdown.dialects.Gruber.inline ); - -Markdown.dialects.Maruku = Markdown.subclassDialect( Markdown.dialects.Gruber ); - -Markdown.dialects.Maruku.block.document_meta = function document_meta( block, next ) { - // we're only interested in the first block - if ( block.lineNumber > 1 ) return undefined; - - // document_meta blocks consist of one or more lines of `Key: Value\n` - if ( ! block.match( /^(?:\w+:.*\n)*\w+:.*$/ ) ) return undefined; - - // make an attribute node if it doesn't exist - if ( !extract_attr( this.tree ) ) { - this.tree.splice( 1, 0, {} ); - } - - var pairs = block.split( /\n/ ); - for ( p in pairs ) { - var m = pairs[ p ].match( /(\w+):\s*(.*)$/ ), - key = m[ 1 ].toLowerCase(), - value = m[ 2 ]; - - this.tree[ 1 ][ key ] = value; - } - - // document_meta produces no content! - return []; -} - -Markdown.dialects.Maruku.block.block_meta = function block_meta( block, next ) { - // check if the last line of the block is an meta hash - var m = block.match( /(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/ ); - if ( !m ) return undefined; - - // process the meta hash - var attr = process_meta_hash( m[ 2 ] ); - - // if we matched ^ then we need to apply meta to the previous block - if ( m[ 1 ] === "" ) { - var node = this.tree[ this.tree.length - 1 ], - hash = extract_attr( node ); - - // if the node is a string (rather than JsonML), bail - if ( typeof node === "string" ) return undefined; - - // create the attribute hash if it doesn't exist - if ( !hash ) { - hash = {}; - node.splice( 1, 0, hash ); - } - - // add the attributes in - for ( a in attr ) { - hash[ a ] = attr[ a ]; - } - - // return nothing so the meta hash is removed - return []; - } - - // pull the meta hash off the block and process what's left - var b = block.replace( /\n.*$/, "" ), - result = this.processBlock( b, [] ); - - // get or make the attributes hash - var hash = extract_attr( result[ 0 ] ); - if ( !hash ) { - hash = {}; - result[ 0 ].splice( 1, 0, hash ); - } - - // attach the attributes to the block - for ( a in attr ) { - hash[ a ] = attr[ a ]; - } - - return result; -} - -Markdown.dialects.Maruku.block.definition_list = function definition_list( block, next ) { - // one or more terms followed by one or more definitions, in a single block - var tight = /^((?:[^\s:].*\n)+):\s+([^]+)$/, - list = [ "dl" ]; - - // see if we're dealing with a tight or loose block - if ( ( m = block.match( tight ) ) ) { - // pull subsequent tight DL blocks out of `next` - var blocks = [ block ]; - while ( next.length && tight.exec( next[ 0 ] ) ) { - blocks.push( next.shift() ); - } - - for ( var b = 0; b < blocks.length; ++b ) { - var m = blocks[ b ].match( tight ), - terms = m[ 1 ].replace( /\n$/, "" ).split( /\n/ ), - defns = m[ 2 ].split( /\n:\s+/ ); - - // print( uneval( m ) ); - - for ( var i = 0; i < terms.length; ++i ) { - list.push( [ "dt", terms[ i ] ] ); - } - - for ( var i = 0; i < defns.length; ++i ) { - // run inline processing over the definition - list.push( [ "dd" ].concat( this.processInline( defns[ i ].replace( /(\n)\s+/, "$1" ) ) ) ); - } - } - } - else { - return undefined; - } - - return [ list ]; -} - -Markdown.dialects.Maruku.inline[ "{:" ] = function inline_meta( text, matches, out ) { - if ( !out.length ) { - return [ 2, "{:" ]; - } - - // get the preceeding element - var before = out[ out.length - 1 ]; - - if ( typeof before === "string" ) { - return [ 2, "{:" ]; - } - - // match a meta hash - var m = text.match( /^\{:\s*((?:\\\}|[^\}])*)\s*\}/ ); - - // no match, false alarm - if ( !m ) { - return [ 2, "{:" ]; - } - - // attach the attributes to the preceeding element - var meta = process_meta_hash( m[ 1 ] ), - attr = extract_attr( before ); - - if ( !attr ) { - attr = {}; - before.splice( 1, 0, attr ); - } - - for ( var k in meta ) { - attr[ k ] = meta[ k ]; - } - - // cut out the string and replace it with nothing - return [ m[ 0 ].length, "" ]; -} - -Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block ); -Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline ); - -function extract_attr( jsonml ) { - return jsonml instanceof Array - && jsonml.length > 1 - && typeof jsonml[ 1 ] === "object" - && !( jsonml[ 1 ] instanceof Array ) - ? jsonml[ 1 ] - : undefined; -} - -function process_meta_hash( meta_string ) { - var meta = split_meta_hash( meta_string ), - attr = {}; - - for ( var i = 0; i < meta.length; ++i ) { - // id: #foo - if ( /^#/.test( meta[ i ] ) ) { - attr.id = meta[ i ].substring( 1 ); - } - // class: .foo - else if ( /^\./.test( meta[ i ] ) ) { - // if class already exists, append the new one - if ( attr['class'] ) { - attr['class'] = attr['class'] + meta[ i ].replace( /./, " " ); - } - else { - attr['class'] = meta[ i ].substring( 1 ); - } - } - // attribute: foo=bar - else if ( /=/.test( meta[ i ] ) ) { - var s = meta[ i ].split( /=/ ); - attr[ s[ 0 ] ] = s[ 1 ]; - } - } - - return attr; -} - -function split_meta_hash( meta_string ) { - var meta = meta_string.split( "" ), - parts = [ "" ], - in_quotes = false; - - while ( meta.length ) { - var letter = meta.shift(); - switch ( letter ) { - case " " : - // if we're in a quoted section, keep it - if ( in_quotes ) { - parts[ parts.length - 1 ] += letter; - } - // otherwise make a new part - else { - parts.push( "" ); - } - break; - case "'" : - case '"' : - // reverse the quotes and move straight on - in_quotes = !in_quotes; - break; - case "\\" : - // shift off the next letter to be used straight away. - // it was escaped so we'll keep it whatever it is - letter = meta.shift(); - default : - parts[ parts.length - 1 ] += letter; - break; - } - } - - return parts; -} - -/** - * renderJsonML( jsonml[, options] ) -> String - * - jsonml (Array): JsonML array to render to XML - * - options (Object): options - * - * Converts the given JsonML into well-formed XML. - * - * The options currently understood are: - * - * - root (Boolean): wether or not the root node should be included in the - * output, or just its children. The default `false` is to not include the - * root itself. - */ -expose.renderJsonML = function( jsonml, options ) { - options = options || {}; - // include the root element in the rendered output? - options.root = options.root || false; - - var content = []; - - if ( options.root ) { - content.push( render_tree( jsonml ) ); - } - else { - jsonml.shift(); // get rid of the tag - if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) { - jsonml.shift(); // get rid of the attributes - } - - while ( jsonml.length ) { - content.push( render_tree( jsonml.shift() ) ); - } - } - - return content.join( "\n\n" ); -} - -function render_tree( jsonml ) { - // basic case - if ( typeof jsonml === "string" ) { - return jsonml.replace( /&/g, "&" ) - .replace( //g, ">" ); - } - - var tag = jsonml.shift(), - attributes = {}, - content = []; - - if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) { - attributes = jsonml.shift(); - } - - while ( jsonml.length ) { - content.push( arguments.callee( jsonml.shift() ) ); - } - - var tag_attrs = ""; - for ( var a in attributes ) { - tag_attrs += " " + a + '="' + attributes[ a ] + '"'; - } - - // be careful about adding whitespace here for inline elements - return "<"+ tag + tag_attrs + ">" + content.join( "" ) + ""; -} - -function convert_tree_to_html( tree, references ) { - // shallow clone - var jsonml = tree.slice( 0 ); - - // Clone attributes if the exist - var attrs = extract_attr( jsonml ); - if ( attrs ) { - jsonml[ 1 ] = {}; - for ( var i in attrs ) { - jsonml[ 1 ][ i ] = attrs[ i ]; - } - attrs = jsonml[ 1 ]; - } - - // basic case - if ( typeof jsonml === "string" ) { - return jsonml; - } - - // convert this node - switch ( jsonml[ 0 ] ) { - case "header": - jsonml[ 0 ] = "h" + jsonml[ 1 ].level; - delete jsonml[ 1 ].level; - break; - case "bulletlist": - jsonml[ 0 ] = "ul"; - break; - case "numberlist": - jsonml[ 0 ] = "ol"; - break; - case "listitem": - jsonml[ 0 ] = "li"; - break; - case "para": - jsonml[ 0 ] = "p"; - break; - case "markdown": - jsonml[ 0 ] = "html"; - if ( attrs ) delete attrs.references; - break; - case "code_block": - jsonml[ 0 ] = "pre"; - var i = attrs ? 2 : 1; - var code = [ "code" ]; - code.push.apply( code, jsonml.splice( i ) ); - jsonml[ i ] = code; - break; - case "inlinecode": - jsonml[ 0 ] = "code"; - break; - case "img": - jsonml[ 1 ].src = jsonml[ 1 ].href; - delete jsonml[ 1 ].href; - break; - case "linebreak": - jsonml[0] = "br"; - break; - case "link": - jsonml[ 0 ] = "a"; - break; - case "link_ref": - jsonml[ 0 ] = "a"; - - // grab this ref and clean up the attribute node - var ref = references[ attrs.ref ]; - - // if the reference exists, make the link - if ( ref ) { - delete attrs.ref; - - // add in the href and title, if present - attrs.href = ref.href; - if ( ref.title ) { - attrs.title = ref.title; - } - - // get rid of the unneeded original text - delete attrs.original; - } - // the reference doesn't exist, so revert to plain text - else { - return attrs.original; - } - break; - } - - // convert all the children - var i = 1; - - // deal with the attribute node, if it exists - if ( attrs ) { - // if there are keys, skip over it - for ( var key in jsonml[ 1 ] ) { - i = 2; - } - // if there aren't, remove it - if ( i === 1 ) { - jsonml.splice( i, 1 ); - } - } - - for ( ; i < jsonml.length; ++i ) { - jsonml[ i ] = arguments.callee( jsonml[ i ], references ); - } - - return jsonml; -} - - -// merges adjacent text nodes into a single node -function merge_text_nodes( jsonml ) { - // skip the tag name and attribute hash - var i = extract_attr( jsonml ) ? 2 : 1; - - while ( i < jsonml.length ) { - // if it's a string check the next item too - if ( typeof jsonml[ i ] === "string" ) { - if ( i + 1 < jsonml.length && typeof jsonml[ i + 1 ] === "string" ) { - // merge the second string into the first and remove it - jsonml[ i ] += jsonml.splice( i + 1, 1 )[ 0 ]; - } - else { - ++i; - } - } - // if it's not a string recurse - else { - arguments.callee( jsonml[ i ] ); - ++i; - } - } -} - -} )( (function() { - if ( typeof exports === "undefined" ) { - window.markdown = {}; - return window.markdown; - } - else { - return exports; - } -} )() ); diff --git a/Tools/jsdoc3/node_modules/gfm/showdown.js b/Tools/jsdoc3/node_modules/gfm/showdown.js deleted file mode 100644 index facd58d98c7..00000000000 --- a/Tools/jsdoc3/node_modules/gfm/showdown.js +++ /dev/null @@ -1,1384 +0,0 @@ -// -// showdown.js -- A javascript port of Markdown. -// -// Copyright (c) 2007 John Fraser. -// -// Original Markdown Copyright (c) 2004-2005 John Gruber -// -// -// Redistributable under a BSD-style open source license. -// See license.txt for more information. -// -// The full source distribution is at: -// -// A A L -// T C A -// T K B -// -// -// - -// -// Wherever possible, Showdown is a straight, line-by-line port -// of the Perl version of Markdown. -// -// This is not a normal parser design; it's basically just a -// series of string substitutions. It's hard to read and -// maintain this way, but keeping Showdown close to the original -// design makes it easier to port new features. -// -// More importantly, Showdown behaves like markdown.pl in most -// edge cases. So web applications can do client-side preview -// in Javascript, and then build identical HTML on the server. -// -// This port needs the new RegExp functionality of ECMA 262, -// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers -// should do fine. Even with the new regular expression features, -// We do a lot of work to emulate Perl's regex functionality. -// The tricky changes in this file mostly have the "attacklab:" -// label. Major or self-explanatory changes don't. -// -// Smart diff tools like Araxis Merge will be able to match up -// this file with markdown.pl in a useful way. A little tweaking -// helps: in a copy of markdown.pl, replace "#" with "//" and -// replace "$text" with "text". Be sure to ignore whitespace -// and line endings. -// - - -// -// Showdown usage: -// -// var text = "Markdown *rocks*."; -// -// var converter = new Showdown.converter(); -// var html = converter.makeHtml(text); -// -// alert(html); -// -// Note: move the sample code to the bottom of this -// file before uncommenting it. -// - - -// ************************************************** -// GitHub Flavored Markdown modifications by Tekkub -// http://github.github.com/github-flavored-markdown/ -// -// Modifications are tagged with "GFM" -// ************************************************** - -// ================================================== -// CommonJS modifications by benblank -// http://www.commonjs.org/specs/modules/1.0/ -// -// Modifications are tagged with "CJS" -// ================================================== - -// -// Showdown namespace -// -var Showdown = {}; - -// -// converter -// -// Wraps all "globals" so that the only thing -// exposed is makeHtml(). -// -Showdown.converter = function() { - -// -// Globals: -// - -// Global hashes, used by various utility routines -var g_urls; -var g_titles; -var g_html_blocks; - -// Used to track when we're inside an ordered or unordered list -// (see _ProcessListItems() for details): -var g_list_level = 0; - -// == CJS == Allow hardwrapping to be disabled. -var g_hardwrap; - -this.makeHtml = function(text) { -// -// Main function. The order in which other subs are called here is -// essential. Link and image substitutions need to happen before -// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the -// and tags get encoded. -// - - // Clear the global hashes. If we don't clear these, you get conflicts - // from other articles when generating a page which contains more than - // one article (e.g. an index page that shows the N most recent - // articles): - g_urls = new Array(); - g_titles = new Array(); - g_html_blocks = new Array(); - - // == CJS == Allow hardwrapping to be disabled. - g_hardwrap = typeof this.hardwrap === "undefined" || this.hardwrap; - - // attacklab: Replace ~ with ~T - // This lets us use tilde as an escape char to avoid md5 hashes - // The choice of character is arbitray; anything that isn't - // magic in Markdown will work. - text = text.replace(/~/g,"~T"); - - // attacklab: Replace $ with ~D - // RegExp interprets $ as a special character - // when it's in a replacement string - text = text.replace(/\$/g,"~D"); - - // Standardize line endings - text = text.replace(/\r\n/g,"\n"); // DOS to Unix - text = text.replace(/\r/g,"\n"); // Mac to Unix - - // Make sure text begins and ends with a couple of newlines: - text = "\n\n" + text + "\n\n"; - - // Convert all tabs to spaces. - text = _Detab(text); - - // Strip any lines consisting only of spaces and tabs. - // This makes subsequent regexen easier to write, because we can - // match consecutive blank lines with /\n+/ instead of something - // contorted like /[ \t]*\n+/ . - text = text.replace(/^[ \t]+$/mg,""); - - // Turn block-level HTML blocks into hash entries - text = _HashHTMLBlocks(text); - - // Strip link definitions, store in hashes. - text = _StripLinkDefinitions(text); - - text = _RunBlockGamut(text); - - text = _UnescapeSpecialChars(text); - - // attacklab: Restore dollar signs - text = text.replace(/~D/g,"$$"); - - // attacklab: Restore tildes - text = text.replace(/~T/g,"~"); - - // == CJS == Create local `GitHub` object for use by GFM - var GitHub = this.githubRepoName && this.githubRepoOwner ? { - nameWithOwner: this.githubRepoOwner + "/" + this.githubRepoName, - repoName: this.githubRepoName - } : typeof window !== "undefined" ? window.GitHub : undefined; - - // ** GFM ** Auto-link URLs and emails - text = text.replace(/https?\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!]/g, function(wholeMatch,matchIndex){ - var left = text.slice(0, matchIndex), right = text.slice(matchIndex) - if (left.match(/<[^>]+$/) && right.match(/^[^>]*>/)) {return wholeMatch} - href = wholeMatch.replace(/^http:\/\/github.com\//, "https://github.com/") - return "" + wholeMatch + ""; - }); - text = text.replace(/[a-z0-9_\-+=.]+@[a-z0-9\-]+(\.[a-z0-9-]+)+/ig, function(wholeMatch){return "" + wholeMatch + "";}); - - // ** GFM ** Auto-link sha1 if GitHub.nameWithOwner is defined - text = text.replace(/[a-f0-9]{40}/ig, function(wholeMatch,matchIndex){ - if (typeof(GitHub) == "undefined" || typeof(GitHub.nameWithOwner) == "undefined") {return wholeMatch;} - var left = text.slice(0, matchIndex), right = text.slice(matchIndex) - if (left.match(/@$/) || (left.match(/<[^>]+$/) && right.match(/^[^>]*>/))) {return wholeMatch;} - return "" + wholeMatch.substring(0,7) + ""; - }); - - // ** GFM ** Auto-link user@sha1 if GitHub.nameWithOwner is defined - text = text.replace(/([a-z0-9_\-+=.]+)@([a-f0-9]{40})/ig, function(wholeMatch,username,sha,matchIndex){ - if (typeof(GitHub) == "undefined" || typeof(GitHub.nameWithOwner) == "undefined") {return wholeMatch;} - GitHub.repoName = GitHub.repoName || _GetRepoName() - var left = text.slice(0, matchIndex), right = text.slice(matchIndex) - if (left.match(/\/$/) || (left.match(/<[^>]+$/) && right.match(/^[^>]*>/))) {return wholeMatch;} - return "" + username + "@" + sha.substring(0,7) + ""; - }); - - // ** GFM ** Auto-link user/repo@sha1 - text = text.replace(/([a-z0-9_\-+=.]+\/[a-z0-9_\-+=.]+)@([a-f0-9]{40})/ig, function(wholeMatch,repo,sha){ - return "" + repo + "@" + sha.substring(0,7) + ""; - }); - - // ** GFM ** Auto-link #issue if GitHub.nameWithOwner is defined - text = text.replace(/#([0-9]+)/ig, function(wholeMatch,issue,matchIndex){ - if (typeof(GitHub) == "undefined" || typeof(GitHub.nameWithOwner) == "undefined") {return wholeMatch;} - var left = text.slice(0, matchIndex), right = text.slice(matchIndex) - if (left == "" || left.match(/[a-z0-9_\-+=.]$/) || (left.match(/<[^>]+$/) && right.match(/^[^>]*>/))) {return wholeMatch;} - return "" + wholeMatch + ""; - }); - - // ** GFM ** Auto-link user#issue if GitHub.nameWithOwner is defined - text = text.replace(/([a-z0-9_\-+=.]+)#([0-9]+)/ig, function(wholeMatch,username,issue,matchIndex){ - if (typeof(GitHub) == "undefined" || typeof(GitHub.nameWithOwner) == "undefined") {return wholeMatch;} - GitHub.repoName = GitHub.repoName || _GetRepoName() - var left = text.slice(0, matchIndex), right = text.slice(matchIndex) - if (left.match(/\/$/) || (left.match(/<[^>]+$/) && right.match(/^[^>]*>/))) {return wholeMatch;} - return "" + wholeMatch + ""; - }); - - // ** GFM ** Auto-link user/repo#issue - text = text.replace(/([a-z0-9_\-+=.]+\/[a-z0-9_\-+=.]+)#([0-9]+)/ig, function(wholeMatch,repo,issue){ - return "" + wholeMatch + ""; - }); - - return text; -} - - -var _GetRepoName = function() { - return GitHub.nameWithOwner.match(/^.+\/(.+)$/)[1] -} - -var _StripLinkDefinitions = function(text) { -// -// Strips link definitions from text, stores the URLs and titles in -// hash references. -// - - // Link defs are in the form: ^[id]: url "optional title" - - /* - var text = text.replace(/ - ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1 - [ \t]* - \n? // maybe *one* newline - [ \t]* - ? // url = $2 - [ \t]* - \n? // maybe one newline - [ \t]* - (?: - (\n*) // any lines skipped = $3 attacklab: lookbehind removed - ["(] - (.+?) // title = $4 - [")] - [ \t]* - )? // title is optional - (?:\n+|$) - /gm, - function(){...}); - */ - var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm, - function (wholeMatch,m1,m2,m3,m4) { - m1 = m1.toLowerCase(); - g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive - if (m3) { - // Oops, found blank lines, so it's not a title. - // Put back the parenthetical statement we stole. - return m3+m4; - } else if (m4) { - g_titles[m1] = m4.replace(/"/g,"""); - } - - // Completely remove the definition from the text - return ""; - } - ); - - return text; -} - - -var _HashHTMLBlocks = function(text) { - // attacklab: Double up blank lines to reduce lookaround - text = text.replace(/\n/g,"\n\n"); - - // Hashify HTML blocks: - // We only want to do this for block-level HTML tags, such as headers, - // lists, and tables. That's because we still want to wrap

    s around - // "paragraphs" that are wrapped in non-block-level tags, such as anchors, - // phrase emphasis, and spans. The list of tags we're looking for is - // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" - - // First, look for nested blocks, e.g.: - //

    - //
    - // tags for inner block must be indented. - //
    - //
    - // - // The outermost tags must start at the left margin for this to match, and - // the inner nested divs must be indented. - // We need to do this before the next, more liberal match, because the next - // match will start at the first `
    ` and stop at the first `
    `. - - // attacklab: This regex can be expensive when it fails. - /* - var text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_a) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*?\n // any number of lines, minimally matching - // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement); - - // - // Now match more liberally, simply from `\n` to `\n` - // - - /* - var text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_b) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*? // any number of lines, minimally matching - .* // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement); - - // Special case just for
    . It was easier to make a special case than - // to make the other regex more complicated. - - /* - text = text.replace(/ - ( // save in $1 - \n\n // Starting after a blank line - [ ]{0,3} - (<(hr) // start tag = $2 - \b // word break - ([^<>])*? // - \/?>) // the matching end tag - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement); - - // Special case for standalone HTML comments: - - /* - text = text.replace(/ - ( // save in $1 - \n\n // Starting after a blank line - [ ]{0,3} // attacklab: g_tab_width - 1 - - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,hashElement); - - // PHP and ASP-style processor instructions ( and <%...%>) - - /* - text = text.replace(/ - (?: - \n\n // Starting after a blank line - ) - ( // save in $1 - [ ]{0,3} // attacklab: g_tab_width - 1 - (?: - <([?%]) // $2 - [^\r]*? - \2> - ) - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement); - - // attacklab: Undo double lines (see comment at top of this function) - text = text.replace(/\n\n/g,"\n"); - return text; -} - -var hashElement = function(wholeMatch,m1) { - var blockText = m1; - - // Undo double lines - blockText = blockText.replace(/\n\n/g,"\n"); - blockText = blockText.replace(/^\n/,""); - - // strip trailing blank lines - blockText = blockText.replace(/\n+$/g,""); - - // Replace the element text with a marker ("~KxK" where x is its key) - blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n"; - - return blockText; -}; - -var _RunBlockGamut = function(text) { -// -// These are all the transformations that form block-level -// tags like paragraphs, headers, and list items. -// - text = _DoHeaders(text); - - // Do Horizontal Rules: - var key = hashBlock("
    "); - text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key); - text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key); - text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key); - - text = _DoLists(text); - text = _DoCodeBlocks(text); - text = _DoBlockQuotes(text); - - // We already ran _HashHTMLBlocks() before, in Markdown(), but that - // was to escape raw HTML in the original Markdown source. This time, - // we're escaping the markup we've just created, so that we don't wrap - //

    tags around block-level tags. - text = _HashHTMLBlocks(text); - text = _FormParagraphs(text); - - return text; -} - - -var _RunSpanGamut = function(text) { -// -// These are all the transformations that occur *within* block-level -// tags like paragraphs, headers, and list items. -// - - text = _DoCodeSpans(text); - text = _EscapeSpecialCharsWithinTagAttributes(text); - text = _EncodeBackslashEscapes(text); - - // Process anchor and image tags. Images must come first, - // because ![foo][f] looks like an anchor. - text = _DoImages(text); - text = _DoAnchors(text); - - // Make links out of things like `` - // Must come after _DoAnchors(), because you can use < and > - // delimiters in inline links like [this](). - text = _DoAutoLinks(text); - text = _EncodeAmpsAndAngles(text); - text = _DoItalicsAndBold(text); - - // Do hard breaks: - text = text.replace(/ +\n/g,"
    \n"); - - return text; -} - -var _EscapeSpecialCharsWithinTagAttributes = function(text) { -// -// Within tags -- meaning between < and > -- encode [\ ` * _] so they -// don't conflict with their use in Markdown for code, italics and strong. -// - - // Build a regex to find HTML tags and comments. See Friedl's - // "Mastering Regular Expressions", 2nd Ed., pp. 200-201. - var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi; - - text = text.replace(regex, function(wholeMatch) { - var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`"); - tag = escapeCharacters(tag,"\\`*_"); - return tag; - }); - - return text; -} - -var _DoAnchors = function(text) { -// -// Turn Markdown link shortcuts into XHTML tags. -// - // - // First, handle reference-style links: [link text] [id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[] // or anything else - )* - ) - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - )()()()() // pad remaining backreferences - /g,_DoAnchors_callback); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag); - - // - // Next, inline-style links: [link text](url "optional title") - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[\]] // or anything else - ) - ) - \] - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // href = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // Title = $7 - \6 // matching quote - [ \t]* // ignore any spaces/tabs between closing quote and ) - )? // title is optional - \) - ) - /g,writeAnchorTag); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag); - - // - // Last, handle reference-style shortcuts: [link text] - // These must come last in case you've also got [link test][1] - // or [link test](/foo) - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ([^\[\]]+) // link text = $2; can't contain '[' or ']' - \] - )()()()()() // pad rest of backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); - - return text; -} - -var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { - if (m7 == undefined) m7 = ""; - var whole_match = m1; - var link_text = m2; - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = link_text.toLowerCase().replace(/ ?\n/g," "); - } - url = "#"+link_id; - - if (g_urls[link_id] != undefined) { - url = g_urls[link_id]; - if (g_titles[link_id] != undefined) { - title = g_titles[link_id]; - } - } - else { - if (whole_match.search(/\(\s*\)$/m)>-1) { - // Special case for explicit empty url - url = ""; - } else { - return whole_match; - } - } - } - - url = escapeCharacters(url,"*_"); - var result = ""; - - return result; -} - - -var _DoImages = function(text) { -// -// Turn Markdown image shortcuts into tags. -// - - // - // First, handle reference-style labeled images: ![alt text][id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - )()()()() // pad rest of backreferences - /g,writeImageTag); - */ - text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag); - - // - // Next, handle inline images: ![alt text](url "optional title") - // Don't forget: encode * and _ - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - \s? // One optional whitespace character - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // src url = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // title = $7 - \6 // matching quote - [ \t]* - )? // title is optional - \) - ) - /g,writeImageTag); - */ - text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag); - - return text; -} - -var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { - var whole_match = m1; - var alt_text = m2; - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (!title) title = ""; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = alt_text.toLowerCase().replace(/ ?\n/g," "); - } - url = "#"+link_id; - - if (g_urls[link_id] != undefined) { - url = g_urls[link_id]; - if (g_titles[link_id] != undefined) { - title = g_titles[link_id]; - } - } - else { - return whole_match; - } - } - - alt_text = alt_text.replace(/"/g,"""); - url = escapeCharacters(url,"*_"); - var result = "\""" + _RunSpanGamut(m1) + "");}); - - text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, - function(matchFound,m1){return hashBlock("

    " + _RunSpanGamut(m1) + "

    ");}); - - // atx-style headers: - // # Header 1 - // ## Header 2 - // ## Header 2 with closing hashes ## - // ... - // ###### Header 6 - // - - /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ - - text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, - function(wholeMatch,m1,m2) { - var h_level = m1.length; - return hashBlock("" + _RunSpanGamut(m2) + ""); - }); - - return text; -} - -// This declaration keeps Dojo compressor from outputting garbage: -var _ProcessListItems; - -var _DoLists = function(text) { -// -// Form HTML ordered (numbered) and unordered (bulleted) lists. -// - - // attacklab: add sentinel to hack around khtml/safari bug: - // http://bugs.webkit.org/show_bug.cgi?id=11231 - text += "~0"; - - // Re-usable pattern to match any entirel ul or ol list: - - /* - var whole_list = / - ( // $1 = whole list - ( // $2 - [ ]{0,3} // attacklab: g_tab_width - 1 - ([*+-]|\d+[.]) // $3 = first list item marker - [ \t]+ - ) - [^\r]+? - ( // $4 - ~0 // sentinel for workaround; should be $ - | - \n{2,} - (?=\S) - (?! // Negative lookahead for another list item marker - [ \t]* - (?:[*+-]|\d+[.])[ \t]+ - ) - ) - )/g - */ - var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; - - if (g_list_level) { - text = text.replace(whole_list,function(wholeMatch,m1,m2) { - var list = m1; - var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol"; - - // Turn double returns into triple returns, so that we can make a - // paragraph for the last item in a list, if necessary: - list = list.replace(/\n{2,}/g,"\n\n\n");; - var result = _ProcessListItems(list); - - // Trim any trailing whitespace, to put the closing `` - // up on the preceding line, to get it past the current stupid - // HTML block parser. This is a hack to work around the terrible - // hack that is the HTML block parser. - result = result.replace(/\s+$/,""); - result = "<"+list_type+">" + result + "\n"; - return result; - }); - } else { - whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g; - text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) { - var runup = m1; - var list = m2; - - var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol"; - // Turn double returns into triple returns, so that we can make a - // paragraph for the last item in a list, if necessary: - var list = list.replace(/\n{2,}/g,"\n\n\n");; - var result = _ProcessListItems(list); - result = runup + "<"+list_type+">\n" + result + "\n"; - return result; - }); - } - - // attacklab: strip sentinel - text = text.replace(/~0/,""); - - return text; -} - -_ProcessListItems = function(list_str) { -// -// Process the contents of a single ordered or unordered list, splitting it -// into individual list items. -// - // The $g_list_level global keeps track of when we're inside a list. - // Each time we enter a list, we increment it; when we leave a list, - // we decrement. If it's zero, we're not in a list anymore. - // - // We do this because when we're not inside a list, we want to treat - // something like this: - // - // I recommend upgrading to version - // 8. Oops, now this line is treated - // as a sub-list. - // - // As a single paragraph, despite the fact that the second line starts - // with a digit-period-space sequence. - // - // Whereas when we're inside a list (or sub-list), that line will be - // treated as the start of a sub-list. What a kludge, huh? This is - // an aspect of Markdown's syntax that's hard to parse perfectly - // without resorting to mind-reading. Perhaps the solution is to - // change the syntax rules such that sub-lists must start with a - // starting cardinal number; e.g. "1." or "a.". - - g_list_level++; - - // trim trailing blank lines: - list_str = list_str.replace(/\n{2,}$/,"\n"); - - // attacklab: add sentinel to emulate \z - list_str += "~0"; - - /* - list_str = list_str.replace(/ - (\n)? // leading line = $1 - (^[ \t]*) // leading whitespace = $2 - ([*+-]|\d+[.]) [ \t]+ // list marker = $3 - ([^\r]+? // list item text = $4 - (\n{1,2})) - (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+)) - /gm, function(){...}); - */ - list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm, - function(wholeMatch,m1,m2,m3,m4){ - var item = m4; - var leading_line = m1; - var leading_space = m2; - - if (leading_line || (item.search(/\n{2,}/)>-1)) { - item = _RunBlockGamut(_Outdent(item)); - } - else { - // Recursion for sub-lists: - item = _DoLists(_Outdent(item)); - item = item.replace(/\n$/,""); // chomp(item) - item = _RunSpanGamut(item); - } - - return "
  • " + item + "
  • \n"; - } - ); - - // attacklab: strip sentinel - list_str = list_str.replace(/~0/g,""); - - g_list_level--; - return list_str; -} - - -var _DoCodeBlocks = function(text) { -// -// Process Markdown `
    ` blocks.
    -//
    -
    -	/*
    -		text = text.replace(text,
    -			/(?:\n\n|^)
    -			(								// $1 = the code block -- one or more lines, starting with a space/tab
    -				(?:
    -					(?:[ ]{4}|\t)			// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
    -					.*\n+
    -				)+
    -			)
    -			(\n*[ ]{0,3}[^ \t\n]|(?=~0))	// attacklab: g_tab_width
    -		/g,function(){...});
    -	*/
    -
    -	// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
    -	text += "~0";
    -
    -	text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
    -		function(wholeMatch,m1,m2) {
    -			var codeblock = m1;
    -			var nextChar = m2;
    -
    -			codeblock = _EncodeCode( _Outdent(codeblock));
    -			codeblock = _Detab(codeblock);
    -			codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
    -			codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
    -
    -			codeblock = "
    " + codeblock + "\n
    "; - - return hashBlock(codeblock) + nextChar; - } - ); - - // attacklab: strip sentinel - text = text.replace(/~0/,""); - - return text; -} - -var hashBlock = function(text) { - text = text.replace(/(^\n+|\n+$)/g,""); - return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n"; -} - - -var _DoCodeSpans = function(text) { -// -// * Backtick quotes are used for spans. -// -// * You can use multiple backticks as the delimiters if you want to -// include literal backticks in the code span. So, this input: -// -// Just type ``foo `bar` baz`` at the prompt. -// -// Will translate to: -// -//

    Just type foo `bar` baz at the prompt.

    -// -// There's no arbitrary limit to the number of backticks you -// can use as delimters. If you need three consecutive backticks -// in your code, use four for delimiters, etc. -// -// * You can use spaces to get literal backticks at the edges: -// -// ... type `` `bar` `` ... -// -// Turns to: -// -// ... type `bar` ... -// - - /* - text = text.replace(/ - (^|[^\\]) // Character before opening ` can't be a backslash - (`+) // $2 = Opening run of ` - ( // $3 = The code block - [^\r]*? - [^`] // attacklab: work around lack of lookbehind - ) - \2 // Matching closer - (?!`) - /gm, function(){...}); - */ - - text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, - function(wholeMatch,m1,m2,m3,m4) { - var c = m3; - c = c.replace(/^([ \t]*)/g,""); // leading whitespace - c = c.replace(/[ \t]*$/g,""); // trailing whitespace - c = _EncodeCode(c); - return m1+""+c+""; - }); - - return text; -} - - -var _EncodeCode = function(text) { -// -// Encode/escape certain characters inside Markdown code runs. -// The point is that in code, these characters are literals, -// and lose their special Markdown meanings. -// - // Encode all ampersands; HTML entities are not - // entities within a Markdown code span. - text = text.replace(/&/g,"&"); - - // Do the angle bracket song and dance: - text = text.replace(//g,">"); - - // Now, escape characters that are magic in Markdown: - text = escapeCharacters(text,"\*_{}[]\\",false); - -// jj the line above breaks this: -//--- - -//* Item - -// 1. Subitem - -// special char: * -//--- - - return text; -} - - -var _DoItalicsAndBold = function(text) { - - // must go first: - text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, - "$2"); - - text = text.replace(/(\w)_(\w)/g, "$1~E95E$2") // ** GFM ** "~E95E" == escaped "_" - text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, - "$2"); - - return text; -} - - -var _DoBlockQuotes = function(text) { - - /* - text = text.replace(/ - ( // Wrap whole match in $1 - ( - ^[ \t]*>[ \t]? // '>' at the start of a line - .+\n // rest of the first line - (.+\n)* // subsequent consecutive lines - \n* // blanks - )+ - ) - /gm, function(){...}); - */ - - text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, - function(wholeMatch,m1) { - var bq = m1; - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting - - // attacklab: clean up hack - bq = bq.replace(/~0/g,""); - - bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines - bq = _RunBlockGamut(bq); // recurse - - bq = bq.replace(/(^|\n)/g,"$1 "); - // These leading spaces screw with
     content, so we need to fix that:
    -			bq = bq.replace(
    -					/(\s*
    [^\r]+?<\/pre>)/gm,
    -				function(wholeMatch,m1) {
    -					var pre = m1;
    -					// attacklab: hack around Konqueror 3.5.4 bug:
    -					pre = pre.replace(/^  /mg,"~0");
    -					pre = pre.replace(/~0/g,"");
    -					return pre;
    -				});
    -
    -			return hashBlock("
    \n" + bq + "\n
    "); - }); - return text; -} - - -var _FormParagraphs = function(text) { -// -// Params: -// $text - string to process with html

    tags -// - - // Strip leading and trailing lines: - text = text.replace(/^\n+/g,""); - text = text.replace(/\n+$/g,""); - - var grafs = text.split(/\n{2,}/g); - var grafsOut = new Array(); - - // - // Wrap

    tags. - // - var end = grafs.length; - for (var i=0; i= 0) { - grafsOut.push(str); - } - else if (str.search(/\S/) >= 0) { - str = _RunSpanGamut(str); - // == CJS == Allow hardwrapping to be disabled. - if (g_hardwrap) str = str.replace(/\n/g,"
    "); // ** GFM ** - str = str.replace(/^([ \t]*)/g,"

    "); - str += "

    " - grafsOut.push(str); - } - - } - - // - // Unhashify HTML blocks - // - end = grafsOut.length; - for (var i=0; i= 0) { - var blockText = g_html_blocks[RegExp.$1]; - blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs - grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText); - } - } - - return grafsOut.join("\n\n"); -} - - -var _EncodeAmpsAndAngles = function(text) { -// Smart processing for ampersands and angle brackets that need to be encoded. - - // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: - // http://bumppo.net/projects/amputator/ - text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"); - - // Encode naked <'s - text = text.replace(/<(?![a-z\/?\$!])/gi,"<"); - - return text; -} - - -var _EncodeBackslashEscapes = function(text) { -// -// Parameter: String. -// Returns: The string, with after processing the following backslash -// escape sequences. -// - - // attacklab: The polite way to do this is with the new - // escapeCharacters() function: - // - // text = escapeCharacters(text,"\\",true); - // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); - // - // ...but we're sidestepping its use of the (slow) RegExp constructor - // as an optimization for Firefox. This function gets called a LOT. - - text = text.replace(/\\(\\)/g,escapeCharacters_callback); - text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback); - return text; -} - - -var _DoAutoLinks = function(text) { - - text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"
    $1"); - - // Email addresses: - - /* - text = text.replace(/ - < - (?:mailto:)? - ( - [-.\w]+ - \@ - [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ - ) - > - /gi, _DoAutoLinks_callback()); - */ - text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, - function(wholeMatch,m1) { - return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); - } - ); - - return text; -} - - -var _EncodeEmailAddress = function(addr) { -// -// Input: an email address, e.g. "foo@example.com" -// -// Output: the email address as a mailto link, with each character -// of the address encoded as either a decimal or hex entity, in -// the hopes of foiling most address harvesting spam bots. E.g.: -// -// foo -// @example.com -// -// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk -// mailing list: -// - - // attacklab: why can't javascript speak hex? - function char2hex(ch) { - var hexDigits = '0123456789ABCDEF'; - var dec = ch.charCodeAt(0); - return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15)); - } - - var encode = [ - function(ch){return "&#"+ch.charCodeAt(0)+";";}, - function(ch){return "&#x"+char2hex(ch)+";";}, - function(ch){return ch;} - ]; - - addr = "mailto:" + addr; - - addr = addr.replace(/./g, function(ch) { - if (ch == "@") { - // this *must* be encoded. I insist. - ch = encode[Math.floor(Math.random()*2)](ch); - } else if (ch !=":") { - // leave ':' alone (to spot mailto: later) - var r = Math.random(); - // roughly 10% raw, 45% hex, 45% dec - ch = ( - r > .9 ? encode[2](ch) : - r > .45 ? encode[1](ch) : - encode[0](ch) - ); - } - return ch; - }); - - addr = "" + addr + ""; - addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part - - return addr; -} - - -var _UnescapeSpecialChars = function(text) { -// -// Swap back in all the special characters we've hidden. -// - text = text.replace(/~E(\d+)E/g, - function(wholeMatch,m1) { - var charCodeToReplace = parseInt(m1); - return String.fromCharCode(charCodeToReplace); - } - ); - return text; -} - - -var _Outdent = function(text) { -// -// Remove one level of line-leading tabs or spaces -// - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width - - // attacklab: clean up hack - text = text.replace(/~0/g,"") - - return text; -} - -var _Detab = function(text) { -// attacklab: Detab's completely rewritten for speed. -// In perl we could fix it by anchoring the regexp with \G. -// In javascript we're less fortunate. - - // expand first n-1 tabs - text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width - - // replace the nth with two sentinels - text = text.replace(/\t/g,"~A~B"); - - // use the sentinel to anchor our regex so it doesn't explode - text = text.replace(/~B(.+?)~A/g, - function(wholeMatch,m1,m2) { - var leadingText = m1; - var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width - - // there *must* be a better way to do this: - for (var i=0; i\n" : "/>"; - if (hasChild) { - for (var m in v) { - if (m == "#text") - xml += makeSafe(v[m]); - else if (m == "#cdata") - xml += ""; - else if (m.charAt(0) != "@") - xml += toXml(v[m], m, ind+"\t"); - } - xml += (xml.charAt(xml.length-1)=="\n"?ind:"") + "\n"; - } - } - else { // added special-character transform, but this needs to be better handled [micmath] - xml += ind + "<" + name + ">" + makeSafe(v.toString()) + "\n"; - } - return xml; - }, - xml=""; - - for (var m in o) { - xml += toXml(o[m], m, ""); - } - - return xml; - } - - function lines(str) { - // normalise line endings, all in file will be unixy - str = str.replace(/\r\n/g, '\n'); - - return str; - } - - function makeSafe(str) { - // xml special charaters - str = str.replace(/ 16) bkey = binl_md5(bkey, key.length * 8); - - var ipad = Array(16), opad = Array(16); - for(var i = 0; i < 16; i++) - { - ipad[i] = bkey[i] ^ 0x36363636; - opad[i] = bkey[i] ^ 0x5C5C5C5C; - } - - var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8); - return binl2rstr(binl_md5(opad.concat(hash), 512 + 128)); -} - -/* - * Convert a raw string to a hex string - */ -function rstr2hex(input) -{ - try { hexcase } catch(e) { hexcase=0; } - var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; - var output = ""; - var x; - for(var i = 0; i < input.length; i++) - { - x = input.charCodeAt(i); - output += hex_tab.charAt((x >>> 4) & 0x0F) - + hex_tab.charAt( x & 0x0F); - } - return output; -} - -/* - * Convert a raw string to a base-64 string - */ -function rstr2b64(input) -{ - try { b64pad } catch(e) { b64pad=''; } - var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - var output = ""; - var len = input.length; - for(var i = 0; i < len; i += 3) - { - var triplet = (input.charCodeAt(i) << 16) - | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) - | (i + 2 < len ? input.charCodeAt(i+2) : 0); - for(var j = 0; j < 4; j++) - { - if(i * 8 + j * 6 > input.length * 8) output += b64pad; - else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); - } - } - return output; -} - -/* - * Convert a raw string to an arbitrary string encoding - */ -function rstr2any(input, encoding) -{ - var divisor = encoding.length; - var i, j, q, x, quotient; - - /* Convert to an array of 16-bit big-endian values, forming the dividend */ - var dividend = Array(Math.ceil(input.length / 2)); - for(i = 0; i < dividend.length; i++) - { - dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); - } - - /* - * Repeatedly perform a long division. The binary array forms the dividend, - * the length of the encoding is the divisor. Once computed, the quotient - * forms the dividend for the next step. All remainders are stored for later - * use. - */ - var full_length = Math.ceil(input.length * 8 / - (Math.log(encoding.length) / Math.log(2))); - var remainders = Array(full_length); - for(j = 0; j < full_length; j++) - { - quotient = Array(); - x = 0; - for(i = 0; i < dividend.length; i++) - { - x = (x << 16) + dividend[i]; - q = Math.floor(x / divisor); - x -= q * divisor; - if(quotient.length > 0 || q > 0) - quotient[quotient.length] = q; - } - remainders[j] = x; - dividend = quotient; - } - - /* Convert the remainders to the output string */ - var output = ""; - for(i = remainders.length - 1; i >= 0; i--) - output += encoding.charAt(remainders[i]); - - return output; -} - -/* - * Encode a string as utf-8. - * For efficiency, this assumes the input is valid utf-16. - */ -function str2rstr_utf8(input) -{ - var output = ""; - var i = -1; - var x, y; - - while(++i < input.length) - { - /* Decode utf-16 surrogate pairs */ - x = input.charCodeAt(i); - y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; - if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) - { - x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); - i++; - } - - /* Encode output as utf-8 */ - if(x <= 0x7F) - output += String.fromCharCode(x); - else if(x <= 0x7FF) - output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F), - 0x80 | ( x & 0x3F)); - else if(x <= 0xFFFF) - output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), - 0x80 | ((x >>> 6 ) & 0x3F), - 0x80 | ( x & 0x3F)); - else if(x <= 0x1FFFFF) - output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), - 0x80 | ((x >>> 12) & 0x3F), - 0x80 | ((x >>> 6 ) & 0x3F), - 0x80 | ( x & 0x3F)); - } - return output; -} - -/* - * Encode a string as utf-16 - */ -function str2rstr_utf16le(input) -{ - var output = ""; - for(var i = 0; i < input.length; i++) - output += String.fromCharCode( input.charCodeAt(i) & 0xFF, - (input.charCodeAt(i) >>> 8) & 0xFF); - return output; -} - -function str2rstr_utf16be(input) -{ - var output = ""; - for(var i = 0; i < input.length; i++) - output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, - input.charCodeAt(i) & 0xFF); - return output; -} - -/* - * Convert a raw string to an array of little-endian words - * Characters >255 have their high-byte silently ignored. - */ -function rstr2binl(input) -{ - var output = Array(input.length >> 2); - for(var i = 0; i < output.length; i++) - output[i] = 0; - for(var i = 0; i < input.length * 8; i += 8) - output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32); - return output; -} - -/* - * Convert an array of little-endian words to a string - */ -function binl2rstr(input) -{ - var output = ""; - for(var i = 0; i < input.length * 32; i += 8) - output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF); - return output; -} - -/* - * Calculate the MD5 of an array of little-endian words, and a bit length. - */ -function binl_md5(x, len) -{ - /* append padding */ - x[len >> 5] |= 0x80 << ((len) % 32); - x[(((len + 64) >>> 9) << 4) + 14] = len; - - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - - for(var i = 0; i < x.length; i += 16) - { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - - a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); - d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); - c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); - b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); - a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); - d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); - c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); - b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); - a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); - d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); - c = md5_ff(c, d, a, b, x[i+10], 17, -42063); - b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); - a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); - d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); - c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); - b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); - - a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); - d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); - c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); - b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); - a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); - d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); - c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); - b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); - a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); - d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); - c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); - b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); - a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); - d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); - c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); - b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); - - a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); - d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); - c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); - b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); - a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); - d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); - c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); - b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); - a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); - d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); - c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); - b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); - a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); - d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); - c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); - b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); - - a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); - d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); - c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); - b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); - a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); - d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); - c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); - b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); - a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); - d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); - c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); - b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); - a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); - d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); - c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); - b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); - - a = safe_add(a, olda); - b = safe_add(b, oldb); - c = safe_add(c, oldc); - d = safe_add(d, oldd); - } - return Array(a, b, c, d); -} - -/* - * These functions implement the four basic operations the algorithm uses. - */ -function md5_cmn(q, a, b, x, s, t) -{ - return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); -} -function md5_ff(a, b, c, d, x, s, t) -{ - return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); -} -function md5_gg(a, b, c, d, x, s, t) -{ - return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); -} -function md5_hh(a, b, c, d, x, s, t) -{ - return md5_cmn(b ^ c ^ d, a, b, x, s, t); -} -function md5_ii(a, b, c, d, x, s, t) -{ - return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); -} - -/* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - */ -function safe_add(x, y) -{ - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); -} - -/* - * Bitwise rotate a 32-bit number to the left. - */ -function bit_rol(num, cnt) -{ - return (num << cnt) | (num >>> (32 - cnt)); -} - -exports.hex_md5 = hex_md5; -exports.b64_md5 = b64_md5; -exports.rstr_md5 = rstr_md5; \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/sitepen/jsonschema.js b/Tools/jsdoc3/node_modules/sitepen/jsonschema.js deleted file mode 100644 index 13756333cc7..00000000000 --- a/Tools/jsdoc3/node_modules/sitepen/jsonschema.js +++ /dev/null @@ -1,233 +0,0 @@ -/** - * JSONSchema Validator - Validates JavaScript objects using JSON Schemas - * (http://www.json.com/json-schema-proposal/) - * - * Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com) - * Licensed under the MIT (MIT-LICENSE.txt) license. -To use the validator call JSONSchema.validate with an instance object and an optional schema object. -If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), -that schema will be used to validate and the schema parameter is not necessary (if both exist, -both validations will occur). -The validate method will return an array of validation errors. If there are no errors, then an -empty list will be returned. A validation error will have two properties: -"property" which indicates which property had the error -"message" which indicates what the error was - */ - -// setup primitive classes to be JSON Schema types -String.type = "string"; -Boolean.type = "boolean"; -Number.type = "number"; -exports.Integer = {type:"integer"}; -Object.type = "object"; -Array.type = "array"; -Date.type = "string"; -Date.format = "date-time"; - -exports.validate = function(/*Any*/instance,/*Object*/schema) { - // Summary: - // To use the validator call JSONSchema.validate with an instance object and an optional schema object. - // If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), - // that schema will be used to validate and the schema parameter is not necessary (if both exist, - // both validations will occur). - // The validate method will return an object with two properties: - // valid: A boolean indicating if the instance is valid by the schema - // errors: An array of validation errors. If there are no errors, then an - // empty list will be returned. A validation error will have two properties: - // property: which indicates which property had the error - // message: which indicates what the error was - // - return validate(instance,schema,false); - }; -exports.checkPropertyChange = function(/*Any*/value,/*Object*/schema, /*String*/ property) { - // Summary: - // The checkPropertyChange method will check to see if an value can legally be in property with the given schema - // This is slightly different than the validate method in that it will fail if the schema is readonly and it will - // not check for self-validation, it is assumed that the passed in value is already internally valid. - // The checkPropertyChange method will return the same object type as validate, see JSONSchema.validate for - // information. - // - return validate(value,schema, property || "property"); - }; -var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { - - var errors = []; - // validate a value against a property definition - function checkProp(value, schema, path,i){ - var l; - path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; - function addError(message){ - errors.push({property:path,message:message}); - } - - if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function') && !(schema && schema.type)){ - if(typeof schema == 'function'){ - if(!(value instanceof schema)){ - addError("is not an instance of the class/constructor " + schema.name); - } - }else if(schema){ - addError("Invalid schema/property definition " + schema); - } - return null; - } - if(_changing && schema.readonly){ - addError("is a readonly field, it can not be changed"); - } - if(schema['extends']){ // if it extends another schema, it must pass that schema as well - checkProp(value,schema['extends'],path,i); - } - // validate a value against a type definition - function checkType(type,value){ - if(type){ - if(typeof type == 'string' && type != 'any' && - (type == 'null' ? value !== null : typeof value != type) && - !(value instanceof Array && type == 'array') && - !(type == 'integer' && value%1===0)){ - return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; - } - if(type instanceof Array){ - var unionErrors=[]; - for(var j = 0; j < type.length; j++){ // a union type - if(!(unionErrors=checkType(type[j],value)).length){ - break; - } - } - if(unionErrors.length){ - return unionErrors; - } - }else if(typeof type == 'object'){ - var priorErrors = errors; - errors = []; - checkProp(value,type,path); - var theseErrors = errors; - errors = priorErrors; - return theseErrors; - } - } - return []; - } - if(value === undefined){ - if(!schema.optional && !schema.get){ - addError("is missing and it is not optional"); - } - }else{ - errors = errors.concat(checkType(schema.type,value)); - if(schema.disallow && !checkType(schema.disallow,value).length){ - addError(" disallowed value was matched"); - } - if(value !== null){ - if(value instanceof Array){ - if(schema.items){ - if(schema.items instanceof Array){ - for(i=0,l=value.length; i schema.maxItems){ - addError("There must be a maximum of " + schema.maxItems + " in the array"); - } - }else if(schema.properties || schema.additionalProperties){ - errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties)); - } - if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ - addError("does not match the regex pattern " + schema.pattern); - } - if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ - addError("may only be " + schema.maxLength + " characters long"); - } - if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ - addError("must be at least " + schema.minLength + " characters long"); - } - if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && - schema.minimum > value){ - addError("must have a minimum value of " + schema.minimum); - } - if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && - schema.maximum < value){ - addError("must have a maximum value of " + schema.maximum); - } - if(schema['enum']){ - var enumer = schema['enum']; - l = enumer.length; - var found; - for(var j = 0; j < l; j++){ - if(enumer[j]===value){ - found=1; - break; - } - } - if(!found){ - addError("does not have a value in the enumeration " + enumer.join(", ")); - } - } - if(typeof schema.maxDecimal == 'number' && - (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ - addError("may only have " + schema.maxDecimal + " digits of decimal places"); - } - } - } - return null; - } - // validate an object against a schema - function checkObj(instance,objTypeDef,path,additionalProp){ - - if(typeof objTypeDef =='object'){ - if(typeof instance != 'object' || instance instanceof Array){ - errors.push({property:path,message:"an object is required"}); - } - - for(var i in objTypeDef){ - if(objTypeDef.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_')){ - var value = instance[i]; - var propDef = objTypeDef[i]; - checkProp(value,propDef,path,i); - } - } - } - for(i in instance){ - if(instance.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_') && objTypeDef && !objTypeDef[i] && additionalProp===false){ - errors.push({property:path,message:(typeof value) + "The property " + i + - " is not defined in the schema and the schema does not allow additional properties"}); - } - var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires; - if(requires && !(requires in instance)){ - errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); - } - value = instance[i]; - if(additionalProp && (!(objTypeDef && typeof objTypeDef == 'object') || !(i in objTypeDef))){ - checkProp(value,additionalProp,path,i); - } - if(!_changing && value && value.$schema){ - errors = errors.concat(checkProp(value,value.$schema,path,i)); - } - } - return errors; - } - if(schema){ - checkProp(instance,schema,'',_changing || ''); - } - if(!_changing && instance && instance.$schema){ - checkProp(instance,instance.$schema,'',''); - } - return {valid:!errors.length,errors:errors}; -}; -exports.mustBeValid = function(result){ - // summary: - // This checks to ensure that the result is valid and will throw an appropriate error message if it is not - // result: the result returned from checkPropertyChange or validate - if(!result.valid){ - throw new TypeError(result.errors.map(function(error){return "for property " + error.property + ': ' + error.message;}).join(", \n")); - } -} - /* will add this later - newFromSchema : function() { - } -*/ diff --git a/Tools/jsdoc3/node_modules/typicaljoe/taffy.js b/Tools/jsdoc3/node_modules/typicaljoe/taffy.js deleted file mode 100644 index 03fe852aebf..00000000000 --- a/Tools/jsdoc3/node_modules/typicaljoe/taffy.js +++ /dev/null @@ -1,1427 +0,0 @@ -/* - -Software License Agreement (BSD License) -http://taffydb.com -Copyright (c) 2008 -All rights reserved. -Version 1.7.3 - - -Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following condition is met: - -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -SUMMARY: -TAFFY takes a JavaScript object and returns a set of methods -to search, modify, and manipulate that object. - -*/ - -var TAFFY = function (obj) { - var conf = { - template:null - }, T = TAFFY, raw = (T.isString(obj)) ? T.JSON.parse(obj) : obj, TOb = raw, TIA = [], t = true, f=false; - - - // **************************************** - // * - // * Create prvate mergeTemp function - // * Loop over set of indexes and apply a template to the record - // * - // **************************************** - var mergeTemp = function (rows,tmpl) { - var tmpl = tmpl || conf.template; - if (!TAFFY.isNull(tmpl)) - { - for(var x = 0, xl = rows.length; x < xl; x++) { - TOb[rows[x]] = TAFFY.mergeObj(TOb[rows[x]],tmpl); - } - } - }; - - // **************************************** - // * - // * Create prvate bTIA function - // * Loop over every index within the Taffy Object TOb - // * and populate the Taffy Index Array TIA with the indexes - // * - // **************************************** - var bTIA = function () { - TIA = []; - for(var x = 0, xl = TOb.length; x < xl; x++) { - TIA[TIA.length] = x; - } - }; - bTIA(); - - - // **************************************** - // * - // * Create prvate findTests Object - // * Collect all possible true/false expression used when - // * doing lookups via the public find method. - // * Purpose: Used to house and document all of the - // * possible ways to match a value to a field with the - // * TAFFY Object. Each of the contained functions does an - // * evaluation against a value from the TAFFY Obj and a test - // * provided by the caller of the find method. If this - // * evaluation is true then the find method will add - // * the TAFFY Object record to the results set. - // * - // **************************************** - - var findTests = { - - pickTest:function(Tt) - { - var m = (Tt.indexOf("!") === 0) ? f : t; - if (!m) - { - Tt = Tt.substring(1,Tt.length); - } - return {test:(Tt == 'equal') ? 'is' : - (Tt == 'notequal') ? 'not' : - (Tt == 'startswith') ? 'starts' : - (Tt == 'endswith') ? 'ends' : - (Tt == 'greaterthan') ? 'gt' : - (Tt == 'lessthan') ? 'lt' : - (Tt == 'regexppass') ? 'regex' : Tt,mode:(m) ? {s:t,f:f} : {s:f,f:t}}; - }, - run:function(s,mvalue,mtest,b) { - return ((s=="regex") ? (mtest.test(mvalue)) : - (s=="lt") ? (mvalue < mtest) : - (s=="gt") ? (mvalue > mtest) : - (s=="lte") ? (mvalue <= mtest) : - (s=="gte") ? (mvalue >= mtest) : - (s=="starts") ? (mvalue.indexOf(mtest) === 0) : - (s=="ends") ? (mvalue.substring((mvalue.length - mtest.length)) == mtest) : - (s=="like") ? (mvalue.indexOf(mtest) >= 0) : - (s=="is") ? (mvalue == mtest) : - (s=="has") ? (T.has(mvalue,mtest)) : - (s=="hasAll") ? (T.hasAll(mvalue,mtest)) : - (s=="length") ? (findTests.length(mvalue,mtest,b)) : - findTests[s](mvalue,mtest)) ? b.s : b.f; - }, - length:function (mvalue,mtest,b) - { - // If a value length exits and meets filter criteria - var rlen = (!T.isUndefined(mvalue.length)) ? mvalue.length : (!T.isUndefined(mvalue.getLength)) ? mvalue.getLength() : 0; - if (T.isObject(mtest)) { - for(var kt in mtest) - { - if (mtest.hasOwnProperty(kt)) - { - var pt = findTests.pickTest(kt); - return findTests.run(pt.test,rlen,mtest[kt],pt.mode) ? t : f; - } - } - } - // default return - return rlen == mtest ? b.s : b.f; - } - }; - - // Add in isObjectType checks - (function () { - for(var z in TAFFY) - { - if (TAFFY.hasOwnProperty(z) && z.indexOf("is") === 0) - { - (function (y) { - findTests["is" + y] = function (mvalue,mtest,b) { - return (TAFFY["is" + y](mvalue) == mtest) ? t : f; - }; - }(z.substring(2,z.length))); - } - } - }()); - - // **************************************** - // * - // * Create prvate bDexArray method - // * Return an array of indexes - // * Purpose: Used to create a variable that is an - // * array that contains the indexes of the records - // * that an action should be taken on. If a single - // * number is passed then an array is created with that - // * number being in postion 0. If an array is passed - // * in then that array is returned. If no value is - // * passed in then an array containing every index - // * in the TAFFY Obj is returned. If an object is passed - // * then a call to the find function is made and the - // * resulting array of indexes returned. - // * - // **************************************** - - var bDexArray = function (iA,f) { - var rA = []; - if (!T.isArray(iA) && TAFFY.isNumber(iA)) - { - rA[rA.length] = iA; - } - else if (T.isArray(iA)) - { - rA = iA; - - } - else if (T.isObject(iA)) - { - rA = f(iA); - } - else if (!T.isArray(iA) && !T.isNumber(iA)) - { - rA = TIA; - } - return rA; - }; - - // **************************************** - // * - // * Create private toLogicalArray method - // * return custom array for use in array.sort based on sort obj - // * argument - // * Purpose: This is used by the buildSortFunction function in the case - // * of logical and logicaldesc sort types. This function splits a complex - // * value into an array so that each array item can be compared against - // * the item at the index in each value. - // * - // **************************************** - var toLogicalArray = function (value) { - var rArray = [0],type = "none",value = value + ""; - if (!T.isNull(value) && !T.isUndefined(value)) { - for(var n = 0, nl = value.length;n y[z]){ - returnvar = 1; - break; - } - } - if (x.length < y.length && returnvar==0) - { - returnvar = -1; - } else if (x.length > y.length && returnvar==0) { - returnvar = 1; - } - } else if (custO[sa].sortDir == 'logicaldesc') { - x = toLogicalArray(x); - y = toLogicalArray(y); - for(var z = 0, zl = y.length;z y[z] && z < x.length) { - returnvar = -1; - break; - } else if (x[z] < y[z]){ - returnvar = 1; - break; - } - } - if (x.length < y.length && returnvar==0) - { - returnvar = 1; - } else if (x.length > y.length && returnvar==0) { - returnvar = -1; - } - } else { - if (T.isNull(x) || T.isUndefined(x) || x < y) { - returnvar = -1; - } else if (T.isNull(y) || T.isUndefined(y) || x > y){ - returnvar = 1; - } - } - - } - - } - return returnvar; - - }; - - }; - - // **************************************** - // * - // * Return Obj containing Methods - // * - // **************************************** - return { - - // **************************************** - // * - // * This is a simple true flag to identify - // * the returned collection as being created by - // * TAFFY() - // * - // **************************************** - TAFFY:true, - - // **************************************** - // * - // * Get the length of the TAFFY collection. - // * - // **************************************** - getLength:function () { - return TOb.length; - }, - - // **************************************** - // * - // * This is the date of the last change - // * to the TAFFY object. - // * - // **************************************** - lastModifyDate:new Date(), - - // **************************************** - // * - // * Create public find method - // * Returns array of index numbers for matching array values - // * Purpose: This takes an obj that defines a set of match - // * cases for use against the TOb. Matching indexes are - // * added to an array and then returned to the user. This is the - // * primary "lookup" feature of TAFFY and is how you find individual - // * or sets of records for use in update, remove, get, etc. - // * - // **************************************** - find : function (matchObj,findFilter) { - - - // define findMatches array and findMatchesLoaded flag - var findIndex = 0; - - // if findFilter is provided use findFilter to start findMatches array - // otherwise use TIA which contains all indexes of the TOb - if (T.isArray(findFilter)) { - var findMatches = findFilter; - } else { - var findMatches = TIA; - - } - - // if matchObject is a function run it against every item in findMatches - if (T.isFunction(matchObj)) { - var thisMatchArray = []; - // loop over every element in the findMatches - for (var d = 0, dl = findMatches.length; d < dl; d++) { - // add to matched item list if function returns true - if (matchObj(TOb[d], d)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - } - } - findMatches = thisMatchArray; - } - else { - // loop over attributes in matchObj - for (var mi in matchObj) { - if (matchObj.hasOwnProperty(mi)) { - // default matchType, matchValue, matchField - var matchType = 'is', matchValue = '', matchField = mi, matchMode = { - s: t, - f: f - }, pt = {}; - - // If the matchObj attribute is an object - if (T.isObject(matchObj[mi])) { - - // loop over match field attributes - for (var fi in matchObj[mi]) { - if (matchObj[mi].hasOwnProperty(fi)) { - // switch over attributes, extract data - pt = findTests.pickTest(fi); - matchType = pt.test; - matchMode = pt.mode; - - matchValue = matchObj[mi][fi]; - } - } - } - // If the matchObj attribute is not an object - else { - // set the match value to the value provided - matchValue = matchObj[mi]; - } - - //define thisMatchArray for this find method - var thisMatchArray = []; - - // loop over every element in the findMatches - for (var d = 0, dl = findMatches.length; d < dl; d++) { - - // if the value is an array of values, loop rather than do 1 to 1 - if (T.isArray(matchValue) && matchType != 'isSameArray' && matchType != 'hasAll') { - // call the correct filter based on matchType and add the record if the filter returns true for normal mode - if (matchMode.s) { - for (var md = 0; md < matchValue.length; md++) { - - if (findTests.run(matchType, TOb[findMatches[d]][matchField], matchValue[md], matchMode)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - - } - - } - } - else { - - // call the correct filter based on matchType and add the record only if fit passes every filter value if negative (!) mode - var pt = 1; - for (var md = 0; md < matchValue.length; md++) { - - if (!findTests.run(matchType, TOb[findMatches[d]][matchField], matchValue[md], matchMode)) { - pt = 0; - - } - - } - if (pt == 1) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - } - } - } - // if the value is a function call function and append index if it returns true - else - if (T.isFunction(matchValue) && matchValue(TOb[findMatches[d]][matchField], d)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - } - // if the value is not an array but a single value - // If an exact match is found then add it to the array - - else - if (findTests.run(matchType, TOb[findMatches[d]][matchField], matchValue, matchMode)) { - thisMatchArray[thisMatchArray.length] = findMatches[d]; - - } - } - - findMatches = thisMatchArray; - } - } - } - // Garther only unique finds - findMatches = T.gatherUniques(findMatches); - - return findMatches; - }, - - // **************************************** - // * - // * Create public remove method - // * Purpose: This is used to remove a record from - // * the TOb by an index or an array of indexes. - // * - // **************************************** - remove : function (dex) { - - var removeIndex = bDexArray(dex,this.find); - - // loop over removeIndex and set each record to remove - // this is done so all records are flagged for remove - // before the size of the array changes do to the splice - // function below - for(var di = 0, dil = removeIndex.length; di < dil; di++) { - if (!T.isNull(this.onRemove)) - { - this.onRemove(TOb[removeIndex[di]]); - } - TOb[removeIndex[di]] = 'remove'; - } - - // nested function find delete - var removeRemaining = function () { - for(var tdi = 0, tdil = TOb.length; tdi < tdil; tdi++) { - if (TOb[tdi] === 'remove') { - return t; - } - } - return f; - }; - - // loop over TOb and remove all rows set to remove - while (removeRemaining()) { - for(var tdi = 0, tdil = TOb.length; tdi < tdil; tdi++) { - if (TOb[tdi] === 'remove') { - TOb.splice(tdi,1); - // update lastModifyDate - this.lastModifyDate = new Date(); - } - } - } - - // populate TIA - bTIA(); - return removeIndex; - }, - - - - - // **************************************** - // * - // * Create public insert method - // * Purpose: this takes an obj and inserts it into - // * the TAFFY Obj array - // * - // **************************************** - insert : function (newRecordObj) { - - var rec = (TAFFY.isArray(newRecordObj)) ? newRecordObj : [newRecordObj]; - - for (var x = 0; x < rec.length; x++) { - if (!T.isNull(this.onInsert)) { - this.onInsert(rec[x]); - } - - - // Do insert - TOb[TOb.length] = (TAFFY.isNull(conf.template)) ? rec[x] : TAFFY.mergeObj(conf.template, rec[x]); - - // update lastModifyDate - this.lastModifyDate = new Date(); - - // populate TIA - TIA[TIA.length] = TOb.length - 1; - - } - return [TOb.length-1]; - }, - - // **************************************** - // * - // * Create public update method - // * Purpose: This takes an obj of name/value - // * pairs and then a set of 1 or more indexes - // * and updates those records with in the TOb - // * - // **************************************** - update : function (updateObj,dex) { - - var updateIndex = bDexArray(dex,this.find), updateCount=0; - - for(var d = 0, dl = updateIndex.length; d < dl; d++) { - // set the updatedex - var updateDex = updateIndex[d]; - - if (!T.isNull(this.onUpdate)) - { - this.onUpdate(updateObj,TOb[updateDex]); - } - - // Merge Objects - TOb[updateDex] = T.mergeObj(TOb[updateDex],updateObj); - - // add the updaecount - updateCount++; - - } - - return updateIndex; - }, - - - // **************************************** - // * - // * Create public get method - // * Purpose: This return an array containing - // * the rows for a set of indexes. Used to get - // * a record set with the help of the find - // * function. Returns an empty array if - // * no records are found. - // * - // **************************************** - - get : function (dex) { - - var nT = []; - - var getIndex = bDexArray(dex,this.find); - - // loop over all of the indexes - for(var d = 0, dl = getIndex.length; d < dl; d++) { - - // add the TOb to the newTAFFYArray array - nT[nT.length] = TOb[getIndex[d]]; - } - return nT; - }, - - // **************************************** - // * - // * Create public first method - // * Purpose: This returns the first row - // * from a set of indexes. Used to get - // * a record with the help of the find - // * function. Returns false if no records - // * are found. - // * - // **************************************** - - first : function (dex) { - - var getIndex = bDexArray(dex,this.find); - - return (getIndex.length > 0) ? TOb[getIndex[0]] : false; - - }, - - // **************************************** - // * - // * Create public last method - // * Purpose: This returns the last row - // * from a set of indexes. Used to get - // * a record with the help of the find - // * function. Returns false if no records - // * are found. - // * - // **************************************** - - last : function (dex) { - - var getIndex = bDexArray(dex,this.find); - - return (getIndex.length > 0) ? TOb[getIndex[(getIndex.length - 1)]] : false; - }, - - // **************************************** - // * - // * Create public stringify method - // * Purpose: This returns a string JSON array - // * from a set of indexes. Used to get records - // * for handling by AJAX or other langauges. - // * - // **************************************** - - stringify : function (dex) { - - return T.JSON.stringify(this.get(dex)); - }, - - // **************************************** - // * - // * Create public orderBy method - // * Purpose: Reorder the array according - // * to a list of fields. Very useful for - // * ordering tables or other types of - // * sorting. - // * - // **************************************** - orderBy : function (Obj) { - - // Only attempt to sort if there is a length - // to the TAFFY array - if (TOb.length > 0) { - // Use the private buildSortFunction method - // to create a custom sort function unless one is provided - - if (T.isFunction(Obj)) { - var customSort = Obj; - } else { - var customSort = buildSortFunction(Obj); - } - - // Call JavaScript's array.sort with the custom - // sort function - TOb.sort(customSort); - - // update lastModifyDate - this.lastModifyDate = new Date(); - - - } - }, - - // **************************************** - // * - // * Create public forEach method - // * Purpose: Loop over every item in a TOb - // * (or at least the ones passed in the forIndex) - // * and call the provided user created function. - // * - // **************************************** - forEach : function (func2call,dex) { - - var forIndex = bDexArray(dex,this.find); - - var row; - // loop over all of the indexes - for(var fe = 0, fel = forIndex.length; fe < fel; fe++) { - // get this row from the TOb - row = TOb[forIndex[fe]]; - // call the function passed in to the method - var nr = func2call(row,forIndex[fe]); - - // If nr is an object then set the row equal to the new object - if (T.isObject(nr)) - { - if (TAFFY.isSameObject(nr,TAFFY.EXIT)) { - break; - } else { - this.update(nr,forIndex[fe]); - } - } - } - - }, - - // **************************************** - // * - // * Create public sum method - // * Purpose: Take a column name and a forIndex - // * and sum up the numeric total for every row. - // * - // **************************************** - sum : function (col,dex) { - var t = 0; - this.forEach(function (r) { - if(TAFFY.isNumeric(r[col])) { - t = t + r[col]; - } - - },dex) - - return t; - }, - - // **************************************** - // * - // * Create public max method - // * Purpose: Take a column name and a forIndex - // * and find the highest value in that column - // * over every row. - // * - // **************************************** - max : function (col,dex) { - var t, f = 0; - this.forEach(function (r) { - if (f==1 && r[col] > t) { - t = r[col]; - } else if (f==0) { - t=r[col]; - f=1; - } - },dex) - - return t; - }, - - // **************************************** - // * - // * Create public min method - // * Purpose: Take a column name and a forIndex - // * and find the lowest value in that column - // * over every row. - // * - // **************************************** - min : function (col,dex) { - var t, f = 0; - this.forEach(function (r) { - if (f==1 && r[col] < t) { - t = r[col]; - } else if (f==0) { - t=r[col]; - f=1; - } - },dex) - - return t; - }, - - // **************************************** - // * - // * Create public values method - // * Purpose: Take a column name and a forIndex - // * and find all the values for the rows returned. - // * - // **************************************** - values : function (col,dex) { - var t = []; - this.forEach(function (r) { - t[t.length] = r[col]; - },dex) - return t; - }, - // **************************************** - // * - // * Create public uniqueValues method - // * Purpose: Take a column name and a forIndex - // * and find only the unique values for the rows returned. - // * - // **************************************** - uniqueValues : function (col,dex) { - var t = TAFFY([]); - this.forEach(function (r) { - if (t.find({value:r[col]}).length == 0) { - t.insert({value:r[col]}); - } - },dex) - return t.values("value"); - }, - // **************************************** - // * - // * config variable object - // * - // **************************************** - config:{ - // **************************************** - // * - // * Create public set method - // * Purpose: Set a config value - // * - // **************************************** - set:function (n,v) { - conf[n] = v; - if (n == 'template' && !TAFFY.isNull(v)) { - mergeTemp(TIA,v); - } - }, - // **************************************** - // * - // * Create public get method - // * Purpose: Get a config value - // * - // **************************************** - get:function (n) { - return conf[n]; - } - }, - - // **************************************** - // * - // * Create public stringify method - // * Purpose: This returns a string JSON array - // * from a set of indexes. Used to get records - // * for handling by AJAX or other langauges. - // * - // **************************************** - - applyTemplate : function (tmp,dex) { - var getIndex = bDexArray(dex,this.find); - - mergeTemp(getIndex,tmp); - }, - // **************************************** - // * - // * Empty On Update Event - This can be replaced with a function - // * to call a custom action as each record is updated. - // * - // **************************************** - onUpdate:null, - - // **************************************** - // * - // * Empty On Remove Event - This can be replaced with a function - // * to call a custom action as each record is removed. - // * - // **************************************** - onRemove:null, - - // **************************************** - // * - // * Empty On Insert Event - This can be replaced with a function - // * to call a custom action as each record is inserted. - // * - // **************************************** - onInsert:null - - }; - -}; - - // **************************************** - // * - // * TAFFY Public Utilities - // * Accessed via TAFFY[methodname]() - // * - // **************************************** - - - // **************************************** - // * - // * typeOf Fixed in JavaScript as public utility - // * - // **************************************** - TAFFY.typeOf = function (v) { - var s = typeof v; - if (s === 'object') { - if (v) { - if (typeof v.length === 'number' && - !(v.propertyIsEnumerable('length')) && - typeof v.splice === 'function') { - s = 'array'; - } - } else { - s = 'null'; - } - } - return s; - }; - - - // **************************************** - // * - // * JSON Object Handler / public utility - // * See http://www.JSON.org/js.html - // * The following JSON Object is Public Domain - // * No warranty expressed or implied. Use at your own risk. - // * - // **************************************** - - TAFFY.JSON = function () { - - function f(n) { - return n < 10 ? '0' + n : n; - } - - Date.prototype.toJSON = function () { - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - - var m = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }; - - function stringify(value, whitelist) { - var a,i,k,l, r = /["\\\x00-\x1f\x7f-\x9f]/g,v; - - switch (typeof value) { - case 'string': - - return r.test(value) ? - '"' + value.replace(r, function (a) { - var c = m[a]; - if (c) { - return c; - } - c = a.charCodeAt(); - return '\\u00' + Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - }) + '"' : - '"' + value + '"'; - - case 'number': - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - return String(value); - - case 'object': - - if (!value) { - return 'null'; - } - - if (typeof value.toJSON === 'function') { - return stringify(value.toJSON()); - } - a = []; - if (typeof value.length === 'number' && - !(value.propertyIsEnumerable('length'))) { - - l = value.length; - for (i = 0; i < l; i += 1) { - a.push(stringify(value[i], whitelist) || 'null'); - } - - return '[' + a.join(',') + ']'; - } - if (whitelist) { - - l = whitelist.length; - for (i = 0; i < l; i += 1) { - k = whitelist[i]; - if (typeof k === 'string') { - v = stringify(value[k], whitelist); - if (v) { - a.push(stringify(k) + ':' + v); - } - } - } - } else { - - for (k in value) { - if (typeof k === 'string') { - v = stringify(value[k], whitelist); - if (v) { - a.push(stringify(k) + ':' + v); - } - } - } - } - - return '{' + a.join(',') + '}'; - } - return ""; - } - - return { - stringify: stringify, - parse: function (text, filter) { - var j; - - function walk(k, v) { - var i, n; - if (v && typeof v === 'object') { - for (i in v) { - if (Object.prototype.hasOwnProperty.apply(v, [i])) { - n = walk(i, v[i]); - if (n !== undefined) { - v[i] = n; - } else { - delete v[i]; - } - } - } - } - return filter(k, v); - } - - - if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@'). - replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). - replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { - - j = eval('(' + text + ')'); - - return typeof filter === 'function' ? walk('', j) : j; - } - - throw new SyntaxError('parseJSON'); - } - }; - }(); - - - // **************************************** - // * - // * End JSON Code Object Handler - // * - // **************************************** - - // **************************************** - // * - // * Create public utility mergeObj method - // * Return a new object where items from obj2 - // * have replaced or been added to the items in - // * obj1 - // * Purpose: Used to combine objs - // * - // **************************************** - TAFFY.mergeObj = function (ob1,ob2) { - var c = {}; - for(var n in ob1) - { - if (ob1.hasOwnProperty(n)) { - c[n] = ob1[n]; - } - } - for(var n in ob2) - { - if (ob2.hasOwnProperty(n)) { - c[n] = ob2[n]; - } - } - return c; - }; - - // **************************************** - // * - // * Create public utility getObjectKeys method - // * Returns an array of an objects keys - // * Purpose: Used to get the keys for an object - // * - // **************************************** - TAFFY.getObjectKeys = function (ob) { - var kA = []; - for(var n in ob) - { - if (ob.hasOwnProperty(n)) - { - kA[kA.length] = n; - } - } - kA.sort(); - return kA; - }; - - // **************************************** - // * - // * Create public utility isSameArray - // * Returns an array of an objects keys - // * Purpose: Used to get the keys for an object - // * - // **************************************** - TAFFY.isSameArray = function (ar1,ar2) { - return (TAFFY.isArray(ar1) && TAFFY.isArray(ar2) && ar1.join(",") == ar2.join(",")) ? true : false; - }; - - // **************************************** - // * - // * Create public utility isSameObject method - // * Returns true if objects contain the same - // * material or false if they do not - // * Purpose: Used to comare objects - // * - // **************************************** - TAFFY.isSameObject = function (ob1,ob2) { - var T = TAFFY; - if (T.isObject(ob1) && T.isObject(ob2)) { - if (T.isSameArray(T.getObjectKeys(ob1),T.getObjectKeys(ob2))) { - for(var n in ob1) - { - if (ob1.hasOwnProperty(n)) - { - if ((T.isObject(ob1[n]) && T.isObject(ob2[n]) && T.isSameObject(ob1[n],ob2[n])) - || (T.isArray(ob1[n]) && T.isArray(ob2[n]) && T.isSameArray(ob1[n],ob2[n])) - || (ob1[n] == ob2[n])) { - } else { - return false; - } - } - } - } else { - return false; - } - } else { - return false; - } - return true; - }; - - // **************************************** - // * - // * Create public utility has method - // * Returns true if a complex object, array - // * or taffy collection contains the material - // * provided in the second argument - // * Purpose: Used to comare objects - // * - // **************************************** - TAFFY.has = function(var1, var2){ - var T = TAFFY; - var re = true; - if (T.isTAFFY(var1)) { - re = var1.find(var2); - if (re.length > 0) - { - return true; - } else { - return false; - } - } - else { - switch (T.typeOf(var1)) { - case "object": - if (T.isObject(var2)) { - for (var x in var2) { - if (re === true&& var2.hasOwnProperty(x) && !T.isUndefined(var1[x]) && var1.hasOwnProperty(x)) { - re = T.has(var1[x], var2[x]); - } else { - return false; - } - } - return re; - } - else - if (T.isArray(var2)) { - for (var x = 0; x < var2.length; x++) { - re = T.has(var1, var2[x]); - if (re === true) { - return true; - } - } - } - else - if (T.isString(var2) && !TAFFY.isUndefined(var1[var2])) { - return true; - } - break; - case "array": - if (T.isObject(var2)) { - for (var n = 0; n < var1.length; n++) { - re = T.has(var1[n], var2); - if (re == true) { - return true; - } - } - } - else - if (T.isArray(var2)) { - for (var x = 0; x < var2.length; x++) { - for (var n = 0; n < var1.length; n++) { - re = T.has(var1[n], var2[x]); - if (re == true) { - return true; - } - } } - } - else - if (T.isString(var2)) { - for (var n = 0; n < var1.length; n++) { - re = T.has(var1[n], var2); - if (re == true) { - return true; - } - } - } - break; - case "string": - if (T.isString(var2) && var2 == var1) { - return true; - } - break; - default: - if (T.typeOf(var1) == T.typeOf(var2) && var1 == var2) { - return true; - } - break; - } - } - return false; - }; - - // **************************************** - // * - // * Create public utility hasAll method - // * Returns true if a complex object, array - // * or taffy collection contains the material - // * provided in the call - for arrays it must - // * contain all the material in each array item - // * Purpose: Used to comare objects - // * - // **************************************** - - TAFFY.hasAll = function (var1,var2) { - var T = TAFFY; - if (T.isArray(var2)) { - var ar = true; - for(var i = 0, il = var2.length;i/g, - interpolate : /<%=([\s\S]+?)%>/g -}; - -// JavaScript micro-templating, similar to John Resig's implementation. -// Underscore templating handles arbitrary delimiters, preserves whitespace, -// and correctly escapes quotes within interpolated code. -exports.render = function(templateStr, data) { - var settings = exports.settings, - compiledTemplate, - renderFunction; - - compiledTemplate = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' + - 'with(data||{}){__p.push(\'' + - templateStr.replace(/\\/g, '\\\\') - .replace(/'/g, "\\'") - .replace(settings.interpolate, function(match, code) { - return "'," + code.replace(/\\'/g, "'") + ",'"; - }) - .replace(settings.evaluate || null, function(match, code) { - return "');" + code.replace(/\\'/g, "'") - .replace(/[\r\n\t]/g, ' ') + "__p.push('"; - }) - .replace(/\r/g, '\\r') - .replace(/\n/g, '\\n') - .replace(/\t/g, '\\t') - + "');}return __p.join('');"; - - renderFunction = new Function('data', compiledTemplate); - return data ? renderFunction(data) : renderFunction; -}; \ No newline at end of file diff --git a/Tools/jsdoc3/node_modules/wrench/wrench.js b/Tools/jsdoc3/node_modules/wrench/wrench.js deleted file mode 100644 index 592aa6fec6e..00000000000 --- a/Tools/jsdoc3/node_modules/wrench/wrench.js +++ /dev/null @@ -1,397 +0,0 @@ -/* wrench.js - * - * A collection of various utility functions I've found myself in need of - * for use with Node.js (http://nodejs.org/). This includes things like: - * - * - Recursively deleting directories in Node.js (Sync, not Async) - * - Recursively copying directories in Node.js (Sync, not Async) - * - Recursively chmoding a directory structure from Node.js (Sync, not Async) - * - Other things that I'll add here as time goes on. Shhhh... - * - * ~ Ryan McGrath (ryan [at] venodesigns.net) - */ - -var fs = require("fs"), - _path = require("path"); - - -/* wrench.readdirSyncRecursive("directory_path"); - * - * Recursively dives through directories and read the contents of all the - * children directories. - */ -exports.readdirSyncRecursive = function(baseDir) { - baseDir = baseDir.replace(/\/$/, ''); - - var readdirSyncRecursive = function(baseDir) { - var files = [], - curFiles, - nextDirs, - isDir = function(fname){ - return fs.statSync( _path.join(baseDir, fname) ).isDirectory(); - }, - prependBaseDir = function(fname){ - return _path.join(baseDir, fname); - }; - - curFiles = fs.readdirSync(baseDir); - nextDirs = curFiles.filter(isDir); - curFiles = curFiles.map(prependBaseDir); - - files = files.concat( curFiles ); - - while (nextDirs.length) { - files = files.concat( readdirSyncRecursive( _path.join(baseDir, nextDirs.shift()) ) ); - } - - return files; - }; - - // convert absolute paths to relative - var fileList = readdirSyncRecursive(baseDir).map(function(val){ - return val.replace(baseDir + '/', ''); - }); - - return fileList; -}; - -/* wrench.readdirRecursive("directory_path", function(error, files) {}); - * - * Recursively dives through directories and read the contents of all the - * children directories. - * - * Asynchronous, so returns results/error in callback. - * Callback receives the of files in currently recursed directory. - * When no more directories are left, callback is called with null for all arguments. - * - */ -exports.readdirRecursive = function(baseDir, fn) { - baseDir = baseDir.replace(/\/$/, ''); - - var waitCount = 0; - - function readdirRecursive(curDir) { - var files = [], - curFiles, - nextDirs, - prependcurDir = function(fname){ - return _path.join(curDir, fname); - }; - - waitCount++; - fs.readdir(curDir, function(e, curFiles) { - waitCount--; - - curFiles = curFiles.map(prependcurDir); - - curFiles.forEach(function(it) { - waitCount++; - - fs.stat(it, function(e, stat) { - waitCount--; - - if (e) { - fn(e); - } else { - if (stat.isDirectory()) { - readdirRecursive(it); - } - } - - if (waitCount == 0) { - fn(null, null); - } - }); - }); - - fn(null, curFiles.map(function(val) { - // convert absolute paths to relative - return val.replace(baseDir + '/', ''); - })); - - if (waitCount == 0) { - fn(null, null); - } - }); - }; - - readdirRecursive(baseDir); -}; - - - -/* wrench.rmdirSyncRecursive("directory_path", forceDelete, failSilent); - * - * Recursively dives through directories and obliterates everything about it. This is a - * Sync-function, which blocks things until it's done. No idea why anybody would want an - * Asynchronous version. :\ - */ -exports.rmdirSyncRecursive = function(path, failSilent) { - var files; - - try { - files = fs.readdirSync(path); - } catch (err) { - if(failSilent) return; - throw new Error(err.message); - } - - /* Loop through and delete everything in the sub-tree after checking it */ - for(var i = 0; i < files.length; i++) { - var currFile = fs.lstatSync(path + "/" + files[i]); - - if(currFile.isDirectory()) // Recursive function back to the beginning - exports.rmdirSyncRecursive(path + "/" + files[i]); - - else if(currFile.isSymbolicLink()) // Unlink symlinks - fs.unlinkSync(path + "/" + files[i]); - - else // Assume it's a file - perhaps a try/catch belongs here? - fs.unlinkSync(path + "/" + files[i]); - } - - /* Now that we know everything in the sub-tree has been deleted, we can delete the main - directory. Huzzah for the shopkeep. */ - return fs.rmdirSync(path); -}; - -/* wrench.copyDirSyncRecursive("directory_to_copy", "new_directory_location", opts); - * - * Recursively dives through a directory and moves all its files to a new location. This is a - * Synchronous function, which blocks things until it's done. If you need/want to do this in - * an Asynchronous manner, look at wrench.copyDirRecursively() below. - * - * Note: Directories should be passed to this function without a trailing slash. - */ -exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) { - - if (!opts || !opts.preserve) { - try { - if(fs.statSync(newDirLocation).isDirectory()) exports.rmdirSyncRecursive(newDirLocation); - } catch(e) { } - } - - /* Create the directory where all our junk is moving to; read the mode of the source directory and mirror it */ - var checkDir = fs.statSync(sourceDir); - try { - fs.mkdirSync(newDirLocation, checkDir.mode); - } catch (e) { - //if the directory already exists, that's okay - if (e.code !== 'EEXIST') throw e; - } - - var files = fs.readdirSync(sourceDir); - - for(var i = 0; i < files.length; i++) { - var currFile = fs.lstatSync(sourceDir + "/" + files[i]); - - if(currFile.isDirectory()) { - /* recursion this thing right on back. */ - exports.copyDirSyncRecursive(sourceDir + "/" + files[i], newDirLocation + "/" + files[i], opts); - } else if(currFile.isSymbolicLink()) { - var symlinkFull = fs.readlinkSync(sourceDir + "/" + files[i]); - fs.symlinkSync(symlinkFull, newDirLocation + "/" + files[i]); - } else { - /* At this point, we've hit a file actually worth copying... so copy it on over. */ - var contents = fs.readFileSync(sourceDir + "/" + files[i]); - fs.writeFileSync(newDirLocation + "/" + files[i], contents); - } - } -}; - -/* wrench.chmodSyncRecursive("directory", filemode); - * - * Recursively dives through a directory and chmods everything to the desired mode. This is a - * Synchronous function, which blocks things until it's done. - * - * Note: Directories should be passed to this function without a trailing slash. - */ -exports.chmodSyncRecursive = function(sourceDir, filemode) { - var files = fs.readdirSync(sourceDir); - - for(var i = 0; i < files.length; i++) { - var currFile = fs.lstatSync(sourceDir + "/" + files[i]); - - if(currFile.isDirectory()) { - /* ...and recursion this thing right on back. */ - exports.chmodSyncRecursive(sourceDir + "/" + files[i], filemode); - } else { - /* At this point, we've hit a file actually worth copying... so copy it on over. */ - fs.chmod(sourceDir + "/" + files[i], filemode); - } - } - - /* Finally, chmod the parent directory */ - fs.chmod(sourceDir, filemode); -}; - - -/* wrench.chownSyncRecursive("directory", uid, gid); - * - * Recursively dives through a directory and chowns everything to the desired user and group. This is a - * Synchronous function, which blocks things until it's done. - * - * Note: Directories should be passed to this function without a trailing slash. - */ -exports.chownSyncRecursive = function(sourceDir, uid, gid) { - var files = fs.readdirSync(sourceDir); - - for(var i = 0; i < files.length; i++) { - var currFile = fs.lstatSync(sourceDir + "/" + files[i]); - - if(currFile.isDirectory()) { - /* ...and recursion this thing right on back. */ - exports.chownSyncRecursive(sourceDir + "/" + files[i], uid, gid); - } else { - /* At this point, we've hit a file actually worth chowning... so own it. */ - fs.chownSync(sourceDir + "/" + files[i], uid, gid); - } - } - - /* Finally, chown the parent directory */ - fs.chownSync(sourceDir, uid, gid); -}; - - - -/* wrench.rmdirRecursive("directory_path", callback); - * - * Recursively dives through directories and obliterates everything about it. - */ -exports.rmdirRecursive = function rmdirRecursive(dir, clbk){ - fs.readdir(dir, function(err, files){ - if (err) return clbk(err); - (function rmFile(err){ - if (err) return clbk(err); - - var filename = files.shift(); - if (filename === null || typeof filename == 'undefined') - return fs.rmdir(dir, clbk); - - var file = dir+'/'+filename; - fs.stat(file, function(err, stat){ - if (err) return clbk(err); - if (stat.isDirectory()) - rmdirRecursive(file, rmFile); - else - fs.unlink(file, rmFile); - }); - })(); - }); -}; - -/* wrench.copyDirRecursive("directory_to_copy", "new_location", callback); - * - * Recursively dives through a directory and moves all its files to a new - * location. - * - * Note: Directories should be passed to this function without a trailing slash. - */ -exports.copyDirRecursive = function copyDirRecursive(srcDir, newDir, clbk) { - fs.stat(newDir, function(err, newDirStat){ - if (!err) return exports.rmdirRecursive(newDir, function(err){ - copyDirRecursive(srcDir, newDir, clbk); - }); - - fs.stat(srcDir, function(err, srcDirStat){ - if (err) return clbk(err); - fs.mkdir(newDir, srcDirStat.mode, function(err){ - if (err) return clbk(err); - fs.readdir(srcDir, function(err, files){ - if (err) return clbk(err); - (function copyFiles(err){ - if (err) return clbk(err); - - var filename = files.shift(); - if (filename === null || typeof filename == 'undefined') - return clbk(); - - var file = srcDir+'/'+filename, - newFile = newDir+'/'+filename; - - fs.stat(file, function(err, fileStat){ - if (fileStat.isDirectory()) - copyDirRecursive(file, newFile, copyFiles); - else if (fileStat.isSymbolicLink()) - fs.readlink(file, function(err, link){ - fs.symlink(link, newFile, copyFiles); - }); - else - fs.readFile(file, function(err, data){ - fs.writeFile(newFile, data, copyFiles); - }); - }); - })(); - }); - }); - }); - }); -}; - -var mkdirSyncRecursive = function(path, mode) { - var self = this; - - try { - fs.mkdirSync(path, mode); - } catch(err) { - if(err.code == "ENOENT") { - var slashIdx = path.lastIndexOf("/"); - if(slashIdx < 0) { - slashIdx = path.lastIndexOf("\\"); - } - - if(slashIdx > 0) { - var parentPath = path.substring(0, slashIdx); - mkdirSyncRecursive(parentPath, mode); - mkdirSyncRecursive(path, mode); - } else { - throw err; - } - } else if(err.code == "EEXIST") { - return; - } else { - throw err; - } - } -}; -exports.mkdirSyncRecursive = mkdirSyncRecursive; - -exports.LineReader = function(filename, bufferSize) { - this.bufferSize = bufferSize || 8192; - this.buffer = ""; - this.fd = fs.openSync(filename, "r"); - this.currentPosition = 0; -}; - -exports.LineReader.prototype = { - getBufferAndSetCurrentPosition: function(position) { - var res = fs.readSync(this.fd, this.bufferSize, position, "ascii"); - - this.buffer += res[0]; - if(res[1] === 0) return -1; - - this.currentPosition = position + res[1]; - return this.currentPosition; - }, - - hasNextLine: function() { - while(this.buffer.indexOf('\n') === -1) { - this.getBufferAndSetCurrentPosition(this.currentPosition); - if(this.currentPosition === -1) return false; - if(this.buffer.length === 0) return false; - } - - if(this.buffer.indexOf("\n") > -1) return true; - return false; - }, - - getNextLine: function() { - var lineEnd = this.buffer.indexOf("\n"), - result = this.buffer.substring(0, lineEnd); - - this.buffer = this.buffer.substring(result.length + 1, this.buffer.length); - return result; - } -}; - -// vim: et ts=4 sw=4 diff --git a/Tools/jsdoc3/package.json b/Tools/jsdoc3/package.json deleted file mode 100644 index ed6f2d26776..00000000000 --- a/Tools/jsdoc3/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "JSDoc", - "version": "3.0.0alpha", - "revision": "1323947228470", - "description": "An automatic documentation generator for javascript.", - "keywords": [ "documentation", "javascript" ], - "licenses": [ - { - "type": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0" - } - ], - "repositories": [ - { - "type": "git", - "url": "git://github.com/micmath/jsdoc.git" - } - ], - "bugs": "https://github.com/micmath/jsdoc/issues", - "contributors" : [ - { - "name": "Michael Mathews", - "email": "micmath@gmail.com" - }, - { - "name": "Rafa\u0105 Wrzeszcz", - "email": "rafal.wrzeszcz@wrzasq.pl" - } - ], - "maintainers": [ - { - "name": "Michael Mathews", - "email": "micmath@gmail.com" - } - ] -} diff --git a/Tools/jsdoc3/plugins/README.md b/Tools/jsdoc3/plugins/README.md deleted file mode 100644 index b22c3f8e12a..00000000000 --- a/Tools/jsdoc3/plugins/README.md +++ /dev/null @@ -1,373 +0,0 @@ -Adding a Plugin ----- - -There are two steps required to install a new plugin: - -1. Create a JavaScript module to contain your plugin code. -2. Include the name of that module in the "plugins" array of `conf.json`. - -For example, if your plugin source code was saved in the "plugins/shout.js" -file, you would include it in conf.json like so: - - { - "plugins": [ - "plugins/shout" - ] - } - -Authoring JSDoc 3 Plugins ----- - -The plugin system for JSDoc 3 is pretty powerful and provides plugin authors -multiple methods, from high-level to low-level, of affecting document generation: - -- Defining event handlers -- Defining tags -- Defining a parse tree node processor - -### Event Handlers - -At the highest level, a plugin may register handlers for specific named-events -that occur in the documentation generation process. JSDoc will pass the handler -an event object containing pertinent information. Your plugin module should -export a _handlers_ object that contains your handler, like so: - - exports.handlers = { - newDoclet: function(e) { - //Do something when we see a new doclet - } - } - -#### Event: fileBegin - -This is triggered when the parser has started on a new file. You might use this -to do any per-file initialization your plugin needs to do. - -The event object will contain the following properties: - -- filename: the name of the file - -#### Event: beforeParse - -This is triggered before parsing has begun. You can use this method to modify -the source code that will be parsed. For instance, you might add some virtual -doclets so they get added to the documentation. - -The event object will contain the following properties: - -- filename: the name of the file -- source: the contents of the file - -Below is an example that adds a virtual doclet for a function to the source so -that it will get parsed and added to the documentation. This might be done to -document methods that will be present for end-user use, but might not be in the -source code being documented, like methods provided by a third-party superclass: - - exports.handlers = { - beforeParse: function(e) { - var extraDoc = ["", - "/**", - "Here's a description of this function", - "@name superFunc", - "@memberof ui.mywidget", - "@function", - "*/", ""]; - e.source += extraDoc.join("\n"); - } - } - -#### Event: jsDocCommentFound - -This is fired whenever a jsdoc comment is found. It may or may not be associated -with any code. You might use this to modify the contents of a comment before it -is processed. - -The event object will contain the following properties: - -- filename: the name of the file -- comment: the text of the comment -- lineno: the line number the comment was found on - -#### Event: symbolFound - -This is fired when the parser comes across a symbol in the code it thinks is -important. This usually means things that one might want to document -- -variables, functions, object literals, object property definitions, -assignments, etc., but the symbols the parser finds can be modified by a plugin -(see "Node Visitors" below). - -The event object will contain the following properties: - -- filename: the name of the file -- comment: the comment associated with the symbol, if any -- id: the unique id of the symbol -- lineno: the line number the symbols was found on -- astnode: the node of the parse tree -- code: information about the code. This usually contains "name", "type", and - "node" properties and might also have "value", "paramnames", or "funcscope" - properties depending on the symbol. - -#### Event: newDoclet - -This is the highest level event and is fired when a new doclet has been created. -This means that a jsdoc or a symbol has been processed and the actual doclet -that will be passed to the template has been created. - -The event object will contain the following properties: - -- doclet: the new doclet that was created - -The properties of the doclet can vary depending on the comment or symbol used to -create it. Additionally, tag definitions (See "Tag Definitions" below) can -modify the doclet. Some common properties you're likely to see include: - -- comment: the text of the comment (may be empty if symbol is undocumented) -- meta: some information about the doclet, like filename, line number, etc. -- description -- kind -- name -- longname: the fully qualified name, including memberof info -- memberof: the function/class/namespace that this is a member of -- scope: (global|static|instance|inner) -- undocumented: true if the symbol didn't have a jsdoc comment -- defaultvalue: the specified default value for a property/variable -- type: the specified type of parameter/property/function return (e.g. Boolean) -- params: an object containing the list of parameters to a function -- tags: an object containing the set of tags not handled by the parser (note: - this is only available if ```allowUnknownTags``` is set to true in the conf.json - file for JSDoc3) - -Below is an example of a newDoclet handler that shouts the descriptions: - - exports.handlers = { - newDoclet: function(e) { - // e.doclet will refer to the newly created doclet - // you can read and modify properties of that doclet if you wish - if (typeof e.doclet.description === 'string') { - e.doclet.description = e.doclet.description.toUpperCase(); - } - } - }; - -#### Event: fileComplete - -This is fired when the parser is done with a file. You might use this to -perform some cleanup for your plugin. - -The event object will contain the following properties: - -- filename: the name of the file -- source: the contents of the file - -### Tag Definitions - -Adding tags to the tag dictionary is a mid-level way to affect documentation -generation. Before a newDoclet event is triggered, jsdoc comment blocks are -parsed to determine the description and any jsdoc tags that may be present. When -a tag is found, if it has been defined in the tag dictionary, it is given a -chance to modify the doclet. - -Plugins can define tags by exporting a _defineTags_ function. That function will -be passed a dictionary that can be used to define tags, like so: - - exports.defineTags = function(dictionary) { - //define tags here - } - -#### The Dictionary - -The dictionary provides the following methods: - -1. defineTag(title, opts) - Used to define tags. - The first parameter is the name of the tag (e.g. "param" or "overview"). the - second is an object containing options for the tag. The options can be the - following: - - mustHaveValue (Boolean): whether or not the tag must have a value - (e.g "@name TheName") - - mustNotHaveValue (Boolean): whether or not the tag must not have a value - - canHaveType (Boolean): Whether or not the tag can have a type - (e.g. "@param **{String}** name the description of name") - - canHaveName (Boolean): Whether or not the tag can have a name - (e.g. "@param {String} **name** the description of name") - - isNamespace (Boolean): Whether or not the tag marks a doclet as representing - a namespace. The "@module" tag, for instance, sets this to true. - - onTagged (Function): A callback function executed when the tag is found. The - function is passed two parameters: the doclet and the tag. Here's an example: - - dictionary.defineTag('instance', { - onTagged: function(doclet, tag) { - doclet.scope = "instance"; - } - }); - The defineTag method returns a Tag. The Tag object has a method "synonym" - that can be used to declare synonyms to the tag. For example: - - dictionary.defineTag('exception', { - - }) - .synonym('throws'); -2. lookUp(title) - Used to lookup a tag. Returns either the tag or false if it's not defined -3. isNamespace(kind) - Used to determine if a particular doclet type represents a namespace -4. normalise(title) - Used to find the canonical name of a tag. The name passed in might be that - name or a synonym - -### Node Visitors - -At the lowest level, plugin authors can process each node in the parse tree by -defining a node visitor that will visit each node, creating an opportunity to -do things like modify comments and trigger parser events for any arbitrary piece -of code. - -Plugins can define a node visitor by exporting a ```nodeVisitor``` object that -contains a ```visitNode``` function, like so: - - exports.nodeVisitor = { - visitNode: function(node, e, parser, currentSourceName) { - //do all sorts of crazy things here - } - } - -The function is called on each node with the following parameters: - -- node: the node of the parse tree -- e: the event. If the node is one that the parser handles, this will already - be populated with the same things described in the _symbolFound_ event above. - Otherwise, it will be an empty object on which to set various properties. -- parser: the parser -- currentSourceName: the name of the file being parsed - -#### Making things happen - -The primary reasons to implement a node visitor are to be able to document -things that aren't normally documented (like function calls that create classes) -or to auto generate documentation for code that isn't documented. For instance, -a plugin might look for calls to a "_trigger" method since it knows that means -an event is fired and then generate documentation for the event. - -To make things happen, the ```visitNode``` function should modify properties -of the event parameter. In general the goal is to construct a comment and then -get an event to fire. After the parser lets all of the node visitors have a -look at the node, it looks to see if the event object has a ```comment``` -property and an ```event``` property. If it has both, the event named in the event -property is fired. The event is usually "symbolFound" or "jsDocCommentFound", -but theoretically, a plugin could define its own events and handle them. - -#### Example - -Below is an example of what a plugin for documenting jQuery UI widgets might do. -jQuery UI uses a factory function call to create widget classes. The plugin -looks for that function call and creates a symbol with documentation. It also -looks for any "this._trigger" function calls and automatically creates -documentation for the events that are triggered: - - exports.nodeVisitor = { - visitNode: function(node, e, parser, currentSourceName) { - if (node.type === Token.OBJECTLIT && node.parent && node.parent.type === Token.CALL && isInWidgetFactory(node, 1)) { - var widgetName = node.parent.arguments.get(0).toSource(); - e.id = 'astnode' + node.hashCode(); // the id of the object literal node - e.comment = String(node.parent.jsDoc||''); - e.lineno = node.parent.getLineno(); - e.filename = currentSourceName; - e.astnode = node; - e.code = { - name: "" + widgetName.substring(1, widgetName.length() - 1), - type: "class", - node: node - }; - e.event = "symbolFound"; - e.finishers = [parser.addDocletRef]; - - addCommentTag(e, "param", "{Object=} options A set of configuration options"); - } - else if(isTriggerCall(node)) { - var nameNode = node.arguments.get(0); - eventName = String((nameNode.type == Token.STRING) ? nameNode.value : nameNode.toSource()), - func = {}, - comment = "@event\n", - eventKey = ""; - - if (node.enclosingFunction) { - func.id = 'astnode'+node.enclosingFunction.hashCode(); - func.doclet = parser.refs[func.id]; - } - if(func.doclet) { - func.doclet.addTag("fires", eventName); - if (func.doclet.memberof) { - eventKey = func.doclet.memberof + "#event:" + eventName; - comment += "@name " + func.doclet.memberof + "#" + eventName; - } - } - e.comment = comment; - e.lineno = node.getLineno(); - e.filename = currentSourceName; - e.event = "jsdocCommentFound"; - } - } - }; - function isTriggerCall(node) { - if(node.type != Token.CALL) { return false; } - var target = node.getTarget(), - left = target && target.left && String(target.left.toSource()), - right = target && target.right && String(target.right.toSource()); - return (left === "this" && right === "_trigger"); - } - - function isInWidgetFactory(node, depth) { - var parent = node.parent, - d = 0; - while(parent && (!depth || d < depth)) { - if (parent.type === Token.CALL) { - var target = parent.getTarget(), - left = target && target.left && String(target.left.toSource()), - right = target && target.right && String(target.right.toSource()); - return ((left === "$" || left === "jQuery") && right === "widget"); - } else { - parent = parent.parent; - d++; - } - } - return false; - } - -You'll notice a "finishers" property set. The finishers property should contain -an array of functions to be called after the event is fired and all the handlers -have processed it. The parser provides an ```addDocletRef``` function that adds the -doclet to the map (keyed off of the id property) of doclets it knows about. - -Lastly, the visitors are executed in the order the plugins are listed in the -conf.json file. A plugin can stop later plugins from visiting a node by -setting a ```stopPropagation``` property on the event object (e.stopPropagation = true). -A plugin can stop the event from firing setting a ```preventDefault``` property. - -Packaging JSDoc 3 Plugins ----- - -The JSDoc 3 Jakefile has an ```install``` task that can be used to install a plugin -into the jsdoc 3 installation. So running the following will install the plugin: - - $>jake install[path/to/YourPluginFolder] - -_note: on some systems (like MacOS X), you may need to quote the target name and parameters_: - - $>jake 'install[path/to/YourPluginFolder]' - -The task is passed a directory that should look something like the following: - - YourPluginFolder - |- plugins - | |- YourPlugin.js - | \- test - | |- fixtures - | | \- YourFixtures.js - | \- specs - | \- YourTests.js - \- templates - \- YourTemplate - \- publish.js - -Basically everything is copied over into the jsdoc installation directory, the -directory should contain anything you want to put there. \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/commentConvert.js b/Tools/jsdoc3/plugins/commentConvert.js deleted file mode 100644 index 94eb89759e3..00000000000 --- a/Tools/jsdoc3/plugins/commentConvert.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - @overview Demonstrate how to modify the source code before the parser sees it. - @module plugins/commentConvert - @author Michael Mathews - */ - - -exports.handlers = { - /// - /// Convert ///-style comments into jsdoc comments. - /// @param e - /// @param e.filename - /// @param e.source - /// - beforeParse: function(e) { - e.source = e.source.replace(/(\n[ \t]*\/\/\/[^\n]*)+/g, function($) { - var replacement = '\n/**' + $.replace(/^[ \t]*\/\/\//mg, '').replace(/(\n$|$)/, '*/$1'); - return replacement; - }); - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/customTags.js b/Tools/jsdoc3/plugins/customTags.js deleted file mode 100644 index 5102fe7a857..00000000000 --- a/Tools/jsdoc3/plugins/customTags.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - @overview Define custom tags for Cesium - @module plugins/customTags - @author Kristian Calhoun - */ - -exports.defineTags = function(dictionary) { - - dictionary.defineTag('enumeration', { - onTagged: function(doclet, tag) { - doclet.addTag('kind', 'enumeration'); - doclet.filename = doclet.name; - } - }); - - dictionary.defineTag('performance', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.performance) { doclet.performance = []; } - doclet.performance.push(tag.value); - } - }); - - dictionary.defineTag('glsl', { - onTagged: function(doclet, tag) { - doclet.addTag('kind', 'glsl'); - doclet.filename = doclet.name; - } - }).synonym('glslStruct').synonym('glslUniform').synonym('glslConstant').synonym('glslFunction'); - - dictionary.defineTag('demo', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.demo) { doclet.demo = []; } - doclet.demo.push(tag.value); - } - }); -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/escapeHtml.js b/Tools/jsdoc3/plugins/escapeHtml.js deleted file mode 100644 index 925bbede53a..00000000000 --- a/Tools/jsdoc3/plugins/escapeHtml.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - @overview Escape HTML tags in descriptions. - @module plugins/escapeHtml - @author Michael Mathews - */ - - -exports.handlers = { - /** - Translate HTML tags in descriptions into safe entities. - Replaces <, & and newlines - */ - newDoclet: function(e) { - if (e.doclet.description) { - e.doclet.description = e.doclet.description - .replace(/&/g,'&') - .replace(/'); - } - } -}; diff --git a/Tools/jsdoc3/plugins/markdown.js b/Tools/jsdoc3/plugins/markdown.js deleted file mode 100644 index d6d4f40d318..00000000000 --- a/Tools/jsdoc3/plugins/markdown.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - @overview Translate doclet descriptions from MarkDown into HTML. - @module plugins/markdown - @author Michael Mathews - @author Ben Blank - */ - -var conf = env.conf.markdown; -var defaultTags = [ "classdesc", "description", "params", "properties", "returns" ]; -var parse; -var tags; - -/** - Pull in the selected parser and wrap it in a common interface. - - @param {String} parser The name of the selected parser. - @param {Object} [conf] Configuration for the selected parser, if any. - - @returns {Function} A function which accepts markdown source, feeds it to - the selected parser, and returns the resulting HTML. - - @throws {Exception} If the name does not correspond to a known parser. - */ -function getParser(parser, conf) { - conf = conf || {}; - - if (parser === "gfm") { - parser = new (require("gfm/showdown").Converter)(); - parser.githubRepoOwner = conf.githubRepoOwner; - parser.githubRepoName = conf.githubRepoName; - parser.hardwrap = !!conf.hardwrap; - - return function(source) { - return parser.makeHtml(source); - }; - } else if (parser === "evilstreak") { - parser = require("evilstreak/markdown"); - - return function(source) { - return parser.renderJsonML(parser.toHTMLTree(source, conf.dialect)); - } - } else { - throw "unknown Markdown parser: '" + parser + "'"; - } -} - -/** - Process the markdown source in a doclet. The properties which should be - processed are configurable, but always include "classdesc", "description", - "params", "properties", and "returns". Handled properties can be bare - strings, objects, or arrays of objects. - */ -function process(doclet) { - tags.forEach(function(tag) { - if (!doclet.hasOwnProperty(tag)) { - return; - } - - if (typeof doclet[tag] === "string") { - doclet[tag] = parse(doclet[tag]); - } else if (doclet[tag] instanceof Array) { - doclet[tag].forEach(process); - } else if (doclet[tag]) { - process(doclet[tag]); - } - }); -} - -// determine which parser should be used based on configuration options, if any -if (conf && conf.parser) { - parse = getParser(conf.parser, conf); -} else if (conf && conf.githubRepoOwner && conf.githubRepoName) { - // use GitHub-friendly parser if GitHub-specific options are present - parse = getParser("gfm", conf); -} else { - // evilstreak is the default parser - parse = getParser("evilstreak", conf); -} - -// set up the list of "tags" (properties) to process -if (conf && conf.tags) { - tags = conf.tags.slice(); - - defaultTags.forEach(function(tag) { - if (tags.indexOf(tag) === -1) { - tags.push(tag); - } - }); -} else { - tags = defaultTags; -} - -exports.handlers = { - /** - Translate markdown syntax in a new doclet's description into HTML. Is run - by JSDoc 3 whenever a "newDoclet" event fires. - */ - newDoclet: function(e) { - process(e.doclet); - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/markdown.md b/Tools/jsdoc3/plugins/markdown.md deleted file mode 100644 index ef97f4e32bd..00000000000 --- a/Tools/jsdoc3/plugins/markdown.md +++ /dev/null @@ -1,84 +0,0 @@ -# How to use the Markdown plugin - -For most users, all you need to do is add the plugin to your JSDoc configuration (`conf.json`) as you would any other: - - { - "plugins": [ "plugins/markdown" ] - } - -This will cause Markdown in `@description` tags (including implicit descriptions without tags), `@classdesc` tags, `@param` tags, `@property` tags, and `@returns` tags to be parsed. - -# Configuring the Markdown plugin - -The plugin also offers several configuration options for advanced users who want GitHub integration, extended tag support, etc. All configuration for the Markdown plugin should be added to a `"markdown"` property in your JSDoc configuration: - - { - "plugins": [ "plugins/markdown" ], - - "markdown": { - "opt1": "value", - "opt2": [ "foo", "bar", "baz" ] - } - } - -## Choosing a parser - -The plugin currently supports two Markdown parsers. You can select which parser to use by adding a `"parser"` property to your Markdown configuration: - - { - "plugins": [ "plugins/markdown" ], - - "markdown": { - "parser": "gfm" - } - } - -### Dominic "evilstreak" Baggott's markdown-js - -The default parser is Dominic Baggott's excellent [markdown-js](https://github.com/evilstreak/markdown-js). It can be explicitly selected by setting the `parser` to `evilstreak` and has one additional (and optional) configuration option, `dialect`, which can be used to select which of markdown-js' built-in dialects to use. If omitted, markdown-js' default dialect will be used. - - { - "plugins": [ "plugins/markdown" ], - - "markdown": { - "parser": "evilstreak", - "dialect": "Maruku" - } - } - -### GitHib Flavored Markdown - -The alternative parser is the modified Showdown parser supplied by GitHub for their [GitHub Flavored Markdown](http://github.github.com/github-flavored-markdown/). GFM several enhancements to standard Markdown syntax (see its documentation) intended to be useful to developers. It *also* has the ability to quickly link to GitHub repositories, files, and issues. It can be selected by setting the `parser` to `gfm` and supports three additional (and optional) configuration options. - -The `hardwrap` option controls the hard wrapping of line ends. Unlike standard Markdown, GFM considers a single newline to indicate a "hard break" in the paragraph, but this doesn't work well with the line length limitations commonly used with comment documentation, so is disabled by default. If you want to turn hard wrapping back on, set `hardwrap` to `true` (or any non-falsy value). - -The `githubRepoName` and `githubRepoOwner` indicate which GitHub repo should be used for GitHub links which do not fully specify a repo. These options have no effect unless used together and if they are omitted, several of GFM's default link types will be unavailable. Conversely, if you supply both `github*` options but do not explicitly select `gfm` as your parser, it will be automatically selected for you. - - { - "plugins": [ "plugins/markdown" ], - - "markdown": { - "parser": "gfm", - "hardwrap": true - } - } - -### Why two parsers? - -The "evilstreak" parser is flexible, extensible, currently-maintained, and was the only parser available in earlier versions of the Markdown plugin, but doesn't support the useful GFM extensions. The "gfm" parser is based on the no-longer-maintained Showdown parser, but is the actual library used for GitHub's [client-side previews](http://github.github.com/github-flavored-markdown/preview.html). - -In the future, if GFM support is made available for the "evilstreak" parser, this plugin will drop the "gfm" parser in favor of that support. - -## Extended tag support - -While the Markdown plugin already supports JSDoc's default tags, if you're using other plugins, you may well have extra tags available. You can tell the Markdown plugin to handle those extra tags as well using the `tags` property, which is an array of the tags* it should check in addition to the default set. - - { - "plugins": [ "plugins/markdown" ], - - "markdown": { - "tags": [ "foo", "bars", "bazzes" ] - } - } - -\* Because the Markdown plugin works with JSDoc's internal representation rather than with the source comments, the names you need to enter in the `tags` property aren't necessarily the same as the actual tag names. For example, in the default set of tags, `@param` is stored under `params`. If you are having trouble getting the Markdown plugin to work with your extra tags, either take a peek at the output of JSDoc's `--explain` command-line parameter (which displays the internal state which plugins work with) or ask the plugin author which "doclet properties" their plugin uses. The Markdown plugin supports strings, arrays, and objects/subdoclets. diff --git a/Tools/jsdoc3/plugins/railsTemplate.js b/Tools/jsdoc3/plugins/railsTemplate.js deleted file mode 100644 index 9ca63098b26..00000000000 --- a/Tools/jsdoc3/plugins/railsTemplate.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - @overview Strips the rails template tags from a js.erb file - @module plugins/railsTemplate - @author Jannon Frank - */ - - -exports.handlers = { - /** - * Remove rails tags from the source input (e.g. <% foo bar %>) - * @param e - * @param e.filename - * @param e.source - */ - beforeParse: function(e) { - if (e.filename.match(/\.erb$/)) { - e.source = e.source.replace(/<%.*%>/g, ""); - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/shout.js b/Tools/jsdoc3/plugins/shout.js deleted file mode 100644 index bb9c2c5d732..00000000000 --- a/Tools/jsdoc3/plugins/shout.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - @overview This is just an example. - @module plugins/shout - @author Michael Mathews - */ - -exports.handlers = { - /** - Make your descriptions more shoutier. - */ - newDoclet: function(e) { - if (typeof e.doclet.description === 'string') { - e.doclet.description = e.doclet.description.toUpperCase(); - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/sourcetag.js b/Tools/jsdoc3/plugins/sourcetag.js deleted file mode 100644 index 74656c52502..00000000000 --- a/Tools/jsdoc3/plugins/sourcetag.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - @module plugins/sourcetag - @author Michael Mathews - */ - -exports.handlers = { - /** - Support @source tag. Expected value like: - { "filename": "myfile.js", "lineno": 123 } - Modifies the corresponding meta values on the given doclet. - @source { "filename": "sourcetag.js", "lineno": 13 } - */ - newDoclet: function(e) { - var tags = e.doclet.tags, - tag, - value; - - //console.log(e.doclet); - // any user-defined tags in this doclet? - if (typeof tags !== 'undefined') { - // only interested in the @source tags - tags = tags.filter(function($) { - return $.title === 'source'; - }); - - if (tags.length) { - // take the first one - tag = tags[0]; - - try { - value = JSON.parse(tag.value); - } - catch(e) { - throw new Error('@source tag expects a valid JSON value, like { "filename": "myfile.js", "lineno": 123 }.'); - } - - !e.doclet.meta && (e.doclet.meta = {}); - e.doclet.meta.filename = value.filename || ''; - e.doclet.meta.lineno = value.lineno || ''; - } - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/fixtures/railsTemplate.js.erb b/Tools/jsdoc3/plugins/test/fixtures/railsTemplate.js.erb deleted file mode 100644 index 446aa409ecb..00000000000 --- a/Tools/jsdoc3/plugins/test/fixtures/railsTemplate.js.erb +++ /dev/null @@ -1,20 +0,0 @@ -/** - @overview Strips the rails template tags from a js.erb file - @module plugins/railsTemplate - @author Jannon Frank - */ - - -exports.handlers = { - /** - * Remove rails tags from the source input (e.g. <% foo bar %>) - * @param e - * @param e.filename - * @param e.source - */ - beforeParse: function(e) { - if (e.filename.match(/\.erb$/)) { - e.source = e.source.replace(/<%.*%> /g, ""); - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/specs/commentConvert.js b/Tools/jsdoc3/plugins/test/specs/commentConvert.js deleted file mode 100644 index 831c47509a0..00000000000 --- a/Tools/jsdoc3/plugins/test/specs/commentConvert.js +++ /dev/null @@ -1,13 +0,0 @@ -describe("commentConvert plugin", function() { - var parser = new (require("jsdoc/src/parser")).Parser(), - plugin = require('plugins/commentConvert'), - docSet; - - installPlugins(['plugins/commentConvert'], parser); - docSet = jasmine.getDocSetFromFile("plugins/commentConvert.js", parser); - - it("should convert '///-style comments into jsdoc comments", function() { - var doclet = docSet.getByLongname("module:plugins/commentConvert.handlers.beforeParse"); - expect(doclet.length).toEqual(1); - }); -}); \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/specs/escapeHtml.js b/Tools/jsdoc3/plugins/test/specs/escapeHtml.js deleted file mode 100644 index 19ef29b82c2..00000000000 --- a/Tools/jsdoc3/plugins/test/specs/escapeHtml.js +++ /dev/null @@ -1,13 +0,0 @@ -describe("escapeHtml plugin", function() { - var parser = new (require("jsdoc/src/parser")).Parser(), - plugin = require('plugins/escapeHtml'), - docSet; - - installPlugins(['plugins/escapeHtml'], parser); - docSet = jasmine.getDocSetFromFile("plugins/escapeHtml.js", parser); - - it("should escape '&', '<' and newlines in doclet descriptions", function() { - var doclet = docSet.getByLongname("module:plugins/escapeHtml.handlers.newDoclet"); - expect(doclet[0].description).toEqual("Translate HTML tags in descriptions into safe entities.
    Replaces <, & and newlines"); - }); -}); \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/specs/markdown.js b/Tools/jsdoc3/plugins/test/specs/markdown.js deleted file mode 100644 index 382c0d509a6..00000000000 --- a/Tools/jsdoc3/plugins/test/specs/markdown.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - @overview Translate doclet descriptions from MarkDown into HTML. - @module plugins/markdown - @author Michael Mathews - */ - -var mdParser = require('evilstreak/markdown'); - -exports.handlers = { - /** - Translate markdown syntax in a new doclet's description into HTML. Is run - by JSDoc 3 whenever a "newDoclet" event fires. - */ - newDoclet: function(e) { - if (e.doclet.description) { - e.doclet.description = mdParser.toHTML(e.doclet.description) - .replace( /&/g, "&" ) // because markdown escapes these - .replace( /</g, "<" ) - .replace( />/g, ">" ); - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/specs/railsTemplate.js b/Tools/jsdoc3/plugins/test/specs/railsTemplate.js deleted file mode 100644 index 7541f95bd4c..00000000000 --- a/Tools/jsdoc3/plugins/test/specs/railsTemplate.js +++ /dev/null @@ -1,15 +0,0 @@ -describe("railsTemplate plugin", function() { - var parser = new (require("jsdoc/src/parser")).Parser(), - plugin = require('plugins/railsTemplate'); - - - installPlugins(['plugins/railsTemplate'], parser); - require('jsdoc/src/handlers').attachTo(parser); - - it("should remove <% %> rails template tags from the source of *.erb files", function() { - var path = require("path"), - docSet = parser.parse([path.join(__dirname, "plugins/test/fixtures/railsTemplate.js.erb")]); - - expect(docSet[2].description).toEqual("Remove rails tags from the source input (e.g. )"); - }); -}); \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/specs/shout.js b/Tools/jsdoc3/plugins/test/specs/shout.js deleted file mode 100644 index 18e581ef447..00000000000 --- a/Tools/jsdoc3/plugins/test/specs/shout.js +++ /dev/null @@ -1,13 +0,0 @@ -describe("shout plugin", function() { - var parser = new (require("jsdoc/src/parser")).Parser(), - plugin = require('plugins/shout'), - docSet; - - installPlugins(['plugins/shout'], parser); - docSet = jasmine.getDocSetFromFile("plugins/shout.js", parser); - - it("should make the description uppercase", function() { - var doclet = docSet.getByLongname("module:plugins/shout.handlers.newDoclet"); - expect(doclet[0].description).toEqual("MAKE YOUR DESCRIPTIONS MORE SHOUTIER."); - }); -}); \ No newline at end of file diff --git a/Tools/jsdoc3/plugins/test/specs/sourcetag.js b/Tools/jsdoc3/plugins/test/specs/sourcetag.js deleted file mode 100644 index d5202cc0582..00000000000 --- a/Tools/jsdoc3/plugins/test/specs/sourcetag.js +++ /dev/null @@ -1,15 +0,0 @@ -describe("sourcetag plugin", function() { - var parser = new (require("jsdoc/src/parser")).Parser(), - plugin = require('plugins/sourcetag'), - docSet; - - installPlugins(['plugins/sourcetag'], parser); - docSet = jasmine.getDocSetFromFile("plugins/sourcetag.js", parser); - - it("should set the lineno and filename of the doclet's meta property", function() { - var doclet = docSet.getByLongname("module:plugins/sourcetag.handlers.newDoclet"); - expect(doclet[0].meta).toBeDefined(); - expect(doclet[0].meta.filename).toEqual("sourcetag.js"); - expect(doclet[0].meta.lineno).toEqual(13); - }); -}); \ No newline at end of file diff --git a/Tools/jsdoc3/rhino_modules/fs.js b/Tools/jsdoc3/rhino_modules/fs.js deleted file mode 100644 index 98fb7a1cb8b..00000000000 --- a/Tools/jsdoc3/rhino_modules/fs.js +++ /dev/null @@ -1,163 +0,0 @@ -exports.readFileSync = function(filename, encoding) { - encoding = encoding || 'utf-8'; - - return readFile(filename, encoding); -}; - -var readdirSync = exports.readdirSync = function(path) { - var dir, - files; - - dir = new java.io.File(path); - if (!dir.directory) { return [String(dir)]; } - - files = dir.list(); - - //Convert files to Javascript strings so they play nice with node modules - files = files.map(function(fileName) { - return String(fileName); - }); - - return files; -}; - -var ls = exports.ls = function(dir, recurse, _allFiles, _path) { - var files, - file; - - if (typeof _path === 'undefined') { // initially - _allFiles = []; - _path = [dir]; - } - - if (_path.length === 0) { return _allFiles; } - if (typeof recurse === 'undefined') { recurse = 1; } - - if ( stat(dir).isFile(dir) ) { - files = [dir]; - } - else { - files = readdirSync(dir); - } - - for (var f = 0, lenf = files.length; f < lenf; f++) { - file = String(files[f]); - - if (file.match(/^\.[^\.\/\\]/)) { continue; } // skip dot files - - if ((new java.io.File(_path.join('/') + '/' + file)).list()) { // it's a directory - _path.push(file); - - if (_path.length - 1 < recurse) { - ls(_path.join('/'), recurse, _allFiles, _path); - } - _path.pop(); - } - else { // it's a file - _allFiles.push( - (_path.join('/') + '/' + file).replace(/[\/\\]+/g, '/') - ); - } - } - - return _allFiles; -}; - -var stat = exports.stat = exports.statSync = function(path, encoding) { - var f = new java.io.File(path); - return { - isFile: function() { - return f.isFile(); - }, - isDirectory: function() { - return f.isDirectory(); - } - }; - -}; - -exports.mkPath = function(/**Array*/ path) { - if (path.constructor != Array){path = path.split(/[\\\/]/);} - var make = ""; - for (var i = 0, l = path.length; i < l; i++) { - make += path[i] + '/'; - if (! exists(make)) { - makeDir(make); - } - } -}; - -function makeDir(/**string*/ path) { - var dirPath = toDir(path); - (new java.io.File(dirPath)).mkdir(); -} - -function exists(path) { - var f = new java.io.File(path); - - if (f.isDirectory()){ - return true; - } - if (!f.exists()){ - return false; - } - if (!f.canRead()){ - return false; - } - return true; -} - -var toDir = exports.toDir = function(path) { - var f = new java.io.File(path); - - if (f.isDirectory()){ - return path; - } - - var parts = path.split(/[\\\/]/); - parts.pop(); - - return parts.join('/'); -}; - -exports.copyFile = function(inFile, outDir, fileName) { - if (fileName == null){fileName = toFile(inFile);} - - outDir = toDir(outDir); - - var inFile = new java.io.File(inFile); - var outFile = new java.io.File(outDir+'/'+fileName); - - var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096); - var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096); - var theChar; - while ((theChar = bis.read()) != -1) { - bos.write(theChar); - } - bos.close(); - bis.close(); -}; - -var toFile = exports.toFile = function(path) { - var parts = path.split(/[\\\/]/); - return parts.pop(); -}; - -exports.writeFileSync = function(filename, data, encoding) { - encoding = encoding || 'utf-8'; - - var out = new Packages.java.io.PrintWriter( - new Packages.java.io.OutputStreamWriter( - new Packages.java.io.FileOutputStream(filename), - encoding - ) - ); - - try { - out.write(data); - } - finally { - out.flush(); - out.close(); - } -}; diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/augment.js b/Tools/jsdoc3/rhino_modules/jsdoc/augment.js deleted file mode 100644 index 30a9ec6a5eb..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/augment.js +++ /dev/null @@ -1,122 +0,0 @@ - -(function() { - - exports.addInherited = function(docs) { - var dependencies = mapDependencies(docs.index); - var sorted = sort(dependencies); - sorted.forEach(function(name) { - var doclets = docs.index[name]; - var additions = getAdditions(doclets, docs); - additions.forEach(function(doc) { - var name = doc.longname; - if (!(docs.index.hasOwnProperty(name))) { - docs.index[name] = []; - } - docs.index[name].push(doc); - docs.push(doc); - }); - }); - } - - function mapDependencies(index) { - var doclets, doc, len, dependencies = {}; - for (var name in index) { - doclets = index[name]; - for (var i=0, ii=doclets.length; i - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -// requires docs to have been indexed: docs.index must be defined here -/** - Take a copy of the docs for borrowed symbols and attach them to the - docs for the borrowing symbol. This process changes the symbols involved, - moving docs from the "borrowed" array and into the general docs, then - deleting the "borrowed" array. - */ -exports.resolveBorrows = function(docs) { - if (!docs.index) { - throw 'Docs has not been indexed: docs.index must be defined here.'; - } - - docs.forEach(function(doc) { - if (doc.borrowed) { - doc.borrowed.forEach(function(b, i) { - var lent = docs.index[b.from], // lent is an array - asName = b['as'] || b.from; - - if (lent) { - var cloned = doop(lent); - - cloned.forEach(function(clone) { - asName = asName.replace(/^prototype\./, '#'); - var parts = asName.split('#'); - - if (parts.length === 2) clone.scope = 'instance'; - else clone.scope = 'static'; - - asName = parts.pop(); - clone.name = asName; - clone.memberof = doc.longname; - clone.longname = clone.memberof + (clone.scope === 'instance'? '#': '.') + clone.name; - docs.push(clone); - }); - - } - }); - - delete doc.borrowed; - } - }); -} - -/** - Deep clone a simple object. - @private - */ -function doop(o) { - if (o instanceof Object && o.constructor != Function) { - var clone = o instanceof Array ? [] : {}, prop; - - for (prop in o){ - if ( o.hasOwnProperty(prop) ) { - clone[prop] = (o[prop] instanceof Object)? doop(o[prop]) : o[prop]; - } - } - return clone; - } - return o; -}; diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/doclet.js b/Tools/jsdoc3/rhino_modules/jsdoc/doclet.js deleted file mode 100644 index 48d9f86cf1c..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/doclet.js +++ /dev/null @@ -1,328 +0,0 @@ -/** - @overview - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** - @module jsdoc/doclet - @requires jsdoc/tag - @requires jsdoc/name - @requires jsdoc/tag/dictionary - */ - -var jsdoc = { - tag: { - Tag: require('jsdoc/tag').Tag, - dictionary: require('jsdoc/tag/dictionary') - }, - name: require('jsdoc/name') -}; - -/** - @class - @classdesc Represents a single JSDoc comment. - @param {string} docletSrc - The raw source code of the jsdoc comment. - @param {object=} meta - Properties describing the code related to this comment. - */ -exports.Doclet = function(docletSrc, meta) { - var newTags = []; - - /** The original text of the comment from the source code. */ - this.comment = docletSrc; - this.setMeta(meta); - - docletSrc = unwrap(docletSrc); - docletSrc = fixDescription(docletSrc); - - newTags = toTags.call(this, docletSrc); - - for (var i = 0, leni = newTags.length; i < leni; i++) { - this.addTag(newTags[i].title, newTags[i].text); - } - - this.postProcess(); -} - -/** Called once after all tags have been added. */ -exports.Doclet.prototype.postProcess = function() { - if (!this.preserveName) { jsdoc.name.resolve(this); } - if (this.name && !this.longname) { - this.setLongname(this.name); - } - if (this.memberof === '') { - delete(this.memberof); - } - - if (!this.kind && this.meta && this.meta.code) { - this.addTag( 'kind', codetypeToKind(this.meta.code.type) ); - } - - if (this.variation && this.longname && !/\)$/.test(this.longname) ) { - this.longname += '('+this.variation+')'; - } - - // add in any missing param names - if (this.params && this.meta && this.meta.code && this.meta.code.paramnames) { - for (var i = 0, len = this.params.length; i < len; i++) { - if (!this.params[i].name) { - this.params[i].name = this.meta.code.paramnames[i] || ''; - } - } - } -} - -/** Add a tag to this doclet. - @param {string} title - The title of the tag being added. - @param {string} [text] - The text of the tag being added. -*/ -exports.Doclet.prototype.addTag = function(title, text) { - var tagDef = jsdoc.tag.dictionary.lookUp(title), - newTag = new jsdoc.tag.Tag(title, text, this.meta); - - if (tagDef && tagDef.onTagged) { - tagDef.onTagged(this, newTag) - } - - if (!tagDef) { - this.tags = this.tags || []; - this.tags.push(newTag); - } - - applyTag.call(this, newTag); -} - -/** Set the `memberof` property of this doclet. - @param {string} sid - The longname of the symbol that this doclet is a member of. -*/ -exports.Doclet.prototype.setMemberof = function(sid) { - if (/^\.?/.test(sid)) { sid = sid.replace(/^.?/, ''); } - /** - The longname of the symbol that contains this one, if any. - @type string - */ - this.memberof = sid.replace(/\.prototype/g, '#'); -} - -/** Set the `longname` property of this doclet. - @param {string} name -*/ -exports.Doclet.prototype.setLongname = function(name) { - if (/^\.?/.test(name)) { name = name.replace(/^\.?/, ''); } - - /** - The fully resolved symbol name. - @type string - */ - this.longname = name; - if (jsdoc.tag.dictionary.isNamespace(this.kind)) { - this.longname = jsdoc.name.applyNamespace(this.longname, this.kind); - } -} - -/** Add a symbol to this doclet's `borrowed` array. - @param {string} source - The longname of the symbol that is the source. - @param {string} target - The name the symbol is being assigned to. -*/ -exports.Doclet.prototype.borrow = function(source, target) { - var about = {from: source}; - if (target) about.as = target; - - if (!this.borrowed) { - /** - A list of symbols that are borrowed by this one, if any. - @type Array. - */ - this.borrowed = []; - } - this.borrowed.push(about); -} - -exports.Doclet.prototype.mix = function(source) { - if (!this.mixes) { - /** - A list of symbols that are mixed into this one, if any. - @type Array. - */ - this.mixes = []; - } - this.mixes.push(source); -} - -/** Add a symbol to this doclet's `augments` array. - @param {string} base - The longname of the base symbol. -*/ -exports.Doclet.prototype.augment = function(base) { - if (!this.augments) { - /** - A list of symbols that are augmented by this one, if any. - @type Array. - */ - this.augments = []; - } - this.augments.push(base); -} - -/** - Set the `meta` property of this doclet. - @param {object} meta -*/ -exports.Doclet.prototype.setMeta = function(meta) { - if (!this.meta) { - /** - Information about the source code associated with this doclet. - @namespace - */ - this.meta = {}; - } - - if (meta.lineno) { - /** - The line number of the code associated with this doclet. - @type number - */ - this.meta.lineno = meta.lineno; - } - - if (meta.lineno) { - /** - The name of the file containing the code associated with this doclet. - @type string - */ - var idx = meta.filename.lastIndexOf(String(java.lang.System.getProperty("file.separator"))); - if (idx != -1) { - this.meta.path = meta.filename.substring(0, idx); - this.meta.filename = meta.filename.substring(idx + 1); - } else { - this.meta.filename = meta.filename; - } - } - - /** - Information about the code symbol. - @namespace - */ - this.meta.code = (this.meta.code || {}); - if (meta.id) this.meta.code.id = meta.id; - if (meta.code) { - if (meta.code.name) { - /** The name of the symbol in the source code. */ - this.meta.code.name = meta.code.name; - } - if (meta.code.type) { - /** The type of the symbol in the source code. */ - this.meta.code.type = meta.code.type; - } - if (meta.code.node) { - this.meta.code.node = meta.code.node; - } - if (meta.code.funcscope) { - this.meta.code.funcscope = meta.code.funcscope; - } - if (meta.code.value) { - /** The value of the symbol in the source code. */ - this.meta.code.value = meta.code.value; - } - if (meta.code.paramnames) { - this.meta.code.paramnames = meta.code.paramnames.concat([]); - } - } -} - -function applyTag(tag) { - if (tag.title === 'name') { - this.name = tag.value; - } - - if (tag.title === 'kind') { - this.kind = tag.value; - } - - if (tag.title === 'description') { - this.description = tag.value; - } - - if (tag.title === 'scope') { - this.scope = tag.value; - } -} - -// use the meta info about the source code to guess what the doclet kind should be -function codetypeToKind(type) { - var kind = (type || '').toLowerCase(); - - if (kind !== 'function') { - return 'member'; - } - - return kind; -} - -/** - Convert the raw source of the doclet comment into an array of Tag objects. - @private - */ -function toTags(docletSrc) { - var tagSrcs, - tags = []; - - docletSrc = unwrap(docletSrc); - tagSrcs = split(docletSrc); - - for each(tagSrc in tagSrcs) { - tags.push( {title: tagSrc.title, text: tagSrc.text} ); - } - - return tags; -} - -function unwrap(docletSrc) { - if (!docletSrc) { return ''; } - - // note: keep trailing whitespace for @examples - // extra opening/closing stars are ignored - // left margin is considered a star and a space - // use the /m flag on regex to avoid having to guess what this platform's newline is - docletSrc = - docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars - .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker - .replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker - .replace(/\s*\\Z$/g, ''); // remove end-marker - - return docletSrc; -} - -function fixDescription(docletSrc) { - if (!/^\s*@/.test(docletSrc)) { - docletSrc = '@description ' + docletSrc; - } - return docletSrc; -} - -function split(docletSrc) { - var tagSrcs = []; - - // split out the basic tags, keep surrounding whitespace - // like: @tagTitle tagBody - docletSrc - .replace(/^(\s*)@(\S)/gm, '$1\\@$2') // replace splitter ats with an arbitrary sequence - .split('\\@') // then split on that arbitrary sequence - .forEach(function($) { - if ($) { - var parsedTag = $.match(/^(\S+)(:?\s+(\S[\s\S]*))?/); - - if (parsedTag) { - var [, tagTitle, tagText] = parsedTag; - - if (tagTitle) { - tagSrcs.push({ - title: tagTitle, - text: tagText - }); - } - } - } - }); - - return tagSrcs; -} diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/name.js b/Tools/jsdoc3/rhino_modules/jsdoc/name.js deleted file mode 100644 index 0ccfab11aa8..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/name.js +++ /dev/null @@ -1,237 +0,0 @@ -/** - A collection of functions relating to JSDoc symbol name manipulation. - @module jsdoc/name - @requires jsdoc/tag/dictionary - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -var jsdoc = { - tagDictionary: require('jsdoc/tag/dictionary') - }; - -var puncToScope = { '.': 'static', '~': 'inner', '#': 'instance' }, - scopeToPunc = { 'static': '.', 'inner': '~', 'instance': '#' }, - Token = Packages.org.mozilla.javascript.Token; - -/** - Resolves the longname, memberof, variation and name values of the given doclet. - @param {module:jsdoc/doclet.Doclet} doclet - */ -exports.resolve = function(doclet) { - var name = doclet.name, - memberof = doclet.memberof || '', - about = {}, - parentDoc; - - doclet.name = name = name? (''+name).replace(/\.prototype\.?/g, '#') : ''; - - // member of a var in an outer scope? - if (name && !memberof && doclet.meta.code && doclet.meta.code.funcscope) { - name = doclet.longname = doclet.meta.code.funcscope + '~' + name; - } - - if (memberof || doclet.forceMemberof) { // @memberof tag given - memberof = ('' || memberof).replace(/\.prototype\.?/g, '#'); - - // the name is a fullname, like @name foo.bar, @memberof foo - if (name && name.indexOf(memberof) === 0) { - about = exports.shorten(name, (doclet.forceMemberof? memberof : undefined)); - } - else if (name && /([#.~])$/.test(memberof) ) { // like @memberof foo# or @memberof foo~ - about = exports.shorten(memberof + name, (doclet.forceMemberof? memberof : undefined)); - } - else if (name && doclet.scope ) { // like @memberof foo# or @memberof foo~ - about = exports.shorten(memberof + (scopeToPunc[doclet.scope]||'') + name, (doclet.forceMemberof? memberof : undefined)); - } - } - else { // no @memberof - about = exports.shorten(name); - } - - if (about.name) { - doclet.name = about.name; - } - - if (about.memberof) { - doclet.setMemberof(about.memberof); - } - - if (about.longname && !doclet.longname) { - doclet.setLongname(about.longname); - } - - if (doclet.scope === 'global') { // via @global tag? - doclet.setLongname(doclet.name); - delete doclet.memberof; - } - else if (about.scope) { - if (about.memberof === '') { // via @memberof ? - doclet.scope = 'global'; - } - else { - doclet.scope = puncToScope[about.scope]; - } - } - else { - if (doclet.name && doclet.memberof && !doclet.longname) { - doclet.scope = 'static'; // default scope when none is provided - - doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name); - } - } - - if (about.variation) { - doclet.variation = about.variation; - } -} - -/** - @inner - @memberof module:jsdoc/name - @param {string} name - @param {string} kind - @returns {string} The name with unsafe names enclosed in quotes. - */ -function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters which need to be quoted by us - if ( (jsdoc.tagDictionary.lookUp(kind).setsDocletDocspace) && /[^$_a-zA-Z0-9\/]/.test(name) ) { - if (!/^[a-z_$-\/]+:\"/i.test(name)) { - return '"' + name.replace(/\"/g, '"') + '"'; - } - } - - return name; -} - -RegExp.escape = RegExp.escape || function(str) { - var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ - return str.replace(specials, "\\$&"); -} - -/** - @method module:jsdoc/name.applyNamespace - @param {string} longname The full longname of the symbol. - @param {string} ns The namespace to be applied. - @returns {string} The longname with the namespace applied. - */ -exports.applyNamespace = function(longname, ns) { - var nameParts = exports.shorten(longname), - name = nameParts.name, - longname = nameParts.longname; - - if ( !/^[a-zA-Z]+?:.+$/i.test(name) ) { - longname = longname.replace( new RegExp(RegExp.escape(name)+'$'), ns + ':' + name ); - } - - return longname; -} - -/** - Given a longname like "a.b#c(2)", slice it up into ["a.b", "#", 'c', '2'], - representing the memberof, the scope, the name, and variation. - @param {string} longname - @param {string} forcedMemberof - @returns {object} Representing the properties of the given name. - */ -exports.shorten = function(longname, forcedMemberof) { - // quoted strings in a longname are atomic, convert to tokens - var atoms = [], token; - - // handle quoted names like foo["bar"] - longname = longname.replace(/(\[?".+?"\]?)/g, function($) { - var dot = ''; - if ( /^\[/.test($) ) { - dot = '.'; - $ = $.replace( /^\[/g, '' ).replace( /\]$/g, '' ); - } - - token = '@{' + atoms.length + '}@'; - atoms.push($); - - return dot + token; // foo["bar"] => foo.@{1}@ - }); - - var name = '', - scope = '', // ., ~, or # - memberof = '', - variation; - - longname = longname.replace( /\.prototype\.?/g, '#' ); - - if (typeof forcedMemberof !== 'undefined') { - name = longname.substr(forcedMemberof.length); - var parts = forcedMemberof.match(/^(.*?)([#.~]?)$/); - - if (parts[1]) memberof = parts[1] || forcedMemberof; - if (parts[2]) scope = parts[2]; - } - else { - var parts = longname? - (longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ) || []).reverse() - : ['']; - - name = parts[0] || ''; // ensure name is always initialised to avoid error being thrown when calling replace on undefined [gh-24] - scope = parts[1] || ''; // ., ~, or # - memberof = parts[2] || ''; - } - - // like /** @name foo.bar(2) */ - if ( /(.+)\(([^)]+)\)$/.test(name) ) { - name = RegExp.$1, variation = RegExp.$2; - } - - //// restore quoted strings back again - var i = atoms.length; - while (i--) { - longname = longname.replace('@{'+i+'}@', atoms[i]); - memberof = memberof.replace('@{'+i+'}@', atoms[i]); - scope = scope.replace('@{'+i+'}@', atoms[i]); - name = name.replace('@{'+i+'}@', atoms[i]); - } - - //// - return {longname: longname, memberof: memberof, scope: scope, name: name, variation: variation}; -} - -/** - Split a string that starts with a name and ends with a description, into its parts. - @param {string} nameDesc - @returns {object} Hash with "name" and "description" properties. - */ -exports.splitName = function(nameDesc) { - var name = '', - desc = '', - thisChar = '', - inQuote = false; - - for (var i = 0, len = nameDesc.length; i < len; i++) { - thisChar = nameDesc.charAt(i); - - if (thisChar === '\\') { - name += thisChar + nameDesc.charAt(++i); - continue; - } - - if (thisChar === '"') { - inQuote = !inQuote; - } - - if (inQuote) { - name += thisChar; - continue; - } - - if (!inQuote) { - if ( /\s/.test(thisChar) ) { - desc = nameDesc.substr(i); - desc = desc.replace(/^[\s-\s]+/, '').trim(); - break; - } - else { - name += thisChar; - } - } - } - - return { name: name, description: desc }; -} \ No newline at end of file diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/opts/parser.js b/Tools/jsdoc3/rhino_modules/jsdoc/opts/parser.js deleted file mode 100644 index e71e7806cc9..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/opts/parser.js +++ /dev/null @@ -1,77 +0,0 @@ -/** - @module jsdoc/opts/parser - @requires common/args - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -var common = { - args: require('common/args') -}; - -var argParser = new common.args.ArgParser(), - ourOptions, - defaults = { - destination: './out/' - }; - -argParser.addOption('t', 'template', true, 'The name of the template to use. Default: the "default" template'); -argParser.addOption('c', 'configure', true, 'The path to the configuration file. Default: jsdoc __dirname + /conf.json'); -argParser.addOption('e', 'encoding', true, 'Assume this encoding when reading all source files. Default: utf-8'); -argParser.addOption('T', 'test', false, 'Run all tests and quit.'); -argParser.addOption('d', 'destination', true, 'The path to the output folder. Use "console" to dump data to the console. Default: console'); -argParser.addOption('p', 'private', false, 'Display symbols marked with the @private tag. Default: false.'); -argParser.addOption('r', 'recurse', false, 'Recurse into subdirectories when scanning for source code files.'); -argParser.addOption('h', 'help', false, 'Print this message and quit.'); -argParser.addOption('X', 'explain', false, 'Dump all found doclet internals to console and quit.'); -argParser.addOption('q', 'query', true, 'Provide a querystring to define custom variable names/values to add to the options hash.'); -argParser.addOption('u', 'tutorials', true, 'Directory in which JSDoc should search for tutorials.'); - -//TODO [-R, recurseonly] = a number representing the depth to recurse -//TODO [-f, filter] = a regex to filter on <-- this can be better defined in the configs? - -//Here are options specific to tests -argParser.addOption(null, 'verbose', false, 'Display verbose output for tests'); -argParser.addOption(null, 'match', true, 'only run tests containing ', true); -argParser.addOption(null, 'coffee', false, 'load coffee-script which allows execution .coffee files'); - -/** - Set the options for this app. - @throws {Error} Illegal arguments will throw errors. - @param {string|String[]} args The command line arguments for this app. - */ -exports.parse = function(args) { - args = args || []; - - if (typeof args === 'string' || args.constructor === String) { - args = (''+args).split(/\s+/g); - } - - ourOptions = argParser.parse(args, defaults); - - return ourOptions; -} - -/** - Display help message for options. - */ -exports.help = function() { - return argParser.help(); -} - -/** - Get a named option. - @param {string} name The name of the option. - @return {string} The value associated with the given name. - *//** - Get all the options for this app. - @return {Object} A collection of key/values representing all the options. - */ -exports.get = function(name) { - if (typeof name === 'undefined') { - return ourOptions; - } - else { - return ourOptions[name]; - } -} diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/package.js b/Tools/jsdoc3/rhino_modules/jsdoc/package.js deleted file mode 100644 index ef4b8125707..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/package.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - @overview - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** - @module jsdoc/package - @see http://wiki.commonjs.org/wiki/Packages/1.0 - */ - -/** - @class - @classdesc Represents a JavaScript package. - @param {string} json - The contents of package.json. - */ -exports.Package = function(json) { - json = json || "{}"; - - /** The source files associated with this package. - @type {Array} - */ - this.files = []; - - /** The kind of this package. - @readonly - @default - @type {string} - */ - this.kind = 'package'; - - json = JSON.parse(json); - - /** The name of this package. - This value is found in the package.json file passed in as a command line option. - @type {string} - */ - this.name = json.name; - - /** The longname of this package. - @type {string} - */ - this.longname = this.kind + ':' + this.name; - - /** The description of this package. - @type {string} - */ - this.description = json.description; - - /** - The hash summary of the source file. - @type {string} - @since 3.2.0 - */ - this.version = json.version; - - /** - * The licenses of this package. - * @type {Array} - * @example - * "licenses": [ - * { - * "type": "GPLv2", - * "url": "http://www.example.com/licenses/gpl.html" - * } - * ] - */ - this.licenses = json.licenses; -} - diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/schema.js b/Tools/jsdoc3/rhino_modules/jsdoc/schema.js deleted file mode 100644 index 8cd96bd1c4e..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/schema.js +++ /dev/null @@ -1,308 +0,0 @@ -/** - @overview Schema for validating JSON produced by JSDoc Toolkit. - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - @see - */ - -exports.jsdocSchema = { - "properties": { - "doc": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "author": { - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "path": { // unique identifier for each doc - "type": "string", - "maxItems": 1 - }, - "description": { // a description - "type": "string", - "optional": true, - "maxItems": 1 - }, - "classdesc": { // a description of the class that this constructor belongs to - "type": "string", - "optional": true, - "maxItems": 1 - }, - "name": { // probably a trailing substring of the path - "type": "string", - "maxItems": 1 - }, - "version": { // what is the version of this doc - "type": "string", - "optional": true, - "maxItems": 1 - }, - "since": { // at what previous version was this doc added? - "type": "string", - "optional": true, - "maxItems": 1 - }, - "see": { // some thing else to consider - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "tutorials": { // extended tutorials - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "deprecated": { // is usage of this symbol deprecated? - "type": ["string", "boolean"], - "optional": true - }, - "scope": { // how is this symbol attached to it's enclosing scope? - "type": "string", - "maxItems": 1, - "enum": ["global", "static", "instance", "inner"] - }, - "memberof": { // probably a leading substring of the path - "type": "string", - "optional": true, - "maxItems": 1 - }, - "extends": { // the path to another constructor - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "fires": { // the path to another doc object - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "requires": { // the symbol being documented requires another symbol - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "implements": { - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "kind": { // what kind of symbol is this? - "type": "string", - "maxItems": 1, - "enum": ["constructor", "module", "event", "namespace", "method", "member", "enum", "class", "interface", "constant", "mixin", "file", "version"] - }, - "refersto": { // the path to another doc: this doc is simply a renamed alias to that - "type": "string", - "optional": true, - "maxItems": 1 - }, - "access": { // what access priviledges are allowed - "type": "string", - "optional": true, - "maxItems": 1, - "enum": ["private", "protected", "public"] - }, - "virtual": { // is a member left to be implemented during inheritance? - "type": "boolean", - "optional": true, - "default": false - }, - "attrib": { // other attributes, like "readonly" - "type": "string", - "optional": true - }, - "type": { // what type is the value that this doc is associated with, like "number" - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "exception" : { - "optional": true, - "type": "object", - "properties": { - "type": { // what is the type of the value thrown? - "type": "array", - "optional": true, - "items": { - "type": "string" - } - }, - "description": { // a description of the thrown value - "type": "string", - "optional": true - } - }, - "additionalProperties": false - }, - "returns" : { - "optional": true, - "type": "object", - "properties": { - "type": { // what is the type of the value returned? - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "description": { // a description of the returned value - "type": "string", - "optional": true - } - }, - "additionalProperties": false - }, - "param" : { // are there function parameters associated with this doc? - "type": "array", - "optional": true, - "items": { - "type": "object", - "properties": { - "type": { // what are the types of value expected for this parameter? - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "optional": { // is a value for this parameter optional? - "type": "boolean", - "optional": true, - "default": true - }, - "nullable": { // can the value for this parameter be null? - "type": "boolean", - "optional": true, - "default": true - }, - "defaultvalue": { // what is the default value for this parameter? - "type": "string", - "optional": true - }, - "name": { // what name does this parameter have within the function? - "type": "string" - }, - "description": { // a description of the parameter - "type": "string", - "optional": true - } - }, - "additionalProperties": false - } - }, - "thisobj": { - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "example": { // some thing else to consider - "type": ["string", "array"], - "optional": true, - "items": { - "type": "string" - } - }, - "tags": { // arbitrary tags associated with this doc - "type": "array", - "optional": true, - "additionalProperties": false, - "items": { - "type": "string" - } - }, - "meta": { // information about this doc - "type": "object", - "optional": true, - "maxItems": 1, - "properties": { - "file": { // what is the name of the file this doc appears in? - "type": "string", - "optional": true, - "maxItems": 1 - }, - "line": { // on what line of the file does this doc appear? - "type": "number", - "optional": true, - "maxItems": 1 - } - }, - "additionalProperties": false - } - } - } - }, - "meta": { // information about the generation for all the docs - "type": "object", - "optional": true, - "maxItems": 1, - "properties": { - "project": { // to what project does this doc belong? - "type": "object", - "optional": true, - "maxItems": 1, - "properties": { - "name": { // the name of the project - "type": "string", - "maxItems": 1 - }, - "uri": { // the URI of the project - "type": "string", - "maxItems": 1, - "format": "uri" - }, - "version": { // the version of the project - "type": "string", - "maxItems": 1 - }, - "lang": { // the programming language used in the project - "type": "string", - "maxItems": 1 - } - }, - "additionalProperties": false - }, - "generated": { // some information about the running of the doc generator - "type": "object", - "optional": true, - "maxItems": 1, - "properties": { - "date": { // on what date and time was the doc generated? - "type": "string", - "maxItems": 1, - "optional": true, - "format": "date-time" - }, - "parser": { // what tool was used to generate the doc? - "type": "string", - "maxItems": 1, - "optional": true - } - }, - "additionalProperties": false - } - } - } - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/src/handlers.js b/Tools/jsdoc3/rhino_modules/jsdoc/src/handlers.js deleted file mode 100644 index 6f5c3c32415..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/src/handlers.js +++ /dev/null @@ -1,187 +0,0 @@ -/** - @module jsdoc/src/handlers - */ - - -var currentModule = null; - -/** - Attach these event handlers to a particular instance of a parser. - @param parser - */ -exports.attachTo = function(parser) { - var jsdoc = {doclet: require('jsdoc/doclet'), name: require('jsdoc/name')}; - - // handles JSDoc comments that include a @name tag -- the code is ignored in such a case - parser.on('jsdocCommentFound', function(e) { - var newDoclet = new jsdoc.doclet.Doclet(e.comment, e); - - if (!newDoclet.name) { - return false; // only interested in virtual comments (with a @name) here - } - - addDoclet.call(this, newDoclet); - if (newDoclet.kind === 'module') { - currentModule = newDoclet.longname; - } - e.doclet = newDoclet; - - resolveProperties(newDoclet); - }); - - // handles named symbols in the code, may or may not have a JSDoc comment attached - parser.on('symbolFound', function(e) { - var subDoclets = e.comment.split(/@also\b/g); - - for (var i = 0, l = subDoclets.length; i < l; i++) { - newSymbolDoclet.call(this, subDoclets[i], e); - } - }); - - function newSymbolDoclet(docletSrc, e) { - var newDoclet = new jsdoc.doclet.Doclet(docletSrc, e); - - // an undocumented symbol right after a virtual comment? rhino mistakenly connected the two - if (newDoclet.name) { // there was a @name in comment - // try again, without the comment - e.comment = '@undocumented'; - newDoclet = new jsdoc.doclet.Doclet(e.comment, e); - } - - if (newDoclet.alias) { - if (newDoclet.alias === '{@thisClass}') { - memberofName = this.resolveThis(e.astnode); - - // "class" refers to the owner of the prototype, not the prototype itself - if ( /^(.+?)(\.prototype|#)$/.test(memberofName) ) { - memberofName = RegExp.$1; - } - newDoclet.alias = memberofName; - } - newDoclet.addTag('name', newDoclet.alias); - newDoclet.postProcess(); - } - else if (e.code && e.code.name) { // we need to get the symbol name from code - newDoclet.addTag('name', e.code.name); - if (!newDoclet.memberof && e.astnode) { - var memberofName = null, - basename = null, - scope = ''; - if ( /^((module.)?exports|this)(\.|$)/.test(newDoclet.name) ) { - var nameStartsWith = RegExp.$1; - - newDoclet.name = newDoclet.name.replace(/^(exports|this)(\.|$)/, ''); - - // like /** @module foo */ exports.bar = 1; - if (nameStartsWith === 'exports' && currentModule) { - memberofName = currentModule; - scope = 'static'; - } - else if (newDoclet.name === 'module.exports' && currentModule) { - newDoclet.addTag('name', currentModule); - newDoclet.postProcess(); - } - else { - // like /** @module foo */ exports = {bar: 1}; - // or /** blah */ this.foo = 1; - memberofName = this.resolveThis(e.astnode); - scope = nameStartsWith === 'exports'? 'static' : 'instance'; - - // like /** @module foo */ this.bar = 1; - if (nameStartsWith === 'this' && currentModule && !memberofName) { - memberofName = currentModule; - scope = 'static'; - } - } - - if (memberofName) { - if (newDoclet.name) { - newDoclet.name = memberofName + (scope === 'instance'? '#' : '.') + newDoclet.name; - } - else { newDoclet.name = memberofName; } - } - } - else { - memberofName = this.astnodeToMemberof(e.astnode); - if(memberofName instanceof Array) { - basename = memberofName[1]; - memberofName = memberofName[0]; - } - } - - if (memberofName) { - newDoclet.addTag( 'memberof', memberofName); - if (basename) { - newDoclet.name = newDoclet.name.replace(new RegExp('^' + RegExp.escape(basename) + '.'), ''); - } - } - else { - if (currentModule) { - if (!newDoclet.scope){newDoclet.addTag( 'inner');} - if (!newDoclet.memberof && newDoclet.scope !== 'global'){newDoclet.addTag( 'memberof', currentModule);} - } - } - } - - newDoclet.postProcess(); - } - else { - return false; - } - - resolveProperties(newDoclet); - - if (!newDoclet.memberof) { - newDoclet.scope = 'global'; - } - - addDoclet.call(this, newDoclet); - e.doclet = newDoclet; - } - - //parser.on('fileBegin', function(e) { }); - - parser.on('fileComplete', function(e) { - currentModule = null; - }); - - function addDoclet(newDoclet) { - if (newDoclet) { - e = { doclet: newDoclet }; - this.fire('newDoclet', e); - - if (!e.defaultPrevented) { - if ( !filter(newDoclet) ) { - this.addResult(newDoclet); - } - } - } - } - - function filter(doclet) { - // you can't document prototypes - if ( /#$/.test(doclet.longname) ) { - return true; - } - // you can't document symbols added by the parser with a dummy name - if (doclet.meta.code && doclet.meta.code.name === '____') { - return true; - } - - return false; - } - - function resolveProperties(newDoclet) { - // find name and description from each property tag text - if (newDoclet.properties) { - for (var i = 0, len = newDoclet.properties.length; i < len; i++) { - var property = newDoclet.properties[i]; - - var parts = jsdoc.name.splitName(property.description); - property.name = parts.name; - property.description = parts.description; - } - } - } -}; - diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/src/parser.js b/Tools/jsdoc3/rhino_modules/jsdoc/src/parser.js deleted file mode 100644 index b29c47b99e6..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/src/parser.js +++ /dev/null @@ -1,642 +0,0 @@ -/** - * @module jsdoc/src/parser - * @requires common/util - * @requires common/fs - * @requires common/events - */ - -var Token = Packages.org.mozilla.javascript.Token, - currentParser = null, - currentSourceName = ''; - -/** - * @class - * @mixes module:common/events - * - * @example Create a new parser. - * var jsdocParser = new (require('jsdoc/src/parser').Parser)(); - */ -exports.Parser = function() { - this._resultBuffer = []; - //Initialize a global ref to store global members - this.refs = { - __global__: { - meta: {} - } - }; - this._visitors = []; -}; -require('common/util').mixin(exports.Parser.prototype, require('common/events')); - -/** - * Parse the given source files for JSDoc comments. - * @param {Array.} sourceFiles An array of filepaths to the JavaScript sources. - * @param {string} [encoding=utf8] - * - * @fires jsdocCommentFound - * @fires symbolFound - * @fires newDoclet - * @fires fileBegin - * @fires fileComplete - * - * @example Parse two source files. - * var myFiles = ['file1.js', 'file2.js']; - * var docs = jsdocParser.parse(myFiles); - */ -exports.Parser.prototype.parse = function(sourceFiles, encoding) { - const SCHEMA = 'javascript:'; - var sourceCode = '', - filename = ''; - - if (typeof sourceFiles === 'string') { sourceFiles = [sourceFiles]; } - - for (i = 0, leni = sourceFiles.length; i < leni; i++) { - if (sourceFiles[i].indexOf(SCHEMA) === 0) { - sourceCode = sourceFiles[i].substr(SCHEMA.length); - filename = '[[string' + i + ']]'; - } - else { - filename = sourceFiles[i]; - try { - sourceCode = require('fs').readFileSync(filename, encoding); - } - catch(e) { - console.log('FILE READ ERROR: in module:jsdoc/parser.parseFiles: "' + filename + '" ' + e); - continue; - } - } - - currentParser = this; - this._parseSourceCode(sourceCode, filename); - currentParser = null; - } - - return this._resultBuffer; -}; - -/** - * @returns {Array} The accumulated results of any calls to parse. - */ -exports.Parser.prototype.results = function() { - return this._resultBuffer; -} - -/** - * @param {Object} o The parse result to add to the result buffer. - */ -exports.Parser.prototype.addResult = function(o) { - this._resultBuffer.push(o); -} - -/** - * Empty any accumulated results of calls to parse. - */ -exports.Parser.prototype.clear = function() { - currentParser = null; - currentSourceName = ''; - this._resultBuffer = []; -} - -/** - * Adds a node visitor to use in parsing - */ -exports.Parser.prototype.addNodeVisitor = function(visitor) { - this._visitors.push(visitor); -} - -/** - * Get the node visitors used in parsing - */ -exports.Parser.prototype.getVisitors = function() { - return this._visitors; -} - -/** @private */ -exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) { - var e = {filename: sourceName}; - this.fire('fileBegin', e); - - if (!e.defaultPrevented) { - e = {filename: sourceName, source: sourceCode}; - this.fire('beforeParse', e); - sourceCode = e.source; - currentSourceName = sourceName = e.filename; - - sourceCode = pretreat(e.source, currentSourceName); - - var ast = parserFactory().parse(sourceCode, sourceName, 1); - ast.visit( - new Packages.org.mozilla.javascript.ast.NodeVisitor({ - visit: visitNode - }) - ); - } - - this.fire('fileComplete', e); - - currentSourceName = ''; -} - -function pretreat(code, sourceFile){ - var sourceFileName = (sourceFile.split("/").pop()).match(/([A-z_0-9]*)/).pop(); - return code - // make starbangstar comments look like real jsdoc comments - .replace(/\/\*\!\*/g, '/**') - - // make matching comment endings easier - .replace(/\*\//g, '»') - - // merge adjacent doclets - .replace(/»\/\*\*+/g, '@also') - // make lent objectliterals documentable by giving them a dummy name - .replace(/(\/\*\*[^»]*?@lends\b[^»]*?»\s*)\{/g, '$1 ____ = {') // like return @lends { - .replace(/(\/\*\*[^»]*?@lends\b[^»]*?»)(\s*)return(\s*)\{/g, '$2$3 return $1 ____ = {') // like @lends return { - - // make matching comment endings harder - .replace(/»/g, '*/') - - // support for unqualified links to methods - .replace(/@link\s#([A-z_0-9]*)/, "@link "+sourceFileName+"#$1|$1"); -} - -var tkn = { NAMEDFUNCTIONSTATEMENT: -1001 }; -exports.Parser.tkn = tkn; - -/** - * Given a node, determine what the node is a member of. - * @param {astnode} node - * @returns {string} The long name of the node that this is a member of. - */ -exports.Parser.prototype.astnodeToMemberof = function(node) { - var id, - doclet; - - if (node.type === Token.VAR || node.type === Token.FUNCTION || node.type == tkn.NAMEDFUNCTIONSTATEMENT) { - if (node.enclosingFunction) { // an inner var or func - id = 'astnode'+node.enclosingFunction.hashCode(); - doclet = this.refs[id]; - if (!doclet) { - return '~'; - } - return (doclet.longname||doclet.name) + '~'; - } - } - else { - //check local references for aliases - var scope = node, - basename = getBasename(nodeToString(node.left)); - while(scope.enclosingFunction) { - id = 'astnode'+scope.enclosingFunction.hashCode(); - doclet = this.refs[id]; - if (doclet && doclet.meta.vars && basename in doclet.meta.vars) { - var alias = doclet.meta.vars.hasOwnProperty(basename)? doclet.meta.vars[basename] : false; - if (alias !== false) { - return [alias, basename]; - } - } - // move up - scope = scope.enclosingFunction; - } - //First check to see if we have a global scope alias - doclet = this.refs["__global__"]; - if (doclet && doclet.meta.vars && doclet.meta.vars.hasOwnProperty(basename)) { - var alias = doclet.meta.vars[basename]; - if (alias !== false) { - return [alias, basename]; - } - } - - id = 'astnode'+node.parent.hashCode(); - doclet = this.refs[id]; - if (!doclet) return ''; // global? - return doclet.longname||doclet.name; - } -} - -/** - * Resolve what "this" refers too, relative to a node. - * @param {astnode} node - The "this" node - * @returns {string} The longname of the enclosing node. - */ -exports.Parser.prototype.resolveThis = function(node) { - var memberof = {}; - - if (node.type !== Token.COLON && node.enclosingFunction) { - // get documentation for the enclosing function - memberof.id = 'astnode'+node.enclosingFunction.hashCode(); - memberof.doclet = this.refs[memberof.id]; - - if (!memberof.doclet) { - return ''; // TODO handle global this? - } - - if (memberof.doclet['this']) { - return memberof.doclet['this']; - } - // like: Foo.constructor = function(n) { /** blah */ this.name = n; } - else if (memberof.doclet.kind === 'function' && memberof.doclet.memberof) { - return memberof.doclet.memberof; - } - // walk up to the closest class we can find - else if (memberof.doclet.kind === 'class' || memberof.doclet.kind === 'module') { - return memberof.doclet.longname||memberof.doclet.name; - } - else { - if (node.enclosingFunction){ - return this.resolveThis(node.enclosingFunction/*memberof.doclet.meta.code.val*/); - } - else return ''; // TODO handle global this? - } - } - else if (node.parent) { - var parent = node.parent; - if (parent.type === Token.COLON) parent = parent.parent; // go up one more - - memberof.id = 'astnode'+parent.hashCode(); - memberof.doclet = this.refs[memberof.id]; - if (!memberof.doclet) return ''; // global? - - return memberof.doclet.longname||memberof.doclet.name; - } - else { - return ''; // global? - } -} - -/** - Given: foo = { x:1 }, find foo from x. - */ -exports.Parser.prototype.resolvePropertyParent = function(node) { - var memberof = {}; - - if (node.parent) { - var parent = node.parent; - if (parent.type === Token.COLON) parent = parent.parent; // go up one more - - memberof.id = 'astnode'+parent.hashCode(); - memberof.doclet = this.refs[memberof.id]; - - if (memberof.doclet) { return memberof; } - } -} - -/** - * Resolve what function a var is limited to. - * @param {astnode} node - * @param {string} basename The leftmost name in the long name: in foo.bar.zip the basename is foo. - */ -exports.Parser.prototype.resolveVar = function(node, basename) { - var doclet, - enclosingFunction = node.enclosingFunction; - - if (!enclosingFunction) { return ''; } // global - doclet = this.refs['astnode'+enclosingFunction.hashCode()]; - - if ( doclet && doclet.meta.vars && basename in doclet.meta.vars ) { - return doclet.longname; - } - - return this.resolveVar(enclosingFunction, basename); -} - -exports.Parser.prototype.addDocletRef = function(e) { - var node = e.code.node; - if (e.doclet) { - currentParser.refs['astnode'+node.hashCode()] = e.doclet; // allow lookup from value => doclet - } - else if ((node.type == Token.FUNCTION || node.type == tkn.NAMEDFUNCTIONSTATEMENT) && !currentParser.refs['astnode'+node.hashCode()]) { // keep references to undocumented anonymous functions too as they might have scoped vars - currentParser.refs['astnode'+node.hashCode()] = { - longname: '', - meta: { code: e.code } - }; - } -} - -exports.Parser.prototype.resolveEnum = function(e) { - var parent = currentParser.resolvePropertyParent(e.code.node); - if (parent && parent.doclet.isEnum) { - if (!parent.doclet.properties) { parent.doclet.properties = []; } - // members of an enum inherit the enum's type - if (parent.doclet.type && !e.doclet.type) { e.doclet.type = parent.doclet.type; } - delete e.doclet.undocumented; - e.doclet.defaultvalue = e.doclet.meta.code.value; - parent.doclet.properties.push(e.doclet); - } -} - -/** @private */ -function visitNode(node) { - var e, - commentSrc; - - // look for stand-alone doc comments - if (node.type === Token.SCRIPT && node.comments) { - // note: ALL comments are seen in this block... - for each(var comment in node.comments.toArray()) { - if (comment.commentType !== Token.CommentType.JSDOC) { - continue; - } - - if (commentSrc = ''+comment.toSource()) { - - e = { - comment: commentSrc, - lineno: comment.getLineno(), - filename: currentSourceName - }; - - if ( isValidJsdoc(commentSrc) ) { - currentParser.fire('jsdocCommentFound', e, currentParser); - } - } - } - e = null; - } - else if (node.type === Token.ASSIGN) { - e = { - id: 'astnode'+node.hashCode(), // the id of the ASSIGN node - comment: String(node.jsDoc||'@undocumented'), - lineno: node.left.getLineno(), - filename: currentSourceName, - astnode: node, - code: aboutNode(node), - event: "symbolFound", - finishers: [currentParser.addDocletRef] - }; - - var basename = getBasename(e.code.name); - - if (basename !== 'this') e.code.funcscope = currentParser.resolveVar(node, basename); - } - else if (node.type === Token.COLON) { // assignment within an object literal - e = { - id: 'astnode'+node.hashCode(), // the id of the COLON node - comment: String(node.left.jsDoc||'@undocumented'), - lineno: node.left.getLineno(), - filename: currentSourceName, - astnode: node, - code: aboutNode(node), - event: "symbolFound", - finishers: [currentParser.addDocletRef, currentParser.resolveEnum] - }; - } - else if (node.type == Token.VAR || node.type == Token.LET || node.type == Token.CONST) { - - if (node.variables) { - return true; // we'll get each var separately on future visits - } - - if (node.parent.variables.toArray()[0] === node) { // like /** blah */ var a=1, b=2, c=3; - // the first var assignment gets any jsDoc before the whole var series - node.jsDoc = node.parent.jsDoc; - } - - e = { - id: 'astnode'+node.hashCode(), // the id of the VARIABLE node - comment: String(node.jsDoc||'@undocumented'), - lineno: node.getLineno(), - filename: currentSourceName, - astnode: node, - code: aboutNode(node), - event: "symbolFound", - finishers: [currentParser.addDocletRef] - }; - - // keep track of vars in a function or global scope - var func = "__global__", - funcDoc = null; - if (node.enclosingFunction) { - func = 'astnode'+node.enclosingFunction.hashCode(); - } - funcDoc = currentParser.refs[func]; - if (funcDoc) { - funcDoc.meta.vars = funcDoc.meta.vars || {}; - funcDoc.meta.vars[e.code.name] = false; - e.finishers.push(makeVarsFinisher(funcDoc)); - } - } - else if (node.type == Token.FUNCTION || node.type == tkn.NAMEDFUNCTIONSTATEMENT) { - e = { - id: 'astnode'+node.hashCode(), // the id of the COLON node - comment: String(node.jsDoc||'@undocumented'), - lineno: node.getLineno(), - filename: currentSourceName, - astnode: node, - code: aboutNode(node), - event: "symbolFound", - finishers: [currentParser.addDocletRef] - }; - - e.code.name = (node.type == tkn.NAMEDFUNCTIONSTATEMENT)? '' : String(node.name) || ''; - //console.log(':: e.code.name is', e.code.name); - - // keep track of vars in a function or global scope - var func = "__global__", - funcDoc = null; - if (node.enclosingFunction) { - func = 'astnode'+node.enclosingFunction.hashCode(); - } - funcDoc = currentParser.refs[func]; - if (funcDoc) { - funcDoc.meta.vars = funcDoc.meta.vars || {}; - funcDoc.meta.vars[e.code.name] = false; - e.finishers.push(makeVarsFinisher(funcDoc)); - } - - var basename = getBasename(e.code.name) - e.code.funcscope = currentParser.resolveVar(node, basename); - } - - if (!e) { e = {finishers: []}; } - for(var i = 0, l = currentParser._visitors.length; i < l; i++) { - currentParser._visitors[i].visitNode(node, e, currentParser, currentSourceName); - if (e.stopPropagation) { break; } - } - - if (!e.preventDefault && isValidJsdoc(e.comment)) { - currentParser.fire(e.event, e, currentParser); - } - - for (var i = 0, l = e.finishers.length; i < l; i++) { - e.finishers[i].call(currentParser, e); - } - - return true; -} - -/** @private */ -function parserFactory() { - var cx = Packages.org.mozilla.javascript.Context.getCurrentContext(); - - var ce = new Packages.org.mozilla.javascript.CompilerEnvirons(); - ce.setRecordingComments(true); - ce.setRecordingLocalJsDocComments(true); - ce.setLanguageVersion(180); - - ce.initFromContext(cx); - return new Packages.org.mozilla.javascript.Parser(ce, ce.getErrorReporter()); -} - -/** - * Attempts to find the name and type of the given node. - * @private - * @memberof module:src/parser.Parser - */ -function aboutNode(node) { - about = {}; - - if (node.type == Token.FUNCTION || node.type == tkn.NAMEDFUNCTIONSTATEMENT) { - about.name = node.type == tkn.NAMEDFUNCTIONSTATEMENT? '' : '' + node.name; - about.type = 'function'; - about.node = node; - } - else if (node.type == Token.VAR || node.type == Token.LET || node.type == Token.CONST) { - about.name = nodeToString(node.target); - if (node.initializer) { // like var i = 0; - about.node = node.initializer; - about.value = nodeToString(about.node); - about.type = getTypeName(node.initializer); - if (about.type === 'FUNCTION' && about.node.name) { - about.node.type = tkn.NAMEDFUNCTIONSTATEMENT; - } - } - else { // like var i; - about.node = node.target; - about.value = nodeToString(about.node); - about.type = 'undefined'; - } - } - else if (node.type === Token.ASSIGN || node.type === Token.COLON) { - about.name = nodeToString(node.left); - if (node.type === Token.COLON) { - - // objlit keys with unsafe variable-name characters must be quoted - if (!/^[$_a-z][$_a-z0-9]*$/i.test(about.name) ) { - about.name = '"'+about.name.replace(/"/g, '\\"')+'"'; - } - } - about.node = node.right; - about.value = nodeToString(about.node); - about.type = getTypeName(node.right); - - if (about.type === 'FUNCTION' && about.node.name) { - about.node.type = tkn.NAMEDFUNCTIONSTATEMENT; - } - } - else { - // type 39 (NAME) - var string = nodeToString(node); - if (string) { - about.name = string; - } - } - - // get names of the formal parameters declared for this function - if (about.node && about.node.getParamCount) { - var paramCount = about.node.getParamCount(); - if (typeof paramCount === 'number') { - about.node.flattenSymbolTable(true); - var paramNames = []; - for (var i = 0, len = paramCount; i < len; i++) { - paramNames.push(''+about.node.getParamOrVarName(i)); - } - about.paramnames = paramNames; - } - } - - return about; -} - -/** @private - @memberof module:src/parser.Parser -*/ -function nodeToString(node) { - var str; - - if (!node) return; - - if (node.type === Token.GETPROP) { - str = [nodeToString(node.target), node.property.string].join('.'); - } - else if (node.type === Token.VAR) { - str = nodeToString(node.target) - } - else if (node.type === Token.NAME) { - str = node.string; - } - else if (node.type === Token.STRING) { - str = node.value; - } - else if (node.type === Token.NUMBER) { - str = node.value; - } - else if (node.type === Token.THIS) { - str = 'this'; - } - else if (node.type === Token.GETELEM) { - str = node.toSource(); // like: Foo['Bar'] - } - else if (node.type === Token.NEG || node.type === Token.TRUE || node.type === Token.FALSE) { - str = node.toSource(); // like -1 - } - else { - str = getTypeName(node); - } - - return '' + str; -}; - -/** @private - @memberof module:src/parser.Parser -*/ -function getTypeName(node) { - var type = ''; - - if (node) { - type = ''+ Packages.org.mozilla.javascript.Token.typeToName(node.getType()); - } - - return type; -} - -/** @private - @memberof module:src/parser.Parser -*/ -function isValidJsdoc(commentSrc) { - return commentSrc && commentSrc.indexOf('/***') !== 0; /*** ignore comments that start with many stars ***/ -} - -/** @private - * @memberof module:src/parser.Parser - */ -function makeVarsFinisher(funcDoc) { - var func = function(e) { - //no need to evaluate all things related to funcDoc again, just use it - if (funcDoc && e.doclet && e.doclet.alias) { - funcDoc.meta.vars[e.code.name] = e.doclet.longname; - } - } - return func; -} - -/** @private - * @memberof module:src/parser.Parser - * @param {string} name Full symbol name. - * @return {string} Basename. - */ -function getBasename(name) { - if (name !== undefined) { - return name.replace(/^([$a-z_][$a-z_0-9]*).*?$/i, '$1'); - } - return name; -} - -/** - Fired whenever the parser encounters a JSDoc comment in the current source code. - @event jsdocCommentFound - @memberof module:jsdoc/src/parser.Parser - @param {event} e - @param {string} e.comment The text content of the JSDoc comment - @param {number} e.lineno The line number associated with the found comment. - @param {string} e.filename The file name associated with the found comment. -*/ \ No newline at end of file diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/src/scanner.js b/Tools/jsdoc3/rhino_modules/jsdoc/src/scanner.js deleted file mode 100644 index 9b8ff7e6e41..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/src/scanner.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - @module jsdoc/src/scanner - @requires module:common/fs - - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - - -var common = { - mixin: require('common/util').mixin, - events: require('common/events') -}; - -var fs = require('fs'); - -/** - @constructor - @mixes module:common.events - */ -exports.Scanner = function() { -} -common.mixin(exports.Scanner.prototype, common.events); - -/** - Recursively searches the given searchPaths for js files. - @param {Array.} searchPaths - @param {number} [depth=1] - @fires sourceFileFound - */ -exports.Scanner.prototype.scan = function(searchPaths, depth, includeMatch, excludeMatch) { - var filePaths = [], - that = this; - - searchPaths = searchPaths || []; - depth = depth || 1; - - searchPaths.forEach(function($) { - if ( fs.stat($).isFile() ) { - filePaths.push($); - } - else { - filePaths = filePaths.concat(fs.ls($, depth)); - } - }); - - filePaths = filePaths.filter(function($) { - if (includeMatch && !includeMatch.test($)) { - return false - } - - if (excludeMatch && excludeMatch.test($)) { - return false - } - - return true; - }); - - filePaths = filePaths.filter(function($) { - var e = { fileName: $ }; - that.fire('sourceFileFound', e); - - return !e.defaultPrevented; - }); - - return filePaths; -} - diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tag.js b/Tools/jsdoc3/rhino_modules/jsdoc/tag.js deleted file mode 100644 index 3c672aacd14..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tag.js +++ /dev/null @@ -1,134 +0,0 @@ -/** - @overview - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** - Functionality related to JSDoc tags. - @module jsdoc/tag - @requires jsdoc/tag/dictionary - @requires jsdoc/tag/validator - @requires jsdoc/tag/type - */ - - -var jsdoc = { - tag: { - dictionary: require('jsdoc/tag/dictionary'), - validator: require('jsdoc/tag/validator'), - type: require('jsdoc/tag/type') - } -}; - -/** - Constructs a new tag object. Calls the tag validator. - @class - @classdesc Represents a single doclet tag. - @param {string} tagTitle - @param {string=} tagBody - @param {object=} meta - */ -exports.Tag = function(tagTitle, tagBody, meta) { - var tagDef = jsdoc.tag.dictionary.lookUp(tagTitle), - meta = meta || {}; - - this.originalTitle = trim(tagTitle); - - /** The title part of the tag: @title text */ - this.title = jsdoc.tag.dictionary.normalise( this.originalTitle ); - - /** The text part of the tag: @title text */ - this.text = trim(tagBody, tagDef.keepsWhitespace); - - if (this.text) { - - if (tagDef.onTagText) { - this.text = tagDef.onTagText(this.text); - } - - if (tagDef.canHaveType) { - - /** The value property represents the result of parsing the tag text. */ - this.value = {}; - - var [ - /*Array.*/ typeNames, - /*any*/ remainingText, - /*?boolean*/ optional, - /*?boolean*/ nullable, - /*?boolean*/ variable - ] = jsdoc.tag.type.parse(this.text); - - if (typeNames.length) { - this.value.type = { - names: typeNames, - optional: optional, - nullable: nullable, - variable: variable - }; - } - - if (remainingText) { - if (tagDef.canHaveName) { - var [paramName, paramDesc, paramOptional, paramDefault] - = parseParamText(remainingText); - - // note the dash is a special case: as a param name it means "no name" - if (paramName && paramName !== '-') { this.value.name = paramName; } - - if (paramDesc) { this.value.description = paramDesc; } - if (paramOptional) { this.value.optional = paramOptional; } - if (paramDefault) { this.value.defaultvalue = paramDefault; } - } - else { - this.value.description = remainingText; - } - } - } - else { - this.value = this.text; - } - } - - jsdoc.tag.validator.validate(this, meta); -} - -function trim(text, newlines) { - if (!text) { return ''; } - - if (newlines) { - return text.replace(/^[\n\r\f]+|[\n\r\f]+$/g, ''); - } - else { - return text.replace(/^\s+|\s+$/g, ''); - } -} - -/** - Parse the parameter name and parameter desc from the tag text. - @inner - @method parseParamText - @memberof module:jsdoc/tag - @param {string} tagText - @returns {Array.} [pname, pdesc, poptional, pdefault]. - */ -function parseParamText(tagText) { - var pname, pdesc, poptional, pdefault; - - // like: pname, pname pdesc, or name - pdesc - tagText.match(/^(\[[^\]]+\]|\S+)((?:\s*\-\s*|\s+)(\S[\s\S]*))?$/); - pname = RegExp.$1; - pdesc = RegExp.$3; - - if ( /^\[\s*(.+?)\s*\]$/.test(pname) ) { - pname = RegExp.$1; - poptional = true; - - if ( /^(.+?)\s*=\s*(.+)$/.test(pname) ) { - pname = RegExp.$1; - pdefault = RegExp.$2; - } - } - return [pname, pdesc, poptional, pdefault]; -} diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tag/dictionary.js b/Tools/jsdoc3/rhino_modules/jsdoc/tag/dictionary.js deleted file mode 100644 index ab186f4c1c9..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tag/dictionary.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - @overview - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -var _synonyms = {}, - _definitions = {}, - _namespaces = []; - -function _TagDefinition(title, etc) { - etc = etc || {}; - - this.title = dictionary.normalise(title); - - for (var p in etc) { - if (etc.hasOwnProperty(p)) { - this[p] = etc[p]; - } - } -} - -_TagDefinition.prototype.synonym = function(synonymName) { - _synonyms[synonymName.toLowerCase()] = this.title; - return this; // chainable -} - -/** @exports jsdoc/tag/dictionary */ -var dictionary = { - /** @function */ - defineTag: function(title, opts) { - _definitions[title] = new _TagDefinition(title, opts); - - if (opts.isNamespace) { - _namespaces.push(title); - } - - return _definitions[title]; - }, - - /** @function */ - lookUp: function(title) { - title = dictionary.normalise(title); - - if ( _definitions.hasOwnProperty(title) ) { - return _definitions[title]; - } - - return false; - }, - - /** @function */ - isNamespace: function(kind) { - return ( ~ _namespaces.indexOf(kind) ); - }, - - /** @function */ - normalise: function(title) { - canonicalName = title.toLowerCase(); - - if ( _synonyms.hasOwnProperty(canonicalName) ) { - return _synonyms[canonicalName]; - } - - return canonicalName; - } -}; - -require('jsdoc/tag/dictionary/definitions').defineTags(dictionary); - -for (var prop in dictionary) { - if (dictionary.hasOwnProperty(prop)) { - exports[prop] = dictionary[prop]; - } -} - diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tag/dictionary/definitions.js b/Tools/jsdoc3/rhino_modules/jsdoc/tag/dictionary/definitions.js deleted file mode 100644 index d01a715e9a8..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tag/dictionary/definitions.js +++ /dev/null @@ -1,641 +0,0 @@ -/** - Define tags that are known in JSDoc. - @module jsdoc/tag/dictionary/definitions - - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** Populate the given dictionary with all known JSDoc tag definitions. - @param {module:jsdoc/tag/dictionary} dictionary -*/ -exports.defineTags = function(dictionary) { - - dictionary.defineTag('abstract', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - // since "abstract" is reserved word in JavaScript let's use "virtual" in code - doclet.virtual = true; - } - }) - .synonym('virtual'); - - dictionary.defineTag('access', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - // only valid values are private and protected, public is default - if ( /^(private|protected)$/i.test(tag.value) ) { - doclet.access = tag.value.toLowerCase(); - } - else { - delete doclet.access; - } - } - }); - - dictionary.defineTag('alias', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.alias = tag.value; - } - }); - - dictionary.defineTag('author', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.author) { doclet.author = []; } - doclet.author.push(tag.value); - } - }); - - // I add on to that - dictionary.defineTag('augments', { - mustHaveValue: true, - // Allow augments value to be specified as a normal type, e.g. {Type} - onTagText: function(text) { - var type = require('jsdoc/tag/type'), - [tp, tx] = type.getTagType(text); - return tp || text; - }, - onTagged: function(doclet, tag) { - doclet.augment( firstWordOf(tag.value) ); - } - }) - .synonym('extends'); - - // that adds on to me - dictionary.defineTag('borrows', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - var [target, source] = parseBorrows(doclet, tag); - doclet.borrow(target, source); - } - }); - - // that adds all of it's members to me - dictionary.defineTag('mixes', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - var source = firstWordOf(tag.value); - doclet.mix(source); - } - }); - - dictionary.defineTag('class', { - onTagged: function(doclet, tag) { - doclet.addTag('kind', 'class'); - - // handle special case where both @class and @constructor tags exist in same doclet - if (tag.originalTitle === 'class') { - var looksLikeDesc = (tag.value || '').match(/\S+\s+\S+/); // multiple words after @class? - if ( looksLikeDesc || /@construct(s|or)\b/i.test(doclet.comment) ) { - doclet.classdesc = tag.value; // treat the @class tag as a @classdesc tag instead - return; - } - } - - setDocletNameToValue(doclet, tag); - } - }) - .synonym('constructor').synonym('internalConstructor'); - - dictionary.defineTag('classdesc', { - onTagged: function(doclet, tag) { - doclet.classdesc = tag.value; - } - }); - - dictionary.defineTag('constant', { - canHaveType: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - } - } - }) - .synonym('const'); - - dictionary.defineTag('copyright', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.copyright = tag.value; - } - }); - - dictionary.defineTag('constructs', { - onTagged: function(doclet, tag) { - var ownerClassName; - if (!tag.value) { - ownerClassName = '{@thisClass}'; // this can be resolved later in the handlers - } - else { - ownerClassName = firstWordOf(tag.value); - } - doclet.addTag('alias', ownerClassName); - doclet.addTag('kind', 'class'); - } - }); - - dictionary.defineTag('default', { - onTagged: function(doclet, tag) { - if (tag.value) { - doclet.defaultvalue = tag.value; - } - else if (doclet.meta && doclet.meta.code && typeof doclet.meta.code.value !== 'undefined') { - if (doclet.meta.code.type && /STRING|NUMBER|NAME|TRUE|FALSE/.test(doclet.meta.code.type)) { - doclet.defaultvalue = doclet.meta.code.value; - if (doclet.meta.code.type === 'STRING') { - // TODO: handle escaped quotes in values - doclet.defaultvalue = '"'+doclet.defaultvalue.replace(/"/g, '\\"')+'"' - } - - if (doclet.defaultvalue === 'TRUE' || doclet.defaultvalue == 'FALSE') { - doclet.defaultvalue = doclet.defaultvalue.toLowerCase(); - } - } - else if (doclet.meta.code.type === 'NULL') { - // TODO: handle escaped quotes in values - doclet.defaultvalue = 'null' - } - } - } - }) - .synonym('defaultvalue'); - - dictionary.defineTag('deprecated', { - // value is optional - onTagged: function(doclet, tag) { - doclet.deprecated = tag.value || true; - } - }); - - dictionary.defineTag('description', { - mustHaveValue: true - }) - .synonym('desc'); - - dictionary.defineTag('enum', { - canHaveType: true, - onTagged: function(doclet, tag) { - doclet.kind = 'member'; - doclet.isEnum = true; - if (tag.value && tag.value.type) { doclet.type = tag.value.type; } - } - }); - - dictionary.defineTag('event', { - isNamespace: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - applyNamespace(doclet, tag); - } - }); - - dictionary.defineTag('example', { - keepsWhitespace: true, - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.examples) { doclet.examples = []; } - doclet.examples.push(tag.value); - } - }); - - dictionary.defineTag('exception', { - mustHaveValue: true, - canHaveType: true, - onTagged: function(doclet, tag) { - if (!doclet.exceptions) { doclet.exceptions = []; } - doclet.exceptions.push(tag.value); - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - } - } - }) - .synonym('throws'); - - dictionary.defineTag('external', { - canHaveType: true, - isNamespace: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - } - } - }); - - dictionary.defineTag('exports', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - var modName = firstWordOf(tag.value); - - doclet.addTag('alias', modName); - doclet.addTag('kind', 'module'); - doclet.longname = modName; - } - }); - - dictionary.defineTag('file', { - onTagged: function(doclet, tag) { - setNameToFile(doclet, tag); - setDocletKindToTitle(doclet, tag); - setDocletDescriptionToValue(doclet, tag); - - doclet.preserveName = true; - } - }) - .synonym('fileoverview') - .synonym('overview'); - - dictionary.defineTag('fires', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.fires) { doclet.fires = []; } - applyNamespace('event', tag); - doclet.fires.push(tag.value); - } - }); - - dictionary.defineTag('function', { - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - } - }) - .synonym('func') - .synonym('method'); - - dictionary.defineTag('global', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.scope = 'global'; - delete doclet.memberof; - } - }); - - dictionary.defineTag('ignore', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.ignore = true; - } - }); - - dictionary.defineTag('inner', { - onTagged: function(doclet, tag) { - setDocletScopeToTitle(doclet, tag); - } - }); - - dictionary.defineTag('instance', { - onTagged: function(doclet, tag) { - setDocletScopeToTitle(doclet, tag); - } - }); - - dictionary.defineTag('kind', { - mustHaveValue: true - }); - - dictionary.defineTag('lends', { - onTagged: function(doclet, tag) { - doclet.alias = tag.value || ''; - doclet.addTag('undocumented'); - } - }); - - dictionary.defineTag('license', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.license = tag.value; - } - }); - - dictionary.defineTag('member', { - canHaveType: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - } - } - }) - .synonym('var'); - - dictionary.defineTag('memberof', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (tag.originalTitle === 'memberof!') { - doclet.forceMemberof = true; - if (tag.value === '') { - doclet.addTag('global'); - delete doclet.memberof; - } - } - setDocletMemberof(doclet, tag); - } - }) - .synonym('memberof!'); - - dictionary.defineTag('mixin', { - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - } - }); - - dictionary.defineTag('module', { - canHaveType: true, - isNamespace: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - doclet.name || setDocletNameToFilename(doclet, tag); - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - } - } - }); - - dictionary.defineTag('name', { - mustHaveValue: true - }); - - dictionary.defineTag('namespace', { - canHaveType: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - setDocletNameToValue(doclet, tag); - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - } - } - }); - - dictionary.defineTag('param', { - //mustHaveValue: true, // param name can be found in the source code if not provided - canHaveType: true, - canHaveName: true, - onTagged: function(doclet, tag) { - if (!doclet.params) { doclet.params = []; } - doclet.params.push(tag.value||{}); - } - }) - .synonym('argument') - .synonym('arg'); - - dictionary.defineTag('private', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.access = 'private'; - } - }); - - dictionary.defineTag('property', { - mustHaveValue: true, - canHaveType: true, - onTagged: function(doclet, tag) { - if (!doclet.properties) { doclet.properties = []; } - doclet.properties.push(tag.value); - } - }) - .synonym('prop'); - - dictionary.defineTag('protected', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.access = 'protected'; - } - }); - - dictionary.defineTag('public', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - delete doclet.access; // public is default - } - }); - - // use this instead of old deprecated @final tag - dictionary.defineTag('readonly', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.readonly = true; - } - }); - - dictionary.defineTag('requires', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - var modName = firstWordOf(tag.value); - if (modName.indexOf('module:') !== 0) { - modName = 'module:'+modName; - } - if (!doclet.requires) { doclet.requires = []; } - doclet.requires.push(modName); - } - }); - - dictionary.defineTag('returns', { - mustHaveValue: true, - canHaveType: true, - onTagged: function(doclet, tag) { - if (!doclet.returns) { doclet.returns = []; } - doclet.returns.push(tag.value); - } - }) - .synonym('return'); - - dictionary.defineTag('see', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.see) { doclet.see = []; } - doclet.see.push(tag.value); - } - }); - - dictionary.defineTag('since', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.since = tag.value; - } - }); - - dictionary.defineTag('static', { - onTagged: function(doclet, tag) { - setDocletScopeToTitle(doclet, tag); - } - }); - - dictionary.defineTag('summary', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.summary = tag.value; - } - }); - - dictionary.defineTag('this', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.see) { doclet.see = []; } - doclet['this'] = firstWordOf(tag.value); - } - }); - - dictionary.defineTag('todo', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.todo) { doclet.todo = []; } - doclet.todo.push(tag.value); - } - }); - - dictionary.defineTag('tutorial', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - if (!doclet.tutorials) { doclet.tutorials = []; } - doclet.tutorials.push(tag.value); - } - }); - - dictionary.defineTag('type', { - mustHaveValue: true, - canHaveType: true, - onTagText: function(text) { - // any text must be formatted as a type, but for back compat braces are optional - if ( ! /^\{.+\}$/.test(text) ) { - text = '{ '+text+' }'; - } - return text; - }, - onTagged: function(doclet, tag) { - if (tag.value && tag.value.type) { - doclet.type = tag.value.type; - if (doclet.kind === 'function') doclet.addTag('returns', tag.text); // for backwards compatibility we allow @type for functions to imply return type - } - } - }); - - dictionary.defineTag('typedef', { - canHaveType: true, - canHaveName: true, - onTagged: function(doclet, tag) { - setDocletKindToTitle(doclet, tag); - - if (tag.value) { - if (tag.value.name) { - doclet.addTag('name', tag.value.name); - } - if (tag.value.type) { - doclet.type = tag.value.type; - } - } - } - }); - - dictionary.defineTag('undocumented', { - mustNotHaveValue: true, - onTagged: function(doclet, tag) { - doclet.undocumented = true; - doclet.comment = ''; - } - }); - - dictionary.defineTag('variation', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.variation = tag.value; - } - }); - - dictionary.defineTag('version', { - mustHaveValue: true, - onTagged: function(doclet, tag) { - doclet.version = tag.value; - } - }); -} - -/** @private */ -function setDocletKindToTitle(doclet, tag) { - doclet.addTag( 'kind', tag.title ); -} - -function setDocletScopeToTitle(doclet, tag) { - doclet.addTag( 'scope', tag.title ); -} - -function setDocletNameToValue(doclet, tag) { - if (tag.value && tag.value.description) { // as in a long tag - doclet.addTag( 'name', tag.value.description); - } - else if (tag.text) { // or a short tag - doclet.addTag('name', tag.text); - } -} - -function setDocletDescriptionToValue(doclet, tag) { - if (tag.value) { - doclet.addTag( 'description', tag.value ); - } -} - -function setNameToFile(doclet, tag) { - if (doclet.meta.filename) { - var name = 'file:'; - if (doclet.meta.path) { name += doclet.meta.path + java.lang.System.getProperty("file.separator"); } - doclet.addTag( 'name', name + doclet.meta.filename ); - } -} - -function setDocletMemberof(doclet, tag) { - if (tag.value && tag.value !== '') { - doclet.setMemberof(tag.value); - } -} - -function applyNamespace(docletOrNs, tag) { - if (typeof docletOrNs === 'string') { // ns - tag.value = app.jsdoc.name.applyNamespace(tag.value, docletOrNs); - } - else { // doclet - if (!docletOrNs.name) return; // error? - - //doclet.displayname = doclet.name; - docletOrNs.longname = app.jsdoc.name.applyNamespace(docletOrNs.name, tag.title); - } -} - -function setDocletNameToFilename(doclet, tag) { - var name = (doclet.meta.path ? (doclet.meta.path + java.lang.System.getProperty("file.separator")) : "") + doclet.meta.filename; - name = name.replace(/\.js$/i, ''); - - for (var i = 0, len = env.opts._.length; i < len; i++) { - if (name.indexOf(env.opts._[i]) === 0) { - name = name.replace(env.opts._[0], ''); - break - } - } - doclet.name = name; -} - -function parseBorrows(doclet, tag) { - var m = /^(\S+)(?:\s+as\s+(\S+))?$/.exec(tag.text); - if (m) { - if (m[1] && m[2]) { - return [ m[1], m[2] ]; - } - else if (m[1]) { - return [ m[1] ]; - } - } -} - -function firstWordOf(string) { - var m = /^(\S+)/.exec(string); - if (m) { return m[1]; } - else { return ''; } -} diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tag/type.js b/Tools/jsdoc3/rhino_modules/jsdoc/tag/type.js deleted file mode 100644 index d243c4b1c1d..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tag/type.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - @module jsdoc/tag/type - - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - - -/** - @param {string} tagValue - @returns {Array.} - */ -exports.parse = function(tagValue) { - if (typeof tagValue !== 'string') { tagValue = ''; } - var type = '', - text = '', - count = 0, - optional, - nullable, - variable; - - [type, text] = getTagType(tagValue); - if (type === '') { text = tagValue; } - - [type, optional] = parseOptional(type); - [type, nullable] = parseNullable(type); - [type, variable] = parseVariable(type); - - type = parseTypes(type); // make it into an array - - return [type, text, optional, nullable, variable]; -} - -function parseOptional(type) { - var optional = null; - - // {sometype=} means optional - if ( /(.+)=$/.test(type) ) { - type = RegExp.$1; - optional = true; - } - - return [type, optional]; -} - -function parseNullable(type) { - var nullable = null; - - // {?sometype} means nullable, {!sometype} means not-nullable - if ( /^([\?\!])(.+)$/.test(type) ) { - type = RegExp.$2; - nullable = (RegExp.$1 === '?')? true : false; - } - - return [type, nullable]; -} - -function parseVariable(type) { - var variable = null; - - // {...sometype} means variable number of that type - if ( /^(\.\.\.)(.+)$/.test(type) ) { - type = RegExp.$2; - variable = true; - } - - return [type, variable]; -} - -function parseTypes(type) { - var types = []; - - if ( ~type.indexOf('|') ) { - // remove optional parens, like: { ( string | number ) } - // see: http://code.google.com/closure/compiler/docs/js-for-compiler.html#types - if ( /^\s*\(\s*(.+)\s*\)\s*$/.test(type) ) { - type = RegExp.$1; - } - types = type.split(/\s*\|\s*/g); - } - else if (type) { - types = [type]; - } - - return types; -} - -function getTagType(tagValue) { - var type = '', - text = '', - count = 0; - - // type expressions start with '{' - if (tagValue[0] === '{') { - count++; - - // find matching closer '}' - for (var i = 1, leni = tagValue.length; i < leni; i++) { - if (tagValue[i] === '\\') { i++; continue; } // backslash escapes the next character - - if (tagValue[i] === '{') { count++; } - else if (tagValue[i] === '}') { count--; } - - if (count === 0) { - type = trim(tagValue.slice(1, i)) - .replace(/\\\{/g, '{') // unescape escaped curly braces - .replace(/\\\}/g, '}'); - text = trim(tagValue.slice(i+1)); - break; - } - } - } - return [type, text]; -} -exports.getTagType = getTagType; - -/** @private */ -function trim(text) { - return text.trim(); -} diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tag/validator.js b/Tools/jsdoc3/rhino_modules/jsdoc/tag/validator.js deleted file mode 100644 index cc02568dd1a..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tag/validator.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - @module jsdoc/tag/validator - @requires jsdoc/tag/dictionary - - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - - -var dictionary = require('jsdoc/tag/dictionary'); - -/** - Validate the given tag. - */ -exports.validate = function(tag, meta) { - var tagDef = dictionary.lookUp(tag.title); - - if (!tagDef && !env.conf.tags.allowUnknownTags) { - throw new UnknownTagError(tag.title, meta); - } - - if (!tag.text) { - if (tagDef.mustHaveValue) { - throw new TagValueRequiredError(tag.title, meta); - } - } - else { - if (tagDef.mustNotHaveValue) { - throw new TagValueNotPermittedError(tag.title, meta); - } - } -} - -function UnknownTagError(tagName, meta) { - this.name = 'UnknownTagError'; - this.message = 'The @' + tagName + ' tag is not a known tag. File: ' + meta.filename + ', Line: ' + meta.lineno + '\n' + meta.comment; -} -UnknownTagError.prototype = Error.prototype; - -function TagValueRequiredError(tagName, meta) { - this.name = 'TagValueRequiredError'; - this.message = 'The @' + tagName + ' tag requires a value. File: ' + meta.filename + ', Line: ' + meta.lineno + '\n' + meta.comment; -} -TagValueRequiredError.prototype = Error.prototype; - -function TagValueNotPermittedError(tagName, meta) { - this.name = 'TagValueNotPermittedError'; - this.message = 'The @' + tagName + ' tag does not permit a value. File: ' + meta.filename + ', Line: ' + meta.lineno + '\n' + meta.comment; -} -TagValueNotPermittedError.prototype = Error.prototype; - diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/template.js b/Tools/jsdoc3/rhino_modules/jsdoc/template.js deleted file mode 100644 index 74922666445..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/template.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - @overview - @author Rafał Wrzeszcz - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -var template = require('underscore/template'), - fs = require('fs'); - -// override default settings -template.settings.evaluate = /<\?js([\s\S]+?)\?>/g; -template.settings.interpolate = /<\?js=([\s\S]+?)\?>/g; - -/** - @module jsdoc/template - */ - -/** - @class - @classdesc Underscore template helper. - @param {string} path - Templates directory. - */ -exports.Template = function(path) { - // make sure path contains trailing slash - this.path = path.replace(/\/$/, '') + '/'; - - this.layout = null; -}; - -/** Loads template from given file. - @param {string} file - Template filename. - @return {function} Returns template closure. - */ -exports.Template.prototype.load = function(file) { - return template.render(fs.readFileSync(this.path + file)); -}; - -// templates cache -var cache = {}; - -/** - Renders template using given data. - - This is low-level function, for rendering full templates use {@link Template.render()}. - - @param {string} file - Template filename. - @param {object} data - Template variables (doesn't have to be object, but passing variables dictionary is best way and most common use). - @return {string} Rendered template. - */ -exports.Template.prototype.partial = function(file, data) { - // load template into cache - if (!(file in cache)) { - cache[file] = this.load(file); - } - - // keep template helper context - return cache[file].call(this, data); -}; - -/** - Renders template with given data. - - This method automaticaly applies layout if set. - - @param {string} file - Template filename. - @param {object} data - Template variables (doesn't have to be object, but passing variables dictionary is best way and most common use). - @return {string} Rendered template. - */ -exports.Template.prototype.render = function(file, data) { - // main content - var content = this.partial(file, data); - - // apply layout - if (this.layout) { - data.content = content; - content = this.partial(this.layout, data); - } - - return content; -}; diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tutorial.js b/Tools/jsdoc3/rhino_modules/jsdoc/tutorial.js deleted file mode 100644 index d042ceeba90..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tutorial.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - @overview - @author Rafał Wrzeszcz - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -var mdParser = require('evilstreak/markdown'); - -/** - @module jsdoc/tutorial - */ - -/** - @class - @classdesc Represents a single JSDoc tutorial. - @param {string} name - Tutorial name. - @param {string} content - Text content. - @param {number} type - Source formating. - */ -exports.Tutorial = function(name, content, type) { - this.title = this.name = name; - this.content = content; - this.type = type; - - // default values - this.parent = null; - this.children = []; -}; - -/** Moves children from current parent to different one. - @param {Tutorial} parent - New parent. - */ -exports.Tutorial.prototype.setParent = function(parent) { - // removes node from old parent - if (this.parent) { - this.parent.removeChild(this); - } - - this.parent = parent; - this.parent.addChild(this); -}; - -/** Removes children from current node. - @param {Tutorial} child - Old child. - */ -exports.Tutorial.prototype.removeChild = function(child) { - var index = this.children.indexOf(child); - if (index != -1) { - this.children.splice(index, 1); - } -}; - -/** Adds new children to current node. - @param {Tutorial} child - New child. - */ -exports.Tutorial.prototype.addChild = function(child) { - this.children.push(child); -}; - -/** Prepares source. - @return {string} HTML source. - */ -exports.Tutorial.prototype.parse = function() { - switch (this.type) { - // nothing to do - case exports.TYPES.HTML: - return this.content; - - // markdown - case exports.TYPES.MARKDOWN: - return mdParser.toHTML(this.content) - .replace(/&/g, '&') // because markdown escapes these - .replace(/</g, '<') - .replace(/>/g, '>'); - - // uhm... should we react somehow? - // if not then this case can be merged with TYPES.HTML - default: - return this.content; - } -}; - -/** Tutorial source types. - @enum {number} - */ -exports.TYPES = { - HTML: 1, - MARKDOWN: 2 -}; diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/tutorial/resolver.js b/Tools/jsdoc3/rhino_modules/jsdoc/tutorial/resolver.js deleted file mode 100644 index fc78ac02415..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/tutorial/resolver.js +++ /dev/null @@ -1,126 +0,0 @@ -/** - @overview - @author Rafał Wrzeszcz - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** - @module jsdoc/tutorial/resolver - */ - -var tutorial = require('jsdoc/tutorial'), - fs = require('fs'), - conf = {}, - tutorials = {}, - finder = /^(.*)\.(x(?:ht)?ml|html?|md|markdown|js(?:on)?)$/i; - -/** Adds new tutorial. - @param {tutorial.Tutorial} current - New tutorial. - */ -exports.addTutorial = function(current) { - tutorials[current.name] = current; - - // default temporary parent - current.setParent(exports.root); -}; - -/** Root tutorial. - @type tutorial.Tutorial - */ -exports.root = new tutorial.Tutorial('', ''); - -/** Additional instance method for root node. - @param {string} name - Tutorial name. - @reutrn {tutorial.Tutorial} Tutorial instance. - */ -exports.root.getByName = function(name) { - return tutorials[name]; -}; - -/** Load tutorials from given path. - @param {string} path - Tutorials directory. - */ -exports.load = function(path) { - var match, - type, - name, - current, - files = fs.ls(path); - - // tutorials handling - files.forEach(function(file) { - match = file.match(finder); - - // any filetype that can apply to tutorials - if (match) { - name = fs.toFile(match[1]); - content = fs.readFileSync(file); - - switch (match[2].toLowerCase()) { - // HTML type - case 'xml': - case 'xhtml': - case 'html': - case 'htm': - type = tutorial.TYPES.HTML; - break; - - // Markdown typs - case 'md': - case 'markdown': - type = tutorial.TYPES.MARKDOWN; - break; - - // configuration file - case 'js': - case 'json': - conf[name] = JSON.parse(content); - - // how can it be? check `finder' regexp - default: - // not a file we want to work with - return; - } - - current = new tutorial.Tutorial(name, content, type); - exports.addTutorial(current); - } - }); -}; - -/** Resolves hierarchical structure. - @param {object} map - Contents map. - */ -exports.resolve = function() { - var item, - current; - for (var name in conf) { - // should we be restrictive here? - // what is someone just wants to keep sample sources in same directory with tutorials? - // I've decided to leave such cases alone - if (!(name in tutorials)) { - continue; - } - - item = conf[name]; - current = tutorials[name] - - // set title - if (item.title) { - current.title = item.title; - } - - // add children - if (item.children) { - item.children.forEach(function(child) { - // I really didn't want to throw you an exception in most cases - // but now, user, you pissed me off ;) - if (!(child in tutorials)) { - throw new Error("Missing child tutorial: " + child); - } - - tutorials[child].setParent(current); - }); - } - } -}; diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/util/dumper.js b/Tools/jsdoc3/rhino_modules/jsdoc/util/dumper.js deleted file mode 100644 index 1e13d2e0895..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/util/dumper.js +++ /dev/null @@ -1,157 +0,0 @@ -/** - Recursively print out all names and values in a data structure. - @module common/dumper - @author Michael Mathews - @license Apache License 2.0 - See file 'LICENSE.md' in this project. - */ - -/** - @param {any} object - */ -exports.dump = function(object) { - indentBy = 0; - output = ''; - - walk(object); - outdent(false); - return output; -} - -const INDENTATION = ' '; // 4 spaces -var indentBy, - output; - -function pad(depth) { - var padding = ''; - while (depth--) { - padding += INDENTATION; - } - return padding; -} - -/** - @param {string} openingBrace - The opening brace to add, like "{". - @private - @inner - @memberof module:common/dumper - */ -function indent(openingBrace) { - indentBy++; - if (openingBrace) output += openingBrace + '\n'; -} - -/** - @param {string|boolean} closingBrace - The closing brace to add, like "}" or if boolean - `false` no closing brace or trailing newline. - @private - @inner - @memberof module:common/dumper - */ -function outdent(closingBrace) { - indentBy--; - output = output.replace(/,\n$/, '\n'); // trim trailing comma - if (closingBrace === false) { output = output.replace(/\n$/, ''); } - else if (closingBrace) output += pad(indentBy) + closingBrace + ',\n'; -} - -var seen = []; -seen.has = function(object) { - for (var i = 0, l = seen.length; i < l; i++) { - if (seen[i] === object) { return true; } - } - return false; -} - -function walk(object) { - var value; - - if ( value = getValue(object) ) { - output += value + ',\n'; - } - else if ( isUnwalkable(object) ) { - output += ',\n' - } - else if ( isRegExp(object) ) { - output += ',\n' - } - else if ( isDate(object) ) { - output += ',\n' - } - else if ( isFunction(object) ) { - output += ',\n'; - } - else if ( isArray(object) ) { - if ( seen.has(object) ) { - output += ',\n'; - return; - } - else { - seen.push(object); - } - - indent('['); - for (var i = 0, leni = object.length; i < leni; i++) { - output += pad(indentBy); // + i + ': '; - walk( object[i] ); - } - outdent(']'); - } - else if ( isObject(object) ) { - if ( seen.has(object) ) { - output += ',\n'; - return; - } - else { - seen.push(object); - } - - indent('{'); - for (var p in object) { - if ( object.hasOwnProperty(p) ) { - output += pad(indentBy) + stringify(p) + ': '; - walk( object[p] ); - } - } - outdent('}'); - } -} - -function getValue(o) { // see: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/typeof - if (o === null) { return 'null'; } - if ( /^(string|boolean|number|undefined)$/.test(typeof o) ) { - return ''+stringify(o); - } -} - -function stringify(o) { - return JSON.stringify(o); -} - -function isUnwalkable(o) { // some objects are unwalkable, like Java native objects - return (typeof o === 'object' && typeof o.constructor === 'undefined'); -} - -function isArray(o) { - return o && (o instanceof Array) || o.constructor === Array; -} - -function isRegExp(o) { - return (o instanceof RegExp) || - (typeof o.constructor !== 'undefined' && o.constructor.name === 'RegExp'); -} - -function isDate(o) { - return o && (o instanceof Date) || - (typeof o.constructor !== 'undefined' && o.constructor.name === 'Date'); -} - -function isFunction(o) { - return o && (typeof o === 'function' || o instanceof Function);// || - //(typeof o.constructor !== 'undefined' && (o.constructor||{}).name === 'Function'); -} - -function isObject(o) { - return o && o instanceof Object || - (typeof o.constructor !== 'undefined' && o.constructor.name === 'Object'); -} - diff --git a/Tools/jsdoc3/rhino_modules/jsdoc/util/templateHelper.js b/Tools/jsdoc3/rhino_modules/jsdoc/util/templateHelper.js deleted file mode 100644 index 9c78a7598e7..00000000000 --- a/Tools/jsdoc3/rhino_modules/jsdoc/util/templateHelper.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @module jsdoc/util/templateHelper - */ - -var hash = require('pajhome/hash'); -var dictionary = require('jsdoc/tag/dictionary'); - -exports.globalName = 'global'; -exports.fileExtension = '.html'; - -/** Find symbol {@link ...} and {@tutorial ...} strings in text and turn into html links */ -exports.resolveLinks = function(str) { - str = str.replace(/(?:\[(.+?)\])?\{@link +(.+?)\}/gi, - function(match, content, longname) { - return toLink(longname, content); - } - ); - - str = str.replace(/(?:\[(.+?)\])?\{@tutorial +(.+?)\}/gi, - function(match, content, tutorial) { - return toTutorial(tutorial, content); - } - ); - - return str; -} - -// two-way lookup -var linkMap = { - longnameToUrl: {}, - urlToLongname: {} -}; - -exports.registerLink = function(longname, url) { - linkMap.longnameToUrl[longname] = url; - linkMap.urlToLongname[url] = longname; -} - -// each container gets its own html file -var containers = ['class', 'module', 'external', 'namespace', 'mixin', 'glsl', 'enumeration']; - -/** Turn a doclet into a URL. */ -exports.createLink = function(doclet) { - var url = ''; - - if (containers.indexOf(doclet.kind) < 0) { - var longname = doclet.longname, - filename = strToFilename(doclet.memberof || doclet.filename || exports.globalName); - - url = filename + exports.fileExtension + '#' + getNamespace(doclet.kind) + doclet.name; - } - else { - var longname = doclet.longname, - filename = strToFilename(longname); - - url = filename + exports.fileExtension; - } - - return url; -} - -function getNamespace(kind) { - if (dictionary.isNamespace(kind)) { - return kind+':'; - } - return ''; -} - -// compute it here just once -var nsprefix = /^(event|module|external):/; - -function strToFilename(str) { - // allow for namespace prefix - var basename = str.replace(nsprefix, '$1-'); - - if ( /[^$a-z0-9._-]/i.test(basename) ) { - return hash.hex_md5(str).substr(0, 10); - } - return makeFilenameUnique(basename, str); -} - -var files = {}; - -function makeFilenameUnique(filename, str) { - //add suffix underscore until filename gets unique - while (filename in files && files[filename] !== str) { - filename += '_'; - } - files[filename] = str; - return filename; -} - -function toLink(longname, content) { - if (!longname) { - throw new Error('Missing required parameter: url'); - } - - // Has link been specified manually? - var url; - if (/^(http|ftp)s?:/.test(longname)) { - url = longname; - - // Has link text been specified {@link http://github.com|GitHub Website} - var split = url.indexOf('|'); - if (split !== -1) { - content = url.substr(split + 1); - url = url.substr(0, split); - } - } - else { - // support for {@link classname#methodname|Link Name} - url = longname; - var split = url.indexOf('|'); - if (split !== -1){ - content = url.substr(split+1); - url = linkMap.longnameToUrl[url.substr(0,split)]; - } else { - url = linkMap.longnameToUrl[longname]; - } - } - - content = content || longname; - - if (!url) { - return content; - } - else { - return ''+content+''; - } -} - -/** @external {jsdoc.tutorial.Tutorial} */ -var tutorials; - -/** Sets tutorials map. - @param {jsdoc.tutorial.Tutorial} root - Root tutorial node. - */ -exports.setTutorials = function(root) { - tutorials = root; -}; - -exports.toTutorial = toTutorial = function(tutorial, content) { - if (!tutorial) { - throw new Error('Missing required parameter: tutorial'); - } - - var node = tutorials.getByName(tutorial); - // no such tutorial - if (!node) { - return 'Tutorial: '+tutorial+''; - } - - content = content || node.title; - - return ''+content+''; -} - -exports.longnameToUrl = linkMap.longnameToUrl; - -exports.tutorialToUrl = function(tutorial) { - var node = tutorials.getByName(tutorial); - // no such tutorial - if (!node) { - throw new Error('No such tutorial: '+tutorial); - } - - return 'tutorial-'+strToFilename(node.name)+exports.fileExtension; -}; diff --git a/Tools/jsdoc3/rhino_modules/path.js b/Tools/jsdoc3/rhino_modules/path.js deleted file mode 100644 index d21b375ef83..00000000000 --- a/Tools/jsdoc3/rhino_modules/path.js +++ /dev/null @@ -1,146 +0,0 @@ - -var isWindows = java.lang.System.getProperty("os.name").toLowerCase().contains("windows"); -var fileSeparator = java.lang.System.getProperty("file.separator"); - -/** - * Returns everything on a path except for the last item - * e.g. if the path was 'path/to/something', the return value would be 'path/to' - */ -exports.basename = function(path) { - var parts = path.split(fileSeparator); - parts.pop(); - path = parts.join(fileSeparator); - return path; -}; - -/** - * Returns the last item on a path - */ -exports.filename = function(path) { - var parts = path.split(fileSeparator); - if (parts.length > 0) { - return parts.pop(); - } - return null; -}; - -exports.existsSync = function(path) { - var file = new java.io.File(path); - - if (file.isFile()) { - return true; - } - - return false; -}; - -//Code below taken from node - -//resolves . and .. elements in a path array with directory names there -//must be no slashes, empty elements, or device names (c:\) in the array -//(so also no leading and trailing slashes - it does not distinguish -//relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for ( var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last == '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -if (isWindows) { - // Regex to split a windows path into three parts: [*, device, slash, - // tail] windows-only - var splitDeviceRe = - /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/; - - // windows version - exports.normalize = function(path) { - var result = splitDeviceRe.exec(path), - device = result[1] || '', - isUnc = device && device.charAt(1) !== ':', - isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute - tail = result[3], - trailingSlash = /[\\\/]$/.test(tail); - - // Normalize the tail path - tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) { - return !!p; - }), !isAbsolute).join('\\'); - - if (!tail && !isAbsolute) { - tail = '.'; - } - if (tail && trailingSlash) { - tail += '\\'; - } - - return device + (isAbsolute ? '\\' : '') + tail; - }; - - //windows version - exports.join = function() { - function f(p) { - return p && typeof p === 'string'; - } - - var paths = Array.prototype.slice.call(arguments, 0).filter(f); - var joined = paths.join('\\'); - - // Make sure that the joined path doesn't start with two slashes - // - it will be mistaken for an unc path by normalize() - - // unless the paths[0] also starts with two slashes - if (/^[\\\/]{2}/.test(joined) && !/^[\\\/]{2}/.test(paths[0])) { - joined = joined.slice(1); - } - - return exports.normalize(joined); - }; -} else { - // path.normalize(path) - // posix version - exports.normalize = function(path) { - var isAbsolute = path.charAt(0) === '/', - trailingSlash = path.slice(-1) === '/'; - - // Normalize the path - path = normalizeArray(path.split('/').filter(function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; - }; - - // posix version - exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(paths.filter(function(p, index) { - return p && typeof p === 'string'; - }).join('/')); - }; -} \ No newline at end of file diff --git a/Tools/jsdoc3/rhino_modules/sys.js b/Tools/jsdoc3/rhino_modules/sys.js deleted file mode 100644 index d7af7e3fb49..00000000000 --- a/Tools/jsdoc3/rhino_modules/sys.js +++ /dev/null @@ -1,4 +0,0 @@ - -exports.puts = function(str) { - print(String(str)); -}; diff --git a/Tools/jsdoc3/templates/README.md b/Tools/jsdoc3/templates/README.md deleted file mode 100644 index fbdd7dbf169..00000000000 --- a/Tools/jsdoc3/templates/README.md +++ /dev/null @@ -1,20 +0,0 @@ -To create or use your own template, create a folder, and give it the name of your template, for example "mycooltemplate". Within this folder create a file named "publish.js". That file must define a global method named "publish". For example: - -````javascript -/** - * Turn the data about your docs into file output. - * @global - * @param {TAFFY} data - A TaffyDB collection representing - * all the symbols documented in your code. - * @param {object} opts - An object with options information. - */ -function publish(data, opts) { - // do stuff here to generate your output files -} -```` - -To invoke JSDoc 3 with your own template, use the `-t` command line option, giving it the path to your template folder. - -```` -./jsdoc mycode.js -t /path/to/mycooltemplate -```` \ No newline at end of file diff --git a/Tools/jsdoc3/templates/default/README.md b/Tools/jsdoc3/templates/default/README.md deleted file mode 100644 index a7bd96bfd56..00000000000 --- a/Tools/jsdoc3/templates/default/README.md +++ /dev/null @@ -1 +0,0 @@ -The default template for JSDoc 3 uses: [the Taffy Database library](http://taffydb.com/) and the [Underscore Template library](http://documentcloud.github.com/underscore/#template). diff --git a/Tools/jsdoc3/templates/default/publish.js b/Tools/jsdoc3/templates/default/publish.js deleted file mode 100644 index 9257f8d8046..00000000000 --- a/Tools/jsdoc3/templates/default/publish.js +++ /dev/null @@ -1,471 +0,0 @@ -(function() { - - var template = require('jsdoc/template'), - fs = require('fs'), - helper = require('jsdoc/util/templateHelper'), - scopeToPunc = { 'static': '.', 'inner': '~', 'instance': '#' }; - - /** - @global - @param {TAFFY} data See . - @param {object} opts - @param {Tutorial} tutorials - */ - publish = function(data, opts, tutorials) { - var out = '', - view = new template.Template(__dirname + '/templates/default/tmpl'); - - // set up templating - view.layout = 'layout.tmpl'; - - // set up tutorials for helper - helper.setTutorials(tutorials); - - function find(spec) { - return data.get( data.find(spec) ); - } - - function htmlsafe(str) { - return str.replace(/'+p.name+''); } - else { pnames.push(p.name); } - } - }); - } - - f.signature = (f.signature || '') + '('+pnames.join(', ')+')'; - } - - function generateAncestry(thisdoc) { - var ancestors = [], - doc = thisdoc; - - while (doc = doc.memberof) { - doc = find({longname: doc}); - if (doc) { doc = doc[0]; } - if (!doc) break; - ancestors.unshift( linkto(doc.longname, (scopeToPunc[doc.scope] || '') + doc.name) ); - } - if (ancestors.length) { - ancestors[ancestors.length-1] += (scopeToPunc[thisdoc.scope] || ''); - } - return ancestors; - } - - function addSignatureReturns(f) { - var returnTypes = []; - - if (f.returns) { - f.returns.forEach(function(r) { - if (r.type && r.type.names) { - if (! returnTypes.length) { returnTypes = r.type.names; } - } - }); - } - - if (returnTypes && returnTypes.length) { - returnTypes = returnTypes.map(function(r) { - return linkto(r); - }); - } - f.signature = ''+(f.signature || '') + '' + ''+(returnTypes.length? ' → {'+returnTypes.join('|')+'}' : '')+''; - } - - function addSignatureType(f) { - var types = []; - - if (f.type && f.type.names) { - types = f.type.names; - } - - if (types && types.length) { - types = types.map(function(t) { - return linkto(t, htmlsafe(t)); - }); - } - - f.signature = (f.signature || '') + ''+(types.length? ' :'+types.join('|') : '')+''; - } - - function addAttribs(f) { - var attribs = []; - - if (f.virtual) { - attribs.push('virtual'); - } - - if (f.access && f.access !== 'public') { - attribs.push(f.access); - } - - if (f.scope && f.scope !== 'instance' && f.scope !== 'global') { - if (f.kind == 'function' || f.kind == 'member' || f.kind == 'constant') attribs.push(f.scope); - } - - if (f.readonly === true) { - if (f.kind == 'member') attribs.push('readonly'); - } - - if (f.kind === 'constant') { - attribs.push('constant'); - f.kind = 'member'; - } - - f.attribs = ''+htmlsafe(attribs.length? '<'+attribs.join(', ')+'> ' : '')+''; - } - - data.remove({undocumented: true}); - data.remove({ignore: true}); - if (!opts.private) { data.remove({access: 'private'}); } - data.remove({memberof: ''}); - - var packageInfo = (find({kind: 'package'}) || []) [0]; - - //function renderLinks(text) { - // return helper.resolveLinks(text); - //} - - data.forEach(function(doclet) { - doclet.attribs = ''; - - - if (doclet.examples) { - doclet.examples = doclet.examples.map(function(example) { - var caption, code; - - if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) { - caption = RegExp.$1; - code = RegExp.$3; - } - - return { - caption: caption || '', - code: code || example - }; - }); - } - if (doclet.see) { - doclet.see.forEach(function(seeItem, i) { - doclet.see[i] = hashToLink(doclet, seeItem); - }); - } - }); - - data.orderBy(['longname', 'version', 'since']); - - // kinds of containers - var globals = find( {kind: ['member', 'constant', 'typedef'], memberof: {isUndefined: true}} ), - modules = find({kind: 'module'}), - externals = find({kind: 'external'}), - mixins = find({kind: 'mixin'}), - namespaces = find({kind: 'namespace'}), - glslTypes = find({kind: 'glsl'}); - - var outdir = opts.destination; - if (packageInfo && packageInfo.name) { - outdir += '/' + packageInfo.name + '/' + packageInfo.version + '/'; - } - fs.mkPath(outdir); - - // copy static files to outdir - var fromDir = __dirname + '/templates/default/static', - staticFiles = fs.ls(fromDir, 3); - - staticFiles.forEach(function(fileName) { - var toDir = fs.toDir(fileName.replace(fromDir, outdir)); - fs.mkPath(toDir); - fs.copyFile(fileName, toDir); - }); - - function linkto(longname, linktext) { - var url = helper.longnameToUrl[longname]; - return url? ''+(linktext || longname)+'' : (linktext || longname); - } - - function tutoriallink(tutorial) { - return helper.toTutorial(tutorial); - } - - var containers = ['class', 'module', 'external', 'namespace', 'mixin']; - - data.forEach(function(doclet) { - var url = helper.createLink(doclet); - helper.registerLink(doclet.longname, url); - }); - - data.forEach(function(doclet) { - var url = helper.longnameToUrl[doclet.longname]; - - if (url.indexOf('#') > -1) { - doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop(); - } - else { - doclet.id = doclet.name; - } - - if (doclet.kind === 'function' || doclet.kind === 'class') { - addSignatureParams(doclet); - addSignatureReturns(doclet); - addAttribs(doclet); - } - }) - - // do this after the urls have all been generated - data.forEach(function(doclet) { - doclet.ancestors = generateAncestry(doclet); - - doclet.signature = ''; - - if (doclet.kind === 'member') { - addSignatureType(doclet); - addAttribs(doclet) - } - - if (doclet.kind === 'constant') { - addSignatureType(doclet); - addAttribs(doclet) - } - }); - - var nav = '', - seen = {}; - - nav += '
      '; // Start single class list, begin JavaScript div - var classNames = find({kind: 'class'}); - if (classNames.length) { - //nav += '

      Classes

        '; - classNames.forEach(function(c) { - var moduleSameName = find({kind: 'module', longname: c.longname}); - if (moduleSameName.length) { - c.name = c.name.replace('module:', 'require(')+')'; - moduleSameName[0].module = c; - } - - if (!seen.hasOwnProperty(c.longname) ) nav += '
      • '+linkto(c.longname, c.name)+'
      • '; - seen[c.longname] = true; - }); - //nav += '
      '; - } - - var moduleNames = find({kind: 'module'}); - if (moduleNames.length) { - //nav += '

      Modules

        '; - moduleNames.forEach(function(m) { - if ( !seen.hasOwnProperty(m.longname) ) nav += '
      • '+linkto(m.longname, m.name)+'
      • '; - seen[m.longname] = true; - }); - //nav += '
      '; - } - - var externalNames = find({kind: 'external'}); - if (externalNames.length) { - //nav += '

      Externals

        '; - externalNames.forEach(function(e) { - if ( !seen.hasOwnProperty(e.longname) ) nav += '
      • '+linkto( e.longname, e.name.replace(/(^"|"$)/g, '') )+'
      • '; - seen[e.longname] = true; - }); - //nav += '
      '; - } - - var namespaceNames = find({kind: 'namespace'}); - if (namespaceNames.length) { - //nav += '

      Namespaces

        '; - namespaceNames.forEach(function(n) { - if ( !seen.hasOwnProperty(n.longname) ) nav += '
      • '+linkto(n.longname, n.name)+'
      • '; - seen[n.longname] = true; - }); - //nav += '
      '; - } - - var enumerationNames = find({kind: 'enumeration'}); - if (enumerationNames.length) { - enumerationNames.forEach(function(g) { - if (!seen.hasOwnProperty(g.longname) ) nav += '
    • '+linkto(g.longname, g.name)+'
    • '; - seen[g.longname] = true; - }); - } - - nav += '
      '; // End classItems div, start GLSL div - var glslNames = find({kind: 'glsl'}); - if (glslNames.length) { - glslNames.forEach(function(g) { - if ( !seen.hasOwnProperty(g.longname) ) nav += '
    • '+linkto(g.longname, g.name)+'
    • '; - seen[g.longname] = true; - }); - } - nav += '
    '; // End GLSL div, end Class list - -// var constantNames = find({kind: 'constants'}); -// if (constantNames.length) { -// nav += '

    Constants

      '; -// constantNames.forEach(function(c) { -// if ( !seen.hasOwnProperty(c.longname) ) nav += '
    • '+linkto(c.longname, c.name)+'
    • '; -// seen[c.longname] = true; -// }); -// -// nav += '
    '; -// } -/* - var mixinNames = find({kind: 'mixin'}); - if (mixinNames.length) { - nav += '

    Mixins

      '; - mixinNames.forEach(function(m) { - if ( !seen.hasOwnProperty(m.longname) ) nav += '
    • '+linkto(m.longname, m.name)+'
    • '; - seen[m.longname] = true; - }); - - nav += '
    '; - } - - if (tutorials.children.length) { - nav += '

    Tutorials

      '; - tutorials.children.forEach(function(t) { - nav += '
    • '+tutoriallink(t.name)+'
    • '; - }); - - nav += '
    '; - } - - var globalNames = find({kind: ['function', 'constant', 'typedef'], 'memberof': {'isUndefined': true}}); - if (globalNames.length) { - //nav += '

    Global

      '; - globalNames.forEach(function(g) { - if ( g.kind !== 'typedef' && !seen.hasOwnProperty(g.longname) ) nav += '
    • '+linkto(g.longname, g.name)+'
    • '; - seen[g.longname] = true; - }); - - nav += '
    '; - } -*/ - // add template helpers - view.find = find; - view.linkto = linkto; - view.tutoriallink = tutoriallink; - view.htmlsafe = htmlsafe; - // once for all - view.nav = nav; - - var types_json = {}; - for (var longname in helper.longnameToUrl) { - var classes = find({kind: 'class', longname: longname}); - if (classes.length) generate(classes[0].name, classes, helper.longnameToUrl[longname]); - - var enumerations = find({kind: 'enumeration', longname: longname}); - if (enumerations.length) generate(enumerations[0].name, enumerations, helper.longnameToUrl[longname]); - - var glslTypes = find({kind: 'glsl', longname: longname}); - if (glslTypes.length) generate(glslTypes[0].name, glslTypes, helper.longnameToUrl[longname]); - - var modules = find({kind: 'module', longname: longname}); - if (modules.length) generate(modules[0].name, modules, helper.longnameToUrl[longname]); - - var namespaces = find({kind: 'namespace', longname: longname}); - if (namespaces.length) generate('Namespace: '+namespaces[0].name, namespaces, helper.longnameToUrl[longname]); - -// var constants = find({kind: 'constant', longname: longname}); -// if (constants.length) generate('Constant: '+constants[0].name, constants, helper.longnameToUrl[longname]); - - var mixins = find({kind: 'mixin', longname: longname}); - if (mixins.length) generate('Mixin: '+mixins[0].name, mixins, helper.longnameToUrl[longname]); - - var externals = find({kind: 'external', longname: longname}); - if (externals.length) generate('External: '+externals[0].name, externals, helper.longnameToUrl[longname]); - } - - // if (globals.length) generate('Global', [{kind: 'globalobj'}], 'global.html'); - - view.layout = 'index.tmpl'; - var indexHtml = view.render('empty.tmpl', { title: 'Cesium Documentation' }); - fs.writeFileSync(outdir + '/index.html', indexHtml); - - fs.writeFileSync(outdir + '/types.txt', JSON.stringify(types_json)); - - function generate(title, docs, filename) { - var data = { - title: title, - docs: docs - }; - - var path = outdir + '/' + filename, - html = view.render('container.tmpl', data), - titleLower = title.toLowerCase(); - - html = helper.resolveLinks(html); // turn {@link foo} into foo - - if (titleLower in types_json) { - types_json[titleLower].push(filename); - } else { - types_json[titleLower] = [ filename ]; - } - - var pos = 0, pos2, member, memberLower, match = 'h4 class="name" id="', matchLen = match.length; - while ((pos = html.indexOf(match, pos)) >= 0) { - pos += matchLen; - if ((pos2 = html.indexOf('"', pos)) > 0) { - member = html.substring(pos, pos2); - memberLower = member.toLowerCase(); - if (memberLower !== titleLower) { - if (memberLower in types_json) { - // Note ".toString" and ".valueOf" used to be discarded here, before .toLowerCase() was used. - if (typeof types_json[memberLower].push === 'function') { - types_json[memberLower].push(filename + '#' + member); - } - } else { - types_json[memberLower] = [ filename + '#' + member ]; - } - } - } - } - - fs.writeFileSync(path, html); - } - - function generateTutorial(title, tutorial, filename) { - var data = { - title: title, - header: tutorial.title, - content: tutorial.parse(), - children: tutorial.children - }; - - var path = outdir + '/' + filename, - html = view.render('tutorial.tmpl', data); - - // yes, you can use {@link} in tutorials too! - html = helper.resolveLinks(html); // turn {@link foo} into foo - - fs.writeFileSync(path, html); - } - - // tutorials can have only one parent so there is no risk for loops - function saveChildren(node) { - node.children.forEach(function(child) { - generateTutorial('Tutorial: '+child.title, child, helper.tutorialToUrl(child.name)); - saveChildren(child); - }); - } - saveChildren(tutorials); - } - - function hashToLink(doclet, hash) { - if ( !/^(#.+)/.test(hash) ) { return hash; } - - var url = helper.createLink(doclet); - - url = url.replace(/(#.+|$)/, hash); - pos = url.indexOf('|') - if(pos === -1){ - return ''+hash.substr(1)+''; - } - return ''+url.substr(pos+1)+''; - - } - -})(); diff --git a/Tools/jsdoc3/templates/default/static/javascript/all.js b/Tools/jsdoc3/templates/default/static/javascript/all.js deleted file mode 100644 index b2055e75b96..00000000000 --- a/Tools/jsdoc3/templates/default/static/javascript/all.js +++ /dev/null @@ -1,689 +0,0 @@ -/** - - * @fileOverview Contains standard code in the namespace 'wbos' and code specifically written for Codeview in the namespace 'codeview' - - * @author Wouter Bos (www.thebrightlines.com) - - * @since 1.0 - 2010-09-10 - - * @version 1.0 - 2010-09-10 - - */ - - - - - - - - - - - - - -if (typeof(wbos) == "undefined") { - - /** - - * @namespace Standard code of Wouter Bos (wbos) - - */ - - wbos = {} - -} - -if (typeof(wbos.CssTools) == "undefined") { - - /** - - * @namespace Namespace for CSS-related functionality - - */ - - wbos.CssTools = {} - -} - - - - - - - - - -/** - - * @namespace Fallback for CSS advanced media query - - * @class - - * @since 1.0 - 2010-09-10 - - * @version 1.0 - 2010-09-10 - - */ - -wbos.CssTools.MediaQueryFallBack = ( function() { - - var config = { - - cssScreen: "/css/screen.css", - - cssHandheld: "/css/handheld.css", - - mobileMaxWidth: 660, - - testDivClass: "cssLoadCheck", - - dynamicCssLinkId: "DynCssLink", - - resizeDelay: 30 - - } - - var noMediaQuery = false; - - var delay; - - var currentCssMediaType; - - - - // Adding events to elements in the DOM without overwriting it - - function addEvent(element, newFunction, eventType) { - - var oldEvent = eval("element." + eventType); - - var eventContentType = eval("typeof element." + eventType) - - - - if ( eventContentType != 'function' ) { - - eval("element." + eventType + " = newFunction") - - } else { - - eval("element." + eventType + " = function(e) { oldEvent(e); newFunction(e); }") - - } - - } - - - - // Get the the inner width of the browser window - - function getWindowWidth() { - - if (window.innerWidth) { - - return window.innerWidth; - - } else if (document.documentElement.clientWidth) { - - return document.documentElement.clientWidth; - - } else if (document.body.clientWidth) { - - return document.body.clientWidth; - - } else{ - - return 0; - - } - - } - - - - function addCssLink(cssHref) { - - var cssNode = document.createElement('link'); - - var windowWidth; - - cssNode.type = 'text/css'; - - cssNode.rel = 'stylesheet'; - - cssNode.media = 'screen, handheld, fallback'; - - cssNode.href = cssHref; - - document.getElementsByTagName("head")[0].appendChild(cssNode); - - } - - - - - - - - /* Start public */ - - return { - - /** - - * Adds link to CSS in the head if no CSS is loaded - - * - - * @since 1.0 - 2010-08-21 - - * @version 1.0 - 2010-08-21 - - * @param {String|Object} cssScreen URL to CSS file for larger screens - - * @param {String|Object} cssHandheld URL to CSS file for smaller screens - - * @param {Number} mobileMaxWidth Maximum width for handheld devices - - * @example - - * wbos.CssTools.MediaQueryFallBack.LoadCss(['screen.css', 'screen2.css'], 'mobile.css', 480) - - */ - - LoadCss: function(cssScreen, cssHandheld, mobileMaxWidth) { - - // Set config values - - if (typeof(cssScreen) != "undefined") { - - config.cssScreen = cssScreen; - - } - - if (typeof(cssHandheld) != "undefined") { - - config.cssHandheld = cssHandheld; - - } - - if (typeof(mobileMaxWidth) != "undefined") { - - config.mobileMaxWidth = mobileMaxWidth; - - } - - - - // Check if CSS is loaded - - var cssloadCheckNode = document.createElement('div'); - - cssloadCheckNode.className = config.testDivClass; - - document.getElementsByTagName("body")[0].appendChild(cssloadCheckNode); - - if (cssloadCheckNode.offsetWidth != 100 && noMediaQuery == false) { - - noMediaQuery = true; - - } - - cssloadCheckNode.parentNode.removeChild(cssloadCheckNode) - - - - if (noMediaQuery == true) { - - // Browser does not support Media Queries, so JavaScript will supply a fallback - - var cssHref = ""; - - - - // Determines what CSS file to load - - if (getWindowWidth() <= config.mobileMaxWidth) { - - cssHref = config.cssHandheld; - - newCssMediaType = "handheld"; - - } else { - - cssHref = config.cssScreen; - - newCssMediaType = "screen"; - - } - - - - // Add CSS link to of page - - if (cssHref != "" && currentCssMediaType != newCssMediaType) { - - var currentCssLinks = document.styleSheets - - for (var i = 0; i < currentCssLinks.length; i++) { - - for (var ii = 0; ii < currentCssLinks[i].media.length; ii++) { - - if (typeof(currentCssLinks[i].media) == "object") { - - if (currentCssLinks[i].media.item(ii) == "fallback") { - - currentCssLinks[i].ownerNode.parentNode.removeChild(currentCssLinks[i].ownerNode) - - i-- - - break; - - } - - } else { - - if (currentCssLinks[i].media.indexOf("fallback") >= 0) { - - currentCssLinks[i].owningElement.parentNode.removeChild(currentCssLinks[i].owningElement) - - i-- - - break; - - } - - } - - } - - } - - if (typeof(cssHref) == "object") { - - for (var i = 0; i < cssHref.length; i++) { - - addCssLink(cssHref[i]) - - } - - } else { - - addCssLink(cssHref) - - } - - - - currentCssMediaType = newCssMediaType; - - } - - - - - - // Check screen size again if user resizes window - - addEvent(window, wbos.CssTools.MediaQueryFallBack.LoadCssDelayed, 'onresize') - - } - - }, - - - - /** - - * Runs LoadCSS after a short delay - - * - - * @since 1.0 - 2010-08-21 - - * @version 1.0 - 2010-08-21 - - * @example - - * wbos.CssTools.MediaQueryFallBack.LoadCssDelayed() - - */ - - LoadCssDelayed: function() { - - clearTimeout(delay); - - delay = setTimeout( "wbos.CssTools.MediaQueryFallBack.LoadCss()", config.resizeDelay) - - } - - - - } - - /* End public */ - -})(); - - - - - - - - - - - - - -/** - - * @namespace Adds a function to an event of a single element. Use this if - - * you don't want to use jQuery - - * @class - - * @since 1.0 - 2010-02-23 - - * @version 1.0 - 2010-02-23 - - */ - -wbos.Events = ( function() { - - /* Start public */ - - return { - - /** - - * Adds a function to an event of a single element - - * - - * @since 1.0 - 2010-02-23 - - * @version 1.0 - 2010-02-23 - - * @param {Object} element The element on which the event is placed - - * @param {Function} newFunction The function that has to be linked to the event - - * @param {String} eventType Name of the event - - * @example - - * wbos.Events.AddEvent( document.getElementById('elementId'), functionName, "onclick" ) - - */ - - AddEvent: function( element, newFunction, eventType ) { - - var oldEvent = eval("element." + eventType); - - var eventContentType = eval("typeof element." + eventType) - - - - if ( eventContentType != 'function' ) { - - eval("element." + eventType + " = newFunction") - - } else { - - eval("element." + eventType + " = function(e) { oldEvent(e); newFunction(e); }") - - } - - } - - } - - /* End public */ - -})(); - - - - - - - - - - - - - -if (typeof(codeview) == "undefined") { - - /** - - * @namespace Code written for the Codeview template - - */ - - codeview = {} - -} - - - - - - - - - - - - - - - -/** - - * @namespace Enables filtering in class lists - - * @class - - * @since 1.0 - 2010-11-08 - - * @version 1.0 - 2010-11-08 - - */ - -codeview.classFilter = ( function() { - - function onkeyup_ClassFilter() { - - var listItems - - var search = document.getElementById('ClassFilter').value - - search = search.toLowerCase() - - var links = document.getElementById("ClassList").getElementsByTagName('a'); - for (i = 0; i < links.length; i++) { - var currentLink = links[i]; - var prefix = ((currentLink.href).split('?'))[0]; - var anchorIndex = currentLink.href.indexOf('#'); - if (search.length === 0) { - currentLink.href = prefix; - } - else if(anchorIndex !== -1) { - currentLink.href = prefix.slice(0, anchorIndex) + "?classFilter=" + search + "&show=" + document.getElementById("filterType").value + currentLink.href.slice(anchorIndex); - } - else { - currentLink.href = prefix + "?classFilter=" + search + "&show=" + document.getElementById("filterType").value; - } - } - - - if (document.getElementById('ClassList')) { - - listItems = document.getElementById('ClassList').getElementsByTagName('li') - - filterList(listItems, search) - - } - - if (document.getElementById('ClassList2')) { - - listItems = document.getElementById('ClassList2').getElementsByTagName('li') - - filterList(listItems, search) - - } - - if (document.getElementById('FileList')) { - - listItems = document.getElementById('FileList').getElementsByTagName('li') - - filterList(listItems, search) - - } - - } - - - - function filterList(listItems, search, relatedElements) { - - var itemContent = "" - - for (var i=0; i < listItems.length; i++) { - - itemContent = listItems[i].textContent||listItems[i].innerText - - if (itemContent != undefined) { - - itemContent = itemContent.toLowerCase() - - itemContent = itemContent.replace(/\s/g, "") - - if (itemContent.indexOf(search) >= 0 || itemContent == "") { - - listItems[i].style.display = "" - - } else { - - listItems[i].style.display = "none" - - } - - if (relatedElements != null) { - - filterRelatedList(listItems[i], search, relatedElements) - - } - - } - - } - - } - - - - function filterRelatedList(listItem, search, relatedElements) { - - var itemIndex = parseInt(listItem.className.replace('item', '')) - - if (itemIndex <= relatedElements.length) { - - if (relatedElements[itemIndex].className == "item"+ itemIndex) { - - relatedElements[itemIndex].style.display = listItem.style.display - - } - - } - - } - - - /* Start public */ - - return { - - Init: function() { - - wbos.Events.AddEvent( - - document.getElementById('ClassFilter'), - - onkeyup_ClassFilter, - - "onkeyup" - - ) - - } - - } - - /* End public */ - -})(); - -codeview.filter = function (searchTerm){ - var listItems - - if(!searchTerm){ - search = document.getElementById('ClassFilter').value - } - else { - search = searchTerm - } - search = search.toLowerCase() - - if (document.getElementById('ClassList')) { - listItems = document.getElementById('ClassList').getElementsByTagName('li') - filterList(listItems, search) - } - - if (document.getElementById('ClassList2')) { - listItems = document.getElementById('ClassList2').getElementsByTagName('li') - filterList(listItems, search) - } - - if (document.getElementById('FileList')) { - listItems = document.getElementById('FileList').getElementsByTagName('li') - filterList(listItems, search) - } - - function filterList(listItems, search, relatedElements) { - var itemContent = "" - for (var i=0; i < listItems.length; i++) { - - itemContent = listItems[i].textContent||listItems[i].innerText - - if (itemContent != undefined) { - itemContent = itemContent.toLowerCase() - itemContent = itemContent.replace(/\s/g, "") - - if (itemContent.indexOf(search) >= 0 || itemContent == "") { - listItems[i].style.display = "" - } else { - listItems[i].style.display = "none" - } - if (relatedElements != null) { - filterRelatedList(listItems[i], search, relatedElements) - } - } - } - } - - function filterRelatedList(listItem, search, relatedElements) { - var itemIndex = parseInt(listItem.className.replace('item', '')) - if (itemIndex <= relatedElements.length) { - if (relatedElements[itemIndex].className == "item"+ itemIndex) { - relatedElements[itemIndex].style.display = listItem.style.display - } - } - } -}; diff --git a/Tools/jsdoc3/templates/default/static/javascript/indexLinks.js b/Tools/jsdoc3/templates/default/static/javascript/indexLinks.js deleted file mode 100644 index 7b19be153e7..00000000000 --- a/Tools/jsdoc3/templates/default/static/javascript/indexLinks.js +++ /dev/null @@ -1,76 +0,0 @@ -(function() { - var allLink = document.getElementById("allLink"); - var jsLink = document.getElementById("jsIndexLink"); - var glslLink = document.getElementById("glslIndexLink"); - var filterType = document.getElementById("filterType"); - var filterForm = document.getElementById("ClassFilter"); - var all = "all"; - var js = "js"; - var glsl = "glsl"; - - var resetFilter = function() { - document.filterForm.classFilter.value = ''; - codeview.filter(''); - } - - var updateMenuLinks = function() { - var links = document.getElementById("ClassList").getElementsByTagName('a'); - var searchTerm = document.getElementById('ClassFilter').value; - var show = document.getElementById('filterType').value; - for (var i = 0; i < links.length; i++) { - var prefix = links[i].href.split('?')[0]; - links[i].href = prefix + '?classFilter=' + searchTerm + '&show=' + show; - } - } - - function showAll() { - document.getElementById("glslItems").style.display = "block"; - document.getElementById("classItems").style.display = "block"; - filterType.value = all; - } - - function showJs() { - document.getElementById("glslItems").style.display = "none"; - document.getElementById("classItems").style.display = "block"; - filterType.value = js; - } - - function showGlsl() { - document.getElementById("glslItems").style.display = "block"; - document.getElementById("classItems").style.display = "none"; - filterType.value = glsl; - } - - allLink.onclick = function() { - resetFilter(); - showAll(); - updateMenuLinks(); - } - - jsLink.onclick = function() { - resetFilter(); - showJs(); - updateMenuLinks(); - } - - glslLink.onclick = function() { - resetFilter(); - showGlsl(); - updateMenuLinks(); - } - - var menuLinks = document.getElementById("ClassList").getElementsByTagName('a'); - for (var i = 0; i < menuLinks.length; i++) { - menuLinks[i].onclick = function() { - updateMenuLinks(); - } - } - - if (filterType.value === js) { - showJs(); - } else if (filterType.value === glsl) { - showGlsl(); - } else { - showAll(); - } -})(); \ No newline at end of file diff --git a/Tools/jsdoc3/templates/default/tmpl/details.tmpl b/Tools/jsdoc3/templates/default/tmpl/details.tmpl deleted file mode 100644 index 54e8ade690d..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/details.tmpl +++ /dev/null @@ -1,98 +0,0 @@ - -
    - - -
    Properties:
    - -
    - - - - -
    Version:
    -
    - - - -
    Since:
    -
    - - - -
    Deprecated:
    • Yes
      - - - -
      Author:
      -
      -
        -
      • -
      -
      - - - - - - - - -
      License:
      -
      - - - -
      Default Value:
      -
      - - - -
      Tutorials:
      -
      -
        -
      • -
      -
      - - - -
      Demo:
      -
        -
      • -
      - - - -
      See:
      -
        -
      • -
      - - - -
      Source:
      -
        -
      • -
      - - - -
      To Do:
      -
      -
        -
      • -
      -
      - -
      diff --git a/Tools/jsdoc3/templates/default/tmpl/empty.tmpl b/Tools/jsdoc3/templates/default/tmpl/empty.tmpl deleted file mode 100644 index 9398619584f..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/empty.tmpl +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Tools/jsdoc3/templates/default/tmpl/exceptions.tmpl b/Tools/jsdoc3/templates/default/tmpl/exceptions.tmpl deleted file mode 100644 index a891992942d..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/exceptions.tmpl +++ /dev/null @@ -1,12 +0,0 @@ - -
      - - - | - - : -
      - diff --git a/Tools/jsdoc3/templates/default/tmpl/fires.tmpl b/Tools/jsdoc3/templates/default/tmpl/fires.tmpl deleted file mode 100644 index 24b07ce84ef..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/fires.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -
    • - -
    • \ No newline at end of file diff --git a/Tools/jsdoc3/templates/default/tmpl/index.tmpl b/Tools/jsdoc3/templates/default/tmpl/index.tmpl deleted file mode 100644 index ead315d39ef..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/index.tmpl +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - <?js= title ?> - - - - - - - - - - - - - - -
      -
      - - - -
      - Documentation generated by JSDoc 3 on -
      -
      -
      - -
      - - - - - \ No newline at end of file diff --git a/Tools/jsdoc3/templates/default/tmpl/layout.tmpl b/Tools/jsdoc3/templates/default/tmpl/layout.tmpl deleted file mode 100644 index f0e5e37e0ba..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/layout.tmpl +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - <?js= title ?> - Cesium Documentation - - - - - - - - - - - - - - -
      - - - - -
      - -

      - - -
      - Documentation generated by JSDoc 3 on -
      -
      -
      -
      - - - - - diff --git a/Tools/jsdoc3/templates/default/tmpl/members.tmpl b/Tools/jsdoc3/templates/default/tmpl/members.tmpl deleted file mode 100644 index 531f4bc5890..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/members.tmpl +++ /dev/null @@ -1,23 +0,0 @@ - -
      -

      - - -

      - -
      -
      - -
      - -
      - - - -
      Example 1? 's':'' ?>
      - - - - -
      -
      diff --git a/Tools/jsdoc3/templates/default/tmpl/method.tmpl b/Tools/jsdoc3/templates/default/tmpl/method.tmpl deleted file mode 100644 index bf424e10929..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/method.tmpl +++ /dev/null @@ -1,71 +0,0 @@ - -
      -

      - - -

      - -
      -
      - - -

      - -

      - - - -
      Performance:
      -

      - - - -
      This:
      -
      - - - -
      Parameters:
      - - - - -
      Fires:
      -
        - -
      - - - -
      Throws:
      - 1) { ?>
        -
      • -
      - - - - -
      Returns:
      - 1) { ?>
        -
      • -
      - - - - -
      Example 1? 's':'' ?>
      - - - - - -
      -
      diff --git a/Tools/jsdoc3/templates/default/tmpl/returns.tmpl b/Tools/jsdoc3/templates/default/tmpl/returns.tmpl deleted file mode 100644 index 439159d50dc..00000000000 --- a/Tools/jsdoc3/templates/default/tmpl/returns.tmpl +++ /dev/null @@ -1,11 +0,0 @@ - -
      - - - | - - -
      - \ No newline at end of file diff --git a/Tools/jsdoc3/templates/haruki/README.md b/Tools/jsdoc3/templates/haruki/README.md deleted file mode 100644 index ee6d36f1ded..00000000000 --- a/Tools/jsdoc3/templates/haruki/README.md +++ /dev/null @@ -1,39 +0,0 @@ -OVERVIEW -======== - -JSDoc 3 Haruki is an experimental template optimised for use with publishing processes that consume either JSON or XML. Whereas the default JSDoc template outputs an HTML representation of your API, Haruki will output a JSON, or optionally an XML, representation. - -Currently Haruki only supports a subset of the tags supported by the default template. Those are: - - * @name - * @desc - * @type - * @namespace - * @method (or @function) - * @member (or @var) - * @class - * @mixin - * @event - * @param - * @returns - * @throws - * @example - * @access (like @private or @public) - -This limited support set is intentional, as it is meant to be a usable set that could be shared with either JavaScript or PHP documentation -- another experimental tool, named "Vonnegut", can produce Haruki compatible JSON from PHPDoc tags. - -Note: `@link`s will appear in the output untransformed, there is no way to know at this stage what the file layout of your output will eventually be. It is assumed that whatever process emits the final output file/s will transform `@link` tags at that point. - -USAGE -===== - - ./jsdoc myscript.js -t templates/haruki -d console -q format=xml - -The results of this command will appear in `stdout` and can be piped into other tools for further processing. - -MORE -===== - -If you are interested in Haruki, you are encouraged to discuss your questions or ideas on the JSDoc-Users mailing list and fork/contribute to this project. - -For more information contact Michael Mathews at . \ No newline at end of file diff --git a/Tools/jsdoc3/templates/haruki/publish.js b/Tools/jsdoc3/templates/haruki/publish.js deleted file mode 100644 index 42d4ccc70e9..00000000000 --- a/Tools/jsdoc3/templates/haruki/publish.js +++ /dev/null @@ -1,213 +0,0 @@ -/** - @overview Builds a tree-like JSON string from the doclet data. - @version 0.0.1 - @example - ./jsdoc scratch/jsdoc_test.js -t templates/haruki -d console -q format=xml - */ - -(function() { - - /** - @global - @param {TAFFY} data - @param {object} opts - */ - publish = function(data, opts) { - - var root = {}, - docs; - - data.remove({undocumented: true}); - docs = data.get(); // <-- an array of Doclet objects - - graft(root, docs); - - if (opts.destination === 'console') { - if (opts.query && opts.query.format === 'xml') { - var xml = require('goessner/json2xml'); - console.log( '\n' + xml.convert(root) + '\n' ); - } - else { - console.log(root); - } - } - else { - console.log('The only -d destination option currently supported is "console"!'); - } - - } - - function graft(parentNode, childNodes, parentLongname, parentName) { - childNodes - .filter(function (element) { - return (element.memberof === parentLongname); - }) - .forEach(function (element, i) { - if (element.kind === 'namespace') { - if (! parentNode.namespaces) { - parentNode.namespaces = { }; - } - - var thisNamespace = parentNode.namespaces[element.name] = { - 'name': element.name, - 'description': element.description || '', - 'access': element.access || '', - 'virtual': !!element.virtual - }; - - graft(thisNamespace, childNodes, element.longname, element.name); - } - else if (element.kind === 'mixin') { - if (! parentNode.mixins) { - parentNode.mixins = { }; - } - - var thisMixin = parentNode.mixins[element.name] = { - 'name': element.name, - 'description': element.description || '', - 'access': element.access || '', - 'virtual': !!element.virtual - }; - - graft(thisMixin, childNodes, element.longname, element.name); - } - else if (element.kind === 'function') { - if (! parentNode.functions) { - parentNode.functions = { }; - } - - var thisFunction = parentNode.functions[element.name] = { - 'name': element.name, - 'access': element.access || '', - 'virtual': !!element.virtual, - 'description': element.description || '', - 'parameters': [ ], - 'examples': [] - }; - - if (element.returns) { - parentNode.functions[element.name].returns = { - 'type': element.returns[0].type? (element.returns[0].type.names.length === 1? element.returns[0].type.names[0] : element.returns[0].type.names) : '', - 'description': element.returns[0].description || '' - }; - } - - if (element.examples) { - for (var i = 0, len = element.examples.length; i < len; i++) { - parentNode.functions[element.name].examples.push(element.examples[i]); - } - } - - if (element.params) { - for (var i = 0, len = element.params.length; i < len; i++) { - thisFunction.parameters.push({ - 'name': element.params[i].name, - 'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '', - 'description': element.params[i].description || '', - 'default': element.params[i].defaultvalue || '', - 'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '', - 'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : '' - }); - } - } - } - else if (element.kind === 'member') { - if (! parentNode.properties) { - parentNode.properties = { }; - } - parentNode.properties[element.name] = { - 'name': element.name, - 'access': element.access || '', - 'virtual': !!element.virtual, - 'description': element.description || '', - 'type': element.type? (element.type.length === 1? element.type[0] : element.type) : '' - }; - } - - else if (element.kind === 'event') { - if (! parentNode.events) { - parentNode.events = { }; - } - - var thisEvent = parentNode.events[element.name] = { - 'name': element.name, - 'access': element.access || '', - 'virtual': !!element.virtual, - 'description': element.description || '', - 'parameters': [], - 'examples': [] - }; - - if (element.returns) { - parentNode.events[element.name].returns = { - 'type': element.returns.type? (element.returns.type.names.length === 1? element.returns.type.names[0] : element.returns.type.names) : '', - 'description': element.returns.description || '' - }; - } - - if (element.examples) { - for (var i = 0, len = element.examples.length; i < len; i++) { - thisEvent.examples.push(element.examples[i]); - } - } - - if (element.params) { - for (var i = 0, len = element.params.length; i < len; i++) { - thisEvent.parameters.push({ - 'name': element.params[i].name, - 'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '', - 'description': element.params[i].description || '', - 'default': element.params[i].defaultvalue || '', - 'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '', - 'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : '' - }); - } - } - } - else if (element.kind === 'class') { - if (! parentNode.classes) { - parentNode.classes = { }; - } - - var thisClass = parentNode.classes[element.name] = { - 'name': element.name, - 'description': element.classdesc || '', - 'extends': element.augments || [], - 'access': element.access || '', - 'virtual': !!element.virtual, - 'fires': element.fires || '', - 'constructor': { - 'name': element.name, - 'description': element.description || '', - 'parameters': [ - ], - 'examples': [] - } - }; - - if (element.examples) { - for (var i = 0, len = element.examples.length; i < len; i++) { - thisClass.constructor.examples.push(element.examples[i]); - } - } - - if (element.params) { - for (var i = 0, len = element.params.length; i < len; i++) { - thisClass.constructor.parameters.push({ - 'name': element.params[i].name, - 'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '', - 'description': element.params[i].description || '', - 'default': element.params[i].defaultvalue || '', - 'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '', - 'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : '' - }); - } - } - - graft(thisClass, childNodes, element.longname, element.name); - } - }); - } - -})(); - diff --git a/Tools/jsdoc3/test/README.md b/Tools/jsdoc3/test/README.md deleted file mode 100644 index 386cde611fd..00000000000 --- a/Tools/jsdoc3/test/README.md +++ /dev/null @@ -1,45 +0,0 @@ -Testing JSDoc 3 -=============== - -Running Tests -------------- - -Running tests is easy. Just change your working directory to the jsdoc folder -and run the following command on Windows: - - jsdoc -T - -... or on a Max OSX or *nix platform: - - ./jsdoc -T - -If you can't get the short-form commands to work, try invoking Java directly: - - java -cp lib/js.jar org.mozilla.javascript.tools.shell.Main -opt -1 \ - -modules node_modules -modules rhino_modules -modules . \ - jsdoc.js -T - -Writing Tests -------------- - -Adding tests is pretty easy, too. You can write tests for jsdoc itself (to -make sure tags and the parser, etc. are working properly), tests for plugins, and/or -tests for templates. - -JSDoc 3 uses Jasmine (https://github.com/pivotal/jasmine) as its testing framework. -Take a look at that project's wiki for documentation on writing tests in general. - -### Tests for JSDoc - -Take a look at the files in the ```test``` directory for many examples of -writing tests for JSDoc itself. the ```test\fixtures``` directory hold fixtures -for use in the tests and the ```test\specs``` directory holds the tests themselves. - -### Tests for plugins - -Tests for plugins are found in ```plugins\test``` directory. Plugins containing -tests that were installed with the Jakefile install task will be run automatically. - -### Tests for templates - -TODO \ No newline at end of file diff --git a/Tools/jsdoc3/test/async-callback.js b/Tools/jsdoc3/test/async-callback.js deleted file mode 100644 index 7863ea5ad63..00000000000 --- a/Tools/jsdoc3/test/async-callback.js +++ /dev/null @@ -1,56 +0,0 @@ -(function() { - var withoutAsync = {}; - - ["it", "beforeEach", "afterEach"].forEach(function(jasmineFunction) { - withoutAsync[jasmineFunction] = jasmine.Env.prototype[jasmineFunction]; - return jasmine.Env.prototype[jasmineFunction] = function() { - var args = Array.prototype.slice.call(arguments, 0); - var timeout = null; - if (isLastArgumentATimeout(args)) { - timeout = args.pop(); - } - if (isLastArgumentAnAsyncSpecFunction(args)) - { - var specFunction = args.pop(); - args.push(function() { - return asyncSpec(specFunction, this, timeout); - }); - } - return withoutAsync[jasmineFunction].apply(this, args); - }; - }); - - function isLastArgumentATimeout(args) - { - return args.length > 0 && (typeof args[args.length-1]) === "number"; - } - - function isLastArgumentAnAsyncSpecFunction(args) - { - return args.length > 0 && (typeof args[args.length-1]) === "function" && args[args.length-1].length > 0; - } - - function asyncSpec(specFunction, spec, timeout) { - if (timeout == null){timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL || 1000;} - var done = false; - spec.runs(function() { - try { - return specFunction(function(error) { - done = true; - if (error != null) { - return spec.fail(error); - } - }); - } catch (e) { - done = true; - throw e; - } - }); - return spec.waitsFor(function() { - if (done === true) { - return true; - } - }, "spec to complete", timeout); - }; - -}).call(this); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/abstracttag.js b/Tools/jsdoc3/test/fixtures/abstracttag.js deleted file mode 100644 index 07aeb9b7411..00000000000 --- a/Tools/jsdoc3/test/fixtures/abstracttag.js +++ /dev/null @@ -1,17 +0,0 @@ -/** @constructor */ -function Thingy() { - - /** @abstract */ - this.pez = 2; - -} - -// same as... - -/** @constructor */ -function OtherThingy() { - - /** @virtual */ - this.pez = 2; - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/accesstag.js b/Tools/jsdoc3/test/fixtures/accesstag.js deleted file mode 100644 index 497c20dd1b8..00000000000 --- a/Tools/jsdoc3/test/fixtures/accesstag.js +++ /dev/null @@ -1,29 +0,0 @@ -/** @constructor */ -function Thingy() { - - /** @access private */ - var foo = 0; - - /** @access protected */ - this._bar = 1; - - /** @access public */ - this.pez = 2; - -} - -// same as... - -/** @constructor */ -function OtherThingy() { - - /** @private */ - var foo = 0; - - /** @protected */ - this._bar = 1; - - /** @public */ - this.pez = 2; - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/alias.js b/Tools/jsdoc3/test/fixtures/alias.js deleted file mode 100644 index bbb7305cba1..00000000000 --- a/Tools/jsdoc3/test/fixtures/alias.js +++ /dev/null @@ -1,13 +0,0 @@ -var myObject = (function() { - - /** Give x another name. - @alias myObject - @namespace - */ - var x = { - /** document me */ - myProperty: 'foo' - } - - return x; -})(); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/alias2.js b/Tools/jsdoc3/test/fixtures/alias2.js deleted file mode 100644 index e1d8e5a5235..00000000000 --- a/Tools/jsdoc3/test/fixtures/alias2.js +++ /dev/null @@ -1,10 +0,0 @@ -(function() { - - /** @alias ns.Myclass# */ - var x = { - /** document me */ - myProperty: 'foo' - } - - return x; -})(); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/alias3.js b/Tools/jsdoc3/test/fixtures/alias3.js deleted file mode 100644 index 3cea9ababf0..00000000000 --- a/Tools/jsdoc3/test/fixtures/alias3.js +++ /dev/null @@ -1,12 +0,0 @@ -Klass('trackr.CookieManager', - - /** @class - @alias trackr.CookieManager - @param {object} kv - */ - function(kv) { - /** document me */ - this.value = kv; - } - -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/aliasglobal.js b/Tools/jsdoc3/test/fixtures/aliasglobal.js deleted file mode 100644 index 376a43a1c52..00000000000 --- a/Tools/jsdoc3/test/fixtures/aliasglobal.js +++ /dev/null @@ -1,7 +0,0 @@ -(function() { - - /** @alias .log */ - var log = function() { - } - -})(); diff --git a/Tools/jsdoc3/test/fixtures/aliasresolve.js b/Tools/jsdoc3/test/fixtures/aliasresolve.js deleted file mode 100644 index 8e9ec186890..00000000000 --- a/Tools/jsdoc3/test/fixtures/aliasresolve.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @namespace - */ -var A = {}; - -(function(ns) { - /** - * @namespace - * @alias A.F - */ - var f = {}; - - /** - * @return {String} - */ - f.method = function(){}; - - ns.F = f; -})(A); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/aliasresolve2.js b/Tools/jsdoc3/test/fixtures/aliasresolve2.js deleted file mode 100644 index 4ff8b2821ca..00000000000 --- a/Tools/jsdoc3/test/fixtures/aliasresolve2.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @namespace - */ -var A = {}; - -/** - * @namespace - * @alias A.F - */ -var f = {}; - -(function(ns) { - /** - * @return {String} - */ - f.method = function(){}; - - ns.F = f; -})(A); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/also.js b/Tools/jsdoc3/test/fixtures/also.js deleted file mode 100644 index 602bc041a69..00000000000 --- a/Tools/jsdoc3/test/fixtures/also.js +++ /dev/null @@ -1,20 +0,0 @@ -/** @class */ -function Asset() { - this._name = ''; -} - -/** - * - * Set the value of the name property. - * @param {string} newName - * - *//** - * - * Get the value of the name property. - * @returns {string} - * - */ -Asset.prototype.name = function(newName) { - if (newName) { this._name = newName; } - else { return this._name; } -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/augmentstag.js b/Tools/jsdoc3/test/fixtures/augmentstag.js deleted file mode 100644 index a30a1e22580..00000000000 --- a/Tools/jsdoc3/test/fixtures/augmentstag.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @constructor - */ -function Foo() { - /** First property */ - this.prop1 = true; -} - -/** - * Second property - * @type {String} - */ -Foo.prototype.prop2 = "parent prop2"; - -/** - * First parent method. - */ -Foo.prototype.method1 = function() {}; - -/** - * Second parent method. - */ -Foo.prototype.method2 = function() {}; - - -/** - * @constructor - * @extends Foo - */ -function Bar() { - /** Thrid prop **/ - this.prop3 = true; -} - -/** - * Second child method. - */ -Bar.prototype.method2 = function() {}; - -/** - * @constructor - * @extends {Bar} - */ -function Baz() { - /** Override prop1 */ - this.prop1 = "new"; -} - -/** - * Third grandchild method. - */ -Baz.prototype.method3 = function() {}; - diff --git a/Tools/jsdoc3/test/fixtures/authortag.js b/Tools/jsdoc3/test/fixtures/authortag.js deleted file mode 100644 index 155bb5703b6..00000000000 --- a/Tools/jsdoc3/test/fixtures/authortag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @constructor - @author Michael Mathews -*/ -function Thingy() { - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/borrowstag.js b/Tools/jsdoc3/test/fixtures/borrowstag.js deleted file mode 100644 index b6d065ddcda..00000000000 --- a/Tools/jsdoc3/test/fixtures/borrowstag.js +++ /dev/null @@ -1,14 +0,0 @@ -/** @namespace - @borrows trstr as trim -*/ -var util = { - "trim": trstr -}; - -/** - Remove whitespace from around a string. - @param {string} str - */ -function trstr(str) { -} - diff --git a/Tools/jsdoc3/test/fixtures/borrowstag2.js b/Tools/jsdoc3/test/fixtures/borrowstag2.js deleted file mode 100644 index 9e80dd0d594..00000000000 --- a/Tools/jsdoc3/test/fixtures/borrowstag2.js +++ /dev/null @@ -1,21 +0,0 @@ -/** @namespace - @borrows rtrim -*/ -var str = { - rtrim: util.rtrim -}; - -/** @namespace - @borrows rtrim -*/ -var util = { - rtrim: rtrim -}; - -/** - Remove whitespace from the right side of a string. - @param {string} str - */ -function rtrim(str) { -} - diff --git a/Tools/jsdoc3/test/fixtures/classtag.js b/Tools/jsdoc3/test/fixtures/classtag.js deleted file mode 100644 index ea4584b1180..00000000000 --- a/Tools/jsdoc3/test/fixtures/classtag.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - Describe the Ticker class here. - @class - */ -var Ticker = function() { - -}; - -/** - Describe the NewsSource class here. - @class NewsSource - */ \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/constructortag.js b/Tools/jsdoc3/test/fixtures/constructortag.js deleted file mode 100644 index 275ef3c62ea..00000000000 --- a/Tools/jsdoc3/test/fixtures/constructortag.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - Describe your constructor function here. - @class Describe your class here. - @constructor - @param {string} url - @throws MalformedURL - */ -function Feed(url) { -} - -/** - Document your method here. -*/ -Feed.prototype.refresh = function() { -} diff --git a/Tools/jsdoc3/test/fixtures/constructstag.js b/Tools/jsdoc3/test/fixtures/constructstag.js deleted file mode 100644 index a31a1cd02e2..00000000000 --- a/Tools/jsdoc3/test/fixtures/constructstag.js +++ /dev/null @@ -1,19 +0,0 @@ -Classify('TextBlock', { - - /** - Document your constructor function here. - @constructs TextBlock - @classdesc Describe your class here - @param {object} opts - @throws MissingNode - */ - construct: function(node, opts) { - }, - - /** - Document your method here. - @memberof TextBlock# - */ - align: function() { - } -}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/constructstag2.js b/Tools/jsdoc3/test/fixtures/constructstag2.js deleted file mode 100644 index 604d4bade4f..00000000000 --- a/Tools/jsdoc3/test/fixtures/constructstag2.js +++ /dev/null @@ -1,16 +0,0 @@ -Classify('Menu', - /** - @constructs Menu - @param items - */ - function (items) { - - }, - { - /** - @memberof Menu# - */ - show: function(){ - } - } -); diff --git a/Tools/jsdoc3/test/fixtures/constructstag3.js b/Tools/jsdoc3/test/fixtures/constructstag3.js deleted file mode 100644 index 3b4e410fd22..00000000000 --- a/Tools/jsdoc3/test/fixtures/constructstag3.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - A class that represents a person. - @class - */ -var Person = Class.create({ - - /** - @constructs Person - @param {string} name - */ - initialize: function(name) { - - /** The name of the person. */ - this.name = name; - }, - - /** - @memberof Person# - @param {string} message - */ - say: function(message) { - - /** The person's message. */ - this.message = message; - } -}); diff --git a/Tools/jsdoc3/test/fixtures/constructstag4.js b/Tools/jsdoc3/test/fixtures/constructstag4.js deleted file mode 100644 index f00cbf35ce9..00000000000 --- a/Tools/jsdoc3/test/fixtures/constructstag4.js +++ /dev/null @@ -1,24 +0,0 @@ -var Person = Class.create(/** @lends Person# */{ - - /** - Describe the constructor. - @classdesc A class that represents a person. - @constructs - @param {string} name - */ - initialize: function(name) { - - /** The name of the person. */ - this.name = name; - }, - - /** - @param {string} message - */ - say: function(message) { - - /** The person's message. */ - this.message = message; - } -}); - diff --git a/Tools/jsdoc3/test/fixtures/constructstag5.js b/Tools/jsdoc3/test/fixtures/constructstag5.js deleted file mode 100644 index 93063a5ada2..00000000000 --- a/Tools/jsdoc3/test/fixtures/constructstag5.js +++ /dev/null @@ -1,14 +0,0 @@ -Duck = (function() { - return /** @lends Duck# */ { - /** - Constructs a duck. - @constructs - @param tog - */ - constructor: function(tog) { - }, - /** Say hello. */ - quack: function() { - } - } -})(); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/copyrighttag.js b/Tools/jsdoc3/test/fixtures/copyrighttag.js deleted file mode 100644 index 68a09f34eed..00000000000 --- a/Tools/jsdoc3/test/fixtures/copyrighttag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @constructor - @copyright (c) 2011 Michael Mathews -*/ -function Thingy() { - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/defaulttag.js b/Tools/jsdoc3/test/fixtures/defaulttag.js deleted file mode 100644 index bd8461aa260..00000000000 --- a/Tools/jsdoc3/test/fixtures/defaulttag.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - @default - */ -var request = null; - -/** - @default - */ -var response = 'ok'; - -/** - @default - */ -var rcode = 200; - -/** - @default - */ -var rvalid = true; - -/** - @default - */ -var rerrored = false; - -/** - @default the parent window - */ -var win = getParentWindow(); - -/** - @default - */ -var header = getHeaders(request); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/deprecatedtag.js b/Tools/jsdoc3/test/fixtures/deprecatedtag.js deleted file mode 100644 index 6b6269cba9c..00000000000 --- a/Tools/jsdoc3/test/fixtures/deprecatedtag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @deprecated -*/ -function foo() { - -} - -/** @deprecated since version 2.0 -*/ -function bar() { - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/destructuring.js b/Tools/jsdoc3/test/fixtures/destructuring.js deleted file mode 100644 index 2b13f928e3c..00000000000 --- a/Tools/jsdoc3/test/fixtures/destructuring.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - A builder function for the Stick application; - @var {function} Application - */ -var {Application} = require("stick"); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/enumtag.js b/Tools/jsdoc3/test/fixtures/enumtag.js deleted file mode 100644 index 2374f09e754..00000000000 --- a/Tools/jsdoc3/test/fixtures/enumtag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Enum for tri-state values. - * @enum {number} - */ -var TriState = { - /** true */ - TRUE: 1, - FALSE: -1, - /** @type {boolean} */ - MAYBE: true -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/eventfirestag.js b/Tools/jsdoc3/test/fixtures/eventfirestag.js deleted file mode 100644 index 4fe3e746150..00000000000 --- a/Tools/jsdoc3/test/fixtures/eventfirestag.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @class - */ -var Hurl = function () { -}; - -/** - * Throw a snowball. - * - * @fires Hurl#snowball - * @fires Hurl#event:brick - */ -Hurl.prototype.snowball = function () { - /** - * @event Hurl#snowball - */ - this.emit('snowball', {}); -}; diff --git a/Tools/jsdoc3/test/fixtures/exceptiontag.js b/Tools/jsdoc3/test/fixtures/exceptiontag.js deleted file mode 100644 index 14d7d9a74bd..00000000000 --- a/Tools/jsdoc3/test/fixtures/exceptiontag.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - @throws {InvalidArgumentException} -*/ -function foo(x) { - -} - -/** - @exception Will throw an error if argument is null. -*/ -function bar(x) { - -} - -/** - @exception {DivideByZero} Argument x must be non-zero. -*/ -function pez(x) { - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/exports.js b/Tools/jsdoc3/test/fixtures/exports.js deleted file mode 100644 index 9c1324781c6..00000000000 --- a/Tools/jsdoc3/test/fixtures/exports.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * An example of a server-side JavaScript module. - * @module hello/world - * @example - * var g = require('hello/world').sayHello('Gracie'); - */ - -/** - * Generate a greeting. - * @param {string} [subject="world"] To whom we greet. - * @returns {string} - */ -exports.sayHello = function(subject) { - return 'Hello ' + (subject || 'World'); -}; diff --git a/Tools/jsdoc3/test/fixtures/exportstag.js b/Tools/jsdoc3/test/fixtures/exportstag.js deleted file mode 100644 index 26f787eac85..00000000000 --- a/Tools/jsdoc3/test/fixtures/exportstag.js +++ /dev/null @@ -1,20 +0,0 @@ -define(function () { - /** - A module representing a shirt. - @exports my/shirt - @version 1.0 - */ - var shirt = { - - /** A property of the module. */ - color: "black", - - /** @constructor */ - Turtleneck: function(size) { - /** A property of the class. */ - this.size = size; - } - }; - - return shirt; -}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/exportstag2.js b/Tools/jsdoc3/test/fixtures/exportstag2.js deleted file mode 100644 index 5e00268a364..00000000000 --- a/Tools/jsdoc3/test/fixtures/exportstag2.js +++ /dev/null @@ -1,18 +0,0 @@ -define( - ["my/buttons"], - function () { - /** - A module representing a coat. - @exports my/coat - @requires my/buttons - @version 1.0 - */ - var myModule = function(wool) { - /** document me */ - this.wool = wool; - } - - return myModule; - - } -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/exportstag3.js b/Tools/jsdoc3/test/fixtures/exportstag3.js deleted file mode 100644 index d48e94e2963..00000000000 --- a/Tools/jsdoc3/test/fixtures/exportstag3.js +++ /dev/null @@ -1,22 +0,0 @@ -define( - /** - Utility functions to ease working with DOM elements. - @exports html/utils - */ - function () { - - var exports = { - /** Get the value of a property on an element. */ - getStyleProperty: function(element, propertyName) { - // ... - } - }; - - /** Determine if an element is in the document head. */ - exports.isInHead = function(element) { - // ... - } - - return exports; - } -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/exportstag4.js b/Tools/jsdoc3/test/fixtures/exportstag4.js deleted file mode 100644 index 3097a5650d9..00000000000 --- a/Tools/jsdoc3/test/fixtures/exportstag4.js +++ /dev/null @@ -1,12 +0,0 @@ -define( - /** @exports some/module */ - function () { - /** @class */ - function myClass() {} - - /** Some method */ - myClass.prototype.myMethod = function () {}; - - return new myClass(); - } -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/externals.js b/Tools/jsdoc3/test/fixtures/externals.js deleted file mode 100644 index 6a8dd0306bb..00000000000 --- a/Tools/jsdoc3/test/fixtures/externals.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * The built in string object. - * @external String - * @see {@link https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String String} - */ - -/** - * Adds a new method to the built-in string. - * @function external:String#rot13 - * @example - * var greeting = new String('hello world'); - * console.log( greeting.rot13() ); // uryyb jbeyq - */ - -/** - * The jQuery plugin namespace. - * @external "jQuery.fn" - * @see {@link http://docs.jquery.com/Plugins/Authoring The jQuery Plugin Guide} - */ - -/** - * A jQuery plugin to make stars fly around your home page. - * @function external:"jQuery.fn".starfairy - */ diff --git a/Tools/jsdoc3/test/fixtures/file.js b/Tools/jsdoc3/test/fixtures/file.js deleted file mode 100644 index e6d62cdc2d9..00000000000 --- a/Tools/jsdoc3/test/fixtures/file.js +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @overview This is a file doclet. - * @copyright Michael Mathews 2011 - */ - -function ignoreMe() { -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/globaltag.js b/Tools/jsdoc3/test/fixtures/globaltag.js deleted file mode 100644 index 44f1d186ae8..00000000000 --- a/Tools/jsdoc3/test/fixtures/globaltag.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - @global - @constructor - */ -window.Bar = new Function('', a, b, c); - -(function() { - - /** @global */ - var foo; - - foo = 'hello foo'; - - this.foo = foo; - -}).apply(window); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/ignoretag.js b/Tools/jsdoc3/test/fixtures/ignoretag.js deleted file mode 100644 index 4e8c2121509..00000000000 --- a/Tools/jsdoc3/test/fixtures/ignoretag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @ignore -*/ -function foo(x) { - -} diff --git a/Tools/jsdoc3/test/fixtures/ignoretag2.js b/Tools/jsdoc3/test/fixtures/ignoretag2.js deleted file mode 100644 index 43db1b49fb4..00000000000 --- a/Tools/jsdoc3/test/fixtures/ignoretag2.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @ignore value that shouldn't be here -*/ -function foo(x) { - -} diff --git a/Tools/jsdoc3/test/fixtures/inlinecomment.js b/Tools/jsdoc3/test/fixtures/inlinecomment.js deleted file mode 100644 index 883d5f0b9b9..00000000000 --- a/Tools/jsdoc3/test/fixtures/inlinecomment.js +++ /dev/null @@ -1,2 +0,0 @@ -/** Inline Comment 1 */ this.test = function(){} -/** Inline Comment 2 */ this.test2 = function(){}; diff --git a/Tools/jsdoc3/test/fixtures/inner.js b/Tools/jsdoc3/test/fixtures/inner.js deleted file mode 100644 index 4c07b97ab86..00000000000 --- a/Tools/jsdoc3/test/fixtures/inner.js +++ /dev/null @@ -1,7 +0,0 @@ -function sendMessage(text) { - /** document me */ - var encoding = 'utf8'; - - /** document me */ - function encrypt(){} -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/innerscope.js b/Tools/jsdoc3/test/fixtures/innerscope.js deleted file mode 100644 index 5d2d5f5c440..00000000000 --- a/Tools/jsdoc3/test/fixtures/innerscope.js +++ /dev/null @@ -1,18 +0,0 @@ -/** @constructor */ -function Message(to) { - - var headers = {}, - response; - - /** document me */ - headers.to = to; - - (function() { - /** document me */ - response.code = '200'; - - /** document me */ - headers.from = ''; - })() -} - diff --git a/Tools/jsdoc3/test/fixtures/innerscope2.js b/Tools/jsdoc3/test/fixtures/innerscope2.js deleted file mode 100644 index 68f30cba682..00000000000 --- a/Tools/jsdoc3/test/fixtures/innerscope2.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @constructor */ -function Message(to) { - - var headers = {}; - - /** document me */ - headers.to = to; - - (function() { - var headers = { - /** document me */ - cache: {} - }; - - /** document me */ - headers.from = ''; - })() -} - diff --git a/Tools/jsdoc3/test/fixtures/jslangnames.js b/Tools/jsdoc3/test/fixtures/jslangnames.js deleted file mode 100644 index 65f8404a92a..00000000000 --- a/Tools/jsdoc3/test/fixtures/jslangnames.js +++ /dev/null @@ -1,24 +0,0 @@ - -/** @namespace */ -var constructor = { - /** document me */ - toString: function(){} -}; - -/** @namespace */ -var prototye = { - /** document me */ - valueOf: function(){} -} - -/** - This is Object - @namespace Object -*/ - -/** - This is Object.hasOwnProperty - @method Object.hasOwnProperty - */ - -// NOTE: you can't document a prototype of an object in JSDoc -- seriously, you just can't \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/lends.js b/Tools/jsdoc3/test/fixtures/lends.js deleted file mode 100644 index 6d86ae6df16..00000000000 --- a/Tools/jsdoc3/test/fixtures/lends.js +++ /dev/null @@ -1,16 +0,0 @@ -/** @class */ -var Person = makeClass( - /** @lends Person# */ - { - /** Set up initial values. */ - initialize: function(name) { - /** The name of the person. */ - this.name = name; - }, - - /** Speak a message. */ - say: function(message) { - return this.name + " says: " + message; - } - } -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/lends2.js b/Tools/jsdoc3/test/fixtures/lends2.js deleted file mode 100644 index 57c4fa38547..00000000000 --- a/Tools/jsdoc3/test/fixtures/lends2.js +++ /dev/null @@ -1,18 +0,0 @@ - -var Person = makeClass( - /** @lends Person# */ - { - /** Construct a Person. - @constructs Person - */ - initialize: function(name) { - /** The name of the person. */ - this.name = name; - }, - - /** Speak a message. */ - say: function(message) { - return this.name + " says: " + message; - } - } -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/lendsglobal.js b/Tools/jsdoc3/test/fixtures/lendsglobal.js deleted file mode 100644 index 13803be197f..00000000000 --- a/Tools/jsdoc3/test/fixtures/lendsglobal.js +++ /dev/null @@ -1,14 +0,0 @@ -declare({ - globals: /** @lends */ { - - /** document me */ - 'test': function() { }, - - /** @namespace */ - 'test1': { - - /** document me */ - 'test2': function() { } - } - } -}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/linktag.js b/Tools/jsdoc3/test/fixtures/linktag.js deleted file mode 100644 index 6f23ff1f7ac..00000000000 --- a/Tools/jsdoc3/test/fixtures/linktag.js +++ /dev/null @@ -1,15 +0,0 @@ -/** @namespace ns */ -var ns = {}; - -/** -* Similar to [the bar function]{@link bar}. -* @see {@link bar} -*/ -ns.foo = function () { -} - -/** -* @see {@link ns.foo} -*/ -function bar() { -} diff --git a/Tools/jsdoc3/test/fixtures/memberoftag.js b/Tools/jsdoc3/test/fixtures/memberoftag.js deleted file mode 100644 index 27993933bad..00000000000 --- a/Tools/jsdoc3/test/fixtures/memberoftag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @constructor - @memberof mathlib - */ -function Data() { - - /** @member */ - this.point = {}; -} - -/** @namespace */ -mathlib = {Data: Data}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/memberoftag2.js b/Tools/jsdoc3/test/fixtures/memberoftag2.js deleted file mode 100644 index b926dc6ae1f..00000000000 --- a/Tools/jsdoc3/test/fixtures/memberoftag2.js +++ /dev/null @@ -1,10 +0,0 @@ -create( - 'Observable', - { - /** @memberof Observable */ - cache: [], - - /** @memberof Observable.prototype */ - publish: function(msg) {} - } -); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/memberoftag3.js b/Tools/jsdoc3/test/fixtures/memberoftag3.js deleted file mode 100644 index a19f13573b7..00000000000 --- a/Tools/jsdoc3/test/fixtures/memberoftag3.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @module terrain - @example - var terrain = require('terrain'), - forest = new terrain.Forest(), - tree = new forest.Tree(); -*/ - -/** @class */ -exports.Forest = function(){} -var Forest = exports.Forest; - -/** - @class - @memberof module:terrain -*/ -Forest.prototype.Tree = function() { - /** A leaf */ - this.leaf = 1; -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/memberoftagforced.js b/Tools/jsdoc3/test/fixtures/memberoftagforced.js deleted file mode 100644 index c1b495de4b2..00000000000 --- a/Tools/jsdoc3/test/fixtures/memberoftagforced.js +++ /dev/null @@ -1,44 +0,0 @@ - - /** @constructor - */ - function Data() { - - /** - The current position. - @type {object} - @property {boolean} needsRevalidate Does this point need to be revalidated? - */ - this.point = { - /** - The x coordinate of the point. - @type {number} - @name point.x - @memberof! Data# - */ - x: 0, - - /** - The y coordinate of the point. - @type {number} - @name point.y - @memberof! Data# - @see {@link Data#point.x} - */ - y: 0, - - needsRevalidate: false - }; - } - -var map = { - /** - @type {Array} - @name map.routes - @memberof! - @property {Data#point} point - */ - routes: [] -} - -/** The current cursor. */ -var cursor = {}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/moduleinner.js b/Tools/jsdoc3/test/fixtures/moduleinner.js deleted file mode 100644 index 7f2d0a3f573..00000000000 --- a/Tools/jsdoc3/test/fixtures/moduleinner.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @module my/module -*/ -(function() { - -/** document fooIn */ -fooIn = function() { -}; - -/** @namespace */ -bar = { - /** document bar.Zop */ - zop: function() { - } -} - -/** @constructor */ -exports.Frotz = function() { - /** document exports.Frotz#quaz */ - this.quaz = 1; -} - -}) (); - -/** document fooOut -*/ -fooOut = function() { -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/moduleisconstructor.js b/Tools/jsdoc3/test/fixtures/moduleisconstructor.js deleted file mode 100644 index 1990d7f735c..00000000000 --- a/Tools/jsdoc3/test/fixtures/moduleisconstructor.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - Describe the module here. - @module mymodule/config -*/ - -/** - Create a new configuration - @param {string} id - @constructor - @alias module:mymodule/config -*/ -function Config(id) { - /** Document me. */ - this.id = id; -} - -module.exports = Config; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/modules/data/mod-1.js b/Tools/jsdoc3/test/fixtures/modules/data/mod-1.js deleted file mode 100644 index a5de108fe90..00000000000 --- a/Tools/jsdoc3/test/fixtures/modules/data/mod-1.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @module */ -define({ - property: "foo", - method: function() {} -}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/modules/data/mod-2.js b/Tools/jsdoc3/test/fixtures/modules/data/mod-2.js deleted file mode 100644 index 1027fd9d3be..00000000000 --- a/Tools/jsdoc3/test/fixtures/modules/data/mod-2.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @module my/module/name */ -define({ - property: "foo", - method: function() {} -}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/modules/data/mod-3.js b/Tools/jsdoc3/test/fixtures/modules/data/mod-3.js deleted file mode 100644 index 91a3251a0d8..00000000000 --- a/Tools/jsdoc3/test/fixtures/modules/data/mod-3.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - My test module. - @module my/module - */ -define(function() { - - /** - @undocumented - @alias module:my/module - */ - var mod = { - - /** Document a property. */ - myProperty: "foo", - - /** Document a method. */ - myMethod: function() {} - }; - - return mod; -}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/moduletag.js b/Tools/jsdoc3/test/fixtures/moduletag.js deleted file mode 100644 index fb4c4665c5c..00000000000 --- a/Tools/jsdoc3/test/fixtures/moduletag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @module bookshelf - */ - -/** - * @class - */ -this.Book = function(title) { - /** document me */ - this.title = title; -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/moduletag2.js b/Tools/jsdoc3/test/fixtures/moduletag2.js deleted file mode 100644 index 0dd0bc3ec14..00000000000 --- a/Tools/jsdoc3/test/fixtures/moduletag2.js +++ /dev/null @@ -1,9 +0,0 @@ -/** @module color/mixer */ - -module.exports = { - /** Blend two colors together. */ - blend: function(color1, color2) { } -} - -/** Darken a color by the given shade. */ -exports.darken = function(color, shade) { } \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/moduletag3.js b/Tools/jsdoc3/test/fixtures/moduletag3.js deleted file mode 100644 index d3b635b0265..00000000000 --- a/Tools/jsdoc3/test/fixtures/moduletag3.js +++ /dev/null @@ -1,20 +0,0 @@ -/** -@module foo/Photo/manager -@desc Manage a collection of photos. -*/ - -/** -Construct a new Photo manager -@constructor module:foo/Photo/manager -@param {String} collectionId The identifier of the managed collection. -*/ -module.exports = function(collectionId) { - - /** - @function module:foo/Photo/manager#getPhoto - @param {String} photoName - */ - this.getPhoto = function() {} - -} - diff --git a/Tools/jsdoc3/test/fixtures/namedFuncStatement.js b/Tools/jsdoc3/test/fixtures/namedFuncStatement.js deleted file mode 100644 index 924a659fb74..00000000000 --- a/Tools/jsdoc3/test/fixtures/namedFuncStatement.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @class */ -var Foo = function Bar(a) { - /** document me */ - var var1 = 1; - /** document me */ - this.member1 = 2; -}; diff --git a/Tools/jsdoc3/test/fixtures/namedFuncStatement2.js b/Tools/jsdoc3/test/fixtures/namedFuncStatement2.js deleted file mode 100644 index 0223092ab48..00000000000 --- a/Tools/jsdoc3/test/fixtures/namedFuncStatement2.js +++ /dev/null @@ -1,7 +0,0 @@ -/** @class */ -Foo = function Bar(a) { - /** document me */ - var var1 = 1; - /** document me */ - this.member1 = 2; -}; diff --git a/Tools/jsdoc3/test/fixtures/namedFuncStatement3.js b/Tools/jsdoc3/test/fixtures/namedFuncStatement3.js deleted file mode 100644 index 8f1858161c1..00000000000 --- a/Tools/jsdoc3/test/fixtures/namedFuncStatement3.js +++ /dev/null @@ -1,9 +0,0 @@ -ns = { - /** @class */ - Foo: function Bar(a) { - /** document me */ - var var1 = 1; - /** document me */ - this.member1 = 2; - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/objectlit.js b/Tools/jsdoc3/test/fixtures/objectlit.js deleted file mode 100644 index f976cfb4460..00000000000 --- a/Tools/jsdoc3/test/fixtures/objectlit.js +++ /dev/null @@ -1,8 +0,0 @@ -/** document me */ -var tools = { - /** document me */ - serialiser: { - /** document me */ - value: '' - } -}; diff --git a/Tools/jsdoc3/test/fixtures/objectlit2.js b/Tools/jsdoc3/test/fixtures/objectlit2.js deleted file mode 100644 index 072d4eda5ac..00000000000 --- a/Tools/jsdoc3/test/fixtures/objectlit2.js +++ /dev/null @@ -1,8 +0,0 @@ -/** document me */ -var position = { - axis: { - /** document me */ - x: 0, - y: 0 - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/objectpropertykeys.js b/Tools/jsdoc3/test/fixtures/objectpropertykeys.js deleted file mode 100644 index abc611f2d4b..00000000000 --- a/Tools/jsdoc3/test/fixtures/objectpropertykeys.js +++ /dev/null @@ -1,22 +0,0 @@ -Call( -{ - methodA: function() - { - this.id = this.createUUID(); - }, - - valueOf: function() - { - return this.id; - }, - - toString: function() - { - return this.id; - } -}); - -//Simple inheritance model with correct constructor -function Test() {} -function Test2() { Test.call(this); } -Test2.prototype = Object.create(Test.prototype, {constructor: {value: Test2}}); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/paramtag.js b/Tools/jsdoc3/test/fixtures/paramtag.js deleted file mode 100644 index db431bfccc5..00000000000 --- a/Tools/jsdoc3/test/fixtures/paramtag.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @param { String | Array} targetName The name (or names) of what to find. -*/ -function find(targetName) { -} - -/** -* @param {function} callback -*/ -function bind(callback) { -} - -/** -* @param {function} -*/ -function unbind(callback) { -} - -/** -* @param id The id of the element. -*/ -function getElement(id) { -} - -/** -* @param ... Two or more elements. -*/ -function combine() { -} - -/** -* @param delimiter - What to split on. -*/ -function split(delimiter) { -} - -/** -* @param - If true make the commit atomic. -*/ -function commit(atomic) { -} diff --git a/Tools/jsdoc3/test/fixtures/plugins.js b/Tools/jsdoc3/test/fixtures/plugins.js deleted file mode 100644 index d71e6e9dea1..00000000000 --- a/Tools/jsdoc3/test/fixtures/plugins.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @name virtual - */ - -var foo = "bar"; - -/** - * @foo bar - */ -var test = "tada"; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/privatetag.js b/Tools/jsdoc3/test/fixtures/privatetag.js deleted file mode 100644 index 71e0d971076..00000000000 --- a/Tools/jsdoc3/test/fixtures/privatetag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** -* @constructor -* @private -*/ -function Foo() { - - /** document me */ - this.bar = 1; -} - - diff --git a/Tools/jsdoc3/test/fixtures/projecttag.js b/Tools/jsdoc3/test/fixtures/projecttag.js deleted file mode 100644 index b00c8e2c686..00000000000 --- a/Tools/jsdoc3/test/fixtures/projecttag.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - An automated documentation generator for JavaScript. - @project JSDoc - @version 3.0.0 - @copyright 2011 (c) Michael Mathews - @license Apache Version 2 - */ -function blah(url) { -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/propertytag.js b/Tools/jsdoc3/test/fixtures/propertytag.js deleted file mode 100644 index 7b9a1cb8bcc..00000000000 --- a/Tools/jsdoc3/test/fixtures/propertytag.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @namespace - * @property {Object} defaults The default values. - * @property {Number} defaults.a The a property of the defaults. - * @property {String} defaults.b The b property of the defaults. - */ -myobject = { - defaults: { - a: 1, - b: "Hit the light", - /** - * The c property of the defaults. - * @member - * @type {Boolean} - * @property {String} prop The property of c. - */ - c: true - } -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/quotename.js b/Tools/jsdoc3/test/fixtures/quotename.js deleted file mode 100644 index aa7577c1bd5..00000000000 --- a/Tools/jsdoc3/test/fixtures/quotename.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @namespace */ -var chat = {}; - -/** - @namespace - */ -chat["#channel"] = {}; - - -/** - @member - @type {boolean} - @defaultvalue - */ -chat["#channel"].open = true; - -/** - @event chat."#channel"."op:announce-motd" - */ \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/quotename2.js b/Tools/jsdoc3/test/fixtures/quotename2.js deleted file mode 100644 index b05c8136752..00000000000 --- a/Tools/jsdoc3/test/fixtures/quotename2.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @namespace */ -var contacts = { - - /** @namespace */ - 'say-"hello"@example.com': { - - /** document me */ - "username": 'Sue Smart' - } -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/readonlytag.js b/Tools/jsdoc3/test/fixtures/readonlytag.js deleted file mode 100644 index 30e826ce2bd..00000000000 --- a/Tools/jsdoc3/test/fixtures/readonlytag.js +++ /dev/null @@ -1,10 +0,0 @@ -/** -* @constructor -*/ -function Collection() { - - /** @readonly */ - this.length = 0; -} - - diff --git a/Tools/jsdoc3/test/fixtures/requirestag.js b/Tools/jsdoc3/test/fixtures/requirestag.js deleted file mode 100644 index 3fe27229381..00000000000 --- a/Tools/jsdoc3/test/fixtures/requirestag.js +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @requires module:foo/helper -*/ -function foo() { -} - -/** -* @requires foo -* @requires Pez#blat this text is ignored -*/ -function bar() { -} diff --git a/Tools/jsdoc3/test/fixtures/returnstag.js b/Tools/jsdoc3/test/fixtures/returnstag.js deleted file mode 100644 index d3cf4de4e2d..00000000000 --- a/Tools/jsdoc3/test/fixtures/returnstag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** -* @returns { String | Array} The names of the found item(s). -*/ -function find(targetName) { -} - -/** -* @return The binding id. -*/ -function bind(callback) { -} diff --git a/Tools/jsdoc3/test/fixtures/seetag.js b/Tools/jsdoc3/test/fixtures/seetag.js deleted file mode 100644 index b439c261832..00000000000 --- a/Tools/jsdoc3/test/fixtures/seetag.js +++ /dev/null @@ -1,11 +0,0 @@ -/** -* @see {@link bar} -*/ -function foo() { -} - -/** -* @see http://example.com/someref -*/ -function bar() { -} diff --git a/Tools/jsdoc3/test/fixtures/sincetag.js b/Tools/jsdoc3/test/fixtures/sincetag.js deleted file mode 100644 index 527b2a398be..00000000000 --- a/Tools/jsdoc3/test/fixtures/sincetag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @since 1.2.3 -*/ -function foo(x) { - -} diff --git a/Tools/jsdoc3/test/fixtures/src/_dir2/four.js b/Tools/jsdoc3/test/fixtures/src/_dir2/four.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/test/fixtures/src/_ignored.js b/Tools/jsdoc3/test/fixtures/src/_ignored.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/test/fixtures/src/dir1/three.js b/Tools/jsdoc3/test/fixtures/src/dir1/three.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/test/fixtures/src/ignored.txt b/Tools/jsdoc3/test/fixtures/src/ignored.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/test/fixtures/src/one.js b/Tools/jsdoc3/test/fixtures/src/one.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/test/fixtures/src/two.js b/Tools/jsdoc3/test/fixtures/src/two.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Tools/jsdoc3/test/fixtures/starbangstar.js b/Tools/jsdoc3/test/fixtures/starbangstar.js deleted file mode 100644 index 262da969a2c..00000000000 --- a/Tools/jsdoc3/test/fixtures/starbangstar.js +++ /dev/null @@ -1,12 +0,0 @@ -/*!* -* Script that does something awesome -* -* @copyright (c) 2011 Rotorz Limited. All rights reserved. -* @author Lea Hayes -* @module myscript/core -*/ - -/*!********************************* - * This should be ignored by JSDoc - * @var x - */ \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/testPlugin1.js b/Tools/jsdoc3/test/fixtures/testPlugin1.js deleted file mode 100644 index 9436152cddf..00000000000 --- a/Tools/jsdoc3/test/fixtures/testPlugin1.js +++ /dev/null @@ -1,23 +0,0 @@ -exports.handlers = { - fileBegin: jasmine.createSpy('fileBegin'), - beforeParse: jasmine.createSpy('beforeParse'), - jsdocCommentFound: jasmine.createSpy('jsdocCommentFound'), - symbolFound: jasmine.createSpy('symbolFound'), - newDoclet: jasmine.createSpy('newDoclet'), - fileComplete: jasmine.createSpy('fileComplete') -}; - -exports.defineTags = function(dictionary) { - dictionary.defineTag("foo", { - canHaveName: true, - onTagged: function(doclet, tag) { - doclet.foo = true; - } - }); -}; - -exports.nodeVisitor = { - visitNode: jasmine.createSpy("plugin 1 visitNode").andCallFake(function(node, e, parser, currentSourceName) { - e.stopPropagation = true; - }) -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/testPlugin2.js b/Tools/jsdoc3/test/fixtures/testPlugin2.js deleted file mode 100644 index 475999f7e63..00000000000 --- a/Tools/jsdoc3/test/fixtures/testPlugin2.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.handlers = { - fileBegin: jasmine.createSpy('fileBegin'), - beforeParse: jasmine.createSpy('beforeParse'), - jsdocCommentFound: jasmine.createSpy('jsdocCommentFound'), - symbolFound: jasmine.createSpy('symbolFound'), - newDoclet: jasmine.createSpy('newDoclet'), - fileComplete: jasmine.createSpy('fileComplete') -}; - -exports.nodeVisitor = { - visitNode: jasmine.createSpy("plugin 2 visitNode") -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/this-and-objectlit.js b/Tools/jsdoc3/test/fixtures/this-and-objectlit.js deleted file mode 100644 index 37b3c94afac..00000000000 --- a/Tools/jsdoc3/test/fixtures/this-and-objectlit.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @constructor */ -function Page(title) { - this.parts = { - title: title, - body: { - /** document me */ - heading: '', - main: '' - } - }; -} - diff --git a/Tools/jsdoc3/test/fixtures/this.js b/Tools/jsdoc3/test/fixtures/this.js deleted file mode 100644 index 7c167606dad..00000000000 --- a/Tools/jsdoc3/test/fixtures/this.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - @constructor - */ -function Singer() { - - this.tralala = function() { // method of constructor Singer - /** document me */ - this.isSinging = true; // setting a member of constructor Singer - }; -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/this2.js b/Tools/jsdoc3/test/fixtures/this2.js deleted file mode 100644 index 88fd9fa61d7..00000000000 --- a/Tools/jsdoc3/test/fixtures/this2.js +++ /dev/null @@ -1,15 +0,0 @@ -/** @constructor */ -function TemplateBuilder(templateType) { - //** document me */ - //this.templateType = templateType; - - /** @constructor */ - this.Template = function() { // nested constructor of constructor TemplateFactory - /** document me */ - this.render = function(data) { - /** document me */ - this.rendered = true; - } - }; - -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/this3.js b/Tools/jsdoc3/test/fixtures/this3.js deleted file mode 100644 index 7e4e0a77e96..00000000000 --- a/Tools/jsdoc3/test/fixtures/this3.js +++ /dev/null @@ -1,5 +0,0 @@ -function setPosition(newP) { - /** document me */ - this.position = newP; // sets global property -} - diff --git a/Tools/jsdoc3/test/fixtures/thistag.js b/Tools/jsdoc3/test/fixtures/thistag.js deleted file mode 100644 index 1ea79253fe8..00000000000 --- a/Tools/jsdoc3/test/fixtures/thistag.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @constructor */ -function Foo(name) { - setName.apply(this, name); -} - -/** @this Foo */ -function setName(name) { - /** document me */ - this.name = name; -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/typedeftag.js b/Tools/jsdoc3/test/fixtures/typedeftag.js deleted file mode 100644 index 9d82cfdca16..00000000000 --- a/Tools/jsdoc3/test/fixtures/typedeftag.js +++ /dev/null @@ -1,5 +0,0 @@ -/** @typedef {(string|number)} calc.NumberLike */ - -/** @param {calc.NumberLike} x A number or a string. */ -calc.readNumber = function(x) { -} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/typekind.js b/Tools/jsdoc3/test/fixtures/typekind.js deleted file mode 100644 index 687eb7d7241..00000000000 --- a/Tools/jsdoc3/test/fixtures/typekind.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - @module {ConnectServer} blog/server -*/ - -module.exports = require('connect').createServer( - Connect.logger(), - Connect.conditionalGet(), - Connect.favicon(), - Connect.cache(), - Connect.gzip(), - require('wheat')(__dirname) -); - -/** - @member {number} module:blog/server.port - @default 8080 -*/ \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/typetag.js b/Tools/jsdoc3/test/fixtures/typetag.js deleted file mode 100644 index acaa7cac889..00000000000 --- a/Tools/jsdoc3/test/fixtures/typetag.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - @type {string|Array} -*/ -var foo; - - -/** - @type integer -*/ -var bar = +(new Date()).getTime(); \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/utf8.js b/Tools/jsdoc3/test/fixtures/utf8.js deleted file mode 100644 index ec6eea741f9..00000000000 --- a/Tools/jsdoc3/test/fixtures/utf8.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * @constructor - * @desc Τεκμηρίωση είναι η επικοινωνία! - */ -Test = function() { -}; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/var.js b/Tools/jsdoc3/test/fixtures/var.js deleted file mode 100644 index 0daea9f5368..00000000000 --- a/Tools/jsdoc3/test/fixtures/var.js +++ /dev/null @@ -1,10 +0,0 @@ -/** document me */ -const GREEN = 1, - RED = 0; - -/** document me */ -var validate = function(){}; - -var i, - /** document me */ - results; \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/variations.js b/Tools/jsdoc3/test/fixtures/variations.js deleted file mode 100644 index e292cae77da..00000000000 --- a/Tools/jsdoc3/test/fixtures/variations.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @namespace anim - */ - -/** - * @method anim.fadein(1) - * @desc Show the nodelist elements by fading them to opaque. - * @since 1.0 - * - * @param {number} [duration=400] How long the animation will run. - * @param {function} [callback] Called once the animation is complete. - * - * @returns {this} - */ - -/** - * @method anim.fadein(2) - * @desc Show the nodelist elements by fading them to opaque. - * @since 1.4.3 - * - * @param {number} [duration=400] How long the animation will run. - * @param {string} [easing=swing] The easing function for the transition. - * @param {function} [callback] Called once the animation is complete. - * - * @returns {this} - */ \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/variations2.js b/Tools/jsdoc3/test/fixtures/variations2.js deleted file mode 100644 index 2105c463fbb..00000000000 --- a/Tools/jsdoc3/test/fixtures/variations2.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* Describe the namespace. -* @namespace dollar(1) -*/ - -/** -* Describe the constructor. -* @constructor dollar(2) -* @param {object} [options] -*/ - -/** -* Describe the global function. -* @function dollar(3) -* @param {string} selector - The selector string. -*/ -dollar = function(a, b) { -}; - -/** -* Describe the instance method. -* @instance -* @function empty -* @memberof dollar(2) -*/ -dollar.prototype.empty = function() { -} - -/** -* Describe the static method. -* @function klass -* @memberof dollar(1) -* @param {string} name -*/ -dollar.klass = function(name) { -}; diff --git a/Tools/jsdoc3/test/fixtures/variations3.js b/Tools/jsdoc3/test/fixtures/variations3.js deleted file mode 100644 index 0b3fdfc432e..00000000000 --- a/Tools/jsdoc3/test/fixtures/variations3.js +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @constructor -*/ -someObject = function() {} - -/** -* @constructor -* @variation 2 -*/ -someObject = function() {} - -/** -* @memberof someObject(2) -*/ -someMethod = function() {} \ No newline at end of file diff --git a/Tools/jsdoc3/test/fixtures/versiontag.js b/Tools/jsdoc3/test/fixtures/versiontag.js deleted file mode 100644 index a482075ad23..00000000000 --- a/Tools/jsdoc3/test/fixtures/versiontag.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - @version 1.2.3 -*/ -function foo(x) { - -} diff --git a/Tools/jsdoc3/test/fixtures/virtual.js b/Tools/jsdoc3/test/fixtures/virtual.js deleted file mode 100644 index 4eb25c1d207..00000000000 --- a/Tools/jsdoc3/test/fixtures/virtual.js +++ /dev/null @@ -1,3 +0,0 @@ -/** @name dimensions */ - -var width = 12 \ No newline at end of file diff --git a/Tools/jsdoc3/test/jasmine-jsdoc.js b/Tools/jsdoc3/test/jasmine-jsdoc.js deleted file mode 100644 index 51213ca9c21..00000000000 --- a/Tools/jsdoc3/test/jasmine-jsdoc.js +++ /dev/null @@ -1,128 +0,0 @@ -/*First load envjs to give us a browser environment for jasmine. - *Jasmine wants things like set/clearInterval,set/clearTimeout. - *Then load jasmine itself - */ -load('test/lib/env.rhino.js'); -load('test/lib/jasmine.js'); -load('test/async-callback.js'); -var jasmineNode = require('./reporter').jasmineNode, - util = require('common/util'); - -jasmine.loadHelpersInFolder = function(folder, matcher) { - var helpers = [], helperCollection = require('./spec-collection'); - - helperCollection.load(folder, matcher, true); - helpers = helperCollection.getSpecs(); - for ( var i = 0, len = helpers.length; i < len; ++i) { - var file = helpers[i].path(); - var helper = require(file.replace(/\.*$/, "")); - - for (var key in helper) { - this[key] = helper[key]; - } - } -}; - -function removeJasmineFrames(text) { - var lines = []; - text.split(/\n/).forEach(function(line) { - if (line.indexOf(filename) == -1) { - lines.push(line); - } - }); - return lines.join('\n'); -} - -var reporter = null; -jasmine.initialize = function(done, verbose) { - var jasmineEnv = jasmine.getEnv(); - - if (reporter !== null) { - //If we've run before, we need to reset the runner - jasmineEnv.currentRunner_ = new jasmine.Runner(jasmineEnv); - //And clear the reporter - jasmineEnv.reporter.subReporters_.splice(jasmineEnv.reporter.subReporters_.indexOf(reporter)); - } - reporter = new (verbose ? jasmineNode.TerminalVerboseReporter : jasmineNode.TerminalReporter)({ - print : util.print, - color : true, - onComplete : done, - stackFilter : removeJasmineFrames - }); - jasmineEnv.addReporter(reporter); - - //updateInterval is set to 0 because there were not-fully-understood - //issues with asynchronous behavior in jasmine otherwise. - jasmineEnv.updateInterval = 0; - - return jasmineEnv; -}; - -/** - * Execute the specs in the specified folder. Helpers in each folder will be - * added to the environment. Helpers in parent directories will be available to child - * directories. - * @param {string} folder the folder in which the specs are to be found - * @param {function?} done callback function to execute when finished - * @param {boolean} verbose whether or not output verbose results - * @param {RegExp} matcher a regular expression to filter specs by. Only matching specs will run - */ -jasmine.executeSpecsInFolder = function(folder, done, verbose, matcher) { - var fileMatcher = matcher || new RegExp(".(js)$", "i"), - specs = require('./spec-collection'), - jasmineEnv = jasmine.initialize(done, verbose); - - //Load the specs - specs.load(folder, fileMatcher, true); - - //Add the specs to the context - var specsList = specs.getSpecs(); - for ( var i = 0, len = specsList.length; i < len; ++i) { - var filename = specsList[i]; - require(filename.path().replace(/\.\w+$/, "")); - } - - //Run Jasmine - jasmineEnv.execute(); -}; - -function now() { - return new Date().getTime(); -} - -jasmine.asyncSpecWait = function() { - var wait = this.asyncSpecWait; - wait.start = now(); - wait.done = false; - (function innerWait() { - waits(10); - runs(function() { - if (wait.start + wait.timeout < now()) { - expect('timeout waiting for spec').toBeNull(); - } else if (wait.done) { - wait.done = false; - } else { - innerWait(); - } - }); - })(); -}; -jasmine.asyncSpecWait.timeout = 4 * 1000; -jasmine.asyncSpecDone = function() { - jasmine.asyncSpecWait.done = true; -}; - -for ( var key in jasmine) { - exports[key] = jasmine[key]; -} - -exports.spyOn = spyOn; -exports.it = it; -exports.xit = xit; -exports.expect = expect; -exports.runs = runs; -exports.waitsFor = waitsFor; -exports.beforeEach = beforeEach; -exports.afterEach = afterEach; -exports.describe = describe; -exports.xdescribe = xdescribe; \ No newline at end of file diff --git a/Tools/jsdoc3/test/lib/env.rhino.js b/Tools/jsdoc3/test/lib/env.rhino.js deleted file mode 100644 index 90e69bc9773..00000000000 --- a/Tools/jsdoc3/test/lib/env.rhino.js +++ /dev/null @@ -1,14006 +0,0 @@ -/* - * Envjs core-env.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -var Envjs = function(){ - var i, - name, - override = function(){ - for(i=0;i and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - - -/** - * @author john resig - */ -// Helper method for extending one object with another. -function __extend__(a,b) { - for ( var i in b ) { - var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i); - if ( g || s ) { - if ( g ) { a.__defineGetter__(i, g); } - if ( s ) { a.__defineSetter__(i, s); } - } else { - a[i] = b[i]; - } - } return a; -} - -/** - * @author ariel flesler - * http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html - * @param {Object} str - */ -function __trim__( str ){ - return (str || "").replace( /^\s+|\s+$/g, "" ); -} - - -/** - * Writes message to system out - * @param {String} message - */ -Envjs.log = function(message){}; - -/** - * Constants providing enumerated levels for logging in modules - */ -Envjs.DEBUG = 1; -Envjs.INFO = 2; -Envjs.WARN = 3; -Envjs.ERROR = 3; -Envjs.NONE = 3; - -/** - * Writes error info out to console - * @param {Error} e - */ -Envjs.lineSource = function(e){}; - - -/** - * TODO: used in ./event/eventtarget.js - * @param {Object} event - */ -Envjs.defaultEventBehaviors = {}; - - -/** - * describes which script src values will trigger Envjs to load - * the script like a browser would - */ -Envjs.scriptTypes = { - "text/javascript" :false, - "text/envjs" :true -}; - -/** - * will be called when loading a script throws an error - * @param {Object} script - * @param {Object} e - */ -Envjs.onScriptLoadError = function(script, e){ - console.log('error loading script %s %s', script, e); -}; - - -/** - * load and execute script tag text content - * @param {Object} script - */ -Envjs.loadInlineScript = function(script){ - var tmpFile; - tmpFile = Envjs.writeToTempFile(script.text, 'js') ; - load(tmpFile); -}; - -/** - * Should evaluate script in some context - * @param {Object} context - * @param {Object} source - * @param {Object} name - */ -Envjs.eval = function(context, source, name){}; - - -/** - * Executes a script tag - * @param {Object} script - * @param {Object} parser - */ -Envjs.loadLocalScript = function(script){ - //console.log("loading script %s", script); - var types, - src, - i, - base, - filename, - xhr; - - if(script.type){ - types = script.type.split(";"); - for(i=0;i - * - Via an innerHTML parse of a - * - A modificiation of the 'src' attribute of an Image/HTMLImageElement - * - * NOTE: this is optional API. If this doesn't exist then the default - * 'loaded' event occurs. - * - * @param node {Object} the node - * @param node the src value - * @return 'true' to indicate the 'load' succeed, false otherwise - */ -Envjs.loadImage = function(node, src) { - return true; -}; - - -/** - * A 'link' was requested by the document. Typically this occurs when: - * - During inital parse of a - * - Via an innerHTML parse of a - * - A modificiation of the 'href' attribute on a node in the tree - * - * @param node {Object} is the link node in question - * @param href {String} is the href. - * - * Return 'true' to indicate that the 'load' was successful, or false - * otherwise. The appropriate event is then triggered. - * - * NOTE: this is optional API. If this doesn't exist then the default - * 'loaded' event occurs - */ -Envjs.loadLink = function(node, href) { - return true; -}; - -(function(){ - - -/* - * cookie handling - * Private internal helper class used to save/retreive cookies - */ - -/** - * Specifies the location of the cookie file - */ -Envjs.cookieFile = function(){ - return 'file://'+Envjs.homedir+'/.cookies'; -}; - -/** - * saves cookies to a local file - * @param {Object} htmldoc - */ -Envjs.saveCookies = function(){ - var cookiejson = JSON.stringify(Envjs.cookies.peristent,null,'\t'); - //console.log('persisting cookies %s', cookiejson); - Envjs.writeToFile(cookiejson, Envjs.cookieFile()); -}; - -/** - * loads cookies from a local file - * @param {Object} htmldoc - */ -Envjs.loadCookies = function(){ - var cookiejson, - js; - try{ - cookiejson = Envjs.readFromFile(Envjs.cookieFile()) - js = JSON.parse(cookiejson, null, '\t'); - }catch(e){ - //console.log('failed to load cookies %s', e); - js = {}; - } - return js; -}; - -Envjs.cookies = { - persistent:{ - //domain - key on domain name { - //path - key on path { - //name - key on name { - //value : cookie value - //other cookie properties - //} - //} - //} - //expire - provides a timestamp for expiring the cookie - //cookie - the cookie! - }, - temporary:{//transient is a reserved word :( - //like above - } -}; - -var __cookies__; - -//HTMLDocument cookie -Envjs.setCookie = function(url, cookie){ - var i, - index, - name, - value, - properties = {}, - attr, - attrs; - url = Envjs.urlsplit(url); - if(cookie) - attrs = cookie.split(";"); - else - return; - - //for now the strategy is to simply create a json object - //and post it to a file in the .cookies.js file. I hate parsing - //dates so I decided not to implement support for 'expires' - //(which is deprecated) and instead focus on the easier 'max-age' - //(which succeeds 'expires') - cookie = {};//keyword properties of the cookie - cookie['domain'] = url.hostname; - cookie['path'] = url.path||'/'; - for(i=0;i -1){ - name = __trim__(attrs[i].slice(0,index)); - value = __trim__(attrs[i].slice(index+1)); - if(name=='max-age'){ - //we'll have to when to check these - //and garbage collect expired cookies - cookie[name] = parseInt(value, 10); - } else if( name == 'domain' ){ - if(__domainValid__(url, value)){ - cookie['domain'] = value; - } - } else if( name == 'path' ){ - //not sure of any special logic for path - cookie['path'] = value; - } else { - //its not a cookie keyword so store it in our array of properties - //and we'll serialize individually in a moment - properties[name] = value; - } - }else{ - if( attrs[i] == 'secure' ){ - cookie[attrs[i]] = true; - } - } - } - if(!('max-age' in cookie)){ - //it's a transient cookie so it only lasts as long as - //the window.location remains the same (ie in-memory cookie) - __mergeCookie__(Envjs.cookies.temporary, cookie, properties); - }else{ - //the cookie is persistent - __mergeCookie__(Envjs.cookies.persistent, cookie, properties); - Envjs.saveCookies(); - } -}; - -function __domainValid__(url, value){ - var i, - domainParts = url.hostname.split('.').reverse(), - newDomainParts = value.split('.').reverse(); - if(newDomainParts.length > 1){ - for(i=0;i -1) { - for (name in cookies[domain][path]) { - // console.log('cookie domain path name %s', name); - cookieString += - ((i++ > 0)?'; ':'') + - name + "=" + - cookies[domain][path][name].value; - } - } - } - } - } - return cookieString; -}; - -function __mergeCookie__(target, cookie, properties){ - var name, now; - if(!target[cookie.domain]){ - target[cookie.domain] = {}; - } - if(!target[cookie.domain][cookie.path]){ - target[cookie.domain][cookie.path] = {}; - } - for(name in properties){ - now = new Date().getTime(); - target[cookie.domain][cookie.path][name] = { - "value":properties[name], - "secure":cookie.secure, - "max-age":cookie['max-age'], - "date-created":now, - "expiration":(cookie['max-age']===0) ? - 0 : - now + cookie['max-age'] - }; - //console.log('cookie is %o',target[cookie.domain][cookie.path][name]); - } -}; - -})();//end cookies -/* - http://www.JSON.org/json2.js - 2008-07-15 - - Public Domain. - - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - - See http://www.JSON.org/js.html - - - This code should be minified before deployment. - See http://javascript.crockford.com/jsmin.html - - USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO - NOT CONTROL. -*/ -try{ JSON; }catch(e){ -JSON = function () { - - function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; - } - - Date.prototype.toJSON = function (key) { - - return this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z'; - }; - - String.prototype.toJSON = function (key) { - return String(this); - }; - Number.prototype.toJSON = - Boolean.prototype.toJSON = function (key) { - return this.valueOf(); - }; - - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }, - rep; - - - function quote(string) { - - escapeable.lastIndex = 0; - return escapeable.test(string) ? - '"' + string.replace(escapeable, function (a) { - var c = meta[a]; - if (typeof c === 'string') { - return c; - } - return '\\u' + ('0000' + - (+(a.charCodeAt(0))).toString(16)).slice(-4); - }) + '"' : - '"' + string + '"'; - } - - - function str(key, holder) { - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - - return String(value); - - case 'object': - - if (!value) { - return 'null'; - } - gap += indent; - partial = []; - - if (typeof value.length === 'number' && - !(value.propertyIsEnumerable('length'))) { - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - v = partial.length === 0 ? '[]' : - gap ? '[\n' + gap + - partial.join(',\n' + gap) + '\n' + - mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - k = rep[i]; - if (typeof k === 'string') { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } else { - - for (k in value) { - if (Object.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - - v = partial.length === 0 ? '{}' : - gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + - mind + '}' : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } - } - - return { - stringify: function (value, replacer, space) { - - var i; - gap = ''; - indent = ''; - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - - } else if (typeof space === 'string') { - indent = space; - } - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - return str('', {'': value}); - }, - - - parse: function (text, reviver) { - var j; - function walk(holder, key) { - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - } - - cx.lastIndex = 0; - if (cx.test(text)) { - text = text.replace(cx, function (a) { - return '\\u' + ('0000' + - (+(a.charCodeAt(0))).toString(16)).slice(-4); - }); - } - - - if (/^[\],:{}\s]*$/. -test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). -replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). -replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { - - j = eval('(' + text + ')'); - - return typeof reviver === 'function' ? - walk({'': j}, '') : j; - } - - throw new SyntaxError('JSON.parse'); - } - }; -}(); - -} - -/** - * synchronizes thread modifications - * @param {Function} fn - */ -Envjs.sync = function(fn){}; - -/** - * sleep thread for specified duration - * @param {Object} millseconds - */ -Envjs.sleep = function(millseconds){}; - -/** - * Interval to wait on event loop when nothing is happening - */ -Envjs.WAIT_INTERVAL = 20;//milliseconds - -/* - * Copyright (c) 2010 Nick Galbreath - * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * url processing in the spirit of python's urlparse module - * see `pydoc urlparse` or - * http://docs.python.org/library/urlparse.html - * - * urlsplit: break apart a URL into components - * urlunsplit: reconsistute a URL from componets - * urljoin: join an absolute and another URL - * urldefrag: remove the fragment from a URL - * - * Take a look at the tests in urlparse-test.html - * - * On URL Normalization: - * - * urlsplit only does minor normalization the components Only scheme - * and hostname are lowercased urljoin does a bit more, normalizing - * paths with "." and "..". - - * urlnormalize adds additional normalization - * - * * removes default port numbers - * http://abc.com:80/ -> http://abc.com/, etc - * * normalizes path - * http://abc.com -> http://abc.com/ - * and other "." and ".." cleanups - * * if file, remove query and fragment - * - * It does not do: - * * normalizes escaped hex values - * http://abc.com/%7efoo -> http://abc.com/%7Efoo - * * normalize '+' <--> '%20' - * - * Differences with Python - * - * The javascript urlsplit returns a normal object with the following - * properties: scheme, netloc, hostname, port, path, query, fragment. - * All properties are read-write. - * - * In python, the resulting object is not a dict, but a specialized, - * read-only, and has alternative tuple interface (e.g. obj[0] == - * obj.scheme). It's not clear why such a simple function requires - * a unique datastructure. - * - * urlunsplit in javascript takes an duck-typed object, - * { scheme: 'http', netloc: 'abc.com', ...} - * while in * python it takes a list-like object. - * ['http', 'abc.com'... ] - * - * For all functions, the javascript version use - * hostname+port if netloc is missing. In python - * hostname+port were always ignored. - * - * Similar functionality in different languages: - * - * http://php.net/manual/en/function.parse-url.php - * returns assocative array but cannot handle relative URL - * - * TODO: test allowfragments more - * TODO: test netloc missing, but hostname present - */ - -var urlparse = {}; - -// Unlike to be useful standalone -// -// NORMALIZE PATH with "../" and "./" -// http://en.wikipedia.org/wiki/URL_normalization -// http://tools.ietf.org/html/rfc3986#section-5.2.3 -// -urlparse.normalizepath = function(path) -{ - if (!path || path === '/') { - return '/'; - } - - var parts = path.split('/'); - - var newparts = []; - // make sure path always starts with '/' - if (parts[0]) { - newparts.push(''); - } - - for (var i = 0; i < parts.length; ++i) { - if (parts[i] === '..') { - if (newparts.length > 1) { - newparts.pop(); - } else { - newparts.push(parts[i]); - } - } else if (parts[i] != '.') { - newparts.push(parts[i]); - } - } - - path = newparts.join('/'); - if (!path) { - path = '/'; - } - return path; -}; - -// -// Does many of the normalizations that the stock -// python urlsplit/urlunsplit/urljoin neglects -// -// Doesn't do hex-escape normalization on path or query -// %7e -> %7E -// Nor, '+' <--> %20 translation -// -urlparse.urlnormalize = function(url) -{ - var parts = urlparse.urlsplit(url); - switch (parts.scheme) { - case 'file': - // files can't have query strings - // and we don't bother with fragments - parts.query = ''; - parts.fragment = ''; - break; - case 'http': - case 'https': - // remove default port - if ((parts.scheme === 'http' && parts.port == 80) || - (parts.scheme === 'https' && parts.port == 443)) { - parts.port = null; - // hostname is already lower case - parts.netloc = parts.hostname; - } - break; - default: - // if we don't have specific normalizations for this - // scheme, return the original url unmolested - return url; - } - - // for [file|http|https]. Not sure about other schemes - parts.path = urlparse.normalizepath(parts.path); - - return urlparse.urlunsplit(parts); -}; - -urlparse.urldefrag = function(url) -{ - var idx = url.indexOf('#'); - if (idx == -1) { - return [ url, '' ]; - } else { - return [ url.substr(0,idx), url.substr(idx+1) ]; - } -}; - -urlparse.urlsplit = function(url, default_scheme, allow_fragments) -{ - var leftover; - - if (typeof allow_fragments === 'undefined') { - allow_fragments = true; - } - - // scheme (optional), host, port - var fullurl = /^([A-Za-z]+)?(:?\/\/)([0-9.\-A-Za-z]*)(?::(\d+))?(.*)$/; - // path, query, fragment - var parse_leftovers = /([^?#]*)?(?:\?([^#]*))?(?:#(.*))?$/; - - var o = {}; - - var parts = url.match(fullurl); - if (parts) { - o.scheme = parts[1] || default_scheme || ''; - o.hostname = parts[3].toLowerCase() || ''; - o.port = parseInt(parts[4],10) || ''; - // Probably should grab the netloc from regexp - // and then parse again for hostname/port - - o.netloc = parts[3]; - if (parts[4]) { - o.netloc += ':' + parts[4]; - } - - leftover = parts[5]; - } else { - o.scheme = default_scheme || ''; - o.netloc = ''; - o.hostname = ''; - leftover = url; - } - o.scheme = o.scheme.toLowerCase(); - - parts = leftover.match(parse_leftovers); - - o.path = parts[1] || ''; - o.query = parts[2] || ''; - - if (allow_fragments) { - o.fragment = parts[3] || ''; - } else { - o.fragment = ''; - } - - return o; -}; - -urlparse.urlunsplit = function(o) { - var s = ''; - if (o.scheme) { - s += o.scheme + '://'; - } - - if (o.netloc) { - if (s == '') { - s += '//'; - } - s += o.netloc; - } else if (o.hostname) { - // extension. Python only uses netloc - if (s == '') { - s += '//'; - } - s += o.hostname; - if (o.port) { - s += ':' + o.port; - } - } - - if (o.path) { - s += o.path; - } - - if (o.query) { - s += '?' + o.query; - } - if (o.fragment) { - s += '#' + o.fragment; - } - return s; -}; - -urlparse.urljoin = function(base, url, allow_fragments) -{ - if (typeof allow_fragments === 'undefined') { - allow_fragments = true; - } - - var url_parts = urlparse.urlsplit(url); - - // if url parts has a scheme (i.e. absolute) - // then nothing to do - if (url_parts.scheme) { - if (! allow_fragments) { - return url; - } else { - return urlparse.urldefrag(url)[0]; - } - } - var base_parts = urlparse.urlsplit(base); - - // copy base, only if not present - if (!base_parts.scheme) { - base_parts.scheme = url_parts.scheme; - } - - // copy netloc, only if not present - if (!base_parts.netloc || !base_parts.hostname) { - base_parts.netloc = url_parts.netloc; - base_parts.hostname = url_parts.hostname; - base_parts.port = url_parts.port; - } - - // paths - if (url_parts.path.length > 0) { - if (url_parts.path.charAt(0) == '/') { - base_parts.path = url_parts.path; - } else { - // relative path.. get rid of "current filename" and - // replace. Same as var parts = - // base_parts.path.split('/'); parts[parts.length-1] = - // url_parts.path; base_parts.path = parts.join('/'); - var idx = base_parts.path.lastIndexOf('/'); - if (idx == -1) { - base_parts.path = url_parts.path; - } else { - base_parts.path = base_parts.path.substr(0,idx) + '/' + - url_parts.path; - } - } - } - - // clean up path - base_parts.path = urlparse.normalizepath(base_parts.path); - - // copy query string - base_parts.query = url_parts.query; - - // copy fragments - if (allow_fragments) { - base_parts.fragment = url_parts.fragment; - } else { - base_parts.fragment = ''; - } - - return urlparse.urlunsplit(base_parts); -}; - -/** - * getcwd - named after posix call of same name (see 'man 2 getcwd') - * - */ -Envjs.getcwd = function() { - return '.'; -}; - -/** - * resolves location relative to doc location - * - * @param {Object} path Relative or absolute URL - * @param {Object} base (semi-optional) The base url used in resolving "path" above - */ -Envjs.uri = function(path, base) { - //console.log('constructing uri from path %s and base %s', path, base); - - // Semi-common trick is to make an iframe with src='javascript:false' - // (or some equivalent). By returning '', the load is skipped - if (path.indexOf('javascript') === 0) { - return ''; - } - - // if path is absolute, then just normalize and return - if (path.match('^[a-zA-Z]+://')) { - return urlparse.urlnormalize(path); - } - - // interesting special case, a few very large websites use - // '//foo/bar/' to mean 'http://foo/bar' - if (path.match('^//')) { - path = 'http:' + path; - } - - // if base not passed in, try to get it from document - // Ideally I would like the caller to pass in document.baseURI to - // make this more self-sufficient and testable - if (!base && document) { - base = document.baseURI; - } - - // about:blank doesn't count - if (base === 'about:blank'){ - base = ''; - } - - // if base is still empty, then we are in QA mode loading local - // files. Get current working directory - if (!base) { - base = 'file://' + Envjs.getcwd() + '/'; - } - // handles all cases if path is abosulte or relative to base - // 3rd arg is "false" --> remove fragments - var newurl = urlparse.urlnormalize(urlparse.urljoin(base, path, false)); - - return newurl; -}; - - - -/** - * Used in the XMLHttpRquest implementation to run a - * request in a seperate thread - * @param {Object} fn - */ -Envjs.runAsync = function(fn){}; - - -/** - * Used to write to a local file - * @param {Object} text - * @param {Object} url - */ -Envjs.writeToFile = function(text, url){}; - - -/** - * Used to write to a local file - * @param {Object} text - * @param {Object} suffix - */ -Envjs.writeToTempFile = function(text, suffix){}; - -/** - * Used to read the contents of a local file - * @param {Object} url - */ -Envjs.readFromFile = function(url){}; - -/** - * Used to delete a local file - * @param {Object} url - */ -Envjs.deleteFile = function(url){}; - -/** - * establishes connection and calls responsehandler - * @param {Object} xhr - * @param {Object} responseHandler - * @param {Object} data - */ -Envjs.connection = function(xhr, responseHandler, data){}; - - -__extend__(Envjs, urlparse); - -/** - * Makes an object window-like by proxying object accessors - * @param {Object} scope - * @param {Object} parent - */ -Envjs.proxy = function(scope, parent, aliasList){}; - -Envjs.javaEnabled = false; - -Envjs.homedir = ''; -Envjs.tmpdir = ''; -Envjs.os_name = ''; -Envjs.os_arch = ''; -Envjs.os_version = ''; -Envjs.lang = ''; -Envjs.platform = ''; - -/** - * - * @param {Object} frameElement - * @param {Object} url - */ -Envjs.loadFrame = function(frame, url){ - try { - if(frame.contentWindow){ - //mark for garbage collection - frame.contentWindow = null; - } - - //create a new scope for the window proxy - //platforms will need to override this function - //to make sure the scope is global-like - frame.contentWindow = (function(){return this;})(); - new Window(frame.contentWindow, window); - - //I dont think frames load asynchronously in firefox - //and I think the tests have verified this but for - //some reason I'm less than confident... Are there cases? - frame.contentDocument = frame.contentWindow.document; - frame.contentDocument.async = false; - if(url){ - //console.log('envjs.loadFrame async %s', frame.contentDocument.async); - frame.contentWindow.location = url; - } - } catch(e) { - console.log("failed to load frame content: from %s %s", url, e); - } -}; - - -// The following are in rhino/window.js -// TODO: Envjs.unloadFrame -// TODO: Envjs.proxy - -/** - * @author john resig & the envjs team - * @uri http://www.envjs.com/ - * @copyright 2008-2010 - * @license MIT - */ -//CLOSURE_END -}()); -/* - * Envjs rhino-env.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -var __context__ = Packages.org.mozilla.javascript.Context.getCurrentContext(); - -Envjs.platform = "Rhino"; -Envjs.revision = "1.7.0.rc2"; - -/* - * Envjs rhino-env.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - - -/** - * @author john resig - */ -// Helper method for extending one object with another. -function __extend__(a,b) { - for ( var i in b ) { - var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i); - if ( g || s ) { - if ( g ) { a.__defineGetter__(i, g); } - if ( s ) { a.__defineSetter__(i, s); } - } else { - a[i] = b[i]; - } - } return a; -} - -/** - * Writes message to system out. - * - * Some sites redefine 'print' as in 'window.print', so instead of - * printing to stdout, you are popping open a new window, which might - * call print, etc, etc,etc This can cause infinite loops and can - * exhausing all memory. - * - * By defining this upfront now, Envjs.log will always call the native 'print' - * function - * - * @param {Object} message - */ -Envjs.log = print; - -Envjs.lineSource = function(e){ - return e&&e.rhinoException?e.rhinoException.lineSource():"(line ?)"; -}; -/** - * load and execute script tag text content - * @param {Object} script - */ -Envjs.loadInlineScript = function(script){ - if(script.ownerDocument.ownerWindow){ - Envjs.eval( - script.ownerDocument.ownerWindow, - script.text, - 'eval('+script.text.substring(0,16)+'...):'+new Date().getTime() - ); - }else{ - Envjs.eval( - __this__, - script.text, - 'eval('+script.text.substring(0,16)+'...):'+new Date().getTime() - ); - } - //console.log('evaluated at scope %s \n%s', - // script.ownerDocument.ownerWindow.guid, script.text); -}; - - -Envjs.eval = function(context, source, name){ - __context__.evaluateString( - context, - source, - name, - 0, - null - ); -}; - -//Temporary patch for parser module -Packages.org.mozilla.javascript.Context. - getCurrentContext().setOptimizationLevel(-1); - -/** - * Rhino provides a very succinct 'sync' - * @param {Function} fn - */ -try{ - Envjs.sync = sync; - Envjs.spawn = spawn; -} catch(e){ - //sync unavailable on AppEngine - Envjs.sync = function(fn){ - //console.log('Threadless platform, sync is safe'); - return fn; - }; - - Envjs.spawn = function(fn){ - //console.log('Threadless platform, spawn shares main thread.'); - return fn(); - }; -} - -/** - * sleep thread for specified duration - * @param {Object} millseconds - */ -Envjs.sleep = function(millseconds){ - try{ - java.lang.Thread.currentThread().sleep(millseconds); - }catch(e){ - console.log('Threadless platform, cannot sleep.'); - } -}; - -/** - * provides callback hook for when the system exits - */ -Envjs.onExit = function(callback){ - var rhino = Packages.org.mozilla.javascript, - contextFactory = __context__.getFactory(), - listener = new rhino.ContextFactory.Listener({ - contextReleased: function(context){ - if(context === __context__) - console.log('context released', context); - contextFactory.removeListener(this); - if(callback) - callback(); - } - }); - contextFactory.addListener(listener); -}; - -/** - * Get 'Current Working Directory' - */ -Envjs.getcwd = function() { - return java.lang.System.getProperty('user.dir'); -} - -/** - * - * @param {Object} fn - * @param {Object} onInterupt - */ -Envjs.runAsync = function(fn, onInterupt){ - ////Envjs.debug("running async"); - var running = true, - run; - - try{ - run = Envjs.sync(function(){ - fn(); - Envjs.wait(); - }); - Envjs.spawn(run); - }catch(e){ - console.log("error while running async operation", e); - try{if(onInterrupt)onInterrupt(e)}catch(ee){}; - } -}; - -/** - * Used to write to a local file - * @param {Object} text - * @param {Object} url - */ -Envjs.writeToFile = function(text, url){ - //Envjs.debug("writing text to url : " + url); - var out = new java.io.FileWriter( - new java.io.File( - new java.net.URI(url.toString()))); - out.write( text, 0, text.length ); - out.flush(); - out.close(); -}; - -/** - * Used to write to a local file - * @param {Object} text - * @param {Object} suffix - */ -Envjs.writeToTempFile = function(text, suffix){ - //Envjs.debug("writing text to temp url : " + suffix); - // Create temp file. - var temp = java.io.File.createTempFile("envjs-tmp", suffix); - - // Delete temp file when program exits. - temp.deleteOnExit(); - - // Write to temp file - var out = new java.io.FileWriter(temp); - out.write(text, 0, text.length); - out.close(); - return temp.getAbsolutePath().toString()+''; -}; - - -/** - * Used to read the contents of a local file - * @param {Object} url - */ -Envjs.readFromFile = function( url ){ - var fileReader = new java.io.FileReader( - new java.io.File( - new java.net.URI( url ))); - - var stringwriter = new java.io.StringWriter(), - buffer = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 1024), - length; - - while ((length = fileReader.read(buffer, 0, 1024)) != -1) { - stringwriter.write(buffer, 0, length); - } - - stringwriter.close(); - return stringwriter.toString()+""; -}; - - -/** - * Used to delete a local file - * @param {Object} url - */ -Envjs.deleteFile = function(url){ - var file = new java.io.File( new java.net.URI( url ) ); - file["delete"](); -}; - -/** - * establishes connection and calls responsehandler - * @param {Object} xhr - * @param {Object} responseHandler - * @param {Object} data - */ -Envjs.connection = function(xhr, responseHandler, data){ - var url = java.net.URL(xhr.url), - connection, - header, - outstream, - buffer, - length, - binary = false, - name, value, - contentEncoding, - instream, - responseXML, - i; - if ( /^file\:/.test(url) ) { - try{ - if ( "PUT" == xhr.method || "POST" == xhr.method ) { - data = data || "" ; - Envjs.writeToFile(data, url); - xhr.readyState = 4; - //could be improved, I just cant recall the correct http codes - xhr.status = 200; - xhr.statusText = ""; - } else if ( xhr.method == "DELETE" ) { - Envjs.deleteFile(url); - xhr.readyState = 4; - //could be improved, I just cant recall the correct http codes - xhr.status = 200; - xhr.statusText = ""; - } else { - connection = url.openConnection(); - connection.connect(); - //try to add some canned headers that make sense - - try{ - if(xhr.url.match(/html$/)){ - xhr.responseHeaders["Content-Type"] = 'text/html'; - }else if(xhr.url.match(/.xml$/)){ - xhr.responseHeaders["Content-Type"] = 'text/xml'; - }else if(xhr.url.match(/.js$/)){ - xhr.responseHeaders["Content-Type"] = 'text/javascript'; - }else if(xhr.url.match(/.json$/)){ - xhr.responseHeaders["Content-Type"] = 'application/json'; - }else{ - xhr.responseHeaders["Content-Type"] = 'text/plain'; - } - //xhr.responseHeaders['Last-Modified'] = connection.getLastModified(); - //xhr.responseHeaders['Content-Length'] = headerValue+''; - //xhr.responseHeaders['Date'] = new Date()+'';*/ - }catch(e){ - console.log('failed to load response headers',e); - } - } - }catch(e){ - console.log('failed to open file %s %s', url, e); - connection = null; - xhr.readyState = 4; - xhr.statusText = "Local File Protocol Error"; - xhr.responseText = "

      "+ e+ "

      "; - } - } else { - connection = url.openConnection(); - connection.setRequestMethod( xhr.method ); - - // Add headers to Java connection - for (header in xhr.headers){ - connection.addRequestProperty(header+'', xhr.headers[header]+''); - } - - //write data to output stream if required - if(data){ - if(data instanceof Document){ - if ( xhr.method == "PUT" || xhr.method == "POST" ) { - connection.setDoOutput(true); - outstream = connection.getOutputStream(), - xml = (new XMLSerializer()).serializeToString(data); - buffer = new java.lang.String(xml).getBytes('UTF-8'); - outstream.write(buffer, 0, buffer.length); - outstream.close(); - } - }else if(data.length&&data.length>0){ - if ( xhr.method == "PUT" || xhr.method == "POST" ) { - connection.setDoOutput(true); - outstream = connection.getOutputStream(); - buffer = new java.lang.String(data).getBytes('UTF-8'); - outstream.write(buffer, 0, buffer.length); - outstream.close(); - } - } - connection.connect(); - }else{ - connection.connect(); - } - } - - if(connection){ - try{ - length = connection.getHeaderFields().size(); - // Stick the response headers into responseHeaders - for (i = 0; i < length; i++) { - name = connection.getHeaderFieldKey(i); - value = connection.getHeaderField(i); - if (name) - xhr.responseHeaders[name+''] = value+''; - } - }catch(e){ - console.log('failed to load response headers \n%s',e); - } - - xhr.readyState = 4; - xhr.status = parseInt(connection.responseCode,10) || undefined; - xhr.statusText = connection.responseMessage || ""; - - contentEncoding = connection.getContentEncoding() || "utf-8"; - instream = null; - responseXML = null; - - try{ - //console.log('contentEncoding %s', contentEncoding); - if( contentEncoding.equalsIgnoreCase("gzip") || - contentEncoding.equalsIgnoreCase("decompress")){ - //zipped content - binary = true; - outstream = new java.io.ByteArrayOutputStream(); - buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024); - instream = new java.util.zip.GZIPInputStream(connection.getInputStream()) - }else{ - //this is a text file - outstream = new java.io.StringWriter(); - buffer = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 1024); - instream = new java.io.InputStreamReader(connection.getInputStream()); - } - }catch(e){ - if (connection.getResponseCode() == 404){ - console.log('failed to open connection stream \n %s %s', - e.toString(), e); - }else{ - console.log('failed to open connection stream \n %s %s', - e.toString(), e); - } - instream = connection.getErrorStream(); - } - - while ((length = instream.read(buffer, 0, 1024)) != -1) { - outstream.write(buffer, 0, length); - } - - outstream.close(); - instream.close(); - - if(binary){ - xhr.responseText = new String(outstream.toByteArray(), 'UTF-8')+''; - }else{ - xhr.responseText = outstream.toString()+''; - } - - } - if(responseHandler){ - //Envjs.debug('calling ajax response handler'); - responseHandler(); - } -}; - -//Since we're running in rhino I guess we can safely assume -//java is 'enabled'. I'm sure this requires more thought -//than I've given it here -Envjs.javaEnabled = true; - -Envjs.homedir = java.lang.System.getProperty("user.home"); -Envjs.tmpdir = java.lang.System.getProperty("java.io.tmpdir"); -Envjs.os_name = java.lang.System.getProperty("os.name"); -Envjs.os_arch = java.lang.System.getProperty("os.arch"); -Envjs.os_version = java.lang.System.getProperty("os.version"); -Envjs.lang = java.lang.System.getProperty("user.lang"); - - -/** - * - * @param {Object} frameElement - * @param {Object} url - */ -Envjs.loadFrame = function(frame, url){ - try { - if(frame.contentWindow){ - //mark for garbage collection - frame.contentWindow = null; - } - - //create a new scope for the window proxy - frame.contentWindow = Envjs.proxy(); - new Window(frame.contentWindow, window); - - //I dont think frames load asynchronously in firefox - //and I think the tests have verified this but for - //some reason I'm less than confident... Are there cases? - frame.contentDocument = frame.contentWindow.document; - frame.contentDocument.async = false; - if(url){ - //console.log('envjs.loadFrame async %s', frame.contentDocument.async); - frame.contentWindow.location = url; - } - } catch(e) { - console.log("failed to load frame content: from %s %s", url, e); - } -}; - -/** - * unloadFrame - * @param {Object} frame - */ -Envjs.unloadFrame = function(frame){ - var all, length, i; - try{ - //TODO: probably self-referencing structures within a document tree - //preventing it from being entirely garbage collected once orphaned. - //Should have code to walk tree and break all links between contained - //objects. - frame.contentDocument = null; - if(frame.contentWindow){ - frame.contentWindow.close(); - } - gc(); - }catch(e){ - console.log(e); - } -}; - -/** - * Makes an object window-like by proxying object accessors - * @param {Object} scope - * @param {Object} parent - */ -Envjs.proxy = function(scope, parent) { - try{ - if(scope+'' == '[object global]'){ - return scope - }else{ - return __context__.initStandardObjects(); - } - }catch(e){ - console.log('failed to init standard objects %s %s \n%s', scope, parent, e); - } - -}; - -/** - * @author john resig & the envjs team - * @uri http://www.envjs.com/ - * @copyright 2008-2010 - * @license MIT - */ -//CLOSURE_END -}()); - -/** - * @author envjs team - */ -var Console, - console; - -/* - * Envjs console.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - - -/** - * @author envjs team - * borrowed 99%-ish with love from firebug-lite - * - * http://wiki.commonjs.org/wiki/Console - */ -Console = function(module){ - var $level, - $logger, - $null = function(){}; - - - if(Envjs[module] && Envjs[module].loglevel){ - $level = Envjs.module.loglevel; - $logger = { - log: function(level){ - logFormatted(arguments, (module)+" "); - }, - debug: $level>1 ? $null: function() { - logFormatted(arguments, (module)+" debug"); - }, - info: $level>2 ? $null:function(){ - logFormatted(arguments, (module)+" info"); - }, - warn: $level>3 ? $null:function(){ - logFormatted(arguments, (module)+" warning"); - }, - error: $level>4 ? $null:function(){ - logFormatted(arguments, (module)+" error"); - } - }; - } else { - $logger = { - log: function(level){ - logFormatted(arguments, ""); - }, - debug: $null, - info: $null, - warn: $null, - error: $null - }; - } - - return $logger; -}; - -console = new Console("console",1); - -function logFormatted(objects, className) -{ - var html = []; - - var format = objects[0]; - var objIndex = 0; - - if (typeof(format) != "string") - { - format = ""; - objIndex = -1; - } - - var parts = parseFormat(format); - for (var i = 0; i < parts.length; ++i) - { - var part = parts[i]; - if (part && typeof(part) == "object") - { - var object = objects[++objIndex]; - part.appender(object, html); - } - else { - appendText(part, html); - } - } - - for (var i = objIndex+1; i < objects.length; ++i) - { - appendText(" ", html); - - var object = objects[i]; - if (typeof(object) == "string") { - appendText(object, html); - } else { - appendObject(object, html); - } - } - - Envjs.log(html.join(' ')); -} - -function parseFormat(format) -{ - var parts = []; - - var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/; - var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat}; - - for (var m = reg.exec(format); m; m = reg.exec(format)) - { - var type = m[8] ? m[8] : m[5]; - var appender = type in appenderMap ? appenderMap[type] : appendObject; - var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0); - - parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1)); - parts.push({appender: appender, precision: precision}); - - format = format.substr(m.index+m[0].length); - } - - parts.push(format); - - return parts; -} - -function escapeHTML(value) -{ - return value; -} - -function objectToString(object) -{ - try - { - return object+""; - } - catch (exc) - { - return null; - } -} - -// ******************************************************************************************** - -function appendText(object, html) -{ - html.push(escapeHTML(objectToString(object))); -} - -function appendNull(object, html) -{ - html.push(escapeHTML(objectToString(object))); -} - -function appendString(object, html) -{ - html.push(escapeHTML(objectToString(object))); -} - -function appendInteger(object, html) -{ - html.push(escapeHTML(objectToString(object))); -} - -function appendFloat(object, html) -{ - html.push(escapeHTML(objectToString(object))); -} - -function appendFunction(object, html) -{ - var reName = /function ?(.*?)\(/; - var m = reName.exec(objectToString(object)); - var name = m ? m[1] : "function"; - html.push(escapeHTML(name)); -} - -function appendObject(object, html) -{ - try - { - if (object == undefined) { - appendNull("undefined", html); - } else if (object == null) { - appendNull("null", html); - } else if (typeof object == "string") { - appendString(object, html); - } else if (typeof object == "number") { - appendInteger(object, html); - } else if (typeof object == "function") { - appendFunction(object, html); - } else if (object.nodeType == 1) { - appendSelector(object, html); - } else if (typeof object == "object") { - appendObjectFormatted(object, html); - } else { - appendText(object, html); - } - } - catch (exc) - { - } -} - -function appendObjectFormatted(object, html) -{ - var text = objectToString(object); - var reObject = /\[object (.*?)\]/; - - var m = reObject.exec(text); - html.push( m ? m[1] : text); -} - -function appendSelector(object, html) -{ - - html.push(escapeHTML(object.nodeName.toLowerCase())); - if (object.id) { - html.push(escapeHTML(object.id)); - } - if (object.className) { - html.push(escapeHTML(object.className)); - } -} - -function appendNode(node, html) -{ - if (node.nodeType == 1) - { - html.push( node.nodeName.toLowerCase()); - - for (var i = 0; i < node.attributes.length; ++i) - { - var attr = node.attributes[i]; - if (!attr.specified) { - continue; - } - - html.push( attr.nodeName.toLowerCase(),escapeHTML(attr.nodeValue)); - } - - if (node.firstChild) - { - for (var child = node.firstChild; child; child = child.nextSibling) { - appendNode(child, html); - } - - html.push( node.nodeName.toLowerCase()); - } - } - else if (node.nodeType === 3) - { - html.push(escapeHTML(node.nodeValue)); - } -}; - -/** - * @author john resig & the envjs team - * @uri http://www.envjs.com/ - * @copyright 2008-2010 - * @license MIT - */ -//CLOSURE_END -}()); -/* - * Envjs dom.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - * - * Parts of the implementation were originally written by:\ - * and Jon van Noort (jon@webarcana.com.au) \ - * and David Joham (djoham@yahoo.com)",\ - * and Scott Severtson - * - * This file simply provides the global definitions we need to \ - * be able to correctly implement to core browser DOM interfaces." - */ - -var Attr, - CDATASection, - CharacterData, - Comment, - Document, - DocumentFragment, - DocumentType, - DOMException, - DOMImplementation, - Element, - Entity, - EntityReference, - NamedNodeMap, - Namespace, - Node, - NodeList, - Notation, - ProcessingInstruction, - Text, - Range, - XMLSerializer, - DOMParser; - - - -/* - * Envjs dom.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - - -/** - * @author john resig - */ -// Helper method for extending one object with another. -function __extend__(a,b) { - for ( var i in b ) { - var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i); - if ( g || s ) { - if ( g ) { a.__defineGetter__(i, g); } - if ( s ) { a.__defineSetter__(i, s); } - } else { - a[i] = b[i]; - } - } return a; -} - -/** - * @author john resig - */ -//from jQuery -function __setArray__( target, array ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - target.length = 0; - Array.prototype.push.apply( target, array ); -} - -/** - * @class NodeList - - * provides the abstraction of an ordered collection of nodes - * - * @param ownerDocument : Document - the ownerDocument - * @param parentNode : Node - the node that the NodeList is attached to (or null) - */ -NodeList = function(ownerDocument, parentNode) { - this.length = 0; - this.parentNode = parentNode; - this.ownerDocument = ownerDocument; - this._readonly = false; - __setArray__(this, []); -}; - -__extend__(NodeList.prototype, { - item : function(index) { - var ret = null; - if ((index >= 0) && (index < this.length)) { - // bounds check - ret = this[index]; - } - // if the index is out of bounds, default value null is returned - return ret; - }, - get xml() { - var ret = "", - i; - - // create string containing the concatenation of the string values of each child - for (i=0; i < this.length; i++) { - if(this[i]){ - if(this[i].nodeType == Node.TEXT_NODE && i>0 && - this[i-1].nodeType == Node.TEXT_NODE){ - //add a single space between adjacent text nodes - ret += " "+this[i].xml; - }else{ - ret += this[i].xml; - } - } - } - return ret; - }, - toArray: function () { - var children = [], - i; - for ( i=0; i < this.length; i++) { - children.push (this[i]); - } - return children; - }, - toString: function(){ - return "[object NodeList]"; - } -}); - - -/** - * @method __findItemIndex__ - * find the item index of the node - * @author Jon van Noort (jon@webarcana.com.au) - * @param node : Node - * @return : int - */ -var __findItemIndex__ = function (nodelist, node) { - var ret = -1, i; - for (i=0; i= 0) && (refChildIndex <= nodelist.length)) { - // bounds check - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // node is a DocumentFragment - // append the children of DocumentFragment - Array.prototype.splice.apply(nodelist, - [refChildIndex, 0].concat(newChild.childNodes.toArray())); - } - else { - // append the newChild - Array.prototype.splice.apply(nodelist,[refChildIndex, 0, newChild]); - } - } -}; - -/** - * @method __replaceChild__ - * replace the specified Node in the NodeList at the specified index - * Used by Node.replaceChild(). Note: Node.replaceChild() is responsible - * for Node Pointer surgery __replaceChild__ simply modifies the internal - * data structure (Array). - * - * @param newChild : Node - the Node to be inserted - * @param refChildIndex : int - the array index to hold the Node - */ -var __replaceChild__ = function(nodelist, newChild, refChildIndex) { - var ret = null; - - // bounds check - if ((refChildIndex >= 0) && (refChildIndex < nodelist.length)) { - // preserve old child for return - ret = nodelist[refChildIndex]; - - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // node is a DocumentFragment - // get array containing children prior to refChild - Array.prototype.splice.apply(nodelist, - [refChildIndex, 1].concat(newChild.childNodes.toArray())); - } - else { - // simply replace node in array (links between Nodes are - // made at higher level) - nodelist[refChildIndex] = newChild; - } - } - // return replaced node - return ret; -}; - -/** - * @method __removeChild__ - * remove the specified Node in the NodeList at the specified index - * Used by Node.removeChild(). Note: Node.removeChild() is responsible - * for Node Pointer surgery __removeChild__ simply modifies the internal - * data structure (Array). - * @param refChildIndex : int - the array index holding the Node to be removed - */ -var __removeChild__ = function(nodelist, refChildIndex) { - var ret = null; - - if (refChildIndex > -1) { - // found it! - // return removed node - ret = nodelist[refChildIndex]; - - // rebuild array without removed child - Array.prototype.splice.apply(nodelist,[refChildIndex, 1]); - } - // return removed node - return ret; -}; - -/** - * @method __appendChild__ - * append the specified Node to the NodeList. Used by Node.appendChild(). - * Note: Node.appendChild() is responsible for Node Pointer surgery - * __appendChild__ simply modifies the internal data structure (Array). - * @param newChild : Node - the Node to be inserted - */ -var __appendChild__ = function(nodelist, newChild) { - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // node is a DocumentFragment - // append the children of DocumentFragment - Array.prototype.push.apply(nodelist, newChild.childNodes.toArray() ); - } else { - // simply add node to array (links between Nodes are made at higher level) - Array.prototype.push.apply(nodelist, [newChild]); - } - -}; - -/** - * @method __cloneNodes__ - - * Returns a NodeList containing clones of the Nodes in this NodeList - * @param deep : boolean - - * If true, recursively clone the subtree under each of the nodes; - * if false, clone only the nodes themselves (and their attributes, - * if it is an Element). - * @param parentNode : Node - the new parent of the cloned NodeList - * @return : NodeList - NodeList containing clones of the Nodes in this NodeList - */ -var __cloneNodes__ = function(nodelist, deep, parentNode) { - var cloneNodeList = new NodeList(nodelist.ownerDocument, parentNode); - - // create list containing clones of each child - for (var i=0; i < nodelist.length; i++) { - __appendChild__(cloneNodeList, nodelist[i].cloneNode(deep)); - } - - return cloneNodeList; -}; - - -var __ownerDocument__ = function(node){ - return (node.nodeType == Node.DOCUMENT_NODE)?node:node.ownerDocument; -}; - -/** - * @class Node - - * The Node interface is the primary datatype for the entire - * Document Object Model. It represents a single node in the - * document tree. - * @param ownerDocument : Document - The Document object associated with this node. - */ - -Node = function(ownerDocument) { - this.baseURI = 'about:blank'; - this.namespaceURI = null; - this.nodeName = ""; - this.nodeValue = null; - - // A NodeList that contains all children of this node. If there are no - // children, this is a NodeList containing no nodes. The content of the - // returned NodeList is "live" in the sense that, for instance, changes to - // the children of the node object that it was created from are immediately - // reflected in the nodes returned by the NodeList accessors; it is not a - // static snapshot of the content of the node. This is true for every - // NodeList, including the ones returned by the getElementsByTagName method. - this.childNodes = new NodeList(ownerDocument, this); - - // The first child of this node. If there is no such node, this is null - this.firstChild = null; - // The last child of this node. If there is no such node, this is null. - this.lastChild = null; - // The node immediately preceding this node. If there is no such node, - // this is null. - this.previousSibling = null; - // The node immediately following this node. If there is no such node, - // this is null. - this.nextSibling = null; - - this.attributes = null; - // The namespaces in scope for this node - this._namespaces = new NamespaceNodeMap(ownerDocument, this); - this._readonly = false; - - //IMPORTANT: These must come last so rhino will not iterate parent - // properties before child properties. (qunit.equiv issue) - - // The parent of this node. All nodes, except Document, DocumentFragment, - // and Attr may have a parent. However, if a node has just been created - // and not yet added to the tree, or if it has been removed from the tree, - // this is null - this.parentNode = null; - // The Document object associated with this node - this.ownerDocument = ownerDocument; - -}; - -// nodeType constants -Node.ELEMENT_NODE = 1; -Node.ATTRIBUTE_NODE = 2; -Node.TEXT_NODE = 3; -Node.CDATA_SECTION_NODE = 4; -Node.ENTITY_REFERENCE_NODE = 5; -Node.ENTITY_NODE = 6; -Node.PROCESSING_INSTRUCTION_NODE = 7; -Node.COMMENT_NODE = 8; -Node.DOCUMENT_NODE = 9; -Node.DOCUMENT_TYPE_NODE = 10; -Node.DOCUMENT_FRAGMENT_NODE = 11; -Node.NOTATION_NODE = 12; -Node.NAMESPACE_NODE = 13; - -Node.DOCUMENT_POSITION_EQUAL = 0x00; -Node.DOCUMENT_POSITION_DISCONNECTED = 0x01; -Node.DOCUMENT_POSITION_PRECEDING = 0x02; -Node.DOCUMENT_POSITION_FOLLOWING = 0x04; -Node.DOCUMENT_POSITION_CONTAINS = 0x08; -Node.DOCUMENT_POSITION_CONTAINED_BY = 0x10; -Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; - - -__extend__(Node.prototype, { - get localName(){ - return this.prefix? - this.nodeName.substring(this.prefix.length+1, this.nodeName.length): - this.nodeName; - }, - get prefix(){ - return this.nodeName.split(':').length>1? - this.nodeName.split(':')[0]: - null; - }, - set prefix(value){ - if(value === null){ - this.nodeName = this.localName; - }else{ - this.nodeName = value+':'+this.localName; - } - }, - hasAttributes : function() { - if (this.attributes.length == 0) { - return false; - }else{ - return true; - } - }, - get textContent(){ - return __recursivelyGatherText__(this); - }, - set textContent(newText){ - while(this.firstChild != null){ - this.removeChild( this.firstChild ); - } - var text = this.ownerDocument.createTextNode(newText); - this.appendChild(text); - }, - insertBefore : function(newChild, refChild) { - var prevNode; - - if(newChild==null){ - return newChild; - } - if(refChild==null){ - this.appendChild(newChild); - return this.newChild; - } - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Node is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if newChild was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(newChild)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if the node is an ancestor - if (__isAncestor__(this, newChild)) { - throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR)); - } - } - - // if refChild is specified, insert before it - if (refChild) { - // find index of refChild - var itemIndex = __findItemIndex__(this.childNodes, refChild); - // throw Exception if there is no child node with this id - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // if the newChild is already in the tree, - var newChildParent = newChild.parentNode; - if (newChildParent) { - // remove it - newChildParent.removeChild(newChild); - } - - // insert newChild into childNodes - __insertBefore__(this.childNodes, newChild, itemIndex); - - // do node pointer surgery - prevNode = refChild.previousSibling; - - // handle DocumentFragment - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - if (newChild.childNodes.length > 0) { - // set the parentNode of DocumentFragment's children - for (var ind = 0; ind < newChild.childNodes.length; ind++) { - newChild.childNodes[ind].parentNode = this; - } - - // link refChild to last child of DocumentFragment - refChild.previousSibling = newChild.childNodes[newChild.childNodes.length-1]; - } - }else { - // set the parentNode of the newChild - newChild.parentNode = this; - // link refChild to newChild - refChild.previousSibling = newChild; - } - - }else { - // otherwise, append to end - prevNode = this.lastChild; - this.appendChild(newChild); - } - - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // do node pointer surgery for DocumentFragment - if (newChild.childNodes.length > 0) { - if (prevNode) { - prevNode.nextSibling = newChild.childNodes[0]; - }else { - // this is the first child in the list - this.firstChild = newChild.childNodes[0]; - } - newChild.childNodes[0].previousSibling = prevNode; - newChild.childNodes[newChild.childNodes.length-1].nextSibling = refChild; - } - }else { - // do node pointer surgery for newChild - if (prevNode) { - prevNode.nextSibling = newChild; - }else { - // this is the first child in the list - this.firstChild = newChild; - } - newChild.previousSibling = prevNode; - newChild.nextSibling = refChild; - } - - return newChild; - }, - replaceChild : function(newChild, oldChild) { - var ret = null; - - if(newChild==null || oldChild==null){ - return oldChild; - } - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Node is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if newChild was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(newChild)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if the node is an ancestor - if (__isAncestor__(this, newChild)) { - throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR)); - } - } - - // get index of oldChild - var index = __findItemIndex__(this.childNodes, oldChild); - - // throw Exception if there is no child node with this id - if (__ownerDocument__(this).implementation.errorChecking && (index < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // if the newChild is already in the tree, - var newChildParent = newChild.parentNode; - if (newChildParent) { - // remove it - newChildParent.removeChild(newChild); - } - - // add newChild to childNodes - ret = __replaceChild__(this.childNodes,newChild, index); - - - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // do node pointer surgery for Document Fragment - if (newChild.childNodes.length > 0) { - for (var ind = 0; ind < newChild.childNodes.length; ind++) { - newChild.childNodes[ind].parentNode = this; - } - - if (oldChild.previousSibling) { - oldChild.previousSibling.nextSibling = newChild.childNodes[0]; - } else { - this.firstChild = newChild.childNodes[0]; - } - - if (oldChild.nextSibling) { - oldChild.nextSibling.previousSibling = newChild; - } else { - this.lastChild = newChild.childNodes[newChild.childNodes.length-1]; - } - - newChild.childNodes[0].previousSibling = oldChild.previousSibling; - newChild.childNodes[newChild.childNodes.length-1].nextSibling = oldChild.nextSibling; - } - } else { - // do node pointer surgery for newChild - newChild.parentNode = this; - - if (oldChild.previousSibling) { - oldChild.previousSibling.nextSibling = newChild; - }else{ - this.firstChild = newChild; - } - if (oldChild.nextSibling) { - oldChild.nextSibling.previousSibling = newChild; - }else{ - this.lastChild = newChild; - } - newChild.previousSibling = oldChild.previousSibling; - newChild.nextSibling = oldChild.nextSibling; - } - - return ret; - }, - removeChild : function(oldChild) { - if(!oldChild){ - return null; - } - // throw Exception if NamedNodeMap is readonly - if (__ownerDocument__(this).implementation.errorChecking && - (this._readonly || oldChild._readonly)) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get index of oldChild - var itemIndex = __findItemIndex__(this.childNodes, oldChild); - - // throw Exception if there is no child node with this id - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // remove oldChild from childNodes - __removeChild__(this.childNodes, itemIndex); - - // do node pointer surgery - oldChild.parentNode = null; - - if (oldChild.previousSibling) { - oldChild.previousSibling.nextSibling = oldChild.nextSibling; - }else { - this.firstChild = oldChild.nextSibling; - } - if (oldChild.nextSibling) { - oldChild.nextSibling.previousSibling = oldChild.previousSibling; - }else { - this.lastChild = oldChild.previousSibling; - } - - oldChild.previousSibling = null; - oldChild.nextSibling = null; - - return oldChild; - }, - appendChild : function(newChild) { - if(!newChild){ - return null; - } - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Node is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if arg was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(this)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if the node is an ancestor - if (__isAncestor__(this, newChild)) { - throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR)); - } - } - - // if the newChild is already in the tree, - var newChildParent = newChild.parentNode; - if (newChildParent) { - // remove it - //console.debug('removing node %s', newChild); - newChildParent.removeChild(newChild); - } - - // add newChild to childNodes - __appendChild__(this.childNodes, newChild); - - if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // do node pointer surgery for DocumentFragment - if (newChild.childNodes.length > 0) { - for (var ind = 0; ind < newChild.childNodes.length; ind++) { - newChild.childNodes[ind].parentNode = this; - } - - if (this.lastChild) { - this.lastChild.nextSibling = newChild.childNodes[0]; - newChild.childNodes[0].previousSibling = this.lastChild; - this.lastChild = newChild.childNodes[newChild.childNodes.length-1]; - } else { - this.lastChild = newChild.childNodes[newChild.childNodes.length-1]; - this.firstChild = newChild.childNodes[0]; - } - } - } else { - // do node pointer surgery for newChild - newChild.parentNode = this; - if (this.lastChild) { - this.lastChild.nextSibling = newChild; - newChild.previousSibling = this.lastChild; - this.lastChild = newChild; - } else { - this.lastChild = newChild; - this.firstChild = newChild; - } - } - return newChild; - }, - hasChildNodes : function() { - return (this.childNodes.length > 0); - }, - cloneNode: function(deep) { - // use importNode to clone this Node - //do not throw any exceptions - try { - return __ownerDocument__(this).importNode(this, deep); - } catch (e) { - //there shouldn't be any exceptions, but if there are, return null - // may want to warn: $debug("could not clone node: "+e.code); - return null; - } - }, - normalize : function() { - var i; - var inode; - var nodesToRemove = new NodeList(); - - if (this.nodeType == Node.ELEMENT_NODE || this.nodeType == Node.DOCUMENT_NODE) { - var adjacentTextNode = null; - - // loop through all childNodes - for(i = 0; i < this.childNodes.length; i++) { - inode = this.childNodes.item(i); - - if (inode.nodeType == Node.TEXT_NODE) { - // this node is a text node - if (inode.length < 1) { - // this text node is empty - // add this node to the list of nodes to be remove - __appendChild__(nodesToRemove, inode); - }else { - if (adjacentTextNode) { - // previous node was also text - adjacentTextNode.appendData(inode.data); - // merge the data in adjacent text nodes - // add this node to the list of nodes to be removed - __appendChild__(nodesToRemove, inode); - } else { - // remember this node for next cycle - adjacentTextNode = inode; - } - } - } else { - // (soon to be) previous node is not a text node - adjacentTextNode = null; - // normalize non Text childNodes - inode.normalize(); - } - } - - // remove redundant Text Nodes - for(i = 0; i < nodesToRemove.length; i++) { - inode = nodesToRemove.item(i); - inode.parentNode.removeChild(inode); - } - } - }, - isSupported : function(feature, version) { - // use Implementation.hasFeature to determine if this feature is supported - return __ownerDocument__(this).implementation.hasFeature(feature, version); - }, - getElementsByTagName : function(tagname) { - // delegate to _getElementsByTagNameRecursive - // recurse childNodes - var nodelist = new NodeList(__ownerDocument__(this)); - for (var i = 0; i < this.childNodes.length; i++) { - __getElementsByTagNameRecursive__(this.childNodes.item(i), - tagname, - nodelist); - } - return nodelist; - }, - getElementsByTagNameNS : function(namespaceURI, localName) { - // delegate to _getElementsByTagNameNSRecursive - return __getElementsByTagNameNSRecursive__(this, namespaceURI, localName, - new NodeList(__ownerDocument__(this))); - }, - importNode : function(importedNode, deep) { - var i; - var importNode; - - //there is no need to perform namespace checks since everything has already gone through them - //in order to have gotten into the DOM in the first place. The following line - //turns namespace checking off in ._isValidNamespace - __ownerDocument__(this).importing = true; - - if (importedNode.nodeType == Node.ELEMENT_NODE) { - if (!__ownerDocument__(this).implementation.namespaceAware) { - // create a local Element (with the name of the importedNode) - importNode = __ownerDocument__(this).createElement(importedNode.tagName); - - // create attributes matching those of the importedNode - for(i = 0; i < importedNode.attributes.length; i++) { - importNode.setAttribute(importedNode.attributes.item(i).name, importedNode.attributes.item(i).value); - } - } else { - // create a local Element (with the name & namespaceURI of the importedNode) - importNode = __ownerDocument__(this).createElementNS(importedNode.namespaceURI, importedNode.nodeName); - - // create attributes matching those of the importedNode - for(i = 0; i < importedNode.attributes.length; i++) { - importNode.setAttributeNS(importedNode.attributes.item(i).namespaceURI, - importedNode.attributes.item(i).name, importedNode.attributes.item(i).value); - } - - // create namespace definitions matching those of the importedNode - for(i = 0; i < importedNode._namespaces.length; i++) { - importNode._namespaces[i] = __ownerDocument__(this).createNamespace(importedNode._namespaces.item(i).localName); - importNode._namespaces[i].value = importedNode._namespaces.item(i).value; - } - } - } else if (importedNode.nodeType == Node.ATTRIBUTE_NODE) { - if (!__ownerDocument__(this).implementation.namespaceAware) { - // create a local Attribute (with the name of the importedAttribute) - importNode = __ownerDocument__(this).createAttribute(importedNode.name); - } else { - // create a local Attribute (with the name & namespaceURI of the importedAttribute) - importNode = __ownerDocument__(this).createAttributeNS(importedNode.namespaceURI, importedNode.nodeName); - - // create namespace definitions matching those of the importedAttribute - for(i = 0; i < importedNode._namespaces.length; i++) { - importNode._namespaces[i] = __ownerDocument__(this).createNamespace(importedNode._namespaces.item(i).localName); - importNode._namespaces[i].value = importedNode._namespaces.item(i).value; - } - } - - // set the value of the local Attribute to match that of the importedAttribute - importNode.value = importedNode.value; - - } else if (importedNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { - // create a local DocumentFragment - importNode = __ownerDocument__(this).createDocumentFragment(); - } else if (importedNode.nodeType == Node.NAMESPACE_NODE) { - // create a local NamespaceNode (with the same name & value as the importedNode) - importNode = __ownerDocument__(this).createNamespace(importedNode.nodeName); - importNode.value = importedNode.value; - } else if (importedNode.nodeType == Node.TEXT_NODE) { - // create a local TextNode (with the same data as the importedNode) - importNode = __ownerDocument__(this).createTextNode(importedNode.data); - } else if (importedNode.nodeType == Node.CDATA_SECTION_NODE) { - // create a local CDATANode (with the same data as the importedNode) - importNode = __ownerDocument__(this).createCDATASection(importedNode.data); - } else if (importedNode.nodeType == Node.PROCESSING_INSTRUCTION_NODE) { - // create a local ProcessingInstruction (with the same target & data as the importedNode) - importNode = __ownerDocument__(this).createProcessingInstruction(importedNode.target, importedNode.data); - } else if (importedNode.nodeType == Node.COMMENT_NODE) { - // create a local Comment (with the same data as the importedNode) - importNode = __ownerDocument__(this).createComment(importedNode.data); - } else { // throw Exception if nodeType is not supported - throw(new DOMException(DOMException.NOT_SUPPORTED_ERR)); - } - - if (deep) { - // recurse childNodes - for(i = 0; i < importedNode.childNodes.length; i++) { - importNode.appendChild(__ownerDocument__(this).importNode(importedNode.childNodes.item(i), true)); - } - } - - //reset importing - __ownerDocument__(this).importing = false; - return importNode; - - }, - contains : function(node){ - while(node && node != this ){ - node = node.parentNode; - } - return !!node; - }, - compareDocumentPosition : function(b){ - //console.log("comparing document position %s %s", this, b); - var i, - length, - a = this, - parent, - aparents, - bparents; - //handle a couple simpler case first - if(a === b) { - return Node.DOCUMENT_POSITION_EQUAL; - } - if(a.ownerDocument !== b.ownerDocument) { - return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC| - Node.DOCUMENT_POSITION_FOLLOWING| - Node.DOCUMENT_POSITION_DISCONNECTED; - } - if(a.parentNode === b.parentNode){ - length = a.parentNode.childNodes.length; - for(i=0;i aparents.length){ - return Node.DOCUMENT_POSITION_FOLLOWING; - }else if(bparents.length < aparents.length){ - return Node.DOCUMENT_POSITION_PRECEDING; - }else{ - //common ancestor diverge point - if (i === 0) { - return Node.DOCUMENT_POSITION_FOLLOWING; - } else { - parent = aparents[i-1]; - } - return parent.compareDocumentPosition(bparents.pop()); - } - } - } - - return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC| - Node.DOCUMENT_POSITION_DISCONNECTED; - - }, - toString : function() { - return '[object Node]'; - } - -}); - - - -/** - * @method __getElementsByTagNameRecursive__ - implements getElementsByTagName() - * @param elem : Element - The element which are checking and then recursing into - * @param tagname : string - The name of the tag to match on. The special value "*" matches all tags - * @param nodeList : NodeList - The accumulating list of matching nodes - * - * @return : NodeList - */ -var __getElementsByTagNameRecursive__ = function (elem, tagname, nodeList) { - - if (elem.nodeType == Node.ELEMENT_NODE || elem.nodeType == Node.DOCUMENT_NODE) { - - if(elem.nodeType !== Node.DOCUMENT_NODE && - ((elem.nodeName.toUpperCase() == tagname.toUpperCase()) || - (tagname == "*")) ){ - // add matching node to nodeList - __appendChild__(nodeList, elem); - } - - // recurse childNodes - for(var i = 0; i < elem.childNodes.length; i++) { - nodeList = __getElementsByTagNameRecursive__(elem.childNodes.item(i), tagname, nodeList); - } - } - - return nodeList; -}; - -/** - * @method __getElementsByTagNameNSRecursive__ - * implements getElementsByTagName() - * - * @param elem : Element - The element which are checking and then recursing into - * @param namespaceURI : string - the namespace URI of the required node - * @param localName : string - the local name of the required node - * @param nodeList : NodeList - The accumulating list of matching nodes - * - * @return : NodeList - */ -var __getElementsByTagNameNSRecursive__ = function(elem, namespaceURI, localName, nodeList) { - if (elem.nodeType == Node.ELEMENT_NODE || elem.nodeType == Node.DOCUMENT_NODE) { - - if (((elem.namespaceURI == namespaceURI) || (namespaceURI == "*")) && - ((elem.localName == localName) || (localName == "*"))) { - // add matching node to nodeList - __appendChild__(nodeList, elem); - } - - // recurse childNodes - for(var i = 0; i < elem.childNodes.length; i++) { - nodeList = __getElementsByTagNameNSRecursive__( - elem.childNodes.item(i), namespaceURI, localName, nodeList); - } - } - - return nodeList; -}; - -/** - * @method __isAncestor__ - returns true if node is ancestor of target - * @param target : Node - The node we are using as context - * @param node : Node - The candidate ancestor node - * @return : boolean - */ -var __isAncestor__ = function(target, node) { - // if this node matches, return true, - // otherwise recurse up (if there is a parentNode) - return ((target == node) || ((target.parentNode) && (__isAncestor__(target.parentNode, node)))); -}; - - - -var __recursivelyGatherText__ = function(aNode) { - var accumulateText = "", - idx, - node; - for (idx=0;idx < aNode.childNodes.length;idx++){ - node = aNode.childNodes.item(idx); - if(node.nodeType == Node.TEXT_NODE) - accumulateText += node.data; - else - accumulateText += __recursivelyGatherText__(node); - } - return accumulateText; -}; - -/** - * function __escapeXML__ - * @param str : string - The string to be escaped - * @return : string - The escaped string - */ -var escAmpRegEx = /&(?!(amp;|lt;|gt;|quot|apos;))/g; -var escLtRegEx = //g; -var quotRegEx = /"/g; -var aposRegEx = /'/g; - -function __escapeXML__(str) { - str = str.replace(escAmpRegEx, "&"). - replace(escLtRegEx, "<"). - replace(escGtRegEx, ">"). - replace(quotRegEx, """). - replace(aposRegEx, "'"); - - return str; -}; - -/* -function __escapeHTML5__(str) { - str = str.replace(escAmpRegEx, "&"). - replace(escLtRegEx, "<"). - replace(escGtRegEx, ">"); - - return str; -}; -function __escapeHTML5Atribute__(str) { - str = str.replace(escAmpRegEx, "&"). - replace(escLtRegEx, "<"). - replace(escGtRegEx, ">"). - replace(quotRegEx, """). - replace(aposRegEx, "'"); - - return str; -}; -*/ - -/** - * function __unescapeXML__ - * @param str : string - The string to be unescaped - * @return : string - The unescaped string - */ -var unescAmpRegEx = /&/g; -var unescLtRegEx = /</g; -var unescGtRegEx = />/g; -var unquotRegEx = /"/g; -var unaposRegEx = /'/g; -function __unescapeXML__(str) { - str = str.replace(unescAmpRegEx, "&"). - replace(unescLtRegEx, "<"). - replace(unescGtRegEx, ">"). - replace(unquotRegEx, "\""). - replace(unaposRegEx, "'"); - - return str; -}; - -/** - * @class NamedNodeMap - - * used to represent collections of nodes that can be accessed by name - * typically a set of Element attributes - * - * @extends NodeList - - * note W3C spec says that this is not the case, but we need an item() - * method identical to NodeList's, so why not? - * @param ownerDocument : Document - the ownerDocument - * @param parentNode : Node - the node that the NamedNodeMap is attached to (or null) - */ -NamedNodeMap = function(ownerDocument, parentNode) { - NodeList.apply(this, arguments); - __setArray__(this, []); -}; -NamedNodeMap.prototype = new NodeList(); -__extend__(NamedNodeMap.prototype, { - add: function(name){ - this[this.length] = name; - }, - getNamedItem : function(name) { - var ret = null; - //console.log('NamedNodeMap getNamedItem %s', name); - // test that Named Node exists - var itemIndex = __findNamedItemIndex__(this, name); - - if (itemIndex > -1) { - // found it! - ret = this[itemIndex]; - } - // if node is not found, default value null is returned - return ret; - }, - setNamedItem : function(arg) { - //console.log('setNamedItem %s', arg); - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if arg was not created by this Document - if (this.ownerDocument != arg.ownerDocument) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if DOMNamedNodeMap is readonly - if (this._readonly || (this.parentNode && this.parentNode._readonly)) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if arg is already an attribute of another Element object - if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { - throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); - } - } - - //console.log('setNamedItem __findNamedItemIndex__ '); - // get item index - var itemIndex = __findNamedItemIndex__(this, arg.name); - var ret = null; - - //console.log('setNamedItem __findNamedItemIndex__ %s', itemIndex); - if (itemIndex > -1) { // found it! - ret = this[itemIndex]; // use existing Attribute - - // throw Exception if DOMAttr is readonly - if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } else { - this[itemIndex] = arg; // over-write existing NamedNode - this[arg.name.toLowerCase()] = arg; - } - } else { - // add new NamedNode - //console.log('setNamedItem add new named node map (by index)'); - Array.prototype.push.apply(this, [arg]); - //console.log('setNamedItem add new named node map (by name) %s %s', arg, arg.name); - this[arg.name] = arg; - //console.log('finsished setNamedItem add new named node map (by name) %s', arg.name); - - } - - //console.log('setNamedItem parentNode'); - arg.ownerElement = this.parentNode; // update ownerElement - // return old node or new node - //console.log('setNamedItem exit'); - return ret; - }, - removeNamedItem : function(name) { - var ret = null; - // test for exceptions - // throw Exception if NamedNodeMap is readonly - if (__ownerDocument__(this).implementation.errorChecking && - (this._readonly || (this.parentNode && this.parentNode._readonly))) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get item index - var itemIndex = __findNamedItemIndex__(this, name); - - // throw Exception if there is no node named name in this map - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // get Node - var oldNode = this[itemIndex]; - //this[oldNode.name] = undefined; - - // throw Exception if Node is readonly - if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // return removed node - return __removeChild__(this, itemIndex); - }, - getNamedItemNS : function(namespaceURI, localName) { - var ret = null; - - // test that Named Node exists - var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName); - - if (itemIndex > -1) { - // found it! return NamedNode - ret = this[itemIndex]; - } - // if node is not found, default value null is returned - return ret; - }, - setNamedItemNS : function(arg) { - //console.log('setNamedItemNS %s', arg); - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if NamedNodeMap is readonly - if (this._readonly || (this.parentNode && this.parentNode._readonly)) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if arg was not created by this Document - if (__ownerDocument__(this) != __ownerDocument__(arg)) { - throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); - } - - // throw Exception if arg is already an attribute of another Element object - if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { - throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); - } - } - - // get item index - var itemIndex = __findNamedItemNSIndex__(this, arg.namespaceURI, arg.localName); - var ret = null; - - if (itemIndex > -1) { - // found it! - // use existing Attribute - ret = this[itemIndex]; - // throw Exception if Attr is readonly - if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } else { - // over-write existing NamedNode - this[itemIndex] = arg; - } - }else { - // add new NamedNode - Array.prototype.push.apply(this, [arg]); - } - arg.ownerElement = this.parentNode; - - // return old node or null - return ret; - //console.log('finished setNamedItemNS %s', arg); - }, - removeNamedItemNS : function(namespaceURI, localName) { - var ret = null; - - // test for exceptions - // throw Exception if NamedNodeMap is readonly - if (__ownerDocument__(this).implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get item index - var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName); - - // throw Exception if there is no matching node in this map - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - // get Node - var oldNode = this[itemIndex]; - - // throw Exception if Node is readonly - if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - return __removeChild__(this, itemIndex); // return removed node - }, - get xml() { - var ret = ""; - - // create string containing concatenation of all (but last) Attribute string values (separated by spaces) - for (var i=0; i < this.length -1; i++) { - ret += this[i].xml +" "; - } - - // add last Attribute to string (without trailing space) - if (this.length > 0) { - ret += this[this.length -1].xml; - } - - return ret; - }, - toString : function(){ - return "[object NamedNodeMap]"; - } - -}); - -/** - * @method __findNamedItemIndex__ - * find the item index of the node with the specified name - * - * @param name : string - the name of the required node - * @param isnsmap : if its a NamespaceNodeMap - * @return : int - */ -var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) { - var ret = -1; - // loop through all nodes - for (var i=0; i -1) { - // found it! - ret = true; - } - // if node is not found, default value false is returned - return ret; -} - -/** - * @method __hasAttributeNS__ - * Returns true if specified node exists - * - * @param namespaceURI : string - the namespace URI of the required node - * @param localName : string - the local name of the required node - * @return : boolean - */ -var __hasAttributeNS__ = function(namednodemap, namespaceURI, localName) { - var ret = false; - // test that Named Node exists - var itemIndex = __findNamedItemNSIndex__(namednodemap, namespaceURI, localName); - if (itemIndex > -1) { - // found it! - ret = true; - } - // if node is not found, default value false is returned - return ret; -} - -/** - * @method __cloneNamedNodes__ - * Returns a NamedNodeMap containing clones of the Nodes in this NamedNodeMap - * - * @param parentNode : Node - the new parent of the cloned NodeList - * @param isnsmap : bool - is this a NamespaceNodeMap - * @return NamedNodeMap containing clones of the Nodes in this NamedNodeMap - */ -var __cloneNamedNodes__ = function(namednodemap, parentNode, isnsmap) { - var cloneNamedNodeMap = isnsmap? - new NamespaceNodeMap(namednodemap.ownerDocument, parentNode): - new NamedNodeMap(namednodemap.ownerDocument, parentNode); - - // create list containing clones of all children - for (var i=0; i < namednodemap.length; i++) { - __appendChild__(cloneNamedNodeMap, namednodemap[i].cloneNode(false)); - } - - return cloneNamedNodeMap; -}; - - -/** - * @class NamespaceNodeMap - - * used to represent collections of namespace nodes that can be - * accessed by name typically a set of Element attributes - * - * @extends NamedNodeMap - * - * @param ownerDocument : Document - the ownerDocument - * @param parentNode : Node - the node that the NamespaceNodeMap is attached to (or null) - */ -var NamespaceNodeMap = function(ownerDocument, parentNode) { - this.NamedNodeMap = NamedNodeMap; - this.NamedNodeMap(ownerDocument, parentNode); - __setArray__(this, []); -}; -NamespaceNodeMap.prototype = new NamedNodeMap(); -__extend__(NamespaceNodeMap.prototype, { - get xml() { - var ret = "", - ns, - ind; - // identify namespaces declared local to this Element (ie, not inherited) - for (ind = 0; ind < this.length; ind++) { - // if namespace declaration does not exist in the containing node's, parentNode's namespaces - ns = null; - try { - var ns = this.parentNode.parentNode._namespaces. - getNamedItem(this[ind].localName); - }catch (e) { - //breaking to prevent default namespace being inserted into return value - break; - } - if (!(ns && (""+ ns.nodeValue == ""+ this[ind].nodeValue))) { - // display the namespace declaration - ret += this[ind].xml +" "; - } - } - return ret; - } -}); - -/** - * @class Namespace - - * The Namespace interface represents an namespace in an Element object - * - * @param ownerDocument : The Document object associated with this node. - */ -Namespace = function(ownerDocument) { - Node.apply(this, arguments); - // the name of this attribute - this.name = ""; - - // If this attribute was explicitly given a value in the original document, - // this is true; otherwise, it is false. - // Note that the implementation is in charge of this attribute, not the user. - // If the user changes the value of the attribute (even if it ends up having - // the same value as the default value) then the specified flag is - // automatically flipped to true - this.specified = false; -}; -Namespace.prototype = new Node(); -__extend__(Namespace.prototype, { - get value(){ - // the value of the attribute is returned as a string - return this.nodeValue; - }, - set value(value){ - this.nodeValue = value+''; - }, - get nodeType(){ - return Node.NAMESPACE_NODE; - }, - get xml(){ - var ret = ""; - - // serialize Namespace Declaration - if (this.nodeName != "") { - ret += this.nodeName +"=\""+ __escapeXML__(this.nodeValue) +"\""; - } - else { // handle default namespace - ret += "xmlns=\""+ __escapeXML__(this.nodeValue) +"\""; - } - - return ret; - }, - toString: function(){ - return '[object Namespace]'; - } -}); - - -/** - * @class CharacterData - parent abstract class for Text and Comment - * @extends Node - * @param ownerDocument : The Document object associated with this node. - */ -CharacterData = function(ownerDocument) { - Node.apply(this, arguments); -}; -CharacterData.prototype = new Node(); -__extend__(CharacterData.prototype,{ - get data(){ - return this.nodeValue; - }, - set data(data){ - this.nodeValue = data; - }, - get textContent(){ - return this.nodeValue; - }, - set textContent(newText){ - this.nodeValue = newText; - }, - get length(){return this.nodeValue.length;}, - appendData: function(arg){ - // throw Exception if CharacterData is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - // append data - this.data = "" + this.data + arg; - }, - deleteData: function(offset, count){ - // throw Exception if CharacterData is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - if (this.data) { - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length) || (count < 0))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // delete data - if(!count || (offset + count) > this.data.length) { - this.data = this.data.substring(0, offset); - }else { - this.data = this.data.substring(0, offset). - concat(this.data.substring(offset + count)); - } - } - }, - insertData: function(offset, arg){ - // throw Exception if CharacterData is readonly - if(__ownerDocument__(this).implementation.errorChecking && this._readonly){ - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - if(this.data){ - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // insert data - this.data = this.data.substring(0, offset).concat(arg, this.data.substring(offset)); - }else { - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && (offset !== 0)) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // set data - this.data = arg; - } - }, - replaceData: function(offset, count, arg){ - // throw Exception if CharacterData is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - if (this.data) { - // throw Exception if offset is negative or greater than the data length, - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length) || (count < 0))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - - // replace data - this.data = this.data.substring(0, offset). - concat(arg, this.data.substring(offset + count)); - }else { - // set data - this.data = arg; - } - }, - substringData: function(offset, count){ - var ret = null; - if (this.data) { - // throw Exception if offset is negative or greater than the data length, - // or the count is negative - if (__ownerDocument__(this).implementation.errorChecking && - ((offset < 0) || (offset > this.data.length) || (count < 0))) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - // if count is not specified - if (!count) { - ret = this.data.substring(offset); // default to 'end of string' - }else{ - ret = this.data.substring(offset, offset + count); - } - } - return ret; - }, - toString : function(){ - return "[object CharacterData]"; - } -}); - -/** - * @class Text - * The Text interface represents the textual content (termed - * character data in XML) of an Element or Attr. - * If there is no markup inside an element's content, the text is - * contained in a single object implementing the Text interface that - * is the only child of the element. If there is markup, it is - * parsed into a list of elements and Text nodes that form the - * list of children of the element. - * @extends CharacterData - * @param ownerDocument The Document object associated with this node. - */ -Text = function(ownerDocument) { - CharacterData.apply(this, arguments); - this.nodeName = "#text"; -}; -Text.prototype = new CharacterData(); -__extend__(Text.prototype,{ - get localName(){ - return null; - }, - // Breaks this Text node into two Text nodes at the specified offset, - // keeping both in the tree as siblings. This node then only contains - // all the content up to the offset point. And a new Text node, which - // is inserted as the next sibling of this node, contains all the - // content at and after the offset point. - splitText : function(offset) { - var data, - inode; - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Node is readonly - if (this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - // throw Exception if offset is negative or greater than the data length, - if ((offset < 0) || (offset > this.data.length)) { - throw(new DOMException(DOMException.INDEX_SIZE_ERR)); - } - } - if (this.parentNode) { - // get remaining string (after offset) - data = this.substringData(offset); - // create new TextNode with remaining string - inode = __ownerDocument__(this).createTextNode(data); - // attach new TextNode - if (this.nextSibling) { - this.parentNode.insertBefore(inode, this.nextSibling); - } else { - this.parentNode.appendChild(inode); - } - // remove remaining string from original TextNode - this.deleteData(offset); - } - return inode; - }, - get nodeType(){ - return Node.TEXT_NODE; - }, - get xml(){ - return __escapeXML__(""+ this.nodeValue); - }, - toString: function(){ - return "[object Text]"; - } -}); - -/** - * @class CDATASection - * CDATA sections are used to escape blocks of text containing - * characters that would otherwise be regarded as markup. - * The only delimiter that is recognized in a CDATA section is - * the "\]\]\>" string that ends the CDATA section - * @extends Text - * @param ownerDocument : The Document object associated with this node. - */ -CDATASection = function(ownerDocument) { - Text.apply(this, arguments); - this.nodeName = '#cdata-section'; -}; -CDATASection.prototype = new Text(); -__extend__(CDATASection.prototype,{ - get nodeType(){ - return Node.CDATA_SECTION_NODE; - }, - get xml(){ - return ""; - }, - toString : function(){ - return "[object CDATASection]"; - } -}); -/** - * @class Comment - * This represents the content of a comment, i.e., all the - * characters between the starting '' - * @extends CharacterData - * @param ownerDocument : The Document object associated with this node. - */ -Comment = function(ownerDocument) { - CharacterData.apply(this, arguments); - this.nodeName = "#comment"; -}; -Comment.prototype = new CharacterData(); -__extend__(Comment.prototype, { - get localName(){ - return null; - }, - get nodeType(){ - return Node.COMMENT_NODE; - }, - get xml(){ - return ""; - }, - toString : function(){ - return "[object Comment]"; - } -}); - - -/** - * @author envjs team - * @param {Document} onwnerDocument - */ -DocumentType = function(ownerDocument) { - Node.apply(this, arguments); - this.systemId = null; - this.publicId = null; -}; -DocumentType.prototype = new Node(); -__extend__({ - get name(){ - return this.nodeName; - }, - get entities(){ - return null; - }, - get internalSubsets(){ - return null; - }, - get notations(){ - return null; - }, - toString : function(){ - return "[object DocumentType]"; - } -}); - -/** - * @class Attr - * The Attr interface represents an attribute in an Element object - * @extends Node - * @param ownerDocument : The Document object associated with this node. - */ -Attr = function(ownerDocument) { - Node.apply(this, arguments); - // set when Attr is added to NamedNodeMap - this.ownerElement = null; - //TODO: our implementation of Attr is incorrect because we don't - // treat the value of the attribute as a child text node. -}; -Attr.prototype = new Node(); -__extend__(Attr.prototype, { - // the name of this attribute - get name(){ - return this.nodeName; - }, - // the value of the attribute is returned as a string - get value(){ - return this.nodeValue||''; - }, - set value(value){ - // throw Exception if Attribute is readonly - if (__ownerDocument__(this).implementation.errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - // delegate to node - this.nodeValue = value; - }, - get textContent(){ - return this.nodeValue; - }, - set textContent(newText){ - this.nodeValue = newText; - }, - get specified(){ - return (this !== null && this !== undefined); - }, - get nodeType(){ - return Node.ATTRIBUTE_NODE; - }, - get xml() { - if (this.nodeValue) { - return __escapeXML__(this.nodeValue+""); - } else { - return ''; - } - }, - toString : function() { - return '[object Attr]'; - } -}); - - -/** - * @class Element - - * By far the vast majority of objects (apart from text) - * that authors encounter when traversing a document are - * Element nodes. - * @extends Node - * @param ownerDocument : The Document object associated with this node. - */ -Element = function(ownerDocument) { - Node.apply(this, arguments); - this.attributes = new NamedNodeMap(this.ownerDocument, this); -}; -Element.prototype = new Node(); -__extend__(Element.prototype, { - // The name of the element. - get tagName(){ - return this.nodeName; - }, - - getAttribute: function(name) { - var ret = null; - // if attribute exists, use it - var attr = this.attributes.getNamedItem(name); - if (attr) { - ret = attr.value; - } - // if Attribute exists, return its value, otherwise, return null - return ret; - }, - setAttribute : function (name, value) { - // if attribute exists, use it - var attr = this.attributes.getNamedItem(name); - //console.log('attr %s', attr); - //I had to add this check because as the script initializes - //the id may be set in the constructor, and the html element - //overrides the id property with a getter/setter. - if(__ownerDocument__(this)){ - if (attr===null||attr===undefined) { - // otherwise create it - attr = __ownerDocument__(this).createAttribute(name); - //console.log('attr %s', attr); - } - - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Attribute is readonly - if (attr._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if the value string contains an illegal character - if (!__isValidString__(value+'')) { - throw(new DOMException(DOMException.INVALID_CHARACTER_ERR)); - } - } - - // assign values to properties (and aliases) - attr.value = value + ''; - - // add/replace Attribute in NamedNodeMap - this.attributes.setNamedItem(attr); - //console.log('element setNamedItem %s', attr); - }else{ - console.warn('Element has no owner document '+this.tagName+ - '\n\t cant set attribute ' + name + ' = '+value ); - } - }, - removeAttribute : function removeAttribute(name) { - // delegate to NamedNodeMap.removeNamedItem - return this.attributes.removeNamedItem(name); - }, - getAttributeNode : function getAttributeNode(name) { - // delegate to NamedNodeMap.getNamedItem - return this.attributes.getNamedItem(name); - }, - setAttributeNode: function(newAttr) { - // if this Attribute is an ID - if (__isIdDeclaration__(newAttr.name)) { - this.id = newAttr.value; // cache ID for getElementById() - } - // delegate to NamedNodeMap.setNamedItem - return this.attributes.setNamedItem(newAttr); - }, - removeAttributeNode: function(oldAttr) { - // throw Exception if Attribute is readonly - if (__ownerDocument__(this).implementation.errorChecking && oldAttr._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // get item index - var itemIndex = this.attributes._findItemIndex(oldAttr._id); - - // throw Exception if node does not exist in this map - if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) { - throw(new DOMException(DOMException.NOT_FOUND_ERR)); - } - - return this.attributes._removeChild(itemIndex); - }, - getAttributeNS : function(namespaceURI, localName) { - var ret = ""; - // delegate to NAmedNodeMap.getNamedItemNS - var attr = this.attributes.getNamedItemNS(namespaceURI, localName); - if (attr) { - ret = attr.value; - } - return ret; // if Attribute exists, return its value, otherwise return "" - }, - setAttributeNS : function(namespaceURI, qualifiedName, value) { - // call NamedNodeMap.getNamedItem - //console.log('setAttributeNS %s %s %s', namespaceURI, qualifiedName, value); - var attr = this.attributes.getNamedItem(namespaceURI, qualifiedName); - - if (!attr) { // if Attribute exists, use it - // otherwise create it - attr = __ownerDocument__(this).createAttributeNS(namespaceURI, qualifiedName); - } - - value = '' + value; - - // test for exceptions - if (__ownerDocument__(this).implementation.errorChecking) { - // throw Exception if Attribute is readonly - if (attr._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - - // throw Exception if the Namespace is invalid - if (!__isValidNamespace__(this.ownerDocument, namespaceURI, qualifiedName, true)) { - throw(new DOMException(DOMException.NAMESPACE_ERR)); - } - - // throw Exception if the value string contains an illegal character - if (!__isValidString__(value)) { - throw(new DOMException(DOMException.INVALID_CHARACTER_ERR)); - } - } - - // if this Attribute is an ID - //if (__isIdDeclaration__(name)) { - // this.id = value; - //} - - // assign values to properties (and aliases) - attr.value = value; - attr.nodeValue = value; - - // delegate to NamedNodeMap.setNamedItem - this.attributes.setNamedItemNS(attr); - }, - removeAttributeNS : function(namespaceURI, localName) { - // delegate to NamedNodeMap.removeNamedItemNS - return this.attributes.removeNamedItemNS(namespaceURI, localName); - }, - getAttributeNodeNS : function(namespaceURI, localName) { - // delegate to NamedNodeMap.getNamedItemNS - return this.attributes.getNamedItemNS(namespaceURI, localName); - }, - setAttributeNodeNS : function(newAttr) { - // if this Attribute is an ID - if ((newAttr.prefix == "") && __isIdDeclaration__(newAttr.name)) { - this.id = newAttr.value+''; // cache ID for getElementById() - } - - // delegate to NamedNodeMap.setNamedItemNS - return this.attributes.setNamedItemNS(newAttr); - }, - hasAttribute : function(name) { - // delegate to NamedNodeMap._hasAttribute - return __hasAttribute__(this.attributes,name); - }, - hasAttributeNS : function(namespaceURI, localName) { - // delegate to NamedNodeMap._hasAttributeNS - return __hasAttributeNS__(this.attributes, namespaceURI, localName); - }, - get nodeType(){ - return Node.ELEMENT_NODE; - }, - get xml() { - var ret = "", - ns = "", - attrs, - attrstring, - i; - - // serialize namespace declarations - if (this.namespaceURI ){ - if((this === this.ownerDocument.documentElement) || - (!this.parentNode)|| - (this.parentNode && (this.parentNode.namespaceURI !== this.namespaceURI))) { - ns = ' xmlns' + (this.prefix?(':'+this.prefix):'') + - '="' + this.namespaceURI + '"'; - } - } - - // serialize Attribute declarations - attrs = this.attributes; - attrstring = ""; - for(i=0;i< attrs.length;i++){ - if(attrs[i].name.match('xmlns:')) { - attrstring += " "+attrs[i].name+'="'+attrs[i].xml+'"'; - } - } - for(i=0;i< attrs.length;i++){ - if(!attrs[i].name.match('xmlns:')) { - attrstring += " "+attrs[i].name+'="'+attrs[i].xml+'"'; - } - } - - if(this.hasChildNodes()){ - // serialize this Element - ret += "<" + this.tagName + ns + attrstring +">"; - ret += this.childNodes.xml; - ret += ""; - }else{ - ret += "<" + this.tagName + ns + attrstring +"/>"; - } - - return ret; - }, - toString : function(){ - return '[object Element]'; - } -}); -/** - * @class DOMException - raised when an operation is impossible to perform - * @author Jon van Noort (jon@webarcana.com.au) - * @param code : int - the exception code (one of the DOMException constants) - */ -DOMException = function(code) { - this.code = code; -}; - -// DOMException constants -// Introduced in DOM Level 1: -DOMException.INDEX_SIZE_ERR = 1; -DOMException.DOMSTRING_SIZE_ERR = 2; -DOMException.HIERARCHY_REQUEST_ERR = 3; -DOMException.WRONG_DOCUMENT_ERR = 4; -DOMException.INVALID_CHARACTER_ERR = 5; -DOMException.NO_DATA_ALLOWED_ERR = 6; -DOMException.NO_MODIFICATION_ALLOWED_ERR = 7; -DOMException.NOT_FOUND_ERR = 8; -DOMException.NOT_SUPPORTED_ERR = 9; -DOMException.INUSE_ATTRIBUTE_ERR = 10; - -// Introduced in DOM Level 2: -DOMException.INVALID_STATE_ERR = 11; -DOMException.SYNTAX_ERR = 12; -DOMException.INVALID_MODIFICATION_ERR = 13; -DOMException.NAMESPACE_ERR = 14; -DOMException.INVALID_ACCESS_ERR = 15; - -/** - * @class DocumentFragment - - * DocumentFragment is a "lightweight" or "minimal" Document object. - * @extends Node - * @param ownerDocument : The Document object associated with this node. - */ -DocumentFragment = function(ownerDocument) { - Node.apply(this, arguments); - this.nodeName = "#document-fragment"; -}; -DocumentFragment.prototype = new Node(); -__extend__(DocumentFragment.prototype,{ - get nodeType(){ - return Node.DOCUMENT_FRAGMENT_NODE; - }, - get xml(){ - var xml = "", - count = this.childNodes.length; - - // create string concatenating the serialized ChildNodes - for (var i = 0; i < count; i++) { - xml += this.childNodes.item(i).xml; - } - - return xml; - }, - toString : function(){ - return "[object DocumentFragment]"; - }, - get localName(){ - return null; - } -}); - - -/** - * @class ProcessingInstruction - - * The ProcessingInstruction interface represents a - * "processing instruction", used in XML as a way to - * keep processor-specific information in the text of - * the document - * @extends Node - * @author Jon van Noort (jon@webarcana.com.au) - * @param ownerDocument : The Document object associated with this node. - */ -ProcessingInstruction = function(ownerDocument) { - Node.apply(this, arguments); -}; -ProcessingInstruction.prototype = new Node(); -__extend__(ProcessingInstruction.prototype, { - get data(){ - return this.nodeValue; - }, - set data(data){ - // throw Exception if Node is readonly - if (__ownerDocument__(this).errorChecking && this._readonly) { - throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); - } - this.nodeValue = data; - }, - get textContent(){ - return this.data; - }, - get localName(){ - return null; - }, - get target(){ - // The target of this processing instruction. - // XML defines this as being the first token following the markup that begins the processing instruction. - // The content of this processing instruction. - return this.nodeName; - }, - set target(value){ - // The target of this processing instruction. - // XML defines this as being the first token following the markup that begins the processing instruction. - // The content of this processing instruction. - this.nodeName = value; - }, - get nodeType(){ - return Node.PROCESSING_INSTRUCTION_NODE; - }, - get xml(){ - return ""; - }, - toString : function(){ - return "[object ProcessingInstruction]"; - } -}); - - -/** - * @author envjs team - */ - -Entity = function() { - throw new Error("Entity Not Implemented" ); -}; - -Entity.constants = { - // content taken from W3C "HTML 4.01 Specification" - // "W3C Recommendation 24 December 1999" - - nbsp: "\u00A0", - iexcl: "\u00A1", - cent: "\u00A2", - pound: "\u00A3", - curren: "\u00A4", - yen: "\u00A5", - brvbar: "\u00A6", - sect: "\u00A7", - uml: "\u00A8", - copy: "\u00A9", - ordf: "\u00AA", - laquo: "\u00AB", - not: "\u00AC", - shy: "\u00AD", - reg: "\u00AE", - macr: "\u00AF", - deg: "\u00B0", - plusmn: "\u00B1", - sup2: "\u00B2", - sup3: "\u00B3", - acute: "\u00B4", - micro: "\u00B5", - para: "\u00B6", - middot: "\u00B7", - cedil: "\u00B8", - sup1: "\u00B9", - ordm: "\u00BA", - raquo: "\u00BB", - frac14: "\u00BC", - frac12: "\u00BD", - frac34: "\u00BE", - iquest: "\u00BF", - Agrave: "\u00C0", - Aacute: "\u00C1", - Acirc: "\u00C2", - Atilde: "\u00C3", - Auml: "\u00C4", - Aring: "\u00C5", - AElig: "\u00C6", - Ccedil: "\u00C7", - Egrave: "\u00C8", - Eacute: "\u00C9", - Ecirc: "\u00CA", - Euml: "\u00CB", - Igrave: "\u00CC", - Iacute: "\u00CD", - Icirc: "\u00CE", - Iuml: "\u00CF", - ETH: "\u00D0", - Ntilde: "\u00D1", - Ograve: "\u00D2", - Oacute: "\u00D3", - Ocirc: "\u00D4", - Otilde: "\u00D5", - Ouml: "\u00D6", - times: "\u00D7", - Oslash: "\u00D8", - Ugrave: "\u00D9", - Uacute: "\u00DA", - Ucirc: "\u00DB", - Uuml: "\u00DC", - Yacute: "\u00DD", - THORN: "\u00DE", - szlig: "\u00DF", - agrave: "\u00E0", - aacute: "\u00E1", - acirc: "\u00E2", - atilde: "\u00E3", - auml: "\u00E4", - aring: "\u00E5", - aelig: "\u00E6", - ccedil: "\u00E7", - egrave: "\u00E8", - eacute: "\u00E9", - ecirc: "\u00EA", - euml: "\u00EB", - igrave: "\u00EC", - iacute: "\u00ED", - icirc: "\u00EE", - iuml: "\u00EF", - eth: "\u00F0", - ntilde: "\u00F1", - ograve: "\u00F2", - oacute: "\u00F3", - ocirc: "\u00F4", - otilde: "\u00F5", - ouml: "\u00F6", - divide: "\u00F7", - oslash: "\u00F8", - ugrave: "\u00F9", - uacute: "\u00FA", - ucirc: "\u00FB", - uuml: "\u00FC", - yacute: "\u00FD", - thorn: "\u00FE", - yuml: "\u00FF", - fnof: "\u0192", - Alpha: "\u0391", - Beta: "\u0392", - Gamma: "\u0393", - Delta: "\u0394", - Epsilon: "\u0395", - Zeta: "\u0396", - Eta: "\u0397", - Theta: "\u0398", - Iota: "\u0399", - Kappa: "\u039A", - Lambda: "\u039B", - Mu: "\u039C", - Nu: "\u039D", - Xi: "\u039E", - Omicron: "\u039F", - Pi: "\u03A0", - Rho: "\u03A1", - Sigma: "\u03A3", - Tau: "\u03A4", - Upsilon: "\u03A5", - Phi: "\u03A6", - Chi: "\u03A7", - Psi: "\u03A8", - Omega: "\u03A9", - alpha: "\u03B1", - beta: "\u03B2", - gamma: "\u03B3", - delta: "\u03B4", - epsilon: "\u03B5", - zeta: "\u03B6", - eta: "\u03B7", - theta: "\u03B8", - iota: "\u03B9", - kappa: "\u03BA", - lambda: "\u03BB", - mu: "\u03BC", - nu: "\u03BD", - xi: "\u03BE", - omicron: "\u03BF", - pi: "\u03C0", - rho: "\u03C1", - sigmaf: "\u03C2", - sigma: "\u03C3", - tau: "\u03C4", - upsilon: "\u03C5", - phi: "\u03C6", - chi: "\u03C7", - psi: "\u03C8", - omega: "\u03C9", - thetasym: "\u03D1", - upsih: "\u03D2", - piv: "\u03D6", - bull: "\u2022", - hellip: "\u2026", - prime: "\u2032", - Prime: "\u2033", - oline: "\u203E", - frasl: "\u2044", - weierp: "\u2118", - image: "\u2111", - real: "\u211C", - trade: "\u2122", - alefsym: "\u2135", - larr: "\u2190", - uarr: "\u2191", - rarr: "\u2192", - darr: "\u2193", - harr: "\u2194", - crarr: "\u21B5", - lArr: "\u21D0", - uArr: "\u21D1", - rArr: "\u21D2", - dArr: "\u21D3", - hArr: "\u21D4", - forall: "\u2200", - part: "\u2202", - exist: "\u2203", - empty: "\u2205", - nabla: "\u2207", - isin: "\u2208", - notin: "\u2209", - ni: "\u220B", - prod: "\u220F", - sum: "\u2211", - minus: "\u2212", - lowast: "\u2217", - radic: "\u221A", - prop: "\u221D", - infin: "\u221E", - ang: "\u2220", - and: "\u2227", - or: "\u2228", - cap: "\u2229", - cup: "\u222A", - intXX: "\u222B", - there4: "\u2234", - sim: "\u223C", - cong: "\u2245", - asymp: "\u2248", - ne: "\u2260", - equiv: "\u2261", - le: "\u2264", - ge: "\u2265", - sub: "\u2282", - sup: "\u2283", - nsub: "\u2284", - sube: "\u2286", - supe: "\u2287", - oplus: "\u2295", - otimes: "\u2297", - perp: "\u22A5", - sdot: "\u22C5", - lceil: "\u2308", - rceil: "\u2309", - lfloor: "\u230A", - rfloor: "\u230B", - lang: "\u2329", - rang: "\u232A", - loz: "\u25CA", - spades: "\u2660", - clubs: "\u2663", - hearts: "\u2665", - diams: "\u2666", - quot: "\u0022", - amp: "\u0026", - lt: "\u003C", - gt: "\u003E", - OElig: "\u0152", - oelig: "\u0153", - Scaron: "\u0160", - scaron: "\u0161", - Yuml: "\u0178", - circ: "\u02C6", - tilde: "\u02DC", - ensp: "\u2002", - emsp: "\u2003", - thinsp: "\u2009", - zwnj: "\u200C", - zwj: "\u200D", - lrm: "\u200E", - rlm: "\u200F", - ndash: "\u2013", - mdash: "\u2014", - lsquo: "\u2018", - rsquo: "\u2019", - sbquo: "\u201A", - ldquo: "\u201C", - rdquo: "\u201D", - bdquo: "\u201E", - dagger: "\u2020", - Dagger: "\u2021", - permil: "\u2030", - lsaquo: "\u2039", - rsaquo: "\u203A", - euro: "\u20AC", - - // non-standard entities - apos: "'" -}; - -/** - * @author envjs team - */ - -EntityReference = function() { - throw new Error("EntityReference Not Implemented" ); -}; - -/** - * @class DOMImplementation - - * provides a number of methods for performing operations - * that are independent of any particular instance of the - * document object model. - * - * @author Jon van Noort (jon@webarcana.com.au) - */ -DOMImplementation = function() { - this.preserveWhiteSpace = false; // by default, ignore whitespace - this.namespaceAware = true; // by default, handle namespaces - this.errorChecking = true; // by default, test for exceptions -}; - -__extend__(DOMImplementation.prototype,{ - // @param feature : string - The package name of the feature to test. - // the legal only values are "XML" and "CORE" (case-insensitive). - // @param version : string - This is the version number of the package - // name to test. In Level 1, this is the string "1.0".* - // @return : boolean - hasFeature : function(feature, version) { - var ret = false; - if (feature.toLowerCase() == "xml") { - ret = (!version || (version == "1.0") || (version == "2.0")); - } - else if (feature.toLowerCase() == "core") { - ret = (!version || (version == "2.0")); - } - else if (feature == "http://www.w3.org/TR/SVG11/feature#BasicStructure") { - ret = (version == "1.1"); - } - return ret; - }, - createDocumentType : function(qname, publicId, systemId){ - var doctype = new DocumentType(); - doctype.nodeName = qname?qname.toUpperCase():null; - doctype.publicId = publicId?publicId:null; - doctype.systemId = systemId?systemId:null; - return doctype; - }, - createDocument : function(nsuri, qname, doctype){ - - var doc = null, documentElement; - - doc = new Document(this, null); - if(doctype){ - doc.doctype = doctype; - } - - if(nsuri && qname){ - documentElement = doc.createElementNS(nsuri, qname); - }else if(qname){ - documentElement = doc.createElement(qname); - } - if(documentElement){ - doc.appendChild(documentElement); - } - return doc; - }, - createHTMLDocument : function(title){ - var doc = new HTMLDocument($implementation, null, ""); - var html = doc.createElement("html"); doc.appendChild(html); - var head = doc.createElement("head"); html.appendChild(head); - var body = doc.createElement("body"); html.appendChild(body); - var t = doc.createElement("title"); head.appendChild(t); - if( title) { - t.appendChild(doc.createTextNode(title)); - } - return doc; - }, - translateErrCode : function(code) { - //convert DOMException Code to human readable error message; - var msg = ""; - - switch (code) { - case DOMException.INDEX_SIZE_ERR : // 1 - msg = "INDEX_SIZE_ERR: Index out of bounds"; - break; - - case DOMException.DOMSTRING_SIZE_ERR : // 2 - msg = "DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a DOMString"; - break; - - case DOMException.HIERARCHY_REQUEST_ERR : // 3 - msg = "HIERARCHY_REQUEST_ERR: The Node can not be inserted at this location"; - break; - - case DOMException.WRONG_DOCUMENT_ERR : // 4 - msg = "WRONG_DOCUMENT_ERR: The source and the destination Documents are not the same"; - break; - - case DOMException.INVALID_CHARACTER_ERR : // 5 - msg = "INVALID_CHARACTER_ERR: The string contains an invalid character"; - break; - - case DOMException.NO_DATA_ALLOWED_ERR : // 6 - msg = "NO_DATA_ALLOWED_ERR: This Node / NodeList does not support data"; - break; - - case DOMException.NO_MODIFICATION_ALLOWED_ERR : // 7 - msg = "NO_MODIFICATION_ALLOWED_ERR: This object cannot be modified"; - break; - - case DOMException.NOT_FOUND_ERR : // 8 - msg = "NOT_FOUND_ERR: The item cannot be found"; - break; - - case DOMException.NOT_SUPPORTED_ERR : // 9 - msg = "NOT_SUPPORTED_ERR: This implementation does not support function"; - break; - - case DOMException.INUSE_ATTRIBUTE_ERR : // 10 - msg = "INUSE_ATTRIBUTE_ERR: The Attribute has already been assigned to another Element"; - break; - - // Introduced in DOM Level 2: - case DOMException.INVALID_STATE_ERR : // 11 - msg = "INVALID_STATE_ERR: The object is no longer usable"; - break; - - case DOMException.SYNTAX_ERR : // 12 - msg = "SYNTAX_ERR: Syntax error"; - break; - - case DOMException.INVALID_MODIFICATION_ERR : // 13 - msg = "INVALID_MODIFICATION_ERR: Cannot change the type of the object"; - break; - - case DOMException.NAMESPACE_ERR : // 14 - msg = "NAMESPACE_ERR: The namespace declaration is incorrect"; - break; - - case DOMException.INVALID_ACCESS_ERR : // 15 - msg = "INVALID_ACCESS_ERR: The object does not support this function"; - break; - - default : - msg = "UNKNOWN: Unknown Exception Code ("+ code +")"; - } - - return msg; - }, - toString : function(){ - return "[object DOMImplementation]"; - } -}); - - - -/** - * @method DOMImplementation._isNamespaceDeclaration - Return true, if attributeName is a namespace declaration - * @author Jon van Noort (jon@webarcana.com.au) - * @param attributeName : string - the attribute name - * @return : boolean - */ -function __isNamespaceDeclaration__(attributeName) { - // test if attributeName is 'xmlns' - return (attributeName.indexOf('xmlns') > -1); -} - -/** - * @method DOMImplementation._isIdDeclaration - Return true, if attributeName is an id declaration - * @author Jon van Noort (jon@webarcana.com.au) - * @param attributeName : string - the attribute name - * @return : boolean - */ -function __isIdDeclaration__(attributeName) { - // test if attributeName is 'id' (case insensitive) - return attributeName?(attributeName.toLowerCase() == 'id'):false; -} - -/** - * @method DOMImplementation._isValidName - Return true, - * if name contains no invalid characters - * @author Jon van Noort (jon@webarcana.com.au) - * @param name : string - the candidate name - * @return : boolean - */ -function __isValidName__(name) { - // test if name contains only valid characters - return name.match(re_validName); -} -var re_validName = /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/; - -/** - * @method DOMImplementation._isValidString - Return true, if string does not contain any illegal chars - * All of the characters 0 through 31 and character 127 are nonprinting control characters. - * With the exception of characters 09, 10, and 13, (Ox09, Ox0A, and Ox0D) - * Note: different from _isValidName in that ValidStrings may contain spaces - * @author Jon van Noort (jon@webarcana.com.au) - * @param name : string - the candidate string - * @return : boolean - */ -function __isValidString__(name) { - // test that string does not contains invalid characters - return (name.search(re_invalidStringChars) < 0); -} -var re_invalidStringChars = /\x01|\x02|\x03|\x04|\x05|\x06|\x07|\x08|\x0B|\x0C|\x0E|\x0F|\x10|\x11|\x12|\x13|\x14|\x15|\x16|\x17|\x18|\x19|\x1A|\x1B|\x1C|\x1D|\x1E|\x1F|\x7F/; - -/** - * @method DOMImplementation._parseNSName - parse the namespace name. - * if there is no colon, the - * @author Jon van Noort (jon@webarcana.com.au) - * @param qualifiedName : string - The qualified name - * @return : NSName - [ - .prefix : string - The prefix part of the qname - .namespaceName : string - The namespaceURI part of the qname - ] - */ -function __parseNSName__(qualifiedName) { - var resultNSName = {}; - // unless the qname has a namespaceName, the prefix is the entire String - resultNSName.prefix = qualifiedName; - resultNSName.namespaceName = ""; - // split on ':' - var delimPos = qualifiedName.indexOf(':'); - if (delimPos > -1) { - // get prefix - resultNSName.prefix = qualifiedName.substring(0, delimPos); - // get namespaceName - resultNSName.namespaceName = qualifiedName.substring(delimPos +1, qualifiedName.length); - } - return resultNSName; -} - -/** - * @method DOMImplementation._parseQName - parse the qualified name - * @author Jon van Noort (jon@webarcana.com.au) - * @param qualifiedName : string - The qualified name - * @return : QName - */ -function __parseQName__(qualifiedName) { - var resultQName = {}; - // unless the qname has a prefix, the local name is the entire String - resultQName.localName = qualifiedName; - resultQName.prefix = ""; - // split on ':' - var delimPos = qualifiedName.indexOf(':'); - if (delimPos > -1) { - // get prefix - resultQName.prefix = qualifiedName.substring(0, delimPos); - // get localName - resultQName.localName = qualifiedName.substring(delimPos +1, qualifiedName.length); - } - return resultQName; -} -/** - * @author envjs team - */ -Notation = function() { - throw new Error("Notation Not Implemented" ); -};/** - * @author thatcher - */ -Range = function(){ - -}; - -__extend__(Range.prototype, { - get startContainer(){ - - }, - get endContainer(){ - - }, - get startOffset(){ - - }, - get endOffset(){ - - }, - get collapsed(){ - - }, - get commonAncestorContainer(){ - - }, - setStart: function(refNode, offset){//throws RangeException - - }, - setEnd: function(refNode, offset){//throws RangeException - - }, - setStartBefore: function(refNode){//throws RangeException - - }, - setStartAfter: function(refNode){//throws RangeException - - }, - setEndBefore: function(refNode){//throws RangeException - - }, - setEndAfter: function(refNode){//throws RangeException - - }, - collapse: function(toStart){//throws RangeException - - }, - selectNode: function(refNode){//throws RangeException - - }, - selectNodeContents: function(refNode){//throws RangeException - - }, - compareBoundaryPoints: function(how, sourceRange){ - - }, - deleteContents: function(){ - - }, - extractContents: function(){ - - }, - cloneContents: function(){ - - }, - insertNode: function(newNode){ - - }, - surroundContents: function(newParent){ - - }, - cloneRange: function(){ - - }, - toString: function(){ - return '[object Range]'; - }, - detach: function(){ - - } -}); - - - // CompareHow -Range.START_TO_START = 0; -Range.START_TO_END = 1; -Range.END_TO_END = 2; -Range.END_TO_START = 3; - -/* - * Forward declarations - */ -var __isValidNamespace__; - -/** - * @class Document - The Document interface represents the entire HTML - * or XML document. Conceptually, it is the root of the document tree, - * and provides the primary access to the document's data. - * - * @extends Node - * @param implementation : DOMImplementation - the creator Implementation - */ -Document = function(implementation, docParentWindow) { - Node.apply(this, arguments); - - //TODO: Temporary!!! Cnage back to true!!! - this.async = true; - // The Document Type Declaration (see DocumentType) associated with this document - this.doctype = null; - // The DOMImplementation object that handles this document. - this.implementation = implementation; - - this.nodeName = "#document"; - // initially false, set to true by parser - this.parsing = false; - this.baseURI = 'about:blank'; - - this.ownerDocument = null; - - this.importing = false; -}; - -Document.prototype = new Node(); -__extend__(Document.prototype,{ - get localName(){ - return null; - }, - get textContent(){ - return null; - }, - get all(){ - return this.getElementsByTagName("*"); - }, - get documentElement(){ - var i, length = this.childNodes?this.childNodes.length:0; - for(i=0;i -1 ){ - valid = false; - } - - if ((valid) && (!isAttribute)) { - // if the namespaceURI is not null - if (!namespaceURI) { - valid = false; - } - } - - // if the qualifiedName has a prefix - if ((valid) && (qName.prefix === "")) { - valid = false; - } - } - - // if the qualifiedName has a prefix that is "xml" and the namespaceURI is - // different from "http://www.w3.org/XML/1998/namespace" [Namespaces]. - if ((valid) && (qName.prefix === "xml") && (namespaceURI !== "http://www.w3.org/XML/1998/namespace")) { - valid = false; - } - - return valid; -}; -/** - * - * This file only handles XML parser. - * It is extended by parser/domparser.js (and parser/htmlparser.js) - * - * This depends on e4x, which some engines may not have. - * - * @author thatcher - */ -DOMParser = function(principle, documentURI, baseURI) { - // TODO: why/what should these 3 args do? -}; -__extend__(DOMParser.prototype,{ - parseFromString: function(xmlstring, mimetype){ - var doc = new Document(new DOMImplementation()), - e4; - - // The following are e4x directives. - // Full spec is here: - // http://www.ecma-international.org/publications/standards/Ecma-357.htm - // - // that is pretty gross, so checkout this summary - // http://rephrase.net/days/07/06/e4x - // - // also see the Mozilla Developer Center: - // https://developer.mozilla.org/en/E4X - // - XML.ignoreComments = false; - XML.ignoreProcessingInstructions = false; - XML.ignoreWhitespace = false; - - // for some reason e4x can't handle initial xml declarations - // https://bugzilla.mozilla.org/show_bug.cgi?id=336551 - // The official workaround is the big regexp below - // but simpler one seems to be ok - // xmlstring = xmlstring.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); - // - xmlstring = xmlstring.replace(/<\?xml.*\?>/); - - e4 = new XMLList(xmlstring); - - __toDomNode__(e4, doc, doc); - - //console.log('xml \n %s', doc.documentElement.xml); - return doc; - } -}); - -var __toDomNode__ = function(e4, parent, doc){ - var xnode, - domnode, - children, - target, - value, - length, - element, - kind, - item; - //console.log('converting e4x node list \n %s', e4) - - // not using the for each(item in e4) since some engines can't - // handle the syntax (i.e. says syntax error) - // - // for each(xnode in e4) { - for (item in e4) { - // NO do not do this if (e4.hasOwnProperty(item)) { - // breaks spidermonkey - xnode = e4[item]; - - kind = xnode.nodeKind(); - //console.log('treating node kind %s', kind); - switch(kind){ - case 'element': - // add node - //console.log('creating element %s %s', xnode.localName(), xnode.namespace()); - if(xnode.namespace() && (xnode.namespace()+'') !== ''){ - //console.log('createElementNS %s %s',xnode.namespace()+'', xnode.localName() ); - domnode = doc.createElementNS(xnode.namespace()+'', xnode.localName()); - }else{ - domnode = doc.createElement(xnode.name()+''); - } - parent.appendChild(domnode); - - // add attributes - __toDomNode__(xnode.attributes(), domnode, doc); - - // add children - children = xnode.children(); - length = children.length(); - //console.log('recursing? %s', length ? 'yes' : 'no'); - if (length > 0) { - __toDomNode__(children, domnode, doc); - } - break; - case 'attribute': - // console.log('setting attribute %s %s %s', - // xnode.localName(), xnode.namespace(), xnode.valueOf()); - - // - // cross-platform alert. The original code used - // xnode.text() to get the attribute value - // This worked in Rhino, but did not in Spidermonkey - // valueOf seemed to work in both - // - if(xnode.namespace() && xnode.namespace().prefix){ - //console.log("%s", xnode.namespace().prefix); - parent.setAttributeNS(xnode.namespace()+'', - xnode.namespace().prefix+':'+xnode.localName(), - xnode.valueOf()); - }else if((xnode.name()+'').match('http://www.w3.org/2000/xmlns/::')){ - if(xnode.localName()!=='xmlns'){ - parent.setAttributeNS('http://www.w3.org/2000/xmlns/', - 'xmlns:'+xnode.localName(), - xnode.valueOf()); - } - }else{ - parent.setAttribute(xnode.localName()+'', xnode.valueOf()); - } - break; - case 'text': - //console.log('creating text node : %s', xnode); - domnode = doc.createTextNode(xnode+''); - parent.appendChild(domnode); - break; - case 'comment': - //console.log('creating comment node : %s', xnode); - value = xnode+''; - domnode = doc.createComment(value.substring(4,value.length-3)); - parent.appendChild(domnode); - break; - case 'processing-instruction': - //console.log('creating processing-instruction node : %s', xnode); - value = xnode+''; - target = value.split(' ')[0].substring(2); - value = value.split(' ').splice(1).join(' ').replace('?>',''); - //console.log('creating processing-instruction data : %s', value); - domnode = doc.createProcessingInstruction(target, value); - parent.appendChild(domnode); - break; - default: - console.log('e4x DOM ERROR'); - throw new Error("Assertion failed in xml parser"); - } - } -}; -/** - * @author envjs team - * @class XMLSerializer - */ - -XMLSerializer = function() {}; - -__extend__(XMLSerializer.prototype, { - serializeToString: function(node){ - return node.xml; - }, - toString : function(){ - return "[object XMLSerializer]"; - } -}); - -/** - * @author john resig & the envjs team - * @uri http://www.envjs.com/ - * @copyright 2008-2010 - * @license MIT - */ -//CLOSURE_END -}()); -/* - * Envjs event.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - * - * This file simply provides the global definitions we need to - * be able to correctly implement to core browser DOM Event interfaces. - */ -var Event, - MouseEvent, - UIEvent, - KeyboardEvent, - MutationEvent, - DocumentEvent, - EventTarget, - EventException, - //nonstandard but very useful for implementing mutation events - //among other things like general profiling - Aspect; -/* - * Envjs event.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - - -/** - * @author john resig - */ -// Helper method for extending one object with another. -function __extend__(a,b) { - for ( var i in b ) { - var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i); - if ( g || s ) { - if ( g ) { a.__defineGetter__(i, g); } - if ( s ) { a.__defineSetter__(i, s); } - } else { - a[i] = b[i]; - } - } return a; -} - -/** - * @author john resig - */ -//from jQuery -function __setArray__( target, array ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - target.length = 0; - Array.prototype.push.apply( target, array ); -} -/** - * Borrowed with love from: - * - * jQuery AOP - jQuery plugin to add features of aspect-oriented programming (AOP) to jQuery. - * http://jquery-aop.googlecode.com/ - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/mit-license.php - * - * Version: 1.1 - */ -(function() { - - var _after = 1; - var _before = 2; - var _around = 3; - var _intro = 4; - var _regexEnabled = true; - - /** - * Private weaving function. - */ - var weaveOne = function(source, method, advice) { - - var old = source[method]; - - var aspect; - if (advice.type == _after) - aspect = function() { - var returnValue = old.apply(this, arguments); - return advice.value.apply(this, [returnValue, method]); - }; - else if (advice.type == _before) - aspect = function() { - advice.value.apply(this, [arguments, method]); - return old.apply(this, arguments); - }; - else if (advice.type == _intro) - aspect = function() { - return advice.value.apply(this, arguments); - }; - else if (advice.type == _around) { - aspect = function() { - var invocation = { object: this, args: arguments }; - return advice.value.apply(invocation.object, [{ arguments: invocation.args, method: method, proceed : - function() { - return old.apply(invocation.object, invocation.args); - } - }] ); - }; - } - - aspect.unweave = function() { - source[method] = old; - pointcut = source = aspect = old = null; - }; - - source[method] = aspect; - - return aspect; - - }; - - - /** - * Private weaver and pointcut parser. - */ - var weave = function(pointcut, advice) - { - - var source = (typeof(pointcut.target.prototype) != 'undefined') ? pointcut.target.prototype : pointcut.target; - var advices = []; - - // If it's not an introduction and no method was found, try with regex... - if (advice.type != _intro && typeof(source[pointcut.method]) == 'undefined') - { - - for (var method in source) - { - if (source[method] != null && source[method] instanceof Function && method.match(pointcut.method)) - { - advices[advices.length] = weaveOne(source, method, advice); - } - } - - if (advices.length == 0) - throw 'No method: ' + pointcut.method; - - } - else - { - // Return as an array of one element - advices[0] = weaveOne(source, pointcut.method, advice); - } - - return _regexEnabled ? advices : advices[0]; - - }; - - Aspect = - { - /** - * Creates an advice after the defined point-cut. The advice will be executed after the point-cut method - * has completed execution successfully, and will receive one parameter with the result of the execution. - * This function returns an array of weaved aspects (Function). - * - * @example jQuery.aop.after( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } ); - * @result Array - * - * @example jQuery.aop.after( {target: String, method: 'indexOf'}, function(index) { alert('Result found at: ' + index + ' on:' + this); } ); - * @result Array - * - * @name after - * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved. - * @option Object target Target object to be weaved. - * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects. - * @param Function advice Function containing the code that will get called after the execution of the point-cut. It receives one parameter - * with the result of the point-cut's execution. - * - * @type Array - * @cat Plugins/General - */ - after : function(pointcut, advice) - { - return weave( pointcut, { type: _after, value: advice } ); - }, - - /** - * Creates an advice before the defined point-cut. The advice will be executed before the point-cut method - * but cannot modify the behavior of the method, or prevent its execution. - * This function returns an array of weaved aspects (Function). - * - * @example jQuery.aop.before( {target: window, method: 'MyGlobalMethod'}, function() { alert('About to execute MyGlobalMethod'); } ); - * @result Array - * - * @example jQuery.aop.before( {target: String, method: 'indexOf'}, function(index) { alert('About to execute String.indexOf on: ' + this); } ); - * @result Array - * - * @name before - * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved. - * @option Object target Target object to be weaved. - * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects. - * @param Function advice Function containing the code that will get called before the execution of the point-cut. - * - * @type Array - * @cat Plugins/General - */ - before : function(pointcut, advice) - { - return weave( pointcut, { type: _before, value: advice } ); - }, - - - /** - * Creates an advice 'around' the defined point-cut. This type of advice can control the point-cut method execution by calling - * the functions '.proceed()' on the 'invocation' object, and also, can modify the arguments collection before sending them to the function call. - * This function returns an array of weaved aspects (Function). - * - * @example jQuery.aop.around( {target: window, method: 'MyGlobalMethod'}, function(invocation) { - * alert('# of Arguments: ' + invocation.arguments.length); - * return invocation.proceed(); - * } ); - * @result Array - * - * @example jQuery.aop.around( {target: String, method: 'indexOf'}, function(invocation) { - * alert('Searching: ' + invocation.arguments[0] + ' on: ' + this); - * return invocation.proceed(); - * } ); - * @result Array - * - * @example jQuery.aop.around( {target: window, method: /Get(\d+)/}, function(invocation) { - * alert('Executing ' + invocation.method); - * return invocation.proceed(); - * } ); - * @desc Matches all global methods starting with 'Get' and followed by a number. - * @result Array - * - * - * @name around - * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved. - * @option Object target Target object to be weaved. - * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects. - * @param Function advice Function containing the code that will get called around the execution of the point-cut. This advice will be called with one - * argument containing one function '.proceed()', the collection of arguments '.arguments', and the matched method name '.method'. - * - * @type Array - * @cat Plugins/General - */ - around : function(pointcut, advice) - { - return weave( pointcut, { type: _around, value: advice } ); - }, - - /** - * Creates an introduction on the defined point-cut. This type of advice replaces any existing methods with the same - * name. To restore them, just unweave it. - * This function returns an array with only one weaved aspect (Function). - * - * @example jQuery.aop.introduction( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } ); - * @result Array - * - * @example jQuery.aop.introduction( {target: String, method: 'log'}, function() { alert('Console: ' + this); } ); - * @result Array - * - * @name introduction - * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved. - * @option Object target Target object to be weaved. - * @option String method Name of the function to be weaved. - * @param Function advice Function containing the code that will be executed on the point-cut. - * - * @type Array - * @cat Plugins/General - */ - introduction : function(pointcut, advice) - { - return weave( pointcut, { type: _intro, value: advice } ); - }, - - /** - * Configures global options. - * - * @name setup - * @param Map settings Configuration options. - * @option Boolean regexMatch Enables/disables regex matching of method names. - * - * @example jQuery.aop.setup( { regexMatch: false } ); - * @desc Disable regex matching. - * - * @type Void - * @cat Plugins/General - */ - setup: function(settings) - { - _regexEnabled = settings.regexMatch; - } - }; - -})(); - - - - -/** - * @name EventTarget - * @w3c:domlevel 2 - * @uri -//TODO: paste dom event level 2 w3c spc uri here - */ -EventTarget = function(){}; -EventTarget.prototype.addEventListener = function(type, fn, phase){ - __addEventListener__(this, type, fn, phase); -}; -EventTarget.prototype.removeEventListener = function(type, fn){ - __removeEventListener__(this, type, fn); -}; -EventTarget.prototype.dispatchEvent = function(event, bubbles){ - __dispatchEvent__(this, event, bubbles); -}; - -__extend__(Node.prototype, EventTarget.prototype); - - -var $events = [{}]; - -function __addEventListener__(target, type, fn, phase){ - phase = !!phase?"CAPTURING":"BUBBLING"; - if ( !target.uuid ) { - //console.log('event uuid %s %s', target, target.uuid); - target.uuid = $events.length+''; - } - if ( !$events[target.uuid] ) { - //console.log('creating listener for target: %s %s', target, target.uuid); - $events[target.uuid] = {}; - } - if ( !$events[target.uuid][type] ){ - //console.log('creating listener for type: %s %s %s', target, target.uuid, type); - $events[target.uuid][type] = { - CAPTURING:[], - BUBBLING:[] - }; - } - if ( $events[target.uuid][type][phase].indexOf( fn ) < 0 ){ - //console.log('adding event listener %s %s %s %s %s %s', target, target.uuid, type, phase, - // $events[target.uuid][type][phase].length, $events[target.uuid][type][phase].indexOf( fn )); - //console.log('creating listener for function: %s %s %s', target, target.uuid, phase); - $events[target.uuid][type][phase].push( fn ); - //console.log('adding event listener %s %s %s %s %s %s', target, target.uuid, type, phase, - // $events[target.uuid][type][phase].length, $events[target.uuid][type][phase].indexOf( fn )); - } - //console.log('registered event listeners %s', $events.length); -} - -function __removeEventListener__(target, type, fn, phase){ - - phase = !!phase?"CAPTURING":"BUBBLING"; - if ( !target.uuid ) { - return; - } - if ( !$events[target.uuid] ) { - return; - } - if(type == '*'){ - //used to clean all event listeners for a given node - //console.log('cleaning all event listeners for node %s %s',target, target.uuid); - delete $events[target.uuid]; - return; - }else if ( !$events[target.uuid][type] ){ - return; - } - $events[target.uuid][type][phase] = - $events[target.uuid][type][phase].filter(function(f){ - //console.log('removing event listener %s %s %s %s', target, type, phase, fn); - return f != fn; - }); -} - -var __eventuuid__ = 0; -function __dispatchEvent__(target, event, bubbles){ - - if (!event.uuid) { - event.uuid = __eventuuid__++; - } - //the window scope defines the $event object, for IE(^^^) compatibility; - //$event = event; - //console.log('dispatching event %s', event.uuid); - if (bubbles === undefined || bubbles === null) { - bubbles = true; - } - - if (!event.target) { - event.target = target; - } - - //console.log('dispatching? %s %s %s', target, event.type, bubbles); - if ( event.type && (target.nodeType || target === window )) { - - //console.log('dispatching event %s %s %s', target, event.type, bubbles); - __captureEvent__(target, event); - - event.eventPhase = Event.AT_TARGET; - if ( target.uuid && $events[target.uuid] && $events[target.uuid][event.type] ) { - event.currentTarget = target; - //console.log('dispatching %s %s %s %s', target, event.type, - // $events[target.uuid][event.type]['CAPTURING'].length); - $events[target.uuid][event.type].CAPTURING.forEach(function(fn){ - //console.log('AT_TARGET (CAPTURING) event %s', fn); - var returnValue = fn( event ); - //console.log('AT_TARGET (CAPTURING) return value %s', returnValue); - if(returnValue === false){ - event.stopPropagation(); - } - }); - //console.log('dispatching %s %s %s %s', target, event.type, - // $events[target.uuid][event.type]['BUBBLING'].length); - $events[target.uuid][event.type].BUBBLING.forEach(function(fn){ - //console.log('AT_TARGET (BUBBLING) event %s', fn); - var returnValue = fn( event ); - //console.log('AT_TARGET (BUBBLING) return value %s', returnValue); - if(returnValue === false){ - event.stopPropagation(); - } - }); - } - if (target["on" + event.type]) { - target["on" + event.type](event); - } - if (bubbles && !event.cancelled){ - __bubbleEvent__(target, event); - } - if(!event._preventDefault){ - //At this point I'm guessing that just HTMLEvents are concerned - //with default behavior being executed in a browser but I could be - //wrong as usual. The goal is much more to filter at this point - //what events have no need to be handled - //console.log('triggering default behavior for %s', event.type); - if(event.type in Envjs.defaultEventBehaviors){ - Envjs.defaultEventBehaviors[event.type](event); - } - } - //console.log('deleting event %s', event.uuid); - event.target = null; - event = null; - }else{ - throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR); - } -} - -function __captureEvent__(target, event){ - var ancestorStack = [], - parent = target.parentNode; - - event.eventPhase = Event.CAPTURING_PHASE; - while(parent){ - if(parent.uuid && $events[parent.uuid] && $events[parent.uuid][event.type]){ - ancestorStack.push(parent); - } - parent = parent.parentNode; - } - while(ancestorStack.length && !event.cancelled){ - event.currentTarget = ancestorStack.pop(); - if($events[event.currentTarget.uuid] && $events[event.currentTarget.uuid][event.type]){ - $events[event.currentTarget.uuid][event.type].CAPTURING.forEach(function(fn){ - var returnValue = fn( event ); - if(returnValue === false){ - event.stopPropagation(); - } - }); - } - } -} - -function __bubbleEvent__(target, event){ - var parent = target.parentNode; - event.eventPhase = Event.BUBBLING_PHASE; - while(parent){ - if(parent.uuid && $events[parent.uuid] && $events[parent.uuid][event.type] ){ - event.currentTarget = parent; - $events[event.currentTarget.uuid][event.type].BUBBLING.forEach(function(fn){ - var returnValue = fn( event ); - if(returnValue === false){ - event.stopPropagation(); - } - }); - } - parent = parent.parentNode; - } -} - -/** - * @class Event - */ -Event = function(options){ - // event state is kept read-only by forcing - // a new object for each event. This may not - // be appropriate in the long run and we'll - // have to decide if we simply dont adhere to - // the read-only restriction of the specification - this._bubbles = true; - this._cancelable = true; - this._cancelled = false; - this._currentTarget = null; - this._target = null; - this._eventPhase = Event.AT_TARGET; - this._timeStamp = new Date().getTime(); - this._preventDefault = false; - this._stopPropogation = false; -}; - -__extend__(Event.prototype,{ - get bubbles(){return this._bubbles;}, - get cancelable(){return this._cancelable;}, - get currentTarget(){return this._currentTarget;}, - set currentTarget(currentTarget){ this._currentTarget = currentTarget; }, - get eventPhase(){return this._eventPhase;}, - set eventPhase(eventPhase){this._eventPhase = eventPhase;}, - get target(){return this._target;}, - set target(target){ this._target = target;}, - get timeStamp(){return this._timeStamp;}, - get type(){return this._type;}, - initEvent: function(type, bubbles, cancelable){ - this._type=type?type:''; - this._bubbles=!!bubbles; - this._cancelable=!!cancelable; - }, - preventDefault: function(){ - this._preventDefault = true; - }, - stopPropagation: function(){ - if(this._cancelable){ - this._cancelled = true; - this._bubbles = false; - } - }, - get cancelled(){ - return this._cancelled; - }, - toString: function(){ - return '[object Event]'; - } -}); - -__extend__(Event,{ - CAPTURING_PHASE : 1, - AT_TARGET : 2, - BUBBLING_PHASE : 3 -}); - - - -/** - * @name UIEvent - * @param {Object} options - */ -UIEvent = function(options) { - this._view = null; - this._detail = 0; -}; - -UIEvent.prototype = new Event(); -__extend__(UIEvent.prototype,{ - get view(){ - return this._view; - }, - get detail(){ - return this._detail; - }, - initUIEvent: function(type, bubbles, cancelable, windowObject, detail){ - this.initEvent(type, bubbles, cancelable); - this._detail = 0; - this._view = windowObject; - } -}); - -var $onblur, - $onfocus, - $onresize; - - -/** - * @name MouseEvent - * @w3c:domlevel 2 - * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html - */ -MouseEvent = function(options) { - this._screenX= 0; - this._screenY= 0; - this._clientX= 0; - this._clientY= 0; - this._ctrlKey= false; - this._metaKey= false; - this._altKey= false; - this._button= null; - this._relatedTarget= null; -}; -MouseEvent.prototype = new UIEvent(); -__extend__(MouseEvent.prototype,{ - get screenX(){ - return this._screenX; - }, - get screenY(){ - return this._screenY; - }, - get clientX(){ - return this._clientX; - }, - get clientY(){ - return this._clientY; - }, - get ctrlKey(){ - return this._ctrlKey; - }, - get altKey(){ - return this._altKey; - }, - get shiftKey(){ - return this._shiftKey; - }, - get metaKey(){ - return this._metaKey; - }, - get button(){ - return this._button; - }, - get relatedTarget(){ - return this._relatedTarget; - }, - initMouseEvent: function(type, bubbles, cancelable, windowObject, detail, - screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, - metaKey, button, relatedTarget){ - this.initUIEvent(type, bubbles, cancelable, windowObject, detail); - this._screenX = screenX; - this._screenY = screenY; - this._clientX = clientX; - this._clientY = clientY; - this._ctrlKey = ctrlKey; - this._altKey = altKey; - this._shiftKey = shiftKey; - this._metaKey = metaKey; - this._button = button; - this._relatedTarget = relatedTarget; - } -}); - -/** - * Interface KeyboardEvent (introduced in DOM Level 3) - */ -KeyboardEvent = function(options) { - this._keyIdentifier = 0; - this._keyLocation = 0; - this._ctrlKey = false; - this._metaKey = false; - this._altKey = false; - this._metaKey = false; -}; -KeyboardEvent.prototype = new UIEvent(); - -__extend__(KeyboardEvent.prototype,{ - - get ctrlKey(){ - return this._ctrlKey; - }, - get altKey(){ - return this._altKey; - }, - get shiftKey(){ - return this._shiftKey; - }, - get metaKey(){ - return this._metaKey; - }, - get button(){ - return this._button; - }, - get relatedTarget(){ - return this._relatedTarget; - }, - getModifiersState: function(keyIdentifier){ - - }, - initMouseEvent: function(type, bubbles, cancelable, windowObject, - keyIdentifier, keyLocation, modifiersList, repeat){ - this.initUIEvent(type, bubbles, cancelable, windowObject, 0); - this._keyIdentifier = keyIdentifier; - this._keyLocation = keyLocation; - this._modifiersList = modifiersList; - this._repeat = repeat; - } -}); - -KeyboardEvent.DOM_KEY_LOCATION_STANDARD = 0; -KeyboardEvent.DOM_KEY_LOCATION_LEFT = 1; -KeyboardEvent.DOM_KEY_LOCATION_RIGHT = 2; -KeyboardEvent.DOM_KEY_LOCATION_NUMPAD = 3; -KeyboardEvent.DOM_KEY_LOCATION_MOBILE = 4; -KeyboardEvent.DOM_KEY_LOCATION_JOYSTICK = 5; - - - -//We dont fire mutation events until someone has registered for them -var __supportedMutations__ = /DOMSubtreeModified|DOMNodeInserted|DOMNodeRemoved|DOMAttrModified|DOMCharacterDataModified/; - -var __fireMutationEvents__ = Aspect.before({ - target: EventTarget, - method: 'addEventListener' -}, function(target, type){ - if(type && type.match(__supportedMutations__)){ - //unweaving removes the __addEventListener__ aspect - __fireMutationEvents__.unweave(); - // These two methods are enough to cover all dom 2 manipulations - Aspect.around({ - target: Node, - method:"removeChild" - }, function(invocation){ - var event, - node = invocation.arguments[0]; - event = node.ownerDocument.createEvent('MutationEvents'); - event.initEvent('DOMNodeRemoved', true, false, node.parentNode, null, null, null, null); - node.dispatchEvent(event, false); - return invocation.proceed(); - - }); - Aspect.around({ - target: Node, - method:"appendChild" - }, function(invocation) { - var event, - node = invocation.proceed(); - event = node.ownerDocument.createEvent('MutationEvents'); - event.initEvent('DOMNodeInserted', true, false, node.parentNode, null, null, null, null); - node.dispatchEvent(event, false); - return node; - }); - } -}); - -/** - * @name MutationEvent - * @param {Object} options - */ -MutationEvent = function(options) { - this._cancelable = false; - this._timeStamp = 0; -}; - -MutationEvent.prototype = new Event(); -__extend__(MutationEvent.prototype,{ - get relatedNode(){ - return this._relatedNode; - }, - get prevValue(){ - return this._prevValue; - }, - get newValue(){ - return this._newValue; - }, - get attrName(){ - return this._attrName; - }, - get attrChange(){ - return this._attrChange; - }, - initMutationEvent: function( type, bubbles, cancelable, - relatedNode, prevValue, newValue, attrName, attrChange ){ - this._relatedNode = relatedNode; - this._prevValue = prevValue; - this._newValue = newValue; - this._attrName = attrName; - this._attrChange = attrChange; - switch(type){ - case "DOMSubtreeModified": - this.initEvent(type, true, false); - break; - case "DOMNodeInserted": - this.initEvent(type, true, false); - break; - case "DOMNodeRemoved": - this.initEvent(type, true, false); - break; - case "DOMNodeRemovedFromDocument": - this.initEvent(type, false, false); - break; - case "DOMNodeInsertedIntoDocument": - this.initEvent(type, false, false); - break; - case "DOMAttrModified": - this.initEvent(type, true, false); - break; - case "DOMCharacterDataModified": - this.initEvent(type, true, false); - break; - default: - this.initEvent(type, bubbles, cancelable); - } - } -}); - -// constants -MutationEvent.ADDITION = 0; -MutationEvent.MODIFICATION = 1; -MutationEvent.REMOVAL = 2; - - -/** - * @name EventException - */ -EventException = function(code) { - this.code = code; -}; -EventException.UNSPECIFIED_EVENT_TYPE_ERR = 0; -/** - * - * DOM Level 2: http://www.w3.org/TR/DOM-Level-2-Events/events.html - * DOM Level 3: http://www.w3.org/TR/DOM-Level-3-Events/ - * - * interface DocumentEvent { - * Event createEvent (in DOMString eventType) - * raises (DOMException); - * }; - * - * Firefox (3.6) exposes DocumentEvent - * Safari (4) does NOT. - */ - -/** - * TODO: Not sure we need a full prototype. We not just an regular object? - */ -DocumentEvent = function(){}; -DocumentEvent.prototype.__EventMap__ = { - // Safari4: singular and plural forms accepted - // Firefox3.6: singular and plural forms accepted - 'Event' : Event, - 'Events' : Event, - 'UIEvent' : UIEvent, - 'UIEvents' : UIEvent, - 'MouseEvent' : MouseEvent, - 'MouseEvents' : MouseEvent, - 'MutationEvent' : MutationEvent, - 'MutationEvents' : MutationEvent, - - // Safari4: accepts HTMLEvents, but not HTMLEvent - // Firefox3.6: accepts HTMLEvents, but not HTMLEvent - 'HTMLEvent' : Event, - 'HTMLEvents' : Event, - - // Safari4: both not accepted - // Firefox3.6, only KeyEvents is accepted - 'KeyEvent' : KeyboardEvent, - 'KeyEvents' : KeyboardEvent, - - // Safari4: both accepted - // Firefox3.6: none accepted - 'KeyboardEvent' : KeyboardEvent, - 'KeyboardEvents' : KeyboardEvent -}; - -DocumentEvent.prototype.createEvent = function(eventType) { - var Clazz = this.__EventMap__[eventType]; - if (Clazz) { - return new Clazz(); - } - throw(new DOMException(DOMException.NOT_SUPPORTED_ERR)); -}; - -__extend__(Document.prototype, DocumentEvent.prototype); - -/** - * @author john resig & the envjs team - * @uri http://www.envjs.com/ - * @copyright 2008-2010 - * @license MIT - */ -//CLOSURE_END -}()); - -/* - * Envjs timer.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - * - * Parts of the implementation were originally written by:\ - * Steven Parkes - * - * requires Envjs.wait, Envjs.sleep, Envjs.WAIT_INTERVAL - */ -var setTimeout, - clearTimeout, - setInterval, - clearInterval; - -/* - * Envjs timer.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - -/* -* timer.js -* implementation provided by Steven Parkes -*/ - -//private -var $timers = [], - EVENT_LOOP_RUNNING = false; - -$timers.lock = function(fn){ - Envjs.sync(fn)(); -}; - -//private internal class -var Timer = function(fn, interval){ - this.fn = fn; - this.interval = interval; - this.at = Date.now() + interval; - // allows for calling wait() from callbacks - this.running = false; -}; - -Timer.prototype.start = function(){}; -Timer.prototype.stop = function(){}; - -//static -Timer.normalize = function(time) { - time = time*1; - if ( isNaN(time) || time < 0 ) { - time = 0; - } - - if ( EVENT_LOOP_RUNNING && time < Timer.MIN_TIME ) { - time = Timer.MIN_TIME; - } - return time; -}; -// html5 says this should be at least 4, but the parser is using -// a setTimeout for the SAX stuff which messes up the world -Timer.MIN_TIME = /* 4 */ 0; - -/** - * @function setTimeout - * @param {Object} fn - * @param {Object} time - */ -setTimeout = function(fn, time){ - var num; - time = Timer.normalize(time); - $timers.lock(function(){ - num = $timers.length+1; - var tfn; - if (typeof fn == 'string') { - tfn = function() { - try { - // eval in global scope - eval(fn, null); - } catch (e) { - console.log('timer error %s %s', fn, e); - } finally { - clearInterval(num); - } - }; - } else { - tfn = function() { - try { - fn(); - } catch (e) { - console.log('timer error %s %s', fn, e); - } finally { - clearInterval(num); - } - }; - } - //console.log("Creating timer number %s", num); - $timers[num] = new Timer(tfn, time); - $timers[num].start(); - }); - return num; -}; - -/** - * @function setInterval - * @param {Object} fn - * @param {Object} time - */ -setInterval = function(fn, time){ - //console.log('setting interval %s %s', time, fn.toString().substring(0,64)); - time = Timer.normalize(time); - if ( time < 10 ) { - time = 10; - } - if (typeof fn == 'string') { - var fnstr = fn; - fn = function() { - eval(fnstr); - }; - } - var num; - $timers.lock(function(){ - num = $timers.length+1; - //Envjs.debug("Creating timer number "+num); - $timers[num] = new Timer(fn, time); - $timers[num].start(); - }); - return num; -}; - -/** - * clearInterval - * @param {Object} num - */ -clearInterval = clearTimeout = function(num){ - //console.log("clearing interval "+num); - $timers.lock(function(){ - if ( $timers[num] ) { - $timers[num].stop(); - delete $timers[num]; - } - }); -}; - -// wait === null/undefined: execute any timers as they fire, -// waiting until there are none left -// wait(n) (n > 0): execute any timers as they fire until there -// are none left waiting at least n ms but no more, even if there -// are future events/current threads -// wait(0): execute any immediately runnable timers and return -// wait(-n): keep sleeping until the next event is more than n ms -// in the future -// -// TODO: make a priority queue ... - -Envjs.wait = function(wait) { - //console.log('wait %s', wait); - var delta_wait, - start = Date.now(), - was_running = EVENT_LOOP_RUNNING; - - if (wait < 0) { - delta_wait = -wait; - wait = 0; - } - EVENT_LOOP_RUNNING = true; - if (wait !== 0 && wait !== null && wait !== undefined){ - wait += Date.now(); - } - - var earliest, - timer, - sleep, - index, - goal, - now, - nextfn; - - for (;;) { - //console.log('timer loop'); - earliest = sleep = goal = now = nextfn = null; - $timers.lock(function(){ - for(index in $timers){ - if( isNaN(index*0) ) { - continue; - } - timer = $timers[index]; - // determine timer with smallest run-at time that is - // not already running - if( !timer.running && ( !earliest || timer.at < earliest.at) ) { - earliest = timer; - } - } - }); - //next sleep time - sleep = earliest && earliest.at - Date.now(); - if ( earliest && sleep <= 0 ) { - nextfn = earliest.fn; - try { - //console.log('running stack %s', nextfn.toString().substring(0,64)); - earliest.running = true; - nextfn(); - } catch (e) { - console.log('timer error %s %s', nextfn, e); - } finally { - earliest.running = false; - } - goal = earliest.at + earliest.interval; - now = Date.now(); - if ( goal < now ) { - earliest.at = now; - } else { - earliest.at = goal; - } - continue; - } - - // bunch of subtle cases here ... - if ( !earliest ) { - // no events in the queue (but maybe XHR will bring in events, so ... - if ( !wait || wait < Date.now() ) { - // Loop ends if there are no events and a wait hasn't been - // requested or has expired - break; - } - // no events, but a wait requested: fall through to sleep - } else { - // there are events in the queue, but they aren't firable now - /*if ( delta_wait && sleep <= delta_wait ) { - //TODO: why waste a check on a tight - // loop if it just falls through? - // if they will happen within the next delta, fall through to sleep - } else */if ( wait === 0 || ( wait > 0 && wait < Date.now () ) ) { - // loop ends even if there are events but the user - // specifcally asked not to wait too long - break; - } - // there are events and the user wants to wait: fall through to sleep - } - - // Related to ajax threads ... hopefully can go away .. - var interval = Envjs.WAIT_INTERVAL || 100; - if ( !sleep || sleep > interval ) { - sleep = interval; - } - //console.log('sleeping %s', sleep); - Envjs.sleep(sleep); - - } - EVENT_LOOP_RUNNING = was_running; -}; - - -/** - * @author john resig & the envjs team - * @uri http://www.envjs.com/ - * @copyright 2008-2010 - * @license MIT - */ -//CLOSURE_END -}()); -/* - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - * - * This file simply provides the global definitions we need to - * be able to correctly implement to core browser DOM HTML interfaces. - */ -var HTMLDocument, - HTMLElement, - HTMLCollection, - HTMLAnchorElement, - HTMLAreaElement, - HTMLBaseElement, - HTMLQuoteElement, - HTMLBodyElement, - HTMLBRElement, - HTMLButtonElement, - CanvasRenderingContext2D, - HTMLCanvasElement, - HTMLTableColElement, - HTMLModElement, - HTMLDivElement, - HTMLDListElement, - HTMLFieldSetElement, - HTMLFormElement, - HTMLFrameElement, - HTMLFrameSetElement, - HTMLHeadElement, - HTMLHeadingElement, - HTMLHRElement, - HTMLHtmlElement, - HTMLIFrameElement, - HTMLImageElement, - HTMLInputElement, - HTMLLabelElement, - HTMLLegendElement, - HTMLLIElement, - HTMLLinkElement, - HTMLMapElement, - HTMLMetaElement, - HTMLObjectElement, - HTMLOListElement, - HTMLOptGroupElement, - HTMLOptionElement, - HTMLParagraphElement, - HTMLParamElement, - HTMLPreElement, - HTMLScriptElement, - HTMLSelectElement, - HTMLSpanElement, - HTMLStyleElement, - HTMLTableElement, - HTMLTableSectionElement, - HTMLTableCellElement, - HTMLTableDataCellElement, - HTMLTableHeaderCellElement, - HTMLTableRowElement, - HTMLTextAreaElement, - HTMLTitleElement, - HTMLUListElement, - HTMLUnknownElement, - Image, - Option, - __loadImage__, - __loadLink__; - -/* - * Envjs html.1.2.13 - * Pure JavaScript Browser Environment - * By John Resig and the Envjs Team - * Copyright 2008-2010 John Resig, under the MIT License - */ - -//CLOSURE_START -(function(){ - - - - - -/** - * @author ariel flesler - * http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html - * @param {Object} str - */ -function __trim__( str ){ - return (str || "").replace( /^\s+|\s+$/g, "" ); -} - - -/** - * @author john resig - */ -// Helper method for extending one object with another. -function __extend__(a,b) { - for ( var i in b ) { - var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i); - if ( g || s ) { - if ( g ) { a.__defineGetter__(i, g); } - if ( s ) { a.__defineSetter__(i, s); } - } else { - a[i] = b[i]; - } - } return a; -} - -/** - * @author john resig - */ -//from jQuery -function __setArray__( target, array ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - target.length = 0; - Array.prototype.push.apply( target, array ); -} - -/** - * @class HTMLDocument - * The Document interface represents the entire HTML or XML document. - * Conceptually, it is the root of the document tree, and provides - * the primary access to the document's data. - * - * @extends Document - */ -HTMLDocument = function(implementation, ownerWindow, referrer) { - Document.apply(this, arguments); - this.referrer = referrer || ''; - this.baseURI = "about:blank"; - this.ownerWindow = ownerWindow; -}; - -HTMLDocument.prototype = new Document(); - -__extend__(HTMLDocument.prototype, { - createElement: function(tagName){ - var node; - tagName = tagName.toUpperCase(); - // create Element specifying 'this' as ownerDocument - // This is an html document so we need to use explicit interfaces per the - //TODO: would be much faster as a big switch - switch(tagName){ - case "A": - node = new HTMLAnchorElement(this);break; - case "AREA": - node = new HTMLAreaElement(this);break; - case "BASE": - node = new HTMLBaseElement(this);break; - case "BLOCKQUOTE": - node = new HTMLQuoteElement(this);break; - case "CANVAS": - node = new HTMLCanvasElement(this);break; - case "Q": - node = new HTMLQuoteElement(this);break; - case "BODY": - node = new HTMLBodyElement(this);break; - case "BR": - node = new HTMLBRElement(this);break; - case "BUTTON": - node = new HTMLButtonElement(this);break; - case "CAPTION": - node = new HTMLElement(this);break; - case "COL": - node = new HTMLTableColElement(this);break; - case "COLGROUP": - node = new HTMLTableColElement(this);break; - case "DEL": - node = new HTMLModElement(this);break; - case "INS": - node = new HTMLModElement(this);break; - case "DIV": - node = new HTMLDivElement(this);break; - case "DL": - node = new HTMLDListElement(this);break; - case "DT": - node = new HTMLElement(this); break; - case "FIELDSET": - node = new HTMLFieldSetElement(this);break; - case "FORM": - node = new HTMLFormElement(this);break; - case "FRAME": - node = new HTMLFrameElement(this);break; - case "H1": - node = new HTMLHeadingElement(this);break; - case "H2": - node = new HTMLHeadingElement(this);break; - case "H3": - node = new HTMLHeadingElement(this);break; - case "H4": - node = new HTMLHeadingElement(this);break; - case "H5": - node = new HTMLHeadingElement(this);break; - case "H6": - node = new HTMLHeadingElement(this);break; - case "HEAD": - node = new HTMLHeadElement(this);break; - case "HR": - node = new HTMLHRElement(this);break; - case "HTML": - node = new HTMLHtmlElement(this);break; - case "IFRAME": - node = new HTMLIFrameElement(this);break; - case "IMG": - node = new HTMLImageElement(this);break; - case "INPUT": - node = new HTMLInputElement(this);break; - case "LABEL": - node = new HTMLLabelElement(this);break; - case "LEGEND": - node = new HTMLLegendElement(this);break; - case "LI": - node = new HTMLLIElement(this);break; - case "LINK": - node = new HTMLLinkElement(this);break; - case "MAP": - node = new HTMLMapElement(this);break; - case "META": - node = new HTMLMetaElement(this);break; - case "NOSCRIPT": - node = new HTMLElement(this);break; - case "OBJECT": - node = new HTMLObjectElement(this);break; - case "OPTGROUP": - node = new HTMLOptGroupElement(this);break; - case "OL": - node = new HTMLOListElement(this); break; - case "OPTION": - node = new HTMLOptionElement(this);break; - case "P": - node = new HTMLParagraphElement(this);break; - case "PARAM": - node = new HTMLParamElement(this);break; - case "PRE": - node = new HTMLPreElement(this);break; - case "SCRIPT": - node = new HTMLScriptElement(this);break; - case "SELECT": - node = new HTMLSelectElement(this);break; - case "SMALL": - node = new HTMLElement(this);break; - case "SPAN": - node = new HTMLSpanElement(this);break; - case "STRONG": - node = new HTMLElement(this);break; - case "STYLE": - node = new HTMLStyleElement(this);break; - case "TABLE": - node = new HTMLTableElement(this);break; - case "TBODY": - node = new HTMLTableSectionElement(this);break; - case "TFOOT": - node = new HTMLTableSectionElement(this);break; - case "THEAD": - node = new HTMLTableSectionElement(this);break; - case "TD": - node = new HTMLTableDataCellElement(this);break; - case "TH": - node = new HTMLTableHeaderCellElement(this);break; - case "TEXTAREA": - node = new HTMLTextAreaElement(this);break; - case "TITLE": - node = new HTMLTitleElement(this);break; - case "TR": - node = new HTMLTableRowElement(this);break; - case "UL": - node = new HTMLUListElement(this);break; - default: - node = new HTMLUnknownElement(this); - } - // assign values to properties (and aliases) - node.nodeName = tagName; - return node; - }, - createElementNS : function (uri, local) { - //print('createElementNS :'+uri+" "+local); - if(!uri){ - return this.createElement(local); - }else if ("http://www.w3.org/1999/xhtml" == uri) { - return this.createElement(local); - } else if ("http://www.w3.org/1998/Math/MathML" == uri) { - return this.createElement(local); - } else { - return Document.prototype.createElementNS.apply(this,[uri, local]); - } - }, - get anchors(){ - return new HTMLCollection(this.getElementsByTagName('a')); - }, - get applets(){ - return new HTMLCollection(this.getElementsByTagName('applet')); - }, - get documentElement(){ - var html = Document.prototype.__lookupGetter__('documentElement').apply(this,[]); - if( html === null){ - html = this.createElement('html'); - this.appendChild(html); - html.appendChild(this.createElement('head')); - html.appendChild(this.createElement('body')); - } - return html; - }, - //document.head is non-standard - get head(){ - //console.log('get head'); - if (!this.documentElement) { - this.appendChild(this.createElement('html')); - } - var element = this.documentElement, - length = element.childNodes.length, - i; - //check for the presence of the head element in this html doc - for(i=0;i1?matches[1]:""; - }, - set domain(value){ - var i, - domainParts = this.domain.split('.').reverse(), - newDomainParts = value.split('.').reverse(); - if(newDomainParts.length > 1){ - for(i=0;i 0){ - event = doc.createEvent('HTMLEvents'); - event.initEvent( okay ? "load" : "error", false, false ); - node.dispatchEvent( event, false ); - } - }catch(e){ - console.log('error loading html element %s %e', node, e.toString()); - } - } - break; - case 'frame': - case 'iframe': - node.contentWindow = { }; - node.contentDocument = new HTMLDocument(new DOMImplementation(), node.contentWindow); - node.contentWindow.document = node.contentDocument; - try{ - Window; - }catch(e){ - node.contentDocument.addEventListener('DOMContentLoaded', function(){ - event = node.contentDocument.createEvent('HTMLEvents'); - event.initEvent("load", false, false); - node.dispatchEvent( event, false ); - }); - } - try{ - if (node.src && node.src.length > 0){ - //console.log("getting content document for (i)frame from %s", node.src); - Envjs.loadFrame(node, Envjs.uri(node.src)); - event = node.contentDocument.createEvent('HTMLEvents'); - event.initEvent("load", false, false); - node.dispatchEvent( event, false ); - }else{ - //I dont like this being here: - //TODO: better mix-in strategy so the try/catch isnt required - try{ - if(Window){ - Envjs.loadFrame(node); - //console.log('src/html/document.js: triggering frame load'); - event = node.contentDocument.createEvent('HTMLEvents'); - event.initEvent("load", false, false); - node.dispatchEvent( event, false ); - } - }catch(e){} - } - }catch(e){ - console.log('error loading html element %s %e', node, e.toString()); - } - break; - - case 'link': - if (node.href && node.href.length > 0) { - __loadLink__(node, node.href); - } - break; - /* - case 'img': - if (node.src && node.src.length > 0){ - // don't actually load anything, so we're "done" immediately: - event = doc.createEvent('HTMLEvents'); - event.initEvent("load", false, false); - node.dispatchEvent( event, false ); - } - break; - */ - case 'option': - node._updateoptions(); - break; - default: - if(node.getAttribute('onload')){ - console.log('calling attribute onload %s | %s', node.onload, node.tagName); - node.onload(); - } - break; - }//switch on name - default: - break; - }//switch on ns - break; - default: - // console.log('element appended: %s %s', node+'', node.namespaceURI); - }//switch on doc.parsing - return node; - -}); - -Aspect.around({ - target: Node, - method:"removeChild" -}, function(invocation) { - var event, - okay, - node = invocation.proceed(), - doc = node.ownerDocument; - if((node.nodeType !== Node.ELEMENT_NODE)){ - //for now we are only handling element insertions. probably we will need - //to handle text node changes to script tags and changes to src - //attributes - if(node.nodeType !== Node.DOCUMENT_NODE && node.uuid){ - //console.log('removing event listeners, %s', node, node.uuid); - node.removeEventListener('*', null, null); - } - return node; - } - //console.log('appended html element %s %s %s', node.namespaceURI, node.nodeName, node); - - switch(doc.parsing){ - case true: - //handled by parser if included - break; - case false: - switch(node.namespaceURI){ - case null: - //fall through - case "": - //fall through - case "http://www.w3.org/1999/xhtml": - //this is interesting dillema since our event engine is - //storing the registered events in an array accessed - //by the uuid property of the node. unforunately this - //means listeners hang out way after(forever ;)) the node - //has been removed and gone out of scope. - //console.log('removing event listeners, %s', node, node.uuid); - node.removeEventListener('*', null, null); - switch(node.tagName.toLowerCase()){ - case 'frame': - case 'iframe': - try{ - //console.log('removing iframe document'); - try{ - Envjs.unloadFrame(node); - }catch(e){ - console.log('error freeing resources from frame %s', e); - } - node.contentWindow = null; - node.contentDocument = null; - }catch(e){ - console.log('error unloading html element %s %e', node, e.toString()); - } - break; - default: - break; - }//switch on name - default: - break; - }//switch on ns - break; - default: - console.log('element appended: %s %s', node+'', node.namespaceURI); - }//switch on doc.parsing - return node; - -}); - - - -/** - * Named Element Support - * - * - */ - -/* - * - * @returns 'name' if the node has a appropriate name - * null if node does not have a name - */ - -var __isNamedElement__ = function(node) { - if (node.nodeType !== Node.ELEMENT_NODE) { - return null; - } - var tagName = node.tagName.toLowerCase(); - var nodename = null; - - switch (tagName) { - case 'embed': - case 'form': - case 'iframe': - nodename = node.getAttribute('name'); - break; - case 'applet': - nodename = node.id; - break; - case 'object': - // TODO: object needs to be 'fallback free' - nodename = node.id; - break; - case 'img': - nodename = node.id; - if (!nodename || ! node.getAttribute('name')) { - nodename = null; - } - break; - } - return (nodename) ? nodename : null; -}; - - -var __addNamedMap__ = function(target, node) { - var nodename = __isNamedElement__(node); - if (nodename) { - target.__defineGetter__(nodename, function() { - return node; - }); - } -}; - -var __removeNamedMap__ = function(target, node) { - if (!node) { - return; - } - var nodename = __isNamedElement__(node); - if (nodename) { - delete target[nodename]; - } -}; - -/** - * @name HTMLEvents - * @w3c:domlevel 2 - * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html - */ - -var __eval__ = function(script, node){ - if (!script == ""){ - // don't assemble environment if no script... - try{ - eval(script); - }catch(e){ - console.log('error evaluating %s', e); - } - } -}; - -var HTMLEvents= function(){}; -HTMLEvents.prototype = { - onload: function(event){ - __eval__(this.getAttribute('onload')||'', this); - }, - onunload: function(event){ - __eval__(this.getAttribute('onunload')||'', this); - }, - onabort: function(event){ - __eval__(this.getAttribute('onabort')||'', this); - }, - onerror: function(event){ - __eval__(this.getAttribute('onerror')||'', this); - }, - onselect: function(event){ - __eval__(this.getAttribute('onselect')||'', this); - }, - onchange: function(event){ - __eval__(this.getAttribute('onchange')||'', this); - }, - onsubmit: function(event){ - if (__eval__(this.getAttribute('onsubmit')||'', this)) { - this.submit(); - } - }, - onreset: function(event){ - __eval__(this.getAttribute('onreset')||'', this); - }, - onfocus: function(event){ - __eval__(this.getAttribute('onfocus')||'', this); - }, - onblur: function(event){ - __eval__(this.getAttribute('onblur')||'', this); - }, - onresize: function(event){ - __eval__(this.getAttribute('onresize')||'', this); - }, - onscroll: function(event){ - __eval__(this.getAttribute('onscroll')||'', this); - } -}; - -//HTMLDocument, HTMLFramesetElement, HTMLObjectElement -var __load__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("load", false, false); - element.dispatchEvent(event); - return event; -}; - -//HTMLFramesetElement, HTMLBodyElement -var __unload__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("unload", false, false); - element.dispatchEvent(event); - return event; -}; - -//HTMLObjectElement -var __abort__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("abort", true, false); - element.dispatchEvent(event); - return event; -}; - -//HTMLFramesetElement, HTMLObjectElement, HTMLBodyElement -var __error__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("error", true, false); - element.dispatchEvent(event); - return event; -}; - -//HTMLInputElement, HTMLTextAreaElement -var __select__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("select", true, false); - element.dispatchEvent(event); - return event; -}; - -//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement -var __change__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("change", true, false); - element.dispatchEvent(event); - return event; -}; - -//HtmlFormElement -var __submit__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("submit", true, true); - element.dispatchEvent(event); - return event; -}; - -//HtmlFormElement -var __reset__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("reset", false, false); - element.dispatchEvent(event); - return event; -}; - -//LABEL, INPUT, SELECT, TEXTAREA, and BUTTON -var __focus__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("focus", false, false); - element.dispatchEvent(event); - return event; -}; - -//LABEL, INPUT, SELECT, TEXTAREA, and BUTTON -var __blur__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("blur", false, false); - element.dispatchEvent(event); - return event; -}; - -//Window -var __resize__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("resize", true, false); - element.dispatchEvent(event); - return event; -}; - -//Window -var __scroll__ = function(element){ - var event = new Event('HTMLEvents'); - event.initEvent("scroll", true, false); - element.dispatchEvent(event); - return event; -}; - -/** - * @name KeyboardEvents - * @w3c:domlevel 2 - * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html - */ -var KeyboardEvents= function(){}; -KeyboardEvents.prototype = { - onkeydown: function(event){ - __eval__(this.getAttribute('onkeydown')||'', this); - }, - onkeypress: function(event){ - __eval__(this.getAttribute('onkeypress')||'', this); - }, - onkeyup: function(event){ - __eval__(this.getAttribute('onkeyup')||'', this); - } -}; - - -var __registerKeyboardEventAttrs__ = function(elm){ - if(elm.hasAttribute('onkeydown')){ - elm.addEventListener('keydown', elm.onkeydown, false); - } - if(elm.hasAttribute('onkeypress')){ - elm.addEventListener('keypress', elm.onkeypress, false); - } - if(elm.hasAttribute('onkeyup')){ - elm.addEventListener('keyup', elm.onkeyup, false); - } - return elm; -}; - -//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement -var __keydown__ = function(element){ - var event = new Event('KeyboardEvents'); - event.initEvent("keydown", false, false); - element.dispatchEvent(event); -}; - -//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement -var __keypress__ = function(element){ - var event = new Event('KeyboardEvents'); - event.initEvent("keypress", false, false); - element.dispatchEvent(event); -}; - -//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement -var __keyup__ = function(element){ - var event = new Event('KeyboardEvents'); - event.initEvent("keyup", false, false); - element.dispatchEvent(event); -}; - -/** - * @name MaouseEvents - * @w3c:domlevel 2 - * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html - */ -var MouseEvents= function(){}; -MouseEvents.prototype = { - onclick: function(event){ - __eval__(this.getAttribute('onclick')||'', this); - }, - ondblclick: function(event){ - __eval__(this.getAttribute('ondblclick')||'', this); - }, - onmousedown: function(event){ - __eval__(this.getAttribute('onmousedown')||'', this); - }, - onmousemove: function(event){ - __eval__(this.getAttribute('onmousemove')||'', this); - }, - onmouseout: function(event){ - __eval__(this.getAttribute('onmouseout')||'', this); - }, - onmouseover: function(event){ - __eval__(this.getAttribute('onmouseover')||'', this); - }, - onmouseup: function(event){ - __eval__(this.getAttribute('onmouseup')||'', this); - } -}; - -var __registerMouseEventAttrs__ = function(elm){ - if(elm.hasAttribute('onclick')){ - elm.addEventListener('click', elm.onclick, false); - } - if(elm.hasAttribute('ondblclick')){ - elm.addEventListener('dblclick', elm.ondblclick, false); - } - if(elm.hasAttribute('onmousedown')){ - elm.addEventListener('mousedown', elm.onmousedown, false); - } - if(elm.hasAttribute('onmousemove')){ - elm.addEventListener('mousemove', elm.onmousemove, false); - } - if(elm.hasAttribute('onmouseout')){ - elm.addEventListener('mouseout', elm.onmouseout, false); - } - if(elm.hasAttribute('onmouseover')){ - elm.addEventListener('mouseover', elm.onmouseover, false); - } - if(elm.hasAttribute('onmouseup')){ - elm.addEventListener('mouseup', elm.onmouseup, false); - } - return elm; -}; - - -var __click__ = function(element){ - var event = new Event('MouseEvents'); - event.initEvent("click", true, true, null, 0, - 0, 0, 0, 0, false, false, false, - false, null, null); - element.dispatchEvent(event); -}; -var __mousedown__ = function(element){ - var event = new Event('MouseEvents'); - event.initEvent("mousedown", true, true, null, 0, - 0, 0, 0, 0, false, false, false, - false, null, null); - element.dispatchEvent(event); -}; -var __mouseup__ = function(element){ - var event = new Event('MouseEvents'); - event.initEvent("mouseup", true, true, null, 0, - 0, 0, 0, 0, false, false, false, - false, null, null); - element.dispatchEvent(event); -}; -var __mouseover__ = function(element){ - var event = new Event('MouseEvents'); - event.initEvent("mouseover", true, true, null, 0, - 0, 0, 0, 0, false, false, false, - false, null, null); - element.dispatchEvent(event); -}; -var __mousemove__ = function(element){ - var event = new Event('MouseEvents'); - event.initEvent("mousemove", true, true, null, 0, - 0, 0, 0, 0, false, false, false, - false, null, null); - element.dispatchEvent(event); -}; -var __mouseout__ = function(element){ - var event = new Event('MouseEvents'); - event.initEvent("mouseout", true, true, null, 0, - 0, 0, 0, 0, false, false, false, - false, null, null); - element.dispatchEvent(event); -}; - -/** - * HTMLElement - DOM Level 2 - */ - - -/* Hack for http://www.prototypejs.org/ - * - * Prototype 1.6 (the library) creates a new global Element, which causes - * envjs to use the wrong Element. - * - * http://envjs.lighthouseapp.com/projects/21590/tickets/108-prototypejs-wont-load-due-it-clobbering-element - * - * Options: - * (1) Rename the dom/element to something else - * rejected: been done before. people want Element. - * (2) merge dom+html and not export Element to global namespace - * (meaning we would use a local var Element in a closure, so prototype - * can do what ever it wants) - * rejected: want dom and html separate - * (3) use global namespace (put everything under Envjs = {}) - * rejected: massive change - * (4) use commonjs modules (similar to (3) in spirit) - * rejected: massive change - * - * or - * - * (5) take a reference to Element during initial loading ("compile - * time"), and use the reference instead of "Element". That's - * what the next line does. We use __DOMElement__ if we need to - * reference the parent class. Only this file explcity uses - * Element so this should work, and is the most minimal change I - * could think of with no external API changes. - * - */ -var __DOMElement__ = Element; - -HTMLElement = function(ownerDocument) { - __DOMElement__.apply(this, arguments); -}; - -HTMLElement.prototype = new Element(); -__extend__(HTMLElement.prototype, HTMLEvents.prototype); -__extend__(HTMLElement.prototype, { - get className() { - return this.getAttribute("class")||''; - }, - set className(value) { - return this.setAttribute("class",__trim__(value)); - }, - get dir() { - return this.getAttribute("dir")||"ltr"; - }, - set dir(val) { - return this.setAttribute("dir",val); - }, - get id(){ - return this.getAttribute('id') || ''; - }, - set id(id){ - this.setAttribute('id', id); - }, - get innerHTML(){ - var ret = "", - i; - - // create string containing the concatenation of the string - // values of each child - for (i=0; i < this.childNodes.length; i++) { - if(this.childNodes[i]){ - if(this.childNodes[i].nodeType === Node.ELEMENT_NODE){ - ret += this.childNodes[i].xhtml; - } else if (this.childNodes[i].nodeType === Node.TEXT_NODE && i>0 && - this.childNodes[i-1].nodeType === Node.TEXT_NODE){ - //add a single space between adjacent text nodes - ret += " "+this.childNodes[i].xml; - }else{ - ret += this.childNodes[i].xml; - } - } - } - return ret; - }, - get lang() { - return this.getAttribute("lang"); - }, - set lang(val) { - return this.setAttribute("lang",val); - }, - get offsetHeight(){ - return Number((this.style.height || '').replace("px","")); - }, - get offsetWidth(){ - return Number((this.style.width || '').replace("px","")); - }, - offsetLeft: 0, - offsetRight: 0, - get offsetParent(){ - /* TODO */ - return; - }, - set offsetParent(element){ - /* TODO */ - return; - }, - scrollHeight: 0, - scrollWidth: 0, - scrollLeft: 0, - scrollRight: 0, - get style(){ - return this.getAttribute('style')||''; - }, - get title() { - return this.getAttribute("title"); - }, - set title(value) { - return this.setAttribute("title", value); - }, - get tabIndex(){ - var tabindex = this.getAttribute('tabindex'); - if(tabindex!==null){ - return Number(tabindex); - } else { - return 0; - } - }, - set tabIndex(value){ - if (value === undefined || value === null) { - value = 0; - } - this.setAttribute('tabindex',Number(value)); - }, - get outerHTML(){ - //Not in the specs but I'll leave it here for now. - return this.xhtml; - }, - scrollIntoView: function(){ - /*TODO*/ - return; - }, - toString: function(){ - return '[object HTMLElement]'; - }, - get xhtml() { - // HTMLDocument.xhtml is non-standard - // This is exactly like Document.xml except the tagName has to be - // lower cased. I dont like to duplicate this but its really not - // a simple work around between xml and html serialization via - // XMLSerializer (which uppercases html tags) and innerHTML (which - // lowercases tags) - - var ret = "", - ns = "", - name = (this.tagName+"").toLowerCase(), - attrs, - attrstring = "", - i; - - // serialize namespace declarations - if (this.namespaceURI){ - if((this === this.ownerDocument.documentElement) || - (!this.parentNode) || - (this.parentNode && - (this.parentNode.namespaceURI !== this.namespaceURI))) { - ns = ' xmlns' + (this.prefix ? (':' + this.prefix) : '') + - '="' + this.namespaceURI + '"'; - } - } - - // serialize Attribute declarations - attrs = this.attributes; - for(i=0;i< attrs.length;i++){ - attrstring += " "+attrs[i].name+'="'+attrs[i].xml+'"'; - } - - if(this.hasChildNodes()){ - // serialize this Element - ret += "<" + name + ns + attrstring +">"; - for(i=0;i< this.childNodes.length;i++){ - ret += this.childNodes[i].xhtml ? - this.childNodes[i].xhtml : - this.childNodes[i].xml; - } - ret += ""; - }else{ - switch(name){ - case 'script': - ret += "<" + name + ns + attrstring +">"; - break; - default: - ret += "<" + name + ns + attrstring +"/>"; - } - } - - return ret; - }, - - /** - * setAttribute use a dispatch table that other tags can set to - * "listen" to various values being set. The dispatch table - * and registration functions are at the end of the file. - * - */ - - setAttribute: function(name, value) { - var result = __DOMElement__.prototype.setAttribute.apply(this, arguments); - __addNamedMap__(this.ownerDocument, this); - var tagname = this.tagName; - var callback = HTMLElement.getAttributeCallback('set', tagname, name); - if (callback) { - callback(this, value); - } - }, - setAttributeNS: function(namespaceURI, name, value) { - var result = __DOMElement__.prototype.setAttributeNS.apply(this, arguments); - __addNamedMap__(this.ownerDocument, this); - var tagname = this.tagName; - var callback = HTMLElement.getAttributeCallback('set', tagname, name); - if (callback) { - callback(this, value); - } - - return result; - }, - setAttributeNode: function(newnode) { - var result = __DOMElement__.prototype.setAttributeNode.apply(this, arguments); - __addNamedMap__(this.ownerDocument, this); - var tagname = this.tagName; - var callback = HTMLElement.getAttributeCallback('set', tagname, newnode.name); - if (callback) { - callback(this, node.value); - } - return result; - }, - setAttributeNodeNS: function(newnode) { - var result = __DOMElement__.prototype.setAttributeNodeNS.apply(this, arguments); - __addNamedMap__(this.ownerDocument, this); - var tagname = this.tagName; - var callback = HTMLElement.getAttributeCallback('set', tagname, newnode.name); - if (callback) { - callback(this, node.value); - } - return result; - }, - removeAttribute: function(name) { - __removeNamedMap__(this.ownerDocument, this); - return __DOMElement__.prototype.removeAttribute.apply(this, arguments); - }, - removeAttributeNS: function(namespace, localname) { - __removeNamedMap__(this.ownerDocument, this); - return __DOMElement__.prototype.removeAttributeNS.apply(this, arguments); - }, - removeAttributeNode: function(name) { - __removeNamedMap__(this.ownerDocument, this); - return __DOMElement__.prototype.removeAttribute.apply(this, arguments); - }, - removeChild: function(oldChild) { - __removeNamedMap__(this.ownerDocument, oldChild); - return __DOMElement__.prototype.removeChild.apply(this, arguments); - }, - importNode: function(othernode, deep) { - var newnode = __DOMElement__.prototype.importNode.apply(this, arguments); - __addNamedMap__(this.ownerDocument, newnode); - return newnode; - }, - - // not actually sure if this is needed or not - replaceNode: function(newchild, oldchild) { - var newnode = __DOMElement__.prototype.replaceNode.apply(this, arguments); - __removeNamedMap__(this.ownerDocument, oldchild); - __addNamedMap__(this.ownerDocument, newnode); - return newnode; - } -}); - - -HTMLElement.attributeCallbacks = {}; -HTMLElement.registerSetAttribute = function(tag, attrib, callbackfn) { - HTMLElement.attributeCallbacks[tag + ':set:' + attrib] = callbackfn; -}; -HTMLElement.registerRemoveAttribute = function(tag, attrib, callbackfn) { - HTMLElement.attributeCallbacks[tag + ':remove:' + attrib] = callbackfn; -}; - -/** - * This is really only useful internally - * - */ -HTMLElement.getAttributeCallback = function(type, tag, attrib) { - return HTMLElement.attributeCallbacks[tag + ':' + type + ':' + attrib] || null; -}; -/* - * HTMLCollection - * - * HTML5 -- 2.7.2.1 HTMLCollection - * http://dev.w3.org/html5/spec/Overview.html#htmlcollection - * http://dev.w3.org/html5/spec/Overview.html#collections - */ -HTMLCollection = function(nodelist, type) { - - __setArray__(this, []); - var n; - for (var i=0; i= 0) && (idx < this.length)) ? this[idx] : null; - }, - - namedItem: function (name) { - return this[name] || null; - }, - - toString: function() { - return '[object HTMLCollection]'; - } -}; -/* - * a set of convenience classes to centralize implementation of - * properties and methods across multiple in-form elements - * - * the hierarchy of related HTML elements and their members is as follows: - * - * Condensed Version - * - * HTMLInputCommon - * * legent (no value attr) - * * fieldset (no value attr) - * * label (no value attr) - * * option (custom value) - * HTMLTypeValueInputs (extends InputCommon) - * * select (custom value) - * * button (just sets value) - * HTMLInputAreaCommon (extends TypeValueIput) - * * input (custom) - * * textarea (just sets value) - * - * ----------------------- - * HTMLInputCommon: common to all elements - * .form - * - * - * [common plus:] - * .align - * - *
      - * [identical to "legend" plus:] - * .margin - * - * - * **** - * - *