├── .gitignore ├── .gitmodules ├── .npmignore ├── Gruntfile.js ├── LICENSE ├── README.md ├── api └── index.html ├── build ├── cjs.js ├── cjs.min.js └── cjs.min.js.map ├── package.json ├── resources ├── api_doc_generator │ ├── lib │ │ ├── dox-foundation.js │ │ └── dox.js │ ├── tasks │ │ └── dox.js │ └── views │ │ ├── _footer.jade │ │ ├── _head.jade │ │ ├── css │ │ └── cjs-dox.css │ │ └── template.jade ├── docco.css ├── google-code-prettify │ ├── desert.css │ ├── doxy.css │ ├── lang-apollo.js │ ├── lang-basic.js │ ├── lang-clj.js │ ├── lang-css.js │ ├── lang-dart.js │ ├── lang-erlang.js │ ├── lang-go.js │ ├── lang-hs.js │ ├── lang-lisp.js │ ├── lang-llvm.js │ ├── lang-lua.js │ ├── lang-matlab.js │ ├── lang-ml.js │ ├── lang-mumps.js │ ├── lang-n.js │ ├── lang-pascal.js │ ├── lang-proto.js │ ├── lang-r.js │ ├── lang-rd.js │ ├── lang-scala.js │ ├── lang-sql.js │ ├── lang-tcl.js │ ├── lang-tex.js │ ├── lang-vb.js │ ├── lang-vhdl.js │ ├── lang-wiki.js │ ├── lang-xq.js │ ├── lang-yaml.js │ ├── prettify.css │ ├── prettify.js │ ├── run_prettify.js │ ├── sons-of-obsidian.css │ └── sunburst.css └── images │ ├── ConstraintJS_logo.svg │ ├── cjs_button.png │ ├── cjs_logo_256.png │ └── cjs_logo_64.png ├── src ├── array.js ├── binding.js ├── core.js ├── footer.js ├── header.js ├── liven.js ├── map.js ├── memoize.js ├── state_machine │ ├── cjs_events.js │ └── cjs_fsm.js ├── template │ ├── cjs_parser.js │ ├── cjs_template.js │ └── jsep.js └── util.js ├── test ├── chrome_memory_test_client.js ├── memory_test_extension │ ├── background.js │ ├── content_script.js │ └── manifest.json ├── memory_tests.js ├── playground.html ├── resources │ ├── qunit-1.12.0.css │ └── qunit-1.12.0.js ├── unit_tests.html └── unit_tests │ ├── array_test.js │ ├── binding_tests.js │ ├── constraint_test.js │ ├── example_tests.js │ ├── fsm_test.js │ ├── liven_test.js │ ├── map_test.js │ ├── memoize_test.js │ ├── template_test.js │ └── util_test.js └── types └── index.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | node_modules 3 | *.DS_Store 4 | *.zip 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "resources/cjs-dox"] 2 | path = resources/cjs-dox 3 | url = https://github.com/soney/cjs-dox.git 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | dist 2 | annotated_source 3 | docs 4 | *.swp 5 | node_modules 6 | *.DS_Store 7 | ./*.zip 8 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | var package = grunt.file.readJSON('package.json'), // Project configuration. 3 | src_files = ["src/util.js", "src/core.js", "src/array.js", "src/map.js", "src/liven.js", 4 | "src/memoize.js", "src/binding.js", "src/state_machine/cjs_fsm.js", 5 | "src/state_machine/cjs_events.js", "src/template/cjs_parser.js", 6 | "src/template/cjs_template.js", "src/template/jsep.js"], 7 | enclosed_src_files = (["src/header.js"]).concat(src_files, "src/footer.js"); 8 | 9 | grunt.initConfig({ 10 | pkg: package, 11 | jshint: { 12 | source: { 13 | src: src_files 14 | }, 15 | post_concat: { 16 | src: "build/cjs.js" 17 | } 18 | }, 19 | uglify: { 20 | development: { 21 | options: { 22 | banner: '/* <%= pkg.name %> - v<%= pkg.version %> (<%= pkg.homepage %>) */', 23 | report: 'gzip', 24 | sourceMapIn: "build/cjs.js.map", 25 | sourceMap: "build/cjs.min.js.map", 26 | sourceMappingURL: "cjs.min.js.map", 27 | sourceMapPrefix: 1 28 | }, 29 | src: "build/cjs.js", // Use concatenated files 30 | dest: "build/cjs.min.js" 31 | }, 32 | production: { 33 | options: { 34 | banner: '/* <%= pkg.name %> - v<%= pkg.version %> (<%= pkg.homepage %>) */', 35 | sourceMap: "build/cjs.min.js.map", 36 | sourceMappingURL: "cjs.min.js.map", 37 | sourceMapPrefix: 1 38 | }, 39 | src: "build/cjs.js", // Use concatenated files 40 | dest: "build/cjs.min.js" 41 | } 42 | }, 43 | concat_sourcemap: { 44 | options: { 45 | process: { 46 | data: { 47 | version: package.version // the updated version will be added to the concatenated file 48 | } 49 | }, 50 | sourceRoot: '..' 51 | }, 52 | js: { 53 | src: enclosed_src_files, 54 | dest: "build/cjs.js" 55 | } 56 | }, 57 | concat: { 58 | js: { 59 | options: { 60 | stripBanners: true, 61 | process: { 62 | data: { 63 | version: package.version // the updated version will be added to the concatenated file 64 | } 65 | } 66 | }, 67 | src: enclosed_src_files, 68 | dest: "build/cjs.js" 69 | } 70 | }, 71 | qunit: { 72 | files: ['test/unit_tests.html'] 73 | }, 74 | clean: { 75 | build: ["build/"] 76 | }, 77 | watch: { 78 | test: { 79 | files: src_files.concat(['test/unit_tests.js', 'test/unit_tests/*.js']), 80 | tasks: ['jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit'] 81 | }, 82 | quickdev: { 83 | files: src_files, 84 | tasks: ['concat_sourcemap'] 85 | }, 86 | full: { 87 | files: src_files.concat(['test/unit_tests.js', 'test/unit_tests/*.js']), 88 | tasks: ['jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit', 'uglify'] 89 | }, 90 | docs: { 91 | files: enclosed_src_files.concat(['resources/api_doc_generator/views/*', 'resources/api_doc_generator/lib/**']), 92 | tasks: ['dox'] 93 | } 94 | }, 95 | compress: { 96 | production: { 97 | options: { 98 | archive: '<%= pkg.name %>-<%= pkg.version %>.zip' 99 | }, 100 | files: [{ 101 | expand: true, 102 | cwd: 'build/', 103 | src: '*', 104 | dest: '<%= pkg.name %>-<%= pkg.version %>' 105 | }] 106 | } 107 | }, 108 | dox: { 109 | options: { 110 | title: "ConstraintJS Documentation", 111 | blob_name: "v<%= pkg.version %>" 112 | }, 113 | files: { 114 | src: enclosed_src_files, 115 | dest: 'api' 116 | } 117 | } 118 | }); 119 | 120 | grunt.registerTask('usetheforce_on', 'force the force option on if needed', 121 | function() { 122 | if (!grunt.option('force')) { 123 | grunt.config.set('usetheforce_set', true); 124 | grunt.option( 'force', true ); 125 | } 126 | }); 127 | grunt.registerTask('usetheforce_restore', 'turn force option off if we have previously set it', 128 | function() { 129 | if (grunt.config.get('usetheforce_set')) { 130 | grunt.option( 'force', false ); 131 | } 132 | }); 133 | 134 | // Load the plugin that provides the "uglify" task. 135 | grunt.loadNpmTasks('grunt-contrib-uglify'); 136 | grunt.loadNpmTasks('grunt-contrib-jshint'); 137 | grunt.loadNpmTasks('grunt-contrib-concat'); 138 | grunt.loadNpmTasks('grunt-contrib-clean'); 139 | grunt.loadNpmTasks('grunt-contrib-qunit'); 140 | grunt.loadNpmTasks('grunt-contrib-watch'); 141 | grunt.loadNpmTasks('grunt-contrib-compress'); 142 | grunt.loadNpmTasks('grunt-concat-sourcemap'); 143 | grunt.loadTasks('./resources/api_doc_generator/tasks'); 144 | 145 | // Default task(s). 146 | grunt.registerTask('default', ['clean', 'jshint:source', 'concat', 'jshint:post_concat', 'qunit', 'uglify:production', 'dox']); 147 | grunt.registerTask('dev', ['clean', 'jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit', 'uglify:development']); 148 | grunt.registerTask('package', ['clean', 'jshint:source', 'concat', 'jshint:post_concat', 'qunit', 'uglify:production', 'compress', 'dox']); 149 | grunt.registerTask('docs', ['dox']); 150 | 151 | grunt.registerTask('watch_dev', ['usetheforce_on', 'concat_sourcemap', 'watch:quickdev', 'usetheforce_restore']); 152 | grunt.registerTask('watch_doc', ['dox', 'watch:docs']); 153 | grunt.registerTask('watch_dev_full', ['usetheforce_on', 'jshint:source', 'concat_sourcemap', 'jshint:post_concat', 'qunit', 'uglify:development', 'watch:full', 'usetheforce_restore']); 154 | }; 155 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Stephen Oney, http://cjs.from.so/ 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | ConstraintJS 3 |

4 | 5 | ### Documentation 6 | For documentation or the full ConstraintJS API, visit [cjs.from.so/](http://cjs.from.so/ "ConstraintJS Website"). 7 | 8 | ### Downloads 9 | * [Latest stable release](https://github.com/soney/constraintjs/releases/latest "Latest stable release") 10 | * [Latest beta release](https://raw.github.com/soney/constraintjs/master/build/cjs.js "Latest beta release") (not recommended) 11 | 12 | ### Building from source 13 | If you'd rather build from this repository, you must install [node.js](http://nodejs.org/ "node.js") and [Grunt](http://gruntjs.com/installing-grunt, "Grunt"). Then, from inside the constraintjs source directory, run: 14 | 15 | npm install . 16 | grunt 17 | 18 | The CJS Library will appear in the *build/* directory. 19 | 20 | ### Notes on Development 21 | Make changes to the files in *src/* instead of *build/*. After you change a file, be sure to run `grunt` to re-build the files in *build/*. By default, the sourcemap generated for *build/cjs.min.js* links to the *build/cjs.js* file. To build a sourcemap that links back to the original *src/* files (significantly more useful for development), change `grunt` in the instructions above to `grunt dev`: 22 | 23 | npm install . 24 | grunt dev 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "constraintjs", 3 | "version": "0.9.8-beta3", 4 | "description": "Constraint library for JavaScript", 5 | "author": "Stephen Oney (http://from.so/)", 6 | "homepage": "http://cjs.from.so/", 7 | "repository": { 8 | "type" : "git", 9 | "url" : "https://github.com/soney/constraintjs.git" 10 | }, 11 | "licenses": [{ 12 | "type": "MIT", 13 | "url": "https://github.com/soney/constraintjs/blob/master/LICENSE" 14 | }], 15 | "main": "build/cjs.js", 16 | "types": "./types/index.d.ts", 17 | "private": false, 18 | "dependencies": { }, 19 | "devDependencies": { 20 | "grunt": "~0.4.2", 21 | "grunt-contrib-jshint": "~0.7", 22 | "grunt-contrib-qunit": "~0.3", 23 | "grunt-contrib-uglify": "~0.2", 24 | "grunt-contrib-concat": "~0.3", 25 | "grunt-contrib-watch": "~0.5", 26 | "grunt-contrib-clean": "~0.5", 27 | "grunt-contrib-compress": "~0.5", 28 | "grunt-concat-sourcemap": "~0.4", 29 | "underscore": "*", 30 | "commander": "~1.2.0", 31 | "jade": "*", 32 | "mkdirp": "*", 33 | "walkdir": "~0.0.7", 34 | "stylus": "~0.33.1", 35 | "rimraf": "2.x", 36 | "marked": ">= 0.2.10", 37 | "commander": "0.6.1", 38 | "mocha": "*", 39 | "should": "*" 40 | }, 41 | "engines": { 42 | "node": ">= 0.4.7" 43 | }, 44 | "scripts": {"test": "grunt test"} 45 | } 46 | -------------------------------------------------------------------------------- /resources/api_doc_generator/lib/dox-foundation.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Load Dependancies 3 | */ 4 | var fs = require('fs'), 5 | path = require('path'), 6 | jade = require('jade'), 7 | dox = require('./dox'), 8 | _ = require('underscore'), 9 | template; 10 | 11 | /** 12 | * Template used to produce the documentation 13 | */ 14 | var templatePath = exports.templatePath = '../views/template.jade'; 15 | 16 | var BASE_URL = "https://github.com/soney/ConstraintJS/blob/"; 17 | var get_link = function(fname, line, blob_name) { 18 | var rv = BASE_URL+blob_name+'/'+fname+"#L"+line; 19 | return rv; 20 | }; 21 | 22 | var get_doc = function(doc_info, options) { 23 | var info = { 24 | type: false, 25 | info: false, 26 | params: [], 27 | links: [], 28 | examples:[] 29 | }, 30 | fname = doc_info.file, 31 | doc = doc_info.doc, 32 | link = get_link(fname, doc.line, options.blob_name); 33 | info.link = link; 34 | info.fname = fname.replace("../src/", ""); 35 | info.line = doc.line; 36 | 37 | if(doc.description) { info.description = doc.description.full; } 38 | 39 | doc.tags.forEach(function(tag) { 40 | var type = tag.type; 41 | if(type === 'method' || type === 'class' || type === 'property') { 42 | info.type = type; 43 | } else if(tag.type === "param") { 44 | info.params.push(tag); 45 | } else if(tag.type === "return") { 46 | info.returns = tag; 47 | } else if(tag.type === "see") { 48 | info.links.push(tag.name); 49 | } else if(tag.type === "private") { 50 | info.private = true; 51 | } else if(tag.type === "expose") { 52 | info.exposed = true; 53 | } else if(tag.type === "example") { 54 | info.examples.push(tag.code); 55 | } else { 56 | //console.log(tag); 57 | } 58 | }); 59 | 60 | return info; 61 | }; 62 | 63 | /** 64 | * Parse source code to produce documentation 65 | */ 66 | exports.render = function(docs, options) { 67 | templatePath = path.resolve(__dirname, templatePath); 68 | var template = fs.readFileSync(templatePath).toString(), 69 | options = _.extend({ 70 | docs: docs 71 | }, options); 72 | return jade.compile(template, { filename: templatePath })(options); 73 | }; 74 | 75 | /** 76 | * Test if a method should be ignored or not 77 | * 78 | * @param {Object} method 79 | * @return {Boolean} true if the method is not private nor must be ignored 80 | * @api private 81 | */ 82 | exports.shouldPass = function(method) { 83 | if(method.isPrivate) {return false;} 84 | if(method.ignore) {return false;} 85 | 86 | return method.tags.filter(function(tag){ 87 | return tag.type === "private" || tag.type === "ignore"; 88 | }).length === 0; 89 | }; 90 | 91 | /* 92 | * Create an array of all the right files in the source dir 93 | */ 94 | exports.collectFiles = function(source, options, callback) { 95 | var dirtyFiles = [], 96 | ignore = options.ignore || [], 97 | files = []; 98 | 99 | // If more paths are given with the --source flag 100 | if(source.length >= 1){ 101 | var dirtyPaths = source; 102 | 103 | dirtyPaths.forEach(function(dirtyPath){ 104 | dirtyFiles = dirtyFiles.concat(require('walkdir').sync(path.resolve(process.cwd(), dirtyPath),{follow_symlinks:true})); 105 | }); 106 | } 107 | // Just one path given with the --source flag 108 | else { 109 | source = path.resolve(process.cwd(), source); 110 | dirtyFiles = require('walkdir').sync(source,{follow_symlinks:true}); // tee hee! 111 | } 112 | 113 | dirtyFiles.forEach(function(file){ 114 | file = path.relative(process.cwd(), file); 115 | 116 | var doNotIgnore = _.all(ignore, function(d) { 117 | // return true if no part of the path is in the ignore list 118 | return (file.indexOf(d) === -1); 119 | }); 120 | 121 | if ((file.substr(-2) === 'js') && doNotIgnore) { 122 | files.push(file); 123 | } 124 | }); 125 | 126 | return files; 127 | }; 128 | 129 | /* 130 | * Dox all the files found by collectFiles 131 | */ 132 | exports.doxFiles = function(source, target, options, files) { 133 | var source_to_return; 134 | files = files.map(function(file) { 135 | try { 136 | // If more paths are given with the --source flag 137 | if(source.length >= 1){ 138 | var tmpSource = source; 139 | 140 | tmpSource.forEach(function(s){ 141 | if(file.indexOf(s) !== -1) { 142 | source_to_return = s; 143 | } 144 | }); 145 | } else { 146 | source_to_return = source; 147 | } 148 | 149 | var content = fs.readFileSync(file).toString(); 150 | 151 | return { 152 | sourceFile: file, 153 | targetFile: path.relative(process.cwd(),target) + path.sep + file + '.html', 154 | dox: dox.parseComments(content, options) 155 | }; 156 | 157 | } catch(e) { console.log(e); } 158 | }); 159 | 160 | return files; 161 | }; 162 | 163 | exports.compileDox = function(files, options) { 164 | var subjects = {}; 165 | files.forEach(function(file) { 166 | var srcFile = file.sourceFile, 167 | dox = file.dox, lends = ""; 168 | dox.forEach(function(d) { 169 | delete d.code; 170 | d.tags.forEach(function(tag) { 171 | var type = tag.type; 172 | var info = {doc: d, file: file.sourceFile}; 173 | if(type === "method" || type === "property") { 174 | var name = lends + (tag.name || tag.string).replace(/\^\d+$/, ""); 175 | if(name[0] === "{") { 176 | console.log(d); 177 | } 178 | 179 | if(subjects.hasOwnProperty(name)) { 180 | subjects[name].push(info); 181 | } else { 182 | subjects[name] = [info]; 183 | } 184 | } else if(type === "lends") { 185 | lends = tag.string.length > 0 ? tag.string+"." : ""; 186 | } else if(type === "expose" || type==="class") { 187 | var name = tag.string; 188 | if(subjects.hasOwnProperty(name)) { 189 | subjects[name].push(info); 190 | } else { 191 | subjects[name] = [info]; 192 | } 193 | } else if(type === "see") { 194 | tag.name = lends+tag.local; 195 | tag.link = tag.name.replace(".", "_"); 196 | } else { 197 | } 198 | }); 199 | }); 200 | }); 201 | 202 | var tree = {children: []}; 203 | var keys = []; 204 | for(var key in subjects) { 205 | if(subjects.hasOwnProperty(key)) { 206 | keys.push(key); 207 | } 208 | } 209 | 210 | keys = keys.sort(function(a, b) { 211 | var diff = a.split(".").length - b.split(".").length; 212 | if(diff === 0) { 213 | var pna = _.last(a.split(".")), 214 | pnb = _.last(b.split(".")); 215 | 216 | if(pna[0].toLowerCase() !== pna[0] && pnb[0].toLowerCase() === pnb[0]) { 217 | return 1; 218 | } else if(pna[0].toLowerCase() === pna[0] && pnb[0].toLowerCase() !== pnb[0]) { 219 | return -1; 220 | } 221 | return a.localeCompare(b); 222 | } else { 223 | return diff; 224 | } 225 | }); 226 | 227 | //sort by levels 228 | keys.forEach(function(key) { 229 | var objs = key.replace(".prototype", "").split("."), 230 | ctree = tree, 231 | info = get_doc_info(subjects[key], options); 232 | 233 | var level = 0; 234 | objs.forEach(function(obj, i) { 235 | var index = _ .chain(ctree.children) 236 | .pluck("propname") 237 | .indexOf(obj) 238 | .value(); 239 | //console.log(index); 240 | if(index < 0) { 241 | var new_tree = {name: key, propname: obj, children: []}; 242 | ctree.children.push(new_tree); 243 | ctree = new_tree; 244 | } else { 245 | ctree = ctree.children[index]; 246 | } 247 | level++; 248 | }); 249 | 250 | if(info.type === 'method' || info.type === 'class') { 251 | ctree.short_colloquial = ctree.propname.replace('.prototype', '')+'()'; 252 | if(info.calltypes.length === 1) { 253 | ctree.colloquial = ctree.name + '(' + info.calltypes[0].params.map(function(x) { return x.name; }).join(', ') + ')'; 254 | } else { 255 | ctree.colloquial = ctree.name + '(...)'; 256 | } 257 | if(info.type === 'class') { 258 | ctree.colloquial = 'new ' + ctree.colloquial; 259 | } 260 | } else { 261 | ctree.short_colloquial = ctree.propname.replace('.prototype', ''); 262 | ctree.colloquial = ctree.name.replace('.prototype', ''); 263 | } 264 | ctree.short = ctree.name.indexOf(".")<0 ? ctree.name : "."+_.last(ctree.name.split(".")); 265 | 266 | _.extend(ctree, info); 267 | }); 268 | if(tree.children.length === 1) { 269 | tree = tree.children[0]; 270 | } 271 | 272 | return tree; 273 | }; 274 | 275 | var get_doc_info = function(docs, options) { 276 | var subinfos = docs.map(function(x) { return get_doc(x, options); }), 277 | info = { 278 | calltypes: [], 279 | description: "", 280 | type: "", 281 | sourceLinks: [], 282 | links: [], 283 | examples: [] 284 | }, 285 | has_source = false; 286 | 287 | _.each(subinfos, function(si) { 288 | if(si.returns || si.params.length>0) { 289 | info.calltypes.push(si); 290 | } 291 | if(si.description && (si.description.length > info.description.length)) { 292 | info.description = si.description; 293 | } 294 | var type = si.type; 295 | if(type === 'method' || type === 'class' || type === 'property') { 296 | info.type = type; 297 | } 298 | 299 | if(si.exposed) { 300 | info.sourceLinks.push({text:"(Exposed: "+si.fname+":"+si.line+")", link: si.link}); 301 | } else { 302 | if(!has_source) { 303 | info.sourceLinks.push({text:"Source: "+si.fname+":"+si.line+"", link: si.link}); 304 | } 305 | has_source = true; 306 | } 307 | info.links.push.apply(info.links, si.links); 308 | info.examples.push.apply(info.examples, si.examples); 309 | }); 310 | 311 | 312 | return info; 313 | }; 314 | -------------------------------------------------------------------------------- /resources/api_doc_generator/lib/dox.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Module dependencies. 3 | */ 4 | 5 | var markdown = require('marked'), 6 | /** 7 | * Escape the given `html`. 8 | * 9 | * @param {String} html 10 | * @return {String} 11 | * @api private 12 | */ 13 | 14 | escape = function(html){ 15 | return String(html) .replace(/&(?!\w+;)/g, '&') 16 | .replace(//g, '>'); 18 | }, 19 | stripOutsideTags = function(str) { 20 | return str.replace(/^<\w+>\s*/, '').replace(/\s*<\/\w+>\s*\n?\s*$/, ''); 21 | }; 22 | 23 | /** 24 | * Parse comments in the given string of `js`. 25 | * 26 | * @param {String} js 27 | * @param {Object} options 28 | * @return {Array} 29 | * @see exports.parseComment 30 | * @api public 31 | */ 32 | 33 | var line_num; 34 | exports.parseComments = function(js, options) { 35 | options = options || {}; 36 | js = js.replace(/\r\n/gm, '\n'); 37 | line_num = 1; 38 | 39 | var comments = [], 40 | raw = options.raw, 41 | comment, 42 | buf = '', 43 | ignore, 44 | withinMultiline = false, 45 | withinSingle = false, 46 | code, 47 | start_line_num = line_num; 48 | 49 | for (var i = 0, len = js.length; i < len; ++i) { 50 | // start comment 51 | if (!withinMultiline && !withinSingle && '/' == js[i] && '*' == js[i+1]) { 52 | start_line_num = line_num; 53 | // code following previous comment 54 | if (buf.trim().length) { 55 | comment = comments[comments.length - 1]; 56 | if(comment) { 57 | comment.code = code = buf.trim(); 58 | } 59 | buf = ''; 60 | } 61 | i += 2; 62 | withinMultiline = true; 63 | ignore = '!' == js[i]; 64 | // end comment 65 | } else if (withinMultiline && !withinSingle && '*' == js[i] && '/' == js[i+1]) { 66 | i += 2; 67 | buf = buf.replace(/^[ \t]*\* ?/gm, ''); 68 | var comment = exports.parseComment(buf, options); 69 | comment.ignore = ignore; 70 | comment.line = start_line_num; 71 | comments.push(comment); 72 | withinMultiline = ignore = false; 73 | buf = ''; 74 | } else if (!withinSingle && !withinMultiline && '/' == js[i] && '/' == js[i+1]) { 75 | withinSingle = true; 76 | buf += js[i]; 77 | } else if (withinSingle && !withinMultiline && '\n' == js[i]) { 78 | withinSingle = false; 79 | buf += js[i]; 80 | // buffer comment or code 81 | } else { 82 | buf += js[i]; 83 | } 84 | if('\n' == js[i]) { 85 | line_num++; 86 | } 87 | 88 | } 89 | 90 | if (comments.length === 0) { 91 | comments.push({ 92 | tags: [], 93 | description: {full: '', summary: '', body: ''}, 94 | isPrivate: false, 95 | line: start_line_num 96 | }); 97 | } 98 | 99 | // trailing code 100 | if (buf.trim().length) { 101 | comment = comments[comments.length - 1]; 102 | code = buf.trim(); 103 | comment.code = code; 104 | } 105 | 106 | return comments; 107 | }; 108 | 109 | /** 110 | * Parse the given comment `str`. 111 | * 112 | * The comment object returned contains the following 113 | * 114 | * - `tags` array of tag objects 115 | * - `description` the first line of the comment 116 | * - `body` lines following the description 117 | * - `content` both the description and the body 118 | * - `isPrivate` true when "@api private" is used 119 | * 120 | * @param {String} str 121 | * @param {Object} options 122 | * @return {Object} 123 | * @see exports.parseTag 124 | * @api public 125 | */ 126 | 127 | exports.parseComment = function(str, options) { 128 | str = str.trim(); 129 | options = options || {}; 130 | 131 | var comment = { tags: [] }, 132 | raw = options.raw, 133 | description = {}; 134 | 135 | if(str.indexOf("@")===0 && str.indexOf("\n")<0) { // one-line comment 136 | var tags = '@' + str.split('@').slice(1).join('@'); 137 | comment.tags = tags.split('\n').map(exports.parseTag); 138 | } else { 139 | // parse comment body 140 | description.full = str.split('\n@')[0]; 141 | description.summary = description.full.split('\n\n')[0]; 142 | description.body = description.full.split('\n\n').slice(1).join('\n\n'); 143 | comment.description = description; 144 | 145 | // parse tags 146 | if (~str.indexOf('\n@')) { 147 | var tags = str.split('\n@').slice(1).join('\n@'); 148 | comment.tags = tags.split('\n@').map(function(tag) { return "@" + tag; }).map(exports.parseTag); 149 | comment.isPrivate = comment.tags.some(function(tag){ 150 | return 'api' == tag.type && 'private' == tag.visibility; 151 | }) 152 | } 153 | 154 | // markdown 155 | if (!raw) { 156 | description.full = markdown(description.full); 157 | description.summary = markdown(description.summary); 158 | description.body = markdown(description.body); 159 | } 160 | } 161 | 162 | 163 | return comment; 164 | } 165 | 166 | /** 167 | * Parse tag string "@param {Array} name description" etc. 168 | * 169 | * @param {String} 170 | * @return {Object} 171 | * @api public 172 | */ 173 | 174 | exports.parseTag = function(str) { 175 | var tag = {}, 176 | parts = str.split(/[ ]+/), 177 | type = tag.type = parts.shift().replace('@', ''); 178 | 179 | if(str.match(/^@example[\s\n]/)) { 180 | str = str.replace(/^@example/, ""); 181 | //.trim(); 182 | tag = {type: "example", code: markdown(str)}; 183 | return tag; 184 | } 185 | 186 | switch (type) { 187 | case 'param': 188 | case 'property': 189 | tag.types = exports.parseTagTypes(parts.shift()); 190 | tag.name = parts.shift() || ''; 191 | tag.description = stripOutsideTags(markdown(parts.join(' ').replace(/^\s*-?\s*/, ''))); 192 | break; 193 | case 'return': 194 | tag.types = exports.parseTagTypes(parts.shift()); 195 | tag.description = stripOutsideTags(markdown(parts.join(' ').replace(/^\s*-?\s*/, ''))); 196 | break; 197 | case 'see': 198 | if (~str.indexOf('http')) { 199 | tag.title = parts.length > 1 200 | ? parts.shift() 201 | : ''; 202 | tag.url = parts.join(' '); 203 | } else { 204 | tag.local = parts.join(' '); 205 | } 206 | case 'api': 207 | tag.visibility = parts.shift(); 208 | break; 209 | case 'type': 210 | tag.types = exports.parseTagTypes(parts.shift()); 211 | break; 212 | case 'memberOf': 213 | tag.parent = parts.shift(); 214 | break; 215 | case 'augments': 216 | tag.otherClass = parts.shift(); 217 | break; 218 | case 'borrows': 219 | tag.otherMemberName = parts.join(' ').split(' as ')[0]; 220 | tag.thisMemberName = parts.join(' ').split(' as ')[1]; 221 | break; 222 | case 'throws': 223 | tag.types = exports.parseTagTypes(parts.shift()); 224 | tag.description = parts.join(' '); 225 | break; 226 | default: 227 | tag.string = parts.join(' '); 228 | break; 229 | } 230 | 231 | return tag; 232 | } 233 | 234 | /** 235 | * Parse tag type string "{Array|Object}" etc. 236 | * 237 | * @param {String} str 238 | * @return {Array} 239 | * @api public 240 | */ 241 | 242 | exports.parseTagTypes = function(str) { 243 | return str .replace(/[{}]/g, '') 244 | .split(/ *[|,\/] */); 245 | }; 246 | -------------------------------------------------------------------------------- /resources/api_doc_generator/tasks/dox.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-dox 3 | * https://github.com/punkave/grunt-dox 4 | * 5 | * Copyright (c) 2013 Matt McManus 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | var exec = require('child_process').exec, 10 | fs = require('fs'), 11 | mkdirp = require('mkdirp'), 12 | path = require('path'), 13 | rimraf = require('rimraf'), 14 | formatter = require('../lib/dox-foundation'), 15 | ignoredDirs = 'test,static,templates,node_modules'; 16 | 17 | module.exports = function(grunt) { 18 | grunt.registerMultiTask('dox', 'Generate dox output ', function() { 19 | var src = this.filesSrc, 20 | dest = this.data.dest, 21 | indexPath = path.relative(process.cwd(), dest + path.sep + 'index.html'), 22 | ignore = ignoredDirs.trim().replace(' ', '').split(','), 23 | options = this.options(); 24 | 25 | // Cleanup any existing docs 26 | rimraf.sync(dest); 27 | 28 | // Find, cleanup and validate all potential files 29 | var files = formatter.collectFiles(src, { ignore: ignore }, files), 30 | doxedFiles = formatter.doxFiles(src, dest, { raw: false }, files), 31 | dox = formatter.compileDox(doxedFiles, options), 32 | output = formatter.render(dox, options), 33 | dir = path.dirname(indexPath); 34 | 35 | if (!fs.existsSync(dir)) { 36 | mkdirp.sync(dir); 37 | } 38 | fs.writeFileSync(indexPath, output); 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /resources/api_doc_generator/views/_footer.jade: -------------------------------------------------------------------------------- 1 | script(src='http://code.jquery.com/jquery-1.10.1.min.js') 2 | script(src='http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js') 3 | script(src='../resources/google-code-prettify/prettify.js') 4 | script(src='../builds/constraintjs-latest/cjs.min.js') 5 | -------------------------------------------------------------------------------- /resources/api_doc_generator/views/_head.jade: -------------------------------------------------------------------------------- 1 | meta(name='viewport', content='width=device-width', charset='utf-8') 2 | 3 | title= title 4 | 5 | link(rel='stylesheet', href='http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css') 6 | link(rel='stylesheet', href='../style/stylesheet.css') 7 | link(rel='stylesheet', href='../style/page_style.css') 8 | link(rel='stylesheet', href='../resources/google-code-prettify/sunburst.css') 9 | | -------------------------------------------------------------------------------- /resources/api_doc_generator/views/css/cjs-dox.css: -------------------------------------------------------------------------------- 1 | .classname { 2 | font-size: 1.5em; 3 | padding-top: 5px; 4 | padding-bottom: 5px; 5 | } 6 | 7 | .returns .type, .param .type { 8 | padding-right: 5px; 9 | margin-right: 15px; 10 | } 11 | 12 | .params .param { 13 | margin-left: 20px; 14 | margin-right: 15px; 15 | min-width: 180px; 16 | font-weight: 400; 17 | } 18 | 19 | .param .name { 20 | font-family: Menlo,Monaco,Consolas,"Courier New",monospace; 21 | margin-right: 8px; 22 | font-weight: 800; 23 | padding-right: 5px; 24 | padding-left: 15px; 25 | } 26 | 27 | .params .type { 28 | font-style: oblique; 29 | margin-right: 15px; 30 | color: #aaa; 31 | padding-left: 5px; 32 | padding-right: 5px; 33 | } 34 | 35 | .params { 36 | border: 1px solid #E7E7E7; 37 | border-radius: 2px; 38 | } 39 | .param { 40 | vertical-align: top; 41 | } 42 | 43 | 44 | 45 | .type:before { 46 | content: "("; 47 | } 48 | .type:after { 49 | content: ")"; 50 | } 51 | 52 | 53 | .entry { 54 | margin-top: 5px; 55 | margin-bottom: 5px; 56 | border-radius: 3px; 57 | } 58 | 59 | 60 | .panel-footer { 61 | text-align: right; 62 | } 63 | body { 64 | tab-size: 4; 65 | } 66 | 67 | .returns { 68 | vertical-align: top; 69 | background-color: #F5F5F5; 70 | border-top: 1px dashed #DDD; 71 | } 72 | 73 | .returns .static { 74 | color: #aaa; 75 | font-style: oblique; 76 | padding-left: 15px; 77 | } 78 | 79 | .or { 80 | text-align: center; 81 | margin-top: 5px; 82 | margin-bottom: 5px; 83 | } 84 | .description { 85 | width: 100%; 86 | padding-left: 5px; 87 | } 88 | .calldesc { 89 | border-top: 1px solid #eee; 90 | border-bottom: 1px solid #eee; 91 | color: #333; 92 | font-family: Menlo,Monaco,Consolas,"Courier New",monospace; 93 | background-color: #333; 94 | font-weight: 400; 95 | background-color: #CCC; 96 | border: 1px solid #999; 97 | padding: 2px; 98 | } 99 | .noparam { 100 | padding-left: 15px; 101 | color: #aaa; 102 | font-style: oblique; 103 | } 104 | .sidebar .nav { 105 | /* 106 | display: none; 107 | */ 108 | padding-left: 10px; 109 | } 110 | .sidebar .nav li > a { 111 | padding-top: 1px; 112 | padding-bottom: 1px; 113 | } 114 | .sidebar .nav.top { 115 | padding-left: 0px; 116 | } 117 | .sidebar .nav li.active { 118 | border-right: 2px solid red; 119 | background-color: #F0F0F0; 120 | } 121 | .sidebar { 122 | height: 500px; 123 | overflow: scroll; 124 | border: 1px solid #BBB; 125 | background-color: #F7F7F7; 126 | } 127 | li.haschildren > a { 128 | font-weight: 800; 129 | color: black; 130 | } 131 | -------------------------------------------------------------------------------- /resources/api_doc_generator/views/template.jade: -------------------------------------------------------------------------------- 1 | mixin sidebarlist(tree, top) 2 | if top 3 | li.haschildren 4 | a(href='#'+tree.name.replace(/\./g, "_"))=tree.short_colloquial 5 | each item in tree.children 6 | li(class=item.children.length>0 ? "haschildren":"") 7 | a(href='#'+item.name.replace(/\./g, "_"))=item.short_colloquial 8 | +sidebarlist(item) 9 | 10 | mixin apidoclist(item) 11 | if item.colloquial 12 | .row(id=item.name.replace(/\./g, "_")) 13 | .col-md-12.entry 14 | .panel.panel-default 15 | .panel-heading.classname=item.colloquial 16 | .panel-body 17 | .desc!=item.description 18 | if item.calltypes && item.calltypes.length > 0 19 | table.params 20 | tbody 21 | each calltype,index in item.calltypes 22 | tr.callname 23 | td.calldesc(colspan=3)=item.short+'('+calltype.params.map(function(x){return x.name;}).join(", ")+')' 24 | each param in calltype.params 25 | tr.param 26 | td.name=param.name 27 | td.type=param.types 28 | td.description!=param.description 29 | if calltype.returns 30 | tr.returns 31 | td.static Returns 32 | td.type=calltype.returns.types 33 | td.description!=calltype.returns.description 34 | 35 | if item.examples && item.examples.length > 0 36 | .panel-body.examples 37 | h4=item.examples.length===1 ? "Example:" : "Example:" 38 | each example in item.examples 39 | .example!=example 40 | if item.examples && item.links.length > 0 41 | .panel-body.related 42 | h4 Related: 43 | ul.related_links 44 | each link in item.links 45 | li.also_see 46 | a(href="#"+link.replace(".","_"))=link 47 | .panel-footer 48 | if item.sourceLinks 49 | each link in item.sourceLinks 50 | a(target="_blank",href=link.link)=" " + link.text 51 | each child in item.children 52 | +apidoclist(child) 53 | 54 | doctype html 55 | html 56 | head 57 | include ./_head.jade 58 | 59 | body(data-spy="scroll",data-target=".sidebar") 60 | .container 61 | header.keystone.row 62 | .col-md-2 63 | a(href="..") 64 | img#cjs_logo(src="../resources/cjs_logo_256.png",title="ConstraintJS") 65 | .col-md-10 66 | ul.nav.navbar-nav.hidden-xs 67 | li 68 | a(href="..") Home 69 | li 70 | a(target="tut",href="https://github.com/soney/ConstraintJS/wiki") Tutorial 71 | li.active 72 | a(target="_blank",href=".") API 73 | .row 74 | .col-sm-3(role="complimentary").hidden-xs 75 | .sidebar.bs-sidebar(data-spy="affix", data-offset-top=0) 76 | ul.top.nav 77 | +sidebarlist(docs, true) 78 | .col-sm-9.content(role="main") 79 | h1 ConstraintJS API 80 | +apidoclist(docs) 81 | 82 | include ./_footer.jade 83 | script. 84 | $("pre").addClass("prettyprint"); 85 | var height_diff = 100; 86 | $(window).on('resize', function() { 87 | $(".sidebar").height(window.innerHeight-height_diff+"px"); 88 | }); 89 | $(".sidebar").height(window.innerHeight-height_diff+"px"); 90 | prettyPrint(); 91 | -------------------------------------------------------------------------------- /resources/docco.css: -------------------------------------------------------------------------------- 1 | /*--------------------- Typography ----------------------------*/ 2 | 3 | @font-face { 4 | font-family: 'aller-light'; 5 | src: url('public/fonts/aller-light.eot'); 6 | src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'), 7 | url('public/fonts/aller-light.woff') format('woff'), 8 | url('public/fonts/aller-light.ttf') format('truetype'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | @font-face { 14 | font-family: 'aller-bold'; 15 | src: url('public/fonts/aller-bold.eot'); 16 | src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'), 17 | url('public/fonts/aller-bold.woff') format('woff'), 18 | url('public/fonts/aller-bold.ttf') format('truetype'); 19 | font-weight: normal; 20 | font-style: normal; 21 | } 22 | 23 | @font-face { 24 | font-family: 'novecento-bold'; 25 | src: url('public/fonts/novecento-bold.eot'); 26 | src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'), 27 | url('public/fonts/novecento-bold.woff') format('woff'), 28 | url('public/fonts/novecento-bold.ttf') format('truetype'); 29 | font-weight: normal; 30 | font-style: normal; 31 | } 32 | 33 | /*--------------------- Layout ----------------------------*/ 34 | html { height: 100%; } 35 | body { 36 | font-family: "aller-light"; 37 | font-size: 14px; 38 | line-height: 18px; 39 | color: #30404f; 40 | margin: 0; padding: 0; 41 | height:100%; 42 | tab-size: 4; 43 | } 44 | #container { min-height: 100%; } 45 | 46 | a { 47 | color: #000; 48 | } 49 | 50 | b, strong { 51 | font-weight: normal; 52 | font-family: "aller-bold"; 53 | } 54 | 55 | p, ul, ol { 56 | margin: 15px 0 0px; 57 | } 58 | 59 | h1, h2, h3, h4, h5, h6 { 60 | color: #112233; 61 | line-height: 1em; 62 | font-weight: normal; 63 | font-family: "novecento-bold"; 64 | text-transform: uppercase; 65 | margin: 30px 0 15px 0; 66 | } 67 | 68 | h1 { 69 | margin-top: 40px; 70 | } 71 | 72 | hr { 73 | border: 0; 74 | background: 1px solid #ddd; 75 | height: 1px; 76 | margin: 20px 0; 77 | } 78 | 79 | pre, tt, code { 80 | font-size: 12px; line-height: 16px; 81 | font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; 82 | margin: 0; padding: 0; 83 | } 84 | .annotation pre { 85 | display: block; 86 | margin: 0; 87 | padding: 7px 10px; 88 | background: #fcfcfc; 89 | -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); 90 | -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); 91 | box-shadow: inset 0 0 10px rgba(0,0,0,0.1); 92 | overflow-x: auto; 93 | } 94 | .annotation pre code { 95 | border: 0; 96 | padding: 0; 97 | background: transparent; 98 | } 99 | 100 | 101 | blockquote { 102 | border-left: 5px solid #ccc; 103 | margin: 0; 104 | padding: 1px 0 1px 1em; 105 | } 106 | .sections blockquote p { 107 | font-family: Menlo, Consolas, Monaco, monospace; 108 | font-size: 12px; line-height: 16px; 109 | color: #999; 110 | margin: 10px 0 0; 111 | white-space: pre-wrap; 112 | } 113 | 114 | ul.sections { 115 | list-style: none; 116 | padding:0 0 5px 0;; 117 | margin:0; 118 | } 119 | 120 | /* 121 | Force border-box so that % widths fit the parent 122 | container without overlap because of margin/padding. 123 | 124 | More Info : http://www.quirksmode.org/css/box.html 125 | */ 126 | ul.sections > li > div { 127 | -moz-box-sizing: border-box; /* firefox */ 128 | -ms-box-sizing: border-box; /* ie */ 129 | -webkit-box-sizing: border-box; /* webkit */ 130 | -khtml-box-sizing: border-box; /* konqueror */ 131 | box-sizing: border-box; /* css3 */ 132 | } 133 | 134 | 135 | /*---------------------- Jump Page -----------------------------*/ 136 | #jump_to, #jump_page { 137 | margin: 0; 138 | background: white; 139 | -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; 140 | -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; 141 | font: 16px Arial; 142 | cursor: pointer; 143 | text-align: right; 144 | list-style: none; 145 | } 146 | 147 | #jump_to a { 148 | text-decoration: none; 149 | } 150 | 151 | #jump_to a.large { 152 | display: none; 153 | } 154 | #jump_to a.small { 155 | font-size: 22px; 156 | font-weight: bold; 157 | color: #676767; 158 | } 159 | 160 | #jump_to, #jump_wrapper { 161 | position: fixed; 162 | right: 0; top: 0; 163 | padding: 10px 15px; 164 | margin:0; 165 | } 166 | 167 | #jump_wrapper { 168 | display: none; 169 | padding:0; 170 | } 171 | 172 | #jump_to:hover #jump_wrapper { 173 | display: block; 174 | } 175 | 176 | #jump_page { 177 | padding: 5px 0 3px; 178 | margin: 0 0 25px 25px; 179 | } 180 | 181 | #jump_page .source { 182 | display: block; 183 | padding: 15px; 184 | text-decoration: none; 185 | border-top: 1px solid #eee; 186 | } 187 | 188 | #jump_page .source:hover { 189 | background: #f5f5ff; 190 | } 191 | 192 | #jump_page .source:first-child { 193 | } 194 | 195 | /*---------------------- Low resolutions (> 320px) ---------------------*/ 196 | @media only screen and (min-width: 320px) { 197 | .pilwrap { display: none; } 198 | 199 | ul.sections > li > div { 200 | display: block; 201 | padding:5px 10px 0 10px; 202 | } 203 | 204 | ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { 205 | padding-left: 30px; 206 | } 207 | 208 | ul.sections > li > div.content { 209 | background: #f5f5ff; 210 | overflow-x:auto; 211 | -webkit-box-shadow: inset 0 0 5px #e5e5ee; 212 | box-shadow: inset 0 0 5px #e5e5ee; 213 | border: 1px solid #dedede; 214 | margin:5px 10px 5px 10px; 215 | padding-bottom: 5px; 216 | } 217 | 218 | ul.sections > li > div.annotation pre { 219 | margin: 7px 0 7px; 220 | padding-left: 15px; 221 | } 222 | 223 | ul.sections > li > div.annotation p tt, .annotation code { 224 | background: #f8f8ff; 225 | border: 1px solid #dedede; 226 | font-size: 12px; 227 | padding: 0 0.2em; 228 | } 229 | } 230 | 231 | /*---------------------- (> 481px) ---------------------*/ 232 | @media only screen and (min-width: 481px) { 233 | #container { 234 | position: relative; 235 | } 236 | body { 237 | background-color: #F5F5FF; 238 | font-size: 15px; 239 | line-height: 21px; 240 | } 241 | pre, tt, code { 242 | line-height: 18px; 243 | } 244 | p, ul, ol { 245 | margin: 0 0 15px; 246 | } 247 | 248 | 249 | #jump_to { 250 | padding: 5px 10px; 251 | } 252 | #jump_wrapper { 253 | padding: 0; 254 | } 255 | #jump_to, #jump_page { 256 | font: 10px Arial; 257 | text-transform: uppercase; 258 | } 259 | #jump_page .source { 260 | padding: 5px 10px; 261 | } 262 | #jump_to a.large { 263 | display: inline-block; 264 | } 265 | #jump_to a.small { 266 | display: none; 267 | } 268 | 269 | 270 | 271 | #background { 272 | position: absolute; 273 | top: 0; bottom: 0; 274 | width: 350px; 275 | background: #fff; 276 | border-right: 1px solid #e5e5ee; 277 | z-index: -1; 278 | } 279 | 280 | ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { 281 | padding-left: 40px; 282 | } 283 | 284 | ul.sections > li { 285 | white-space: nowrap; 286 | } 287 | 288 | ul.sections > li > div { 289 | display: inline-block; 290 | } 291 | 292 | ul.sections > li > div.annotation { 293 | max-width: 350px; 294 | min-width: 350px; 295 | min-height: 5px; 296 | padding: 13px; 297 | overflow-x: hidden; 298 | white-space: normal; 299 | vertical-align: top; 300 | text-align: left; 301 | } 302 | ul.sections > li > div.annotation pre { 303 | margin: 15px 0 15px; 304 | padding-left: 15px; 305 | } 306 | 307 | ul.sections > li > div.content { 308 | padding: 13px; 309 | vertical-align: top; 310 | background: #f5f5ff; 311 | border: none; 312 | -webkit-box-shadow: none; 313 | box-shadow: none; 314 | } 315 | 316 | .pilwrap { 317 | position: relative; 318 | display: inline; 319 | } 320 | 321 | .pilcrow { 322 | font: 12px Arial; 323 | text-decoration: none; 324 | color: #454545; 325 | position: absolute; 326 | top: 3px; left: -20px; 327 | padding: 1px 2px; 328 | opacity: 0; 329 | -webkit-transition: opacity 0.2s linear; 330 | } 331 | .for-h1 .pilcrow { 332 | top: 47px; 333 | } 334 | .for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow { 335 | top: 35px; 336 | } 337 | 338 | ul.sections > li > div.annotation:hover .pilcrow { 339 | opacity: 1; 340 | } 341 | } 342 | 343 | /*---------------------- (> 1025px) ---------------------*/ 344 | @media only screen and (min-width: 1025px) { 345 | 346 | body { 347 | font-size: 16px; 348 | line-height: 24px; 349 | } 350 | 351 | #background { 352 | width: 525px; 353 | } 354 | ul.sections > li > div.annotation { 355 | max-width: 525px; 356 | min-width: 525px; 357 | padding: 10px 25px 1px 50px; 358 | } 359 | ul.sections > li > div.content { 360 | padding: 9px 15px 16px 25px; 361 | } 362 | } 363 | 364 | /*---------------------- Syntax Highlighting -----------------------------*/ 365 | 366 | td.linenos { background-color: #f0f0f0; padding-right: 10px; } 367 | span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } 368 | /* 369 | 370 | github.com style (c) Vasily Polovnyov 371 | 372 | */ 373 | 374 | pre code { 375 | display: block; padding: 0.5em; 376 | color: #000; 377 | background: #f8f8ff 378 | } 379 | 380 | pre .comment, 381 | pre .template_comment, 382 | pre .diff .header, 383 | pre .javadoc { 384 | color: #408080; 385 | font-style: italic 386 | } 387 | 388 | pre .keyword, 389 | pre .assignment, 390 | pre .literal, 391 | pre .css .rule .keyword, 392 | pre .winutils, 393 | pre .javascript .title, 394 | pre .lisp .title, 395 | pre .subst { 396 | color: #954121; 397 | /*font-weight: bold*/ 398 | } 399 | 400 | pre .number, 401 | pre .hexcolor { 402 | color: #40a070 403 | } 404 | 405 | pre .string, 406 | pre .tag .value, 407 | pre .phpdoc, 408 | pre .tex .formula { 409 | color: #219161; 410 | } 411 | 412 | pre .title, 413 | pre .id { 414 | color: #19469D; 415 | } 416 | pre .params { 417 | color: #00F; 418 | } 419 | 420 | pre .javascript .title, 421 | pre .lisp .title, 422 | pre .subst { 423 | font-weight: normal 424 | } 425 | 426 | pre .class .title, 427 | pre .haskell .label, 428 | pre .tex .command { 429 | color: #458; 430 | font-weight: bold 431 | } 432 | 433 | pre .tag, 434 | pre .tag .title, 435 | pre .rules .property, 436 | pre .django .tag .keyword { 437 | color: #000080; 438 | font-weight: normal 439 | } 440 | 441 | pre .attribute, 442 | pre .variable, 443 | pre .instancevar, 444 | pre .lisp .body { 445 | color: #008080 446 | } 447 | 448 | pre .regexp { 449 | color: #B68 450 | } 451 | 452 | pre .class { 453 | color: #458; 454 | font-weight: bold 455 | } 456 | 457 | pre .symbol, 458 | pre .ruby .symbol .string, 459 | pre .ruby .symbol .keyword, 460 | pre .ruby .symbol .keymethods, 461 | pre .lisp .keyword, 462 | pre .tex .special, 463 | pre .input_number { 464 | color: #990073 465 | } 466 | 467 | pre .builtin, 468 | pre .constructor, 469 | pre .built_in, 470 | pre .lisp .title { 471 | color: #0086b3 472 | } 473 | 474 | pre .preprocessor, 475 | pre .pi, 476 | pre .doctype, 477 | pre .shebang, 478 | pre .cdata { 479 | color: #999; 480 | font-weight: bold 481 | } 482 | 483 | pre .deletion { 484 | background: #fdd 485 | } 486 | 487 | pre .addition { 488 | background: #dfd 489 | } 490 | 491 | pre .diff .change { 492 | background: #0086b3 493 | } 494 | 495 | pre .chunk { 496 | color: #aaa 497 | } 498 | 499 | pre .tex .formula { 500 | opacity: 0.5; 501 | } 502 | -------------------------------------------------------------------------------- /resources/google-code-prettify/desert.css: -------------------------------------------------------------------------------- 1 | /* desert scheme ported from vim to google prettify */ 2 | pre.prettyprint { display: block; background-color: #333 } 3 | pre .nocode { background-color: none; color: #000 } 4 | pre .str { color: #ffa0a0 } /* string - pink */ 5 | pre .kwd { color: #f0e68c; font-weight: bold } 6 | pre .com { color: #87ceeb } /* comment - skyblue */ 7 | pre .typ { color: #98fb98 } /* type - lightgreen */ 8 | pre .lit { color: #cd5c5c } /* literal - darkred */ 9 | pre .pun { color: #fff } /* punctuation */ 10 | pre .pln { color: #fff } /* plaintext */ 11 | pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */ 12 | pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */ 13 | pre .atv { color: #ffa0a0 } /* attribute value - pink */ 14 | pre .dec { color: #98fb98 } /* decimal - lightgreen */ 15 | 16 | /* Specify class=linenums on a pre to get line numbering */ 17 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE } /* IE indents via margin-left */ 18 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 19 | /* Alternate shading for lines */ 20 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 21 | 22 | @media print { 23 | pre.prettyprint { background-color: none } 24 | pre .str, code .str { color: #060 } 25 | pre .kwd, code .kwd { color: #006; font-weight: bold } 26 | pre .com, code .com { color: #600; font-style: italic } 27 | pre .typ, code .typ { color: #404; font-weight: bold } 28 | pre .lit, code .lit { color: #044 } 29 | pre .pun, code .pun { color: #440 } 30 | pre .pln, code .pln { color: #000 } 31 | pre .tag, code .tag { color: #006; font-weight: bold } 32 | pre .atn, code .atn { color: #404 } 33 | pre .atv, code .atv { color: #060 } 34 | } 35 | -------------------------------------------------------------------------------- /resources/google-code-prettify/doxy.css: -------------------------------------------------------------------------------- 1 | /* Doxy pretty-printing styles. Used with prettify.js. */ 2 | 3 | pre .str, code .str { color: #fec243; } /* string - eggyolk gold */ 4 | pre .kwd, code .kwd { color: #8470FF; } /* keyword - light slate blue */ 5 | pre .com, code .com { color: #32cd32; font-style: italic; } /* comment - green */ 6 | pre .typ, code .typ { color: #6ecbcc; } /* type - turq green */ 7 | pre .lit, code .lit { color: #d06; } /* literal - cherry red */ 8 | pre .pun, code .pun { color: #8B8970; } /* punctuation - lemon chiffon4 */ 9 | pre .pln, code .pln { color: #f0f0f0; } /* plaintext - white */ 10 | pre .tag, code .tag { color: #9c9cff; } /* html/xml tag (bluey) */ 11 | pre .htm, code .htm { color: #dda0dd; } /* html tag light purply*/ 12 | pre .xsl, code .xsl { color: #d0a0d0; } /* xslt tag light purply*/ 13 | pre .atn, code .atn { color: #46eeee; font-weight: normal;} /* html/xml attribute name - lt turquoise */ 14 | pre .atv, code .atv { color: #EEB4B4; } /* html/xml attribute value - rosy brown2 */ 15 | pre .dec, code .dec { color: #3387CC; } /* decimal - blue */ 16 | 17 | a { 18 | text-decoration: none; 19 | } 20 | pre.prettyprint, code.prettyprint { 21 | font-family:'Droid Sans Mono','CPMono_v07 Bold','Droid Sans'; 22 | font-weight: bold; 23 | font-size: 9pt; 24 | background-color: #0f0f0f; 25 | -moz-border-radius: 8px; 26 | -webkit-border-radius: 8px; 27 | -o-border-radius: 8px; 28 | -ms-border-radius: 8px; 29 | -khtml-border-radius: 8px; 30 | border-radius: 8px; 31 | } /* background is black (well, just a tad less dark ) */ 32 | 33 | pre.prettyprint { 34 | width: 95%; 35 | margin: 1em auto; 36 | padding: 1em; 37 | white-space: pre-wrap; 38 | } 39 | 40 | pre.prettyprint a, code.prettyprint a { 41 | text-decoration:none; 42 | } 43 | /* Specify class=linenums on a pre to get line numbering; line numbers themselves are the same color as punctuation */ 44 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #8B8970; } /* IE indents via margin-left */ 45 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 46 | /* Alternate shading for lines */ 47 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 48 | 49 | /* print is mostly unchanged from default at present */ 50 | @media print { 51 | pre.prettyprint, code.prettyprint { background-color: #fff; } 52 | pre .str, code .str { color: #088; } 53 | pre .kwd, code .kwd { color: #006; font-weight: bold; } 54 | pre .com, code .com { color: #oc3; font-style: italic; } 55 | pre .typ, code .typ { color: #404; font-weight: bold; } 56 | pre .lit, code .lit { color: #044; } 57 | pre .pun, code .pun { color: #440; } 58 | pre .pln, code .pln { color: #000; } 59 | pre .tag, code .tag { color: #b66ff7; font-weight: bold; } 60 | pre .htm, code .htm { color: #606; font-weight: bold; } 61 | pre .xsl, code .xsl { color: #606; font-weight: bold; } 62 | pre .atn, code .atn { color: #c71585; font-weight: normal; } 63 | pre .atv, code .atv { color: #088; font-weight: normal; } 64 | } 65 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-apollo.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\n\r]*/,null,"#"],["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 2 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[ES]?BANK=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-basic.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^"(?:[^\n\r"\\]|\\.)*(?:"|$)/,a,'"'],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^REM[^\n\r]*/,a],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,a],["pln",/^[a-z][^\W_]?(?:\$|%)?/i,a],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i,a,"0123456789"],["pun", 3 | /^.[^\s\w"$%.]*/,a]]),["basic","cbm"]); 4 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-clj.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 Google Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | var a=null; 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,a], 18 | ["typ",/^:[\dA-Za-z-]+/]]),["clj"]); 19 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n\u000c"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]+)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//], 2 | ["com",/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}\b/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-dart.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"]],[["com",/^#!.*/],["kwd",/^\b(?:import|library|part of|part|as|show|hide)\b/i],["com",/^\/\/.*/],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["kwd",/^\b(?:class|interface)\b/i],["kwd",/^\b(?:assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b/i],["kwd",/^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i], 2 | ["typ",/^\b(?:bool|double|dynamic|int|num|object|string|void)\b/i],["kwd",/^\b(?:false|null|true)\b/i],["str",/^r?'''[\S\s]*?[^\\]'''/],["str",/^r?"""[\S\s]*?[^\\]"""/],["str",/^r?'('|[^\n\f\r]*?[^\\]')/],["str",/^r?"("|[^\n\f\r]*?[^\\]")/],["pln",/^[$_a-z]\w*/i],["pun",/^[!%&*+/:<-?^|~-]/],["lit",/^\b0x[\da-f]+/i],["lit",/^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],["lit",/^\b\.\d+(?:e[+-]?\d+)?/i],["pun",/^[(),.;[\]{}]/]]), 3 | ["dart"]); 4 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-erlang.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["lit",/^[a-z]\w*/],["lit",/^'(?:[^\n\f\r'\\]|\\[^&])+'?/,null,"'"],["lit",/^\?[^\t\n ({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/], 2 | ["kwd",/^-[_a-z]+/],["typ",/^[A-Z_]\w*/],["pun",/^[,.;]/]]),["erlang","erl"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-go.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["pln",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])+(?:'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\/\*[\S\s]*?\*\/)/],["pln",/^(?:[^"'/`]|\/(?![*/]))+/]]),["go"]); 2 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-hs.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^\n\f\r'\\]|\\[^&])'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:--+[^\n\f\r]*|{-(?:[^-]|-+[^}-])*-})/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^\d'A-Za-z]|$)/, 2 | null],["pln",/^(?:[A-Z][\w']*\.)*[A-Za-z][\w']*/],["pun",/^[^\d\t-\r "'A-Za-z]+/]]),["hs"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-lisp.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,a], 3 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 4 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-llvm.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^!?"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["com",/^;[^\n\r]*/,null,";"]],[["pln",/^[!%@](?:[$\-.A-Z_a-z][\w$\-.]*|\d+)/],["kwd",/^[^\W\d]\w*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[Xx][\dA-Fa-f]+)/],["pun",/^[(-*,:<->[\]{}]|\.\.\.$/]]),["llvm","ll"]); 2 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-lua.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\S\s]*?(?:]\1]|$)|[^\n\r]*)/],["str",/^\[(=*)\[[\S\s]*?(?:]\1]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i], 2 | ["pln",/^[_a-z]\w*/i],["pun",/^[^\w\t\n\r \xa0][^\w\t\n\r "'+=\xa0-]*/]]),["lua"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-ml.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xa0]+(?:[$_a-z][\w']*|``[^\t\n\r`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])(?:'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\(\*[\S\s]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/], 2 | ["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^(?:[_a-z][\w']*[!#?]?|``[^\t\n\r`]*(?:``|$))/i],["pun",/^[^\w\t\n\r "'\xa0]+/]]),["fs","ml"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-mumps.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:[^"]|\\.)*"/,null,'"']],[["com",/^;[^\n\r]*/,null,";"],["dec",/^\$(?:d|device|ec|ecode|es|estack|et|etrap|h|horolog|i|io|j|job|k|key|p|principal|q|quit|st|stack|s|storage|sy|system|t|test|tl|tlevel|tr|trestart|x|y|z[a-z]*|a|ascii|c|char|d|data|e|extract|f|find|fn|fnumber|g|get|j|justify|l|length|na|name|o|order|p|piece|ql|qlength|qs|qsubscript|q|query|r|random|re|reverse|s|select|st|stack|t|text|tr|translate|nan)\b/i, 2 | null],["kwd",/^(?:[^$]b|break|c|close|d|do|e|else|f|for|g|goto|h|halt|h|hang|i|if|j|job|k|kill|l|lock|m|merge|n|new|o|open|q|quit|r|read|s|set|tc|tcommit|tre|trestart|tro|trollback|ts|tstart|u|use|v|view|w|write|x|xecute)\b/i,null],["lit",/^[+-]?(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?/i],["pln",/^[a-z][^\W_]*/i],["pun",/^[^\w\t\n\r"$%;^\xa0]|_/]]),["mumps"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-n.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/, 3 | a],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/, 4 | a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]); 5 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-pascal.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^'(?:[^\n\r'\\]|\\.)*(?:'|$)/,a,"'"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^\(\*[\S\s]*?(?:\*\)|$)|^{[\S\s]*?(?:}|$)/,a],["kwd",/^(?:absolute|and|array|asm|assembler|begin|case|const|constructor|destructor|div|do|downto|else|end|external|for|forward|function|goto|if|implementation|in|inline|interface|interrupt|label|mod|not|object|of|or|packed|procedure|program|record|repeat|set|shl|shr|then|to|type|unit|until|uses|var|virtual|while|with|xor)\b/i,a], 3 | ["lit",/^(?:true|false|self|nil)/i,a],["pln",/^[a-z][^\W_]*/i,a],["lit",/^(?:\$[\da-f]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/i,a,"0123456789"],["pun",/^.[^\s\w$'./@]*/,a]]),["pascal"]); 4 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-proto.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]); 2 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-r.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^'\\]|\\[\S\s])*(?:'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![\w.])/],["lit",/^0[Xx][\dA-Fa-f]+([Pp]\d+)?[Li]?/],["lit",/^[+-]?(\d+(\.\d+)?|\.\d+)([Ee][+-]?\d+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|\d+))(?![\w.])/], 2 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|[!*+/^]|%.*?%|[$=@~]|:{1,3}|[(),;?[\]{}])/],["pln",/^(?:[A-Za-z]+[\w.]*|\.[^\W\d][\w.]*)(?![\w.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-rd.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\n\r]*/,null,"%"]],[["lit",/^\\(?:cr|l?dots|R|tab)\b/],["kwd",/^\\[@-Za-z]+/],["kwd",/^#(?:ifn?def|endif)/],["pln",/^\\[{}]/],["pun",/^[()[\]{}]+/]]),["Rd","rd"]); 2 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-scala.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^"(?:""(?:""?(?!")|[^"\\]|\\.)*"{0,3}|(?:[^\n\r"\\]|\\.)*"?)/,null,'"'],["lit",/^`(?:[^\n\r\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&(--:-@[-^{-~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\n\r'\\]|\\(?:'|[^\n\r']+))'/],["lit",/^'[$A-Z_a-z][\w$]*(?![\w$'])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/], 2 | ["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:0(?:[0-7]+|x[\da-f]+)l?|(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:e[+-]?\d+)?f?|l?)|\\.\d+(?:e[+-]?\d+)?f?)/i],["typ",/^[$_]*[A-Z][\d$A-Z_]*[a-z][\w$]*/],["pln",/^[$A-Z_a-z][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-sql.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\n\r]*|\/\*[\S\s]*?(?:\*\/|$))/],["kwd",/^(?:add|all|alter|and|any|apply|as|asc|authorization|backup|begin|between|break|browse|bulk|by|cascade|case|check|checkpoint|close|clustered|coalesce|collate|column|commit|compute|connect|constraint|contains|containstable|continue|convert|create|cross|current|current_date|current_time|current_timestamp|current_user|cursor|database|dbcc|deallocate|declare|default|delete|deny|desc|disk|distinct|distributed|double|drop|dummy|dump|else|end|errlvl|escape|except|exec|execute|exists|exit|fetch|file|fillfactor|following|for|foreign|freetext|freetexttable|from|full|function|goto|grant|group|having|holdlock|identity|identitycol|identity_insert|if|in|index|inner|insert|intersect|into|is|join|key|kill|left|like|lineno|load|match|matched|merge|natural|national|nocheck|nonclustered|nocycle|not|null|nullif|of|off|offsets|on|open|opendatasource|openquery|openrowset|openxml|option|or|order|outer|over|partition|percent|pivot|plan|preceding|precision|primary|print|proc|procedure|public|raiserror|read|readtext|reconfigure|references|replication|restore|restrict|return|revoke|right|rollback|rowcount|rowguidcol|rows?|rule|save|schema|select|session_user|set|setuser|shutdown|some|start|statistics|system_user|table|textsize|then|to|top|tran|transaction|trigger|truncate|tsequal|unbounded|union|unique|unpivot|update|updatetext|use|user|using|values|varying|view|waitfor|when|where|while|with|within|writetext|xml)(?=[^\w-]|$)/i, 2 | null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i],["pln",/^[_a-z][\w-]*/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'+\xa0-]*/]]),["sql"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-tcl.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^{+/,a,"{"],["clo",/^}+/,a,"}"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/,a],["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit", 3 | /^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["tcl"]); 4 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-tex.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\n\r]*/,null,"%"]],[["kwd",/^\\[@-Za-z]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[()=[\]{}]+/]]),["latex","tex"]); 2 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-vb.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})(?:["\u201c\u201d]c|$)|["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})*(?:["\u201c\u201d]|$))/i,null,'"\u201c\u201d'],["com",/^['\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\n\r_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:addhandler|addressof|alias|and|andalso|ansi|as|assembly|auto|boolean|byref|byte|byval|call|case|catch|cbool|cbyte|cchar|cdate|cdbl|cdec|char|cint|class|clng|cobj|const|cshort|csng|cstr|ctype|date|decimal|declare|default|delegate|dim|directcast|do|double|each|else|elseif|end|endif|enum|erase|error|event|exit|finally|for|friend|function|get|gettype|gosub|goto|handles|if|implements|imports|in|inherits|integer|interface|is|let|lib|like|long|loop|me|mod|module|mustinherit|mustoverride|mybase|myclass|namespace|new|next|not|notinheritable|notoverridable|object|on|option|optional|or|orelse|overloads|overridable|overrides|paramarray|preserve|private|property|protected|public|raiseevent|readonly|redim|removehandler|resume|return|select|set|shadows|shared|short|single|static|step|stop|string|structure|sub|synclock|then|throw|to|try|typeof|unicode|until|variant|wend|when|while|with|withevents|writeonly|xor|endif|gosub|let|variant|wend)\b/i, 2 | null],["com",/^rem\b.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\s+(?:\d+[/-]\d+[/-]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:am|pm))?)?|\d+:\d+(?::\d+)?(\s*(?:am|pm))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[!#%&@]+])?|\[(?:[a-z]|_\w)\w*])/i],["pun",/^[^\w\t\n\r "'[\]\xa0\u2018\u2019\u201c\u201d\u2028\u2029]+/],["pun",/^(?:\[|])/]]),["vb","vbs"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-vhdl.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[box]?"(?:[^"]|"")*"|'.')/i],["com",/^--[^\n\r]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, 2 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^'(?:active|ascending|base|delayed|driving|driving_value|event|high|image|instance_name|last_active|last_event|last_value|left|leftof|length|low|path_name|pos|pred|quiet|range|reverse_range|right|rightof|simple_name|stable|succ|transaction|val|value)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w.\\]+#(?:[+-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:e[+-]?\d+(?:_\d+)*)?)/i], 3 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r "'\xa0][^\w\t\n\r "'\xa0-]*/]]),["vhdl","vhd"]); 4 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-wiki.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\d\t a-gi-z\xa0]+/,null,"\t \u00a0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[*=[\]^~]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^[A-Z][a-z][\da-z]+[A-Z][a-z][^\W_]+\b/],["lang-",/^{{{([\S\s]+?)}}}/],["lang-",/^`([^\n\r`]+)`/],["str",/^https?:\/\/[^\s#/?]*(?:\/[^\s#?]*)?(?:\?[^\s#]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\S\s])[^\n\r#*=A-[^`h{~]*/]]),["wiki"]); 2 | PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/lang-yaml.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^\w+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]); 3 | -------------------------------------------------------------------------------- /resources/google-code-prettify/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} -------------------------------------------------------------------------------- /resources/google-code-prettify/prettify.js: -------------------------------------------------------------------------------- 1 | !function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a= 3 | b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;ah[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com", 11 | /^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+ 12 | s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/, 13 | q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d= 14 | c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, 21 | V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", 22 | /^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);p(C([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/], 23 | ["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);p(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);p(v({keywords:M,hashComments:!0,cStyleComments:!0,types:R}),["c","cc","cpp","cxx","cyc","m"]);p(v({keywords:"null,true,false"}),["json"]);p(v({keywords:O,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:R}), 24 | ["cs"]);p(v({keywords:N,cStyleComments:!0}),["java"]);p(v({keywords:y,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);p(v({keywords:P,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);p(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);p(v({keywords:Q, 25 | hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);p(v({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);p(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);p(v({keywords:W,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]); 26 | p(C([],[["str",/^[\S\s]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:C,registerLangHandler:p,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,g){var b=document.createElement("div");b.innerHTML="
"+a+"
";b=b.firstChild;g&&J(b,g,!0);K({h:d,j:g,c:b,i:1}); 27 | return b.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function g(){for(var b=D.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;i=0;){var M=A[m],T=M.src.match(/^[^#?]*\/run_prettify\.js(\?[^#]*)?(?:#.*)?$/);if(T){z=T[1]||"";M.parentNode.removeChild(M);break}}var S=!0,D= 4 | [],N=[],K=[];z.replace(/[&?]([^&=]+)=([^&]+)/g,function(e,j,w){w=decodeURIComponent(w);j=decodeURIComponent(j);j=="autorun"?S=!/^[0fn]/i.test(w):j=="lang"?D.push(w):j=="skin"?N.push(w):j=="callback"&&K.push(w)});m=0;for(z=D.length;m122||(o<65||k>90||f.push([Math.max(65,k)|32,Math.min(o,90)|32]),o<97||k>122||f.push([Math.max(97,k)&-33,Math.min(o,122)&-33]))}}f.sort(function(f,a){return f[0]- 8 | a[0]||a[1]-f[1]});b=[];g=[];for(a=0;ak[0]&&(k[1]+1>k[0]&&c.push("-"),c.push(h(k[1])));c.push("]");return c.join("")}function e(f){for(var a=f.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],g=0,k=0;g=2&&f==="["?a[g]=b(o):f!=="\\"&&(a[g]=o.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var j=0,F=!1,l=!1,I=0,c=a.length;I=5&&"lang-"===y.substring(0,5))&&!(u&&typeof u[1]==="string"))g=!1,y="src";g||(m[B]=y)}k=c;c+=B.length;if(g){g=u[1];var o=B.indexOf(g),H=o+g.length;u[2]&&(H=B.length-u[2].length,o=H-g.length);y=y.substring(5);n(l+k,B.substring(0,o),h,j);n(l+k+o,g,A(y, 13 | g),j);n(l+k+H,B.substring(H),h,j)}else j.push(l+k,y)}a.g=j}var b={},e;(function(){for(var h=a.concat(d),l=[],i={},c=0,p=h.length;c=0;)b[q.charAt(f)]=m;m=m[1];q=""+m;i.hasOwnProperty(q)||(l.push(m),i[q]=r)}l.push(/[\S\s]/);e=j(l)})();var i=d.length;return h}function t(a){var d=[],h=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/, 14 | r,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,r,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,r,"\"'"]);a.verbatimStrings&&h.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,r]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,r,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/, 15 | r,"#"]),h.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,r])):d.push(["com",/^#[^\n\r]*/,r,"#"]));a.cStyleComments&&(h.push(["com",/^\/\/[^\n\r]*/,r]),h.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,r]));if(b=a.regexLiterals){var e=(b=b>1?"":"\n\r")?".":"[\\S\\s]";h.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+ 16 | ("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+e+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+e+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&h.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&h.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),r]);d.push(["pln",/^\s+/,r," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");h.push(["lit",/^@[$_a-z][\w$@]*/i,r],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,r],["pln",/^[$_a-z][\w$@]*/i,r],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i, 17 | r,"0123456789"],["pln",/^\\[\S\s]?/,r],["pun",RegExp(b),r]);return C(d,h)}function z(a,d,h){function b(a){var c=a.nodeType;if(c==1&&!j.test(a.className))if("br"===a.nodeName)e(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&h){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(l.createTextNode(d),a.nextSibling),e(a),c||a.parentNode.removeChild(a)}} 18 | function e(a){function b(a,c){var d=c?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),h=a.nextSibling;f.appendChild(d);for(var e=h;e;e=h)h=e.nextSibling,f.appendChild(e)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var j=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,l=a.ownerDocument,i=l.createElement("li");a.firstChild;)i.appendChild(a.firstChild);for(var c=[i],p=0;p=0;){var b=d[h];U.hasOwnProperty(b)?V.console&&console.warn("cannot override language handler %s",b):U[b]=a}}function A(a,d){if(!a||!U.hasOwnProperty(a))a=/^\s*=o&&(b+=2);h>=H&&(t+=2)}}finally{if(g)g.style.display=k}}catch(v){V.console&&console.log(v&&v.stack||v)}}var V=window,G=["break,continue,do,else,for,if,return,while"],O=[[G,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 22 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],J=[O,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],K=[O,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], 23 | L=[K,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],O=[O,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],M=[G,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 24 | N=[G,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],R=[G,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],G=[G,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],Q=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, 25 | S=/\S/,T=t({keywords:[J,L,O,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",M,N,G],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),U={};i(T,["default-code"]);i(C([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", 26 | /^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);i(C([["pln",/^\s+/,r," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,r,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/], 27 | ["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);i(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);i(t({keywords:J,hashComments:!0,cStyleComments:!0,types:Q}),["c","cc","cpp","cxx","cyc","m"]);i(t({keywords:"null,true,false"}),["json"]);i(t({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:Q}), 28 | ["cs"]);i(t({keywords:K,cStyleComments:!0}),["java"]);i(t({keywords:G,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);i(t({keywords:M,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);i(t({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);i(t({keywords:N, 29 | hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);i(t({keywords:O,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);i(t({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);i(t({keywords:R,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]); 30 | i(C([],[["str",/^[\S\s]+/]]),["regex"]);var X=V.PR={createSimpleLexer:C,registerLangHandler:i,sourceDecorator:t,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:function(a,d,e){var b=document.createElement("div");b.innerHTML="
"+a+"
";b=b.firstChild;e&&z(b,e,!0);D({h:d,j:e,c:b,i:1});return b.innerHTML}, 31 | prettyPrint:e=e=function(a,d){function e(){for(var b=V.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;p 2 | 3 | 4 | 6 | ConstraintJS Logo 7 | 8 | 9 | 12 | 13 | 14 | 15 | 19 | 23 | 29 | 35 | 38 | 45 | 50 | 52 | 58 | 62 | 63 | 64 | 65 | 66 | 75 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /resources/images/cjs_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soney/constraintjs/98a164063efc8d3b59a372b332c7a3e0a1292561/resources/images/cjs_button.png -------------------------------------------------------------------------------- /resources/images/cjs_logo_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soney/constraintjs/98a164063efc8d3b59a372b332c7a3e0a1292561/resources/images/cjs_logo_256.png -------------------------------------------------------------------------------- /resources/images/cjs_logo_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/soney/constraintjs/98a164063efc8d3b59a372b332c7a3e0a1292561/resources/images/cjs_logo_64.png -------------------------------------------------------------------------------- /src/footer.js: -------------------------------------------------------------------------------- 1 | return cjs; 2 | }(this)); 3 | 4 | // Export for node 5 | if (typeof module !== 'undefined' && module.exports) { 6 | /** @exports cjs */ 7 | module.exports = cjs; 8 | } 9 | -------------------------------------------------------------------------------- /src/header.js: -------------------------------------------------------------------------------- 1 | // ConstraintJS (CJS) <%= version %> 2 | // ConstraintJS may be freely distributed under the MIT License 3 | // http://cjs.from.so/ 4 | 5 | /* jslint nomen: true, vars: true */ 6 | /* jshint -W093 */ 7 | /* global document */ 8 | /** @expose cjs */ 9 | var cjs = (function (root) { 10 | "use strict"; 11 | -------------------------------------------------------------------------------- /src/liven.js: -------------------------------------------------------------------------------- 1 | // Liven 2 | // ----- 3 | 4 | // Will automatically call the provided function when it becomes invalid 5 | extend(cjs, { 6 | /** 7 | * Memoize a function to avoid unnecessary re-evaluation. Its options are: 8 | * 9 | * - `context`: The context in which `func` should be evaluated 10 | * - `run_on_create`: Whether to run `func` immediately after creating the live function. (default: `true`) 11 | * - `pause_while_running`: Whether to explicitly prevent this live function from being called recursively (default: `false`) 12 | * - `on_destroy`: A function to call when `destroy` is called (default: `false`) 13 | * 14 | * The return value of this method also has two functions: 15 | * - `pause`: Pause evaluation of the live function 16 | * - `resume`: Resume evaluation of the live function 17 | * - `run`: Run `func` if it's invalid 18 | * 19 | * @method cjs.liven 20 | * @param {function} func - The function to make live 21 | * @param {object} [options] - A set of options to control how liven works 22 | * @return {object} An object with properties `destroy`, `pause`, `resume`, and `run` 23 | * 24 | * @example 25 | * var x_val = cjs(0); 26 | * var api_update = cjs.liven(function() { 27 | * console.log('updating other x'); 28 | * other_api.setX(x_val); 29 | * }); // 'updating other x' 30 | * x_val.set(2); // 'updating other x' 31 | * 32 | */ 33 | liven: function (func, options) { 34 | options = extend({ 35 | context: root, // what to equate `this` to 36 | run_on_create: true, // whether it should run immediately 37 | pause_while_running: false, // whether to allow the function to be called recursively (indirectly) 38 | priority: false, 39 | on_destroy: false // a function to call when this liven function is destroyed 40 | }, options); 41 | 42 | //Make constraint-aware values just by calling func in a constraint 43 | var node = new Constraint(func, { 44 | context: options.context, 45 | cache_value: false, 46 | auto_add_outgoing_dependencies: false, 47 | run_on_add_listener: false 48 | }); 49 | 50 | // check if running 51 | var paused = false; 52 | var do_get; 53 | 54 | var invalidate = function() { 55 | node.invalidate(); 56 | }; 57 | 58 | // Destroy the node and make sure no memory is allocated 59 | var destroy = function (silent) { 60 | if(options.on_destroy) { 61 | options.on_destroy.call(options.context, silent); 62 | } 63 | node.destroy(silent); 64 | }; 65 | 66 | // Stop changing and remove it from the event queue if necessary 67 | var pause = function () { 68 | if(paused === false) { 69 | paused = true; 70 | node.offChange(do_get); 71 | return true; // successfully paused 72 | } 73 | return false; 74 | }; 75 | 76 | // Re-add to the event queue 77 | var resume = function () { 78 | if(paused === true) { 79 | paused = false; 80 | node.onChangeWithPriority(options.priority, do_get); 81 | if(options.run_on_create !== false) { 82 | if (constraint_solver.semaphore >= 0) { 83 | node.get(false); 84 | } else { 85 | each(node._changeListeners, constraint_solver.add_in_call_stack, constraint_solver); 86 | } 87 | } 88 | return true; // successfully resumed 89 | } 90 | return false; 91 | }; 92 | 93 | // The actual getter, will call the constraint's getter 94 | do_get = function () { 95 | if (options.pause_while_running) { 96 | pause(); 97 | } 98 | node.get(); 99 | if (options.pause_while_running) { 100 | resume(); 101 | } 102 | }; 103 | 104 | // When the value changes, call do_get 105 | node.onChangeWithPriority(options.priority, do_get); 106 | 107 | var rv = { 108 | destroy: destroy, 109 | pause: pause, 110 | resume: resume, 111 | run: function(arg0) { 112 | do_get(arg0); 113 | return this; 114 | }, 115 | invalidate: invalidate, 116 | _constraint: node // for debugging purposes 117 | }; 118 | 119 | if(options.run_on_create !== false) { 120 | if (constraint_solver.semaphore >= 0) { 121 | node.get(false); 122 | } else { 123 | each(node._changeListeners, constraint_solver.add_in_call_stack, constraint_solver); 124 | } 125 | } 126 | 127 | return rv; 128 | } 129 | }); 130 | -------------------------------------------------------------------------------- /src/memoize.js: -------------------------------------------------------------------------------- 1 | // A function to hash the arguments passed in. By default, just a concatenation of the arguments' string value 2 | var memoize_default_hash = function () { 3 | var i, len = arguments.length; 4 | var rv = ""; 5 | for (i = 0; i < len; i += 1) { 6 | rv += arguments[i]; 7 | } 8 | return rv; 9 | }, 10 | // A function to check if two sets of arguments are equal; by default just check every value 11 | memoize_default_equals = function (args1, args2) { 12 | var i, 13 | len = args1.length; 14 | if (len === args2.length) { 15 | for (i = 0; i < len; i += 1) { 16 | var arg1 = args1[i], 17 | arg2 = args2[i]; 18 | if (arg1 !== arg2) { 19 | return false; 20 | } 21 | } 22 | return true; 23 | } else { 24 | return false; 25 | } 26 | }; 27 | 28 | extend(cjs, { 29 | /** 30 | * Memoize a function to avoid unnecessary re-evaluation. Its options are: 31 | * 32 | * - `hash`: Create a unique value for each set of arguments (call with an argument array) 33 | * - `equals`: check if two sets of arguments are equal (call with two argument arrays) 34 | * - `context`: The context in which `getter_fn` should be evaluated 35 | * - `literal_values`: Whether values should be literal if they are functions 36 | * 37 | * The return value of this method also has two functions: 38 | * - `each`: Iterate through every set of arguments and value that is memoized 39 | * - `destroy`: Clear the memoized values to clean up memory 40 | * 41 | * @method cjs.memoize 42 | * @param {function} getter_fn - The function to memoize 43 | * @param {object} [options] - A set of options to control how memoization works 44 | * @return {function} The memoized function 45 | * 46 | * @example 47 | * 48 | * var arr = cjs([3,2,1,4,5,10]), 49 | * get_nth_largest = cjs.memoize(function(n) { 50 | * console.log('recomputing'); 51 | * var sorted_arr = arr memoized fn.sort(); 52 | * return sorted_arr[ny]; 53 | * }); 54 | * 55 | * get_nth_largest(0); // logfged: recomputing 56 | * get_nth_largest(0); //ulli (nothing logged because answer memoized) 57 | * arr.splice(0, 1); // N 58 | * get_nth_largest(0); // logged: recomputing 59 | */ 60 | memoize: function (getter_fn, options) { 61 | options = extend({ 62 | hash: memoize_default_hash, 63 | equals: memoize_default_equals, 64 | context: root, 65 | literal_values: true 66 | }, options); 67 | 68 | // Map from args to value 69 | options.args_map = new MapConstraint({ 70 | hash: options.hash, 71 | equals: options.equals, 72 | literal_values: options.literal_values 73 | }); 74 | 75 | // When getting a value either create a constraint or return the existing value 76 | var rv = function () { 77 | var args = slice.call(arguments), 78 | constraint = options.args_map.getOrPut(args, function() { 79 | return new Constraint(function () { 80 | return getter_fn.apply(options.context, args); 81 | }); 82 | }); 83 | return constraint.get(); 84 | }; 85 | 86 | // Clean up memory after self 87 | rv.destroy = function (silent) { 88 | options.args_map.forEach(function (constraint) { 89 | constraint.destroy(silent); 90 | }); 91 | options.args_map.destroy(silent); 92 | }; 93 | 94 | // Run through every argument and call fn on it 95 | rv.each = function (fn) { 96 | options.args_map.forEach(fn); 97 | }; 98 | rv.options = options; 99 | return rv; 100 | } 101 | }); 102 | -------------------------------------------------------------------------------- /src/state_machine/cjs_events.js: -------------------------------------------------------------------------------- 1 | /** 2 | * **Note:** the preferred way to create this object is with the `cjs.on` function 3 | * Creates an event that can be used in a finite-state machine transition 4 | * @class cjs.CJSEvent 5 | * @classdesc A constraint object communicates with the constraint solver to store and maintain constraint values 6 | * @see cjs.on 7 | */ 8 | var CJSEvent = function(parent, filter, onAddTransition, onRemoveTransition) { 9 | this._listeners = []; // parent events that want to know when I fire 10 | this._transitions = []; // a list of transitions that I'm attached to 11 | this._on_add_transition = onAddTransition; // optional listener for when a transition is added 12 | this._on_remove_transition = onRemoveTransition; // optional listener for when a transition is removed 13 | this._live_fns = {}; // one per transitions 14 | this._parent = parent; 15 | if(this._parent) { 16 | this._parent._listeners.push({event:this, filter: filter}); // add an item to my parent's listener if i have a parent 17 | } 18 | }; 19 | 20 | (function(my) { 21 | /** @lends cjs.CJSEvent.prototype */ 22 | var proto = my.prototype; 23 | 24 | /** 25 | * Create a transition that calls filter whenever it fires to ensure that it should fire 26 | * 27 | * @method guard 28 | * @param {function} [filter] - Returns `true` if the event should fire and false otherwise 29 | * @return {CJSEvent} A new event that only fires when `filter` returns a truthy value 30 | * @example If the user clicks and `ready` is `true` 31 | * 32 | * cjs.on("click").guard(function() { 33 | * return ready === true; 34 | * }); 35 | */ 36 | proto.guard = function(filter, filter_eq) { 37 | //Assume filter is the name of a paroperty 38 | if(!isFunction(filter)) { 39 | var prop_name = filter; 40 | filter = function(event) { 41 | return event && event[prop_name] === filter_eq; 42 | }; 43 | } 44 | return new CJSEvent(this, filter); 45 | }; 46 | 47 | /** 48 | * Add a transition to my list of transitions that this event is attached to 49 | * 50 | * @private 51 | * @method _addTransition 52 | * @param {Transition} transition - The transition this event is attached to 53 | */ 54 | proto._addTransition = function(transition) { 55 | this._transitions.push(transition); 56 | if(this._on_add_transition) { 57 | this._live_fns[transition.id()] = this._on_add_transition(transition); 58 | } 59 | if(this._parent && this._parent._on_add_transition) { 60 | this._parent._on_add_transition(transition); 61 | } 62 | }; 63 | 64 | /** 65 | * Remove a transition from my list of transitions 66 | * 67 | * @private 68 | * @method _removeTransition 69 | * @param {Transition} transition - The transition this event is attached to 70 | */ 71 | proto._removeTransition = function(transition) { 72 | if(remove(this._transitions, transition)) { 73 | if(this._on_remove_transition) { 74 | this._on_remove_transition(transition); 75 | 76 | // clear the live fn 77 | var tid = transition.id(); 78 | this._live_fns[tid].destroy(); 79 | delete this._live_fns[tid]; 80 | } 81 | } 82 | if(this._parent && this._parent._on_remove_transition) { 83 | this._parent._on_remove_transition(transition); 84 | } 85 | }; 86 | 87 | /** 88 | * When I fire, go through every transition I'm attached to and fire it then let any interested listeners know as well 89 | * 90 | * @private 91 | * @method _fire 92 | * @param {*} ...events - Any number of events that will be passed to the transition 93 | */ 94 | proto._fire = function() { 95 | var events = arguments; 96 | each(this._transitions, function(transition) { 97 | transition.run.apply(transition, events); 98 | }); 99 | each(this._listeners, function(listener_info) { 100 | var listener = listener_info.event, 101 | filter = listener_info.filter; 102 | 103 | if(!filter || filter.apply(root, events)) { 104 | listener._fire.apply(listener, events); 105 | } 106 | }); 107 | }; 108 | }(CJSEvent)); 109 | /** @lends */ 110 | 111 | var isElementOrWindow = function(elem) { return elem === root || isPolyDOM(elem); }, 112 | split_and_trim = function(x) { return map(x.split(" "), trim); }, 113 | timeout_event_type = "timeout"; 114 | 115 | extend(cjs, { 116 | /** @expose cjs.CJSEvent */ 117 | CJSEvent: CJSEvent, 118 | /** 119 | * Create a new event for use in a finite state machine transition 120 | * 121 | * @constructs CJSEvent 122 | * @method cjs.on 123 | * @param {string} event_type - the type of event to listen for (e.g. mousedown, timeout) 124 | * @param {element|number} ...targets=window - Any number of target objects to listen to 125 | * @return {CJSEvent} - An event that can be attached to 126 | * @example When the window resizes 127 | * 128 | * cjs.on("resize") 129 | * 130 | * @example When the user clicks `elem1` or `elem2` 131 | * 132 | * cjs.on("click", elem1, elem2) 133 | * 134 | * @example After 3 seconds 135 | * 136 | * cjs.on("timeout", 3000) 137 | */ 138 | on: function(event_type) { 139 | var rest_args = arguments.length > 1 ? rest(arguments) : root, 140 | // no parent, no filter by default 141 | event = new CJSEvent(false, false, function(transition) { 142 | var targets = [], 143 | timeout_id = false, 144 | event_type_val = [], 145 | listener = bind(this._fire, this), 146 | fsm = transition.getFSM(), 147 | from = transition.getFrom(), 148 | state_selector = new StateSelector(from), 149 | from_state_selector = new TransitionSelector(true, state_selector, new AnyStateSelector()), 150 | on_listener = function() { 151 | each(event_type_val, function(event_type) { 152 | // If the event is 'timeout' 153 | if(event_type === timeout_event_type) { 154 | // clear the previous timeout 155 | if(timeout_id) { 156 | cTO(timeout_id); 157 | timeout_id = false; 158 | } 159 | 160 | // and set a new one 161 | var delay = cjs.get(rest_args[0]); 162 | if(!isNumber(delay) || delay < 0) { 163 | delay = 0; 164 | } 165 | 166 | timeout_id = sTO(listener, delay); 167 | } else { 168 | each(targets, function(target) { 169 | // otherwise, add the event listener to every one of my targets 170 | aEL(target, event_type, listener); 171 | }); 172 | } 173 | }); 174 | }, 175 | off_listener = function() { 176 | each(event_type_val, function(event_type) { 177 | each(targets, function(target) { 178 | if(event_type === timeout_event_type) { 179 | // If the event is 'timeout' 180 | if(timeout_id) { 181 | cTO(timeout_id); 182 | timeout_id = false; 183 | } 184 | } else { 185 | rEL(target, event_type, listener); 186 | } 187 | }); 188 | }); 189 | }, 190 | live_fn = cjs.liven(function() { 191 | off_listener(); 192 | 193 | event_type_val = split_and_trim(cjs.get(event_type)); 194 | // only use DOM elements (or the window) as my target 195 | targets = flatten(map(filter(get_dom_array(rest_args), isElementOrWindow), getDOMChildren , true)); 196 | 197 | // when entering the state, add the event listeners, then remove them when leaving the state 198 | fsm .on(state_selector, on_listener) 199 | .on(from_state_selector, off_listener); 200 | 201 | if(fsm.is(from)) { 202 | // if the FSM is already in the transition's starting state 203 | on_listener(); 204 | } 205 | }); 206 | return live_fn; 207 | }); 208 | return event; 209 | } 210 | }); 211 | -------------------------------------------------------------------------------- /src/template/cjs_parser.js: -------------------------------------------------------------------------------- 1 | // Based on [Mu's parser](https://github.com/raycmorgan/Mu) and 2 | // John Resig's [HTML parser](http://erik.eae.net/simplehtmlparser/simplehtmlparser.js) 3 | var makeMap = function(str){ 4 | var obj = {}; 5 | each(str.split(","), function(item) { obj[item] = true; }); 6 | return obj; 7 | }; 8 | 9 | // Regular Expressions for parsing tags and attributes 10 | var startTag = /^<([\-A-Za-z0-9_]+)((?:\s+[a-zA-Z0-9_\-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^>\s]+)))?)*)\s*(\/?)>/, 11 | endTag = /^<\/([\-A-Za-z0-9_]+)[^>]*>/, 12 | handlebar = /^\{\{([#=!>|{\/])?\s*((?:(?:"[^"]*")|(?:'[^']*')|[^\}])*)\s*(\/?)\}?\}\}/, 13 | attr = /([\-A-Za-z0-9_]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^\/>\s]+)))?/g, 14 | //hb_attr = /\{\{([^\}]*)\}\}/g, 15 | HB_TYPE = "hb", 16 | HTML_TYPE = "html"; 17 | 18 | // Empty Elements - HTML 4.01 19 | var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"), 20 | // Block Elements - HTML 4.01 21 | block = makeMap("address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul"), 22 | // Inline Elements - HTML 4.01 23 | inline = makeMap("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"), 24 | // Elements that you can, intentionally, leave open (and which close themselves) 25 | closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"), 26 | // Attributes that have their values filled in disabled="disabled" 27 | fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"), 28 | // Special Elements (can contain anything) 29 | special = makeMap("script,style"); 30 | 31 | var IF_TAG = "if", 32 | ELIF_TAG = "elif", 33 | ELSE_TAG = "else", 34 | STATE_TAG = "state", 35 | EACH_TAG = "each", 36 | WITH_TAG = "with", 37 | FSM_TAG = "fsm", 38 | UNLESS_TAG= "unless"; 39 | 40 | // Dictates what parents children must have; state must be a direct descendent of diagram 41 | var parent_rules = {}; 42 | parent_rules[STATE_TAG] = { parent: [FSM_TAG] }; 43 | parent_rules[ELIF_TAG] = { parent: [IF_TAG] }; 44 | parent_rules[ELSE_TAG] = { parent: [IF_TAG, EACH_TAG] }; 45 | 46 | var autoclose_nodes = {}; 47 | autoclose_nodes[ELIF_TAG] = { when_open_sibling: [ELIF_TAG, ELSE_TAG] }; 48 | autoclose_nodes[ELSE_TAG] = { 49 | when_close_parent: [IF_TAG, EACH_TAG], 50 | when_open_sibling: [] 51 | }; 52 | autoclose_nodes[STATE_TAG] = { when_open_sibling: [STATE_TAG] }; 53 | 54 | // elsif and else must come after either if or elsif 55 | var sibling_rules = {}; 56 | sibling_rules[ELIF_TAG] = { 57 | follows: [ELIF_TAG], //what it may follow 58 | or_parent: [IF_TAG] //or the parent can be 'if' 59 | }; 60 | sibling_rules[ELSE_TAG] = { 61 | follows: [ELIF_TAG], 62 | or_parent: [IF_TAG, EACH_TAG] 63 | }; 64 | sibling_rules[STATE_TAG] = { 65 | follows: [STATE_TAG], 66 | or_parent: [FSM_TAG] 67 | }; 68 | 69 | var parseTemplate = function(input_str, handler) { 70 | var html_index, hb_index, last_closed_hb_tag, index, chars, match, stack = [], last = input_str; 71 | stack.last = function() { 72 | return this[this.length - 1]; 73 | }; 74 | 75 | var replace_fn = function(all, text) { 76 | text = text .replace(//g, "$1") 77 | .replace(//g, "$1"); 78 | 79 | if (handler.chars) { 80 | handler.chars(text); 81 | } 82 | 83 | return ""; 84 | }; 85 | 86 | while (input_str) { 87 | chars = true; 88 | 89 | // Make sure we're not in a script or style element 90 | if (!stack.last() || !special[stack.last()]) { 91 | // Comment 92 | if (input_str.indexOf(""); 94 | 95 | if (index >= 0) { 96 | if (handler.HTMLcomment) { 97 | handler.HTMLcomment( input_str.substring( 4, index ) ); 98 | } 99 | input_str = input_str.substring( index + 3 ); 100 | chars = false; 101 | } 102 | 103 | // end tag 104 | } else if (input_str.indexOf("]*>"), replace_fn); 146 | 147 | parseEndTag("", stack.last()); 148 | } 149 | 150 | if (input_str == last) { 151 | throw new Error("Parse Error: " + input_str); 152 | } 153 | last = input_str; 154 | } 155 | 156 | // Clean up any remaining tags 157 | parseEndTag(); 158 | 159 | function parseStartTag( tag, tagName, rest, unary ) { 160 | tagName = tagName.toLowerCase(); 161 | 162 | if ( block[ tagName ] ) { 163 | while ( stack.last() && inline[ stack.last() ] ) { 164 | parseEndTag( "", stack.last() ); 165 | } 166 | } 167 | 168 | if ( closeSelf[ tagName ] && stack.last() == tagName ) { 169 | parseEndTag( "", tagName ); 170 | } 171 | 172 | unary = empty[ tagName ] || !!unary; 173 | 174 | if ( !unary ) { 175 | stack.push({type: HTML_TYPE, tag: tagName}); 176 | } 177 | 178 | if (handler.startHTML) { 179 | var attrs = []; 180 | 181 | rest.replace(attr, function(match, name) { 182 | var value = arguments[2] ? arguments[2] : 183 | arguments[3] ? arguments[3] : 184 | arguments[4] ? arguments[4] : 185 | fillAttrs[name] ? name : ""; 186 | 187 | attrs.push({ 188 | name: name, 189 | value: value, 190 | escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //" 191 | }); 192 | }); 193 | 194 | handler.startHTML(tagName, attrs, unary); 195 | } 196 | } 197 | 198 | function parseEndTag(tag, tagName) { 199 | popStackUntilTag(tagName, HTML_TYPE); 200 | } 201 | function getLatestHandlebarParent() { 202 | var i, stack_i; 203 | for(i = stack.length - 1; i>= 0; i--) { 204 | stack_i = stack[i]; 205 | if(stack_i.type === HB_TYPE) { 206 | return stack_i; 207 | } 208 | } 209 | return undefined; 210 | } 211 | function parseHandlebar(tag, prefix, content) { 212 | var last_stack, tagName, parsed_content = jsep(content); 213 | 214 | if(parsed_content.type === COMPOUND) { 215 | if(parsed_content.body.length > 0 && parsed_content.body[0].type === IDENTIFIER) { 216 | tagName = parsed_content.body[0].name; 217 | } 218 | } else { 219 | if(parsed_content.type === IDENTIFIER) { 220 | tagName = parsed_content.name; 221 | } 222 | } 223 | 224 | switch (prefix) { 225 | case '{': // literal 226 | handler.startHB(tagName, parsed_content, true, true); 227 | break; 228 | case '>': // partial 229 | handler.partialHB(tagName, parsed_content); 230 | break; 231 | case '#': // start block 232 | last_stack = getLatestHandlebarParent(); 233 | 234 | if(last_stack && has(autoclose_nodes, last_stack.tag)) { 235 | var autoclose_node = autoclose_nodes[last_stack.tag]; 236 | if(indexOf(autoclose_node.when_open_sibling, tagName) >= 0) { 237 | popStackUntilTag(last_stack.tag, HB_TYPE); 238 | last_stack = getLatestHandlebarParent(); 239 | } 240 | } 241 | 242 | if(has(parent_rules, tagName)) { 243 | var parent_rule = parent_rules[tagName]; 244 | if(!last_stack || indexOf(parent_rule.parent, last_stack.tag)<0) { 245 | throw new Error("'" + tagName + "' must be inside of a '"+parent_rule.parent+"' block"); 246 | } 247 | } 248 | 249 | if(has(sibling_rules, tagName)) { 250 | var sibling_rule = sibling_rules[tagName]; 251 | if(indexOf(sibling_rule.follows, last_closed_hb_tag) < 0) { 252 | if(!sibling_rule.or_parent || indexOf(sibling_rule.or_parent, last_stack.tag) < 0) { 253 | var error_message = "'" + tagName + "' must follow a '" + sibling_rule.follows[0] + "'"; 254 | if(sibling_rule.or_parent) { 255 | error_message += " or be inside of a '" + sibling_rule.or_parent[0] + "' tag"; 256 | } 257 | throw new Error(error_message); 258 | } 259 | } 260 | } 261 | 262 | stack.push({type: HB_TYPE, tag: tagName}); 263 | handler.startHB(tagName, parsed_content, false); 264 | break; 265 | 266 | case '/': // end block 267 | popStackUntilTag(tagName, HB_TYPE); 268 | break; 269 | case '!': // end block 270 | break; 271 | default: // unary 272 | handler.startHB(tagName, parsed_content, true, false); 273 | break; 274 | } 275 | } 276 | function popStackUntilTag(tagName, type) { 277 | var i, pos, stack_i; 278 | for (pos = stack.length - 1; pos >= 0; pos -= 1) { 279 | if(stack[pos].type === type && stack[pos].tag === tagName) { 280 | break; 281 | } 282 | } 283 | 284 | if (pos >= 0) { 285 | // Close all the open elements, up the stack 286 | for (i = stack.length - 1; i >= pos; i-- ) { 287 | stack_i = stack[i]; 288 | if(stack_i.type === HB_TYPE) { 289 | if (handler.endHB) { 290 | handler.endHB(stack_i.tag); 291 | } 292 | } else { 293 | if (handler.endHTML) { 294 | handler.endHTML(stack_i.tag); 295 | } 296 | } 297 | } 298 | 299 | // Remove the open elements from the stack 300 | stack.length = pos; 301 | } 302 | 303 | if(type === HB_TYPE) { 304 | last_closed_hb_tag = tagName; 305 | } 306 | } 307 | }, 308 | create_template = function(template_str) { 309 | var root = { 310 | children: [], 311 | type: ROOT_TYPE 312 | }, stack = [root], 313 | last_pop = false, has_container = false, fsm_stack = [], condition_stack = []; 314 | 315 | parseTemplate(template_str, { 316 | startHTML: function(tag, attributes, unary) { 317 | last_pop = { 318 | type: HTML_TYPE, 319 | tag: tag, 320 | attributes: attributes, 321 | unary: unary, 322 | children: [] 323 | }; 324 | 325 | last(stack).children.push(last_pop); 326 | 327 | if(!unary) { 328 | stack.push(last_pop); 329 | } 330 | }, 331 | endHTML: function(tag) { 332 | last_pop = stack.pop(); 333 | }, 334 | HTMLcomment: function(str) { 335 | last_pop = { 336 | type: COMMENT_TYPE, 337 | str: str 338 | }; 339 | last(stack).children.push(last_pop); 340 | }, 341 | chars: function(str) { 342 | last_pop = { 343 | type: CHARS_TYPE, 344 | str: str 345 | }; 346 | last(stack).children.push(last_pop); 347 | }, 348 | startHB: function(tag, parsed_content, unary, literal) { 349 | if(unary) { 350 | last_pop = { 351 | type: UNARY_HB_TYPE, 352 | obj: first_body(parsed_content), 353 | literal: literal, 354 | //options: body_event_options(parsed_content), 355 | tag: tag 356 | }; 357 | 358 | last(stack).children.push(last_pop); 359 | } else { 360 | var push_onto_children = true; 361 | 362 | last_pop = { 363 | type: HB_TYPE, 364 | tag: tag, 365 | children: [] 366 | }; 367 | switch(tag) { 368 | case EACH_TAG: 369 | last_pop.parsed_content = rest_body(parsed_content); 370 | last_pop.else_child = false; 371 | break; 372 | case UNLESS_TAG: 373 | case IF_TAG: 374 | last_pop.reverse = tag === UNLESS_TAG; 375 | last_pop.sub_conditions = []; 376 | last_pop.condition = rest_body(parsed_content); 377 | condition_stack.push(last_pop); 378 | break; 379 | case ELIF_TAG: 380 | case ELSE_TAG: 381 | var last_stack = last(stack); 382 | if(last_stack.type === HB_TYPE && last_stack.tag === EACH_TAG) { 383 | last_stack.else_child = last_pop; 384 | } else { 385 | last(condition_stack).sub_conditions.push(last_pop); 386 | } 387 | last_pop.condition = tag === ELSE_TAG ? ELSE_COND : rest_body(parsed_content); 388 | push_onto_children = false; 389 | break; 390 | case EACH_TAG: 391 | case FSM_TAG: 392 | last_pop.fsm_target = rest_body(parsed_content); 393 | last_pop.sub_states = {}; 394 | fsm_stack.push(last_pop); 395 | break; 396 | case STATE_TAG: 397 | var state_name = parsed_content.body[1].name; 398 | last(fsm_stack).sub_states[state_name] = last_pop; 399 | push_onto_children = false; 400 | break; 401 | case WITH_TAG: 402 | last_pop.content = rest_body(parsed_content); 403 | break; 404 | } 405 | if(push_onto_children) { 406 | last(stack).children.push(last_pop); 407 | } 408 | stack.push(last_pop); 409 | } 410 | }, 411 | endHB: function(tag) { 412 | switch(tag) { 413 | case IF_TAG: 414 | case UNLESS_TAG: 415 | condition_stack.pop(); 416 | break; 417 | case FSM_TAG: 418 | fsm_stack.pop(); 419 | } 420 | stack.pop(); 421 | }, 422 | partialHB: function(tagName, parsed_content) { 423 | last_pop = { 424 | type: PARTIAL_HB_TYPE, 425 | tag: tagName, 426 | content: rest_body(parsed_content) 427 | }; 428 | 429 | last(stack).children.push(last_pop); 430 | } 431 | }); 432 | return root; 433 | }; 434 | -------------------------------------------------------------------------------- /test/chrome_memory_test_client.js: -------------------------------------------------------------------------------- 1 | // Install the extension: 2 | // https://chrome.google.com/webstore/detail/memory-tester/nmmiaefdogfanfjdecpabjaooihcmojj 3 | (function(root) { 4 | var command_id = 0, 5 | callbacks = {}, 6 | do_command = function(command_name, parameters, callback) { 7 | var id = command_id++, 8 | message = { id: id, type: "FROM_PAGE", command: command_name }, 9 | key; 10 | 11 | callbacks[id] = callback; 12 | for(var key in parameters) { 13 | if(parameters.hasOwnProperty(key)) { 14 | message[key] = parameters[key]; 15 | } 16 | } 17 | root.postMessage(message, "*"); 18 | }; 19 | 20 | root.addEventListener("message", function(event) { 21 | // We only accept messages from ourselves 22 | if (event.source != root) { return; } 23 | 24 | if (event.data.type && (event.data.type == "FROM_EXTENSION")) { 25 | var id = event.data.id; 26 | if(callbacks.hasOwnProperty(id)) { 27 | var callback = callbacks[id]; 28 | delete callbacks[id]; 29 | callback(event.data.response); 30 | } 31 | } 32 | }, false); 33 | 34 | 35 | root.getMemoryTester = function(onConnect, timeout) { 36 | if(arguments.length < 2) { 37 | timeout = 1000; 38 | } 39 | 40 | var timeout_id = false, 41 | memoryTester = { 42 | takeSnapshot: function(forbiddenTokens, callback) { 43 | if(this.connected) { 44 | do_command("take_snapshot", {forbidden_tokens: forbiddenTokens}, callback); 45 | } else { 46 | callback({ 47 | ililegal_strs: false, 48 | checked: false 49 | }); 50 | } 51 | }, 52 | connected: false 53 | }; 54 | 55 | if(timeout !== false) { 56 | timeout_id = setTimeout(function() { 57 | if(onConnect) { 58 | onConnect(false); 59 | } 60 | }, timeout); 61 | } 62 | 63 | do_command("ping", {}, function() { 64 | if(timeout_id) { 65 | clearTimeout(timeout_id); 66 | } 67 | 68 | memoryTester.connected = true; 69 | 70 | if(onConnect) { 71 | onConnect(memoryTester); 72 | } 73 | }); 74 | 75 | return memoryTester; 76 | }; 77 | }(this)); 78 | -------------------------------------------------------------------------------- /test/memory_test_extension/background.js: -------------------------------------------------------------------------------- 1 | chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { 2 | if(request.command) { 3 | var command = request.command; 4 | if(command === "take_snapshot") { 5 | var debuggerId = {tabId: sender.tab.id}; 6 | //console.log("Attached to tab with id " + sender.tab.id); 7 | chrome.debugger.attach(debuggerId, "1.0", function() { 8 | if(chrome.runtime.lastError) { console.error(chrome.runtime.lastError); return; } 9 | var snapshot_str = ""; 10 | var illegal_strs = false; 11 | var listener = function(source, method, params) { 12 | if(source.tabId === debuggerId.tabId) { 13 | if(request.forbidden_tokens.length > 0) { 14 | if(method === "HeapProfiler.addHeapSnapshotChunk") { 15 | var chunk = params.chunk; 16 | snapshot_str += chunk; 17 | } 18 | 19 | } 20 | } 21 | }; 22 | chrome.debugger.onEvent.addListener(listener); 23 | chrome.debugger.sendCommand(debuggerId, "HeapProfiler.takeHeapSnapshot", { reportProgress: false }, function() { 24 | chrome.debugger.onEvent.removeListener(listener); 25 | if(chrome.runtime.lastError) { console.error(chrome.runtime.lastError); } 26 | if(request.forbidden_tokens.length > 0) { 27 | var check_for_strings = request.forbidden_tokens; 28 | var cfslen = check_for_strings.length; 29 | 30 | var snapshot = JSON.parse(snapshot_str); 31 | var meta = snapshot.snapshot.meta; 32 | var strings = snapshot.strings; 33 | var nodes = snapshot.nodes, 34 | edges = snapshot.edges, 35 | node_types = meta.node_types, 36 | node_types_0 = node_types[0], 37 | edge_types = meta.edge_types, 38 | edge_types_0 = edge_types[0], 39 | node_fields = meta.node_fields, 40 | node_field_len = node_fields.length, 41 | edge_fields = meta.edge_fields, 42 | edge_field_len = edge_fields.length; 43 | 44 | var edge_index = 0; 45 | var num_nodes = snapshot.snapshot.node_count; 46 | var cfs,to_node, i, node, j, edge_count, k, edge, edge_field_value, node_field_value, name; 47 | var computed_nodes = []; 48 | var bad_nodes = []; 49 | outer: for(i = 0; i 2 | 3 | 4 | ConstraintJS 5 | 6 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /test/resources/qunit-1.12.0.css: -------------------------------------------------------------------------------- 1 | /** 2 | * QUnit v1.12.0 - A JavaScript Unit Testing Framework 3 | * 4 | * http://qunitjs.com 5 | * 6 | * Copyright 2012 jQuery Foundation and other contributors 7 | * Released under the MIT license. 8 | * http://jquery.org/license 9 | */ 10 | 11 | /** Font Family and Sizes */ 12 | 13 | #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { 14 | font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; 15 | } 16 | 17 | #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } 18 | #qunit-tests { font-size: smaller; } 19 | 20 | 21 | /** Resets */ 22 | 23 | #qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { 24 | margin: 0; 25 | padding: 0; 26 | } 27 | 28 | 29 | /** Header */ 30 | 31 | #qunit-header { 32 | padding: 0.5em 0 0.5em 1em; 33 | 34 | color: #8699a4; 35 | background-color: #0d3349; 36 | 37 | font-size: 1.5em; 38 | line-height: 1em; 39 | font-weight: normal; 40 | 41 | border-radius: 5px 5px 0 0; 42 | -moz-border-radius: 5px 5px 0 0; 43 | -webkit-border-top-right-radius: 5px; 44 | -webkit-border-top-left-radius: 5px; 45 | } 46 | 47 | #qunit-header a { 48 | text-decoration: none; 49 | color: #c2ccd1; 50 | } 51 | 52 | #qunit-header a:hover, 53 | #qunit-header a:focus { 54 | color: #fff; 55 | } 56 | 57 | #qunit-testrunner-toolbar label { 58 | display: inline-block; 59 | padding: 0 .5em 0 .1em; 60 | } 61 | 62 | #qunit-banner { 63 | height: 5px; 64 | } 65 | 66 | #qunit-testrunner-toolbar { 67 | padding: 0.5em 0 0.5em 2em; 68 | color: #5E740B; 69 | background-color: #eee; 70 | overflow: hidden; 71 | } 72 | 73 | #qunit-userAgent { 74 | padding: 0.5em 0 0.5em 2.5em; 75 | background-color: #2b81af; 76 | color: #fff; 77 | text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; 78 | } 79 | 80 | #qunit-modulefilter-container { 81 | float: right; 82 | } 83 | 84 | /** Tests: Pass/Fail */ 85 | 86 | #qunit-tests { 87 | list-style-position: inside; 88 | } 89 | 90 | #qunit-tests li { 91 | padding: 0.4em 0.5em 0.4em 2.5em; 92 | border-bottom: 1px solid #fff; 93 | list-style-position: inside; 94 | } 95 | 96 | #qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { 97 | display: none; 98 | } 99 | 100 | #qunit-tests li strong { 101 | cursor: pointer; 102 | } 103 | 104 | #qunit-tests li a { 105 | padding: 0.5em; 106 | color: #c2ccd1; 107 | text-decoration: none; 108 | } 109 | #qunit-tests li a:hover, 110 | #qunit-tests li a:focus { 111 | color: #000; 112 | } 113 | 114 | #qunit-tests li .runtime { 115 | float: right; 116 | font-size: smaller; 117 | } 118 | 119 | .qunit-assert-list { 120 | margin-top: 0.5em; 121 | padding: 0.5em; 122 | 123 | background-color: #fff; 124 | 125 | border-radius: 5px; 126 | -moz-border-radius: 5px; 127 | -webkit-border-radius: 5px; 128 | } 129 | 130 | .qunit-collapsed { 131 | display: none; 132 | } 133 | 134 | #qunit-tests table { 135 | border-collapse: collapse; 136 | margin-top: .2em; 137 | } 138 | 139 | #qunit-tests th { 140 | text-align: right; 141 | vertical-align: top; 142 | padding: 0 .5em 0 0; 143 | } 144 | 145 | #qunit-tests td { 146 | vertical-align: top; 147 | } 148 | 149 | #qunit-tests pre { 150 | margin: 0; 151 | white-space: pre-wrap; 152 | word-wrap: break-word; 153 | } 154 | 155 | #qunit-tests del { 156 | background-color: #e0f2be; 157 | color: #374e0c; 158 | text-decoration: none; 159 | } 160 | 161 | #qunit-tests ins { 162 | background-color: #ffcaca; 163 | color: #500; 164 | text-decoration: none; 165 | } 166 | 167 | /*** Test Counts */ 168 | 169 | #qunit-tests b.counts { color: black; } 170 | #qunit-tests b.passed { color: #5E740B; } 171 | #qunit-tests b.failed { color: #710909; } 172 | 173 | #qunit-tests li li { 174 | padding: 5px; 175 | background-color: #fff; 176 | border-bottom: none; 177 | list-style-position: inside; 178 | } 179 | 180 | /*** Passing Styles */ 181 | 182 | #qunit-tests li li.pass { 183 | color: #3c510c; 184 | background-color: #fff; 185 | border-left: 10px solid #C6E746; 186 | } 187 | 188 | #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } 189 | #qunit-tests .pass .test-name { color: #366097; } 190 | 191 | #qunit-tests .pass .test-actual, 192 | #qunit-tests .pass .test-expected { color: #999999; } 193 | 194 | #qunit-banner.qunit-pass { background-color: #C6E746; } 195 | 196 | /*** Failing Styles */ 197 | 198 | #qunit-tests li li.fail { 199 | color: #710909; 200 | background-color: #fff; 201 | border-left: 10px solid #EE5757; 202 | white-space: pre; 203 | } 204 | 205 | #qunit-tests > li:last-child { 206 | border-radius: 0 0 5px 5px; 207 | -moz-border-radius: 0 0 5px 5px; 208 | -webkit-border-bottom-right-radius: 5px; 209 | -webkit-border-bottom-left-radius: 5px; 210 | } 211 | 212 | #qunit-tests .fail { color: #000000; background-color: #EE5757; } 213 | #qunit-tests .fail .test-name, 214 | #qunit-tests .fail .module-name { color: #000000; } 215 | 216 | #qunit-tests .fail .test-actual { color: #EE5757; } 217 | #qunit-tests .fail .test-expected { color: green; } 218 | 219 | #qunit-banner.qunit-fail { background-color: #EE5757; } 220 | 221 | 222 | /** Result */ 223 | 224 | #qunit-testresult { 225 | padding: 0.5em 0.5em 0.5em 2.5em; 226 | 227 | color: #2b81af; 228 | background-color: #D2E0E6; 229 | 230 | border-bottom: 1px solid white; 231 | } 232 | #qunit-testresult .module-name { 233 | font-weight: bold; 234 | } 235 | 236 | /** Fixture */ 237 | 238 | #qunit-fixture { 239 | position: absolute; 240 | top: -10000px; 241 | left: -10000px; 242 | width: 1000px; 243 | height: 1000px; 244 | } 245 | -------------------------------------------------------------------------------- /test/unit_tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | QUnit Tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/unit_tests/array_test.js: -------------------------------------------------------------------------------- 1 | module("Array Constraints"); 2 | 3 | dt("Basic Arrays", 20, function() { 4 | var arr = cjs([1,2,3]); 5 | deepEqual(arr.toArray(), [1,2,3]); // simple toArray 6 | equal(arr.pop(), 3); // Should be the item we removed 7 | equal(arr.push(3, 4), 4); // should be the length of the array 8 | deepEqual(arr.map(function(x) { return x+1;}), [2,3,4,5]); // should be an array plus 1 9 | equal(arr.shift(), 1); // Remove the first item 10 | equal(arr.length(), 3); 11 | equal(arr.unshift(0, 1), 5); // return the length 12 | deepEqual(arr.concat(["other"], cjs(["more", "stuff"])), [0, 1, 2, 3, 4, "other", "more", "stuff"]); 13 | deepEqual(arr.splice(1, 2, "x"), [1,2]); 14 | deepEqual(arr.toArray(), [0, "x", 3, 4]); 15 | deepEqual(arr.splice(1, 2, "x", "y", "z"), ["x", 3]); 16 | deepEqual(arr.toArray(), [0, "x", "y", "z", 4]); 17 | 18 | arr.setValue(["A", "B", "A", "B"]); 19 | equal(arr.indexOf(0), -1); 20 | equal(arr.indexOf("A"), 0); 21 | equal(arr.lastIndexOf("A"), 2); 22 | equal(arr.some(function(x) { return x === "B"; }), true); 23 | equal(arr.every(function(x) { return x === "B"; }), false); 24 | deepEqual(arr.slice(2), ["A", "B"]); 25 | deepEqual(arr.length(), 4); 26 | equal(arr.join(", "), "A, B, A, B"); 27 | arr.destroy(); 28 | arr = null; 29 | }); 30 | 31 | dt("Unsubstantiated Array Items", 4, function() { 32 | var arr = cjs([1, 2, 3]); 33 | var third_item = cjs(function() { return arr.item(2); }); 34 | var fourth_item = cjs(function() { return arr.item(3); }); 35 | equal(third_item.get(), 3); 36 | equal(fourth_item.get(), undefined); 37 | arr.splice(0, 0, 0); 38 | equal(third_item.get(), 2); 39 | equal(fourth_item.get(), 3); 40 | }); 41 | -------------------------------------------------------------------------------- /test/unit_tests/binding_tests.js: -------------------------------------------------------------------------------- 1 | module("Bindings"); 2 | 3 | var getTextContent = function(node) { 4 | if(node.textContent || node.textContent==="") { 5 | return node.textContent; 6 | } else { 7 | return node.innerText; 8 | } 9 | }; 10 | 11 | dt("Basic Text Bindings", 2, function() { 12 | var x = cjs("Hello"), 13 | y = cjs("World"); 14 | var dom_elem = document.createElement("div"); 15 | cjs.bindText(dom_elem, x, y); 16 | equal(getTextContent(dom_elem), "HelloWorld"); 17 | x.set("Goodbye"); 18 | equal(getTextContent(dom_elem), "GoodbyeWorld"); 19 | }); 20 | 21 | dt("Dynamic Text Bindings", 6, function() { 22 | var x = cjs("Hello"), 23 | y = cjs("World"); 24 | 25 | var dom_elem1 = document.createElement("div"); 26 | var dom_elem2 = document.createElement("div"); 27 | 28 | var elems = cjs([dom_elem1, dom_elem2]); 29 | cjs.bindText(elems, x, y); 30 | 31 | equal(getTextContent(dom_elem1), "HelloWorld"); 32 | equal(getTextContent(dom_elem2), "HelloWorld"); 33 | 34 | x.set("Goodbye"); 35 | 36 | equal(getTextContent(dom_elem1), "GoodbyeWorld"); 37 | equal(getTextContent(dom_elem2), "GoodbyeWorld"); 38 | 39 | elems.pop(); 40 | 41 | y.set("Pittsburgh"); 42 | 43 | equal(getTextContent(dom_elem1), "GoodbyePittsburgh"); 44 | equal(getTextContent(dom_elem2), "GoodbyeWorld"); 45 | }); 46 | 47 | dt("Basic Text Bindings", 2, function() { 48 | var x = cjs("Hello"), 49 | y = cjs("World"); 50 | var dom_elem = document.createElement("div"); 51 | cjs.bindText(dom_elem, x, y); 52 | equal(getTextContent(dom_elem), "HelloWorld"); 53 | x.set("Goodbye"); 54 | equal(getTextContent(dom_elem), "GoodbyeWorld"); 55 | }); 56 | 57 | dt("CSS Bindings", 1, function() { 58 | var dom_elem = document.createElement("div"); 59 | var curr_map = cjs({}); 60 | cjs.bindCSS(dom_elem, curr_map); 61 | curr_map.put("color", "red"); 62 | equal(dom_elem.style.color, "red"); 63 | }); 64 | 65 | dt("Class Bindings", 15, function() { 66 | var dom_elem = document.createElement("div"); 67 | var classes = cjs([]); 68 | dom_elem.className = "existing_class"; 69 | ok(dom_elem.className.indexOf("class1") < 0, "No class 1"); 70 | ok(dom_elem.className.indexOf("class2") < 0, "No class 2"); 71 | ok(dom_elem.className.indexOf("existing_class") >= 0, "Old class still there"); 72 | cjs.bindClass(dom_elem, classes); 73 | ok(dom_elem.className.indexOf("class1") < 0, "No class 1"); 74 | ok(dom_elem.className.indexOf("class2") < 0, "No class 2"); 75 | ok(dom_elem.className.indexOf("existing_class") >= 0, "Old class still there"); 76 | classes.push("class1"); 77 | ok(dom_elem.className.indexOf("class1") >= 0, "Has class 1"); 78 | ok(dom_elem.className.indexOf("class2") < 0, "No class 2"); 79 | ok(dom_elem.className.indexOf("existing_class") >= 0, "Old class still there"); 80 | classes.push("class2"); 81 | ok(dom_elem.className.indexOf("class1") >= 0, "Has class 1"); 82 | ok(dom_elem.className.indexOf("class2") >= 0, "Has class 2"); 83 | ok(dom_elem.className.indexOf("existing_class") >= 0, "Old class still there"); 84 | classes.pop(); 85 | ok(dom_elem.className.indexOf("class1") >= 0, "Has class 1"); 86 | ok(dom_elem.className.indexOf("class2") < 0, "No class 2"); 87 | ok(dom_elem.className.indexOf("existing_class") >= 0, "Old class still there"); 88 | }); 89 | 90 | dt("Attr Bindings", 2, function() { 91 | var dom_elem = document.createElement("div"); 92 | var attr_val = cjs("abc"); 93 | cjs.bindAttr(dom_elem, "id", attr_val); 94 | equal(dom_elem.id, "abc"); 95 | attr_val.set("def"); 96 | equal(dom_elem.id, "def"); 97 | }); 98 | -------------------------------------------------------------------------------- /test/unit_tests/constraint_test.js: -------------------------------------------------------------------------------- 1 | module("Constraints"); 2 | 3 | dt("Basic Constraints", 6, function() { 4 | var x = cjs(1); 5 | var y = cjs(function() { return x.get() + 1; }); 6 | var z = cjs(function() { return y.get() * 2; }); 7 | equal(x.get(), 1); 8 | equal(y.get(), 2); 9 | equal(z.get(), 4); 10 | x.set(10); 11 | equal(x.get(), 10); 12 | equal(y.get(), 11); 13 | equal(z.get(), 22); 14 | x.destroy(); 15 | y.destroy(); 16 | z.destroy(); 17 | x = y = z = null; 18 | }); 19 | 20 | dt("Invalidation and change listening", 10, function() { 21 | var x_change_counter = 0, 22 | y_change_counter = 0; 23 | var x = cjs("Hello"); 24 | var x_is_hello = cjs(10); 25 | var x_isnt_hello = cjs(20); 26 | var y = cjs(function() { 27 | if(x.get() === "Hello") { 28 | return x_is_hello.get(); 29 | } else { 30 | return x_isnt_hello.get(); 31 | } 32 | }); 33 | x.onChange(function() { 34 | x_change_counter++; 35 | }); 36 | y.onChange(function() { 37 | y_change_counter++; 38 | }); 39 | equal(x_change_counter, 0); 40 | equal(y_change_counter, 0); 41 | equal(y.get(), x_is_hello.get()); 42 | x.set("World"); 43 | equal(x_change_counter, 1); 44 | equal(y_change_counter, 1); 45 | equal(y.get(), x_isnt_hello.get()); 46 | x_isnt_hello.set(200); 47 | equal(y.get(), x_isnt_hello.get()); 48 | equal(x_change_counter, 1); 49 | equal(y_change_counter, 2); 50 | x.invalidate(); 51 | equal(x.get(), "World"); 52 | }); 53 | 54 | dt("Constraint context", 1, function() { 55 | var x = cjs(function() { 56 | return this.prop1; 57 | }, { 58 | context: {prop1: 1} 59 | }); 60 | equal(x.get(), 1); 61 | }); 62 | 63 | dt("Self Referring", 3, function() { 64 | var x = cjs(1); 65 | equal(x.get(), 1); 66 | x.set(function() { 67 | return x.get() + 1; 68 | }); 69 | equal(x.get(), 2); 70 | equal(x.get(), 2); 71 | }); 72 | 73 | dt("Modifiers", 21, function() { 74 | var x = cjs(1), 75 | y = cjs(2), 76 | sum_plus_one = x.add(y, 1); 77 | equal(sum_plus_one.get(), 4); 78 | y.set(3); 79 | equal(sum_plus_one.get(), 5); 80 | x.set(2); 81 | equal(sum_plus_one.get(), 6); 82 | 83 | var times_a_evaled = 0, 84 | times_b_evaled = 0, 85 | a = cjs(function() { 86 | times_a_evaled++; 87 | return false; 88 | }), 89 | b = cjs(function() { 90 | times_b_evaled++; 91 | return false; 92 | }), 93 | and_val = a.and(b), 94 | or_val = a.or(b); 95 | equal(times_a_evaled, 0); 96 | equal(times_b_evaled, 0); 97 | equal(and_val.get(), false); 98 | equal(times_a_evaled, 1); 99 | equal(times_b_evaled, 0); 100 | a.invalidate(); 101 | b.invalidate(); 102 | equal(or_val.get(), false); 103 | equal(times_a_evaled, 2); 104 | equal(times_b_evaled, 1); 105 | 106 | a.set(function() { 107 | times_a_evaled++; 108 | return true; 109 | }); 110 | 111 | a.invalidate(); 112 | b.invalidate(); 113 | equal(and_val.get(), false); 114 | equal(times_a_evaled, 3); 115 | equal(times_b_evaled, 2); 116 | a.invalidate(); 117 | b.invalidate(); 118 | equal(or_val.get(), true); 119 | equal(times_a_evaled, 4); 120 | equal(times_b_evaled, 2); 121 | 122 | var negx = x.neg(), 123 | not_3 = negx.neq(3); 124 | 125 | equal(not_3.get(), true); 126 | equal(negx.get(), -x.get()); 127 | x.set(-3); 128 | equal(negx.get(), -x.get()); 129 | equal(not_3.get(), false); 130 | }); 131 | 132 | dt("Setting as constraint", 7, function() { 133 | var x = cjs(1); 134 | var y = cjs(x); 135 | var z = cjs(3); 136 | equal(x.get(), 1); 137 | equal(y.get(), 1); 138 | x.set(2); 139 | equal(x.get(), 2); 140 | equal(y.get(), 2); 141 | y.set(z); 142 | equal(x.get(), 2); 143 | equal(y.get(), 3); 144 | equal(z.get(), 3); 145 | }); 146 | 147 | dt("Parsed Constraints", 2, function() { 148 | var a = cjs(1); 149 | var x = cjs.createParsedConstraint("a+b", {a: a, b: cjs(2)}) 150 | equal(x.get(), 3); 151 | a.set(2); 152 | equal(x.get(), 4); 153 | }); 154 | 155 | dt("Parsed Constraints", 2, function() { 156 | var a = cjs(1); 157 | var x = cjs.createParsedConstraint("a+b", {a: a, b: cjs(2)}) 158 | equal(x.get(), 3); 159 | a.set(2); 160 | equal(x.get(), 4); 161 | }); 162 | 163 | dt("Pause Syncronous Getter", 5, function() { 164 | var eval_count = 0; 165 | var a = cjs(function(node) { 166 | node.pauseGetter(1); 167 | node.resumeGetter(10); 168 | }); 169 | var live_fn = cjs.liven(function() { 170 | eval_count++; 171 | a.get(); 172 | }); 173 | var b = a.add(1); 174 | equal(eval_count, 1); 175 | equal(a.get(), 10); 176 | equal(eval_count, 1); 177 | equal(b.get(), 11); 178 | equal(eval_count, 1); 179 | 180 | a.destroy(); 181 | b.destroy(); 182 | live_fn.destroy(); 183 | }); 184 | dtAsync("Pause Asyncronous Getter", 25, function(ready_callback) { 185 | var x = 0; 186 | var a = cjs(function(node) { 187 | node.pauseGetter(1); 188 | x++; 189 | setTimeout(function() { 190 | x++; 191 | node.resumeGetter(10); 192 | }, 50); 193 | }); 194 | equal(x, 0); 195 | var b = a.add(1); 196 | equal(a.get(), 1); 197 | equal(x, 1); 198 | equal(b.get(), 2); 199 | equal(x, 1); 200 | 201 | setTimeout(function() { 202 | equal(x, 1); 203 | equal(a.get(), 1); 204 | equal(x, 1); 205 | equal(b.get(), 2); 206 | equal(x, 1); 207 | }, 25); 208 | setTimeout(function() { 209 | equal(x, 2); 210 | equal(a.get(), 10); 211 | equal(x, 2); 212 | equal(b.get(), 11); 213 | equal(x, 2); 214 | }, 100); 215 | setTimeout(function() { 216 | equal(x, 2); 217 | equal(a.get(), 10); 218 | equal(x, 2); 219 | equal(b.get(), 11); 220 | equal(x, 2); 221 | }, 150); 222 | setTimeout(function() { 223 | equal(x, 2); 224 | equal(a.get(), 10); 225 | equal(x, 2); 226 | equal(b.get(), 11); 227 | equal(x, 2); 228 | a.destroy(); 229 | b.destroy(); 230 | ready_callback(); 231 | }, 200); 232 | }); 233 | 234 | dt("Check on nullify", 9, function() { 235 | var computed_z_times = 0; 236 | var x = cjs(1); 237 | var y = cjs(function() { return x.get() % 2; }, {check_on_nullify: true}); 238 | var z = cjs(function() { 239 | computed_z_times++; 240 | return y.get() + 1; 241 | }); 242 | 243 | equal(computed_z_times, 0); 244 | equal(z.get(), 2); 245 | equal(computed_z_times, 1); 246 | equal(z.get(), 2); 247 | equal(computed_z_times, 1); 248 | x.set(3); 249 | equal(z.get(), 2); 250 | equal(computed_z_times, 1); 251 | x.set(2); 252 | equal(z.get(), 1); 253 | equal(computed_z_times, 2); 254 | }); 255 | 256 | dt("Nullify check infinite loop", 4, function() { 257 | var x = cjs(0, {check_on_nullify: true}); 258 | equal(x.get(), 0); 259 | x.set(function(){return x.get()+1}); 260 | equal(x.get(), 1); 261 | 262 | var y = cjs(0, {check_on_nullify: true}); 263 | var z = cjs(function() { return y.get(); }, {check_on_nullify: false}); 264 | equal(y.get(), 0); 265 | y.set(function(){return z.get()+1}); 266 | equal(z.get(), 1); 267 | }); 268 | -------------------------------------------------------------------------------- /test/unit_tests/example_tests.js: -------------------------------------------------------------------------------- 1 | module("Examples"); 2 | 3 | dt("Two Eaches", 3, function() { 4 | var a1 = cjs([1,2,3]), 5 | a2 = cjs(["A", "B", "C"]); 6 | var tmplate = cjs.createTemplate("{{#each a1}}{{this}}{{/each}}{{#each a2}}{{this}}{{/each}}", {a1: a1, a2: a2}); 7 | equal(getTextContent(tmplate), "123ABC"); 8 | a2.splice(1, 1); 9 | equal(getTextContent(tmplate), "123AC"); 10 | a1.splice(2, 1, "yo"); 11 | equal(getTextContent(tmplate), "12yoAC"); 12 | 13 | a1.destroy(); 14 | a2.destroy(); 15 | cjs.destroyTemplate(tmplate); 16 | }); 17 | 18 | var emulate_mouse_event = function(event_type, target) { 19 | if(document.createEvent) { 20 | var ev = document.createEvent("MouseEvent"); 21 | ev.initMouseEvent(event_type, true, true, window, 22 | 0, 0, 0, 80, 20, false, false, false, false, 0, null); 23 | target.dispatchEvent(ev); 24 | } else if(document.createEventObject) { 25 | var evObj = document.createEventObject(); 26 | target.fireEvent('on' + event_type, evObj); 27 | } 28 | } 29 | emulate_keyboard_event = function(event_class, target, key_code) { 30 | if(document.createEvent) { 31 | var keyboardEvent = document.createEvent("KeyboardEvent"); 32 | 33 | var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; 34 | 35 | 36 | keyboardEvent[initMethod]( 37 | event_class, 38 | true, // bubbles oOooOOo0 39 | true, // cancelable 40 | window, // view 41 | false, // ctrlKeyArg 42 | false, // altKeyArg 43 | false, // shiftKeyArg 44 | false, // metaKeyArg 45 | key_code, 46 | key_code // charCode 47 | ); 48 | keyboardEvent.keyCode = key_code; 49 | keyboardEvent.keyCodeVal = key_code; 50 | keyboardEvent.which = key_code; 51 | 52 | 53 | target.dispatchEvent(keyboardEvent); 54 | } else if(document.createEventObject) { 55 | var evObj = document.createEventObject(); 56 | evObj.keyCode = key_code; 57 | evObj.target = target; 58 | target.fireEvent('on'+event_class, evObj); 59 | } 60 | }; 61 | 62 | dt("Cell", 8, function() { 63 | var value = cjs(""), 64 | tmplate = cjs.createTemplate( 65 | "{{#fsm edit_state}}" + 66 | "{{#state idle}}" + 67 | "{{#if value===''}}" + 68 | "(unset)" + 69 | "{{#else}}" + 70 | "{{value}}" + 71 | "{{/if}}" + 72 | "{{#state editing}}" + 73 | "