├── logos ├── ai │ ├── black.ai │ ├── color.ai │ ├── white.ai │ ├── nanojs1.ai │ └── nanojs2.ai ├── png │ ├── _DS_Store │ ├── horizontal - logo │ │ ├── nano-logo.png │ │ ├── Horizontalhdpi.png │ │ ├── Horizontalldpi.png │ │ ├── Horizontalmdpi.png │ │ ├── Horizontalxhdpi.png │ │ ├── Horizontalxxhdpi.png │ │ ├── Horizontalxxxhdpi.png │ │ └── Horizontal.svg │ └── vertical - logo │ │ ├── verticalhdpi.png │ │ ├── verticalldpi.png │ │ ├── verticalmdpi.png │ │ ├── verticalxhdpi.png │ │ ├── verticalxxhdpi.png │ │ ├── verticalxxxhdpi.png │ │ └── vertical.svg ├── eps │ ├── vertical.eps │ └── horizontal.eps └── Readme.md ├── lab ├── lib │ └── jasmine-3.1.0 │ │ ├── jasmine_favicon.png │ │ ├── boot.js │ │ ├── jasmine.css │ │ └── jasmine-html.js ├── SpecRunner.html ├── sun.html ├── MIT.LICENSE ├── of-onn.html ├── nanoJS.html ├── css.html ├── animate.html ├── src │ └── nano.js └── spec │ └── nanoSpec.js ├── package.json ├── lib ├── prettify.css ├── style.css ├── docJS.js └── prettify.js ├── sun.html ├── LICENSE ├── .gitignore ├── mission.md ├── of-onn.html ├── css.html ├── nanoJS.html ├── docs.md ├── README.md ├── src ├── nanoJS.min.js.map ├── nanoJS.min.js └── nanoJS.js └── animate.html /logos/ai/black.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/ai/black.ai -------------------------------------------------------------------------------- /logos/ai/color.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/ai/color.ai -------------------------------------------------------------------------------- /logos/ai/white.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/ai/white.ai -------------------------------------------------------------------------------- /logos/ai/nanojs1.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/ai/nanojs1.ai -------------------------------------------------------------------------------- /logos/ai/nanojs2.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/ai/nanojs2.ai -------------------------------------------------------------------------------- /logos/png/_DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/_DS_Store -------------------------------------------------------------------------------- /logos/eps/vertical.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/eps/vertical.eps -------------------------------------------------------------------------------- /logos/eps/horizontal.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/eps/horizontal.eps -------------------------------------------------------------------------------- /lab/lib/jasmine-3.1.0/jasmine_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/lab/lib/jasmine-3.1.0/jasmine_favicon.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/nano-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/nano-logo.png -------------------------------------------------------------------------------- /logos/png/vertical - logo/verticalhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/vertical - logo/verticalhdpi.png -------------------------------------------------------------------------------- /logos/png/vertical - logo/verticalldpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/vertical - logo/verticalldpi.png -------------------------------------------------------------------------------- /logos/png/vertical - logo/verticalmdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/vertical - logo/verticalmdpi.png -------------------------------------------------------------------------------- /logos/png/vertical - logo/verticalxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/vertical - logo/verticalxhdpi.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontalhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/Horizontalhdpi.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontalldpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/Horizontalldpi.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontalmdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/Horizontalmdpi.png -------------------------------------------------------------------------------- /logos/png/vertical - logo/verticalxxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/vertical - logo/verticalxxhdpi.png -------------------------------------------------------------------------------- /logos/png/vertical - logo/verticalxxxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/vertical - logo/verticalxxxhdpi.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontalxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/Horizontalxhdpi.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontalxxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/Horizontalxxhdpi.png -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontalxxxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladocar/nanoJS/HEAD/logos/png/horizontal - logo/Horizontalxxxhdpi.png -------------------------------------------------------------------------------- /logos/Readme.md: -------------------------------------------------------------------------------- 1 | All logos are generously provided and created by Mohammad Iqbal. 2 | 3 | You can find Mohammad at [@iqbalhood](https://github.com/iqbalhood) 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vladocar/nanojs", 3 | "version": "1.0.5", 4 | "description": "Minimal standalone JS library for DOM manipulation", 5 | "main": "index.js", 6 | "directories": { 7 | "lib": "lib" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/vladocar/nanoJS.git" 15 | }, 16 | "keywords": [ 17 | "js", 18 | "javascript", 19 | "dom", 20 | "library" 21 | ], 22 | "author": "Vladimir Carrer (http://www.vcarrer.com)", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/vladocar/nanoJS/issues" 26 | }, 27 | "homepage": "https://github.com/vladocar/nanoJS#readme" 28 | } 29 | -------------------------------------------------------------------------------- /lab/SpecRunner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jasmine Spec Runner v3.1.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 |

26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/prettify.css: -------------------------------------------------------------------------------- 1 | /* Pretty printing styles. Used with prettify.js. */ 2 | 3 | .str { color: #080; } 4 | .kwd { color: #008; } 5 | .com { color: #800; } 6 | .typ { color: #606; } 7 | .lit { color: #066; } 8 | .pun { color: #660; } 9 | .pln { color: #000; } 10 | .tag { color: #008; } 11 | .atn { color: #606; } 12 | .atv { color: #080; } 13 | .dec { color: #606; } 14 | pre.prettyprint { padding: 2px; border: 1px solid #888; } 15 | 16 | @media print { 17 | .str { color: #060; } 18 | .kwd { color: #006; font-weight: bold; } 19 | .com { color: #600; font-style: italic; } 20 | .typ { color: #404; font-weight: bold; } 21 | .lit { color: #044; } 22 | .pun { color: #440; } 23 | .pln { color: #000; } 24 | .tag { color: #006; font-weight: bold; } 25 | .atn { color: #404; } 26 | .atv { color: #060; } 27 | } 28 | -------------------------------------------------------------------------------- /sun.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Sun 10 | 11 | 18 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /lab/sun.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Sun 10 | 11 | 18 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /lab/MIT.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2017 Pivotal Labs 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Vladimir Carrer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Custom OS Files 2 | .DS_Store 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | # Runtime data 12 | pids 13 | *.pid 14 | *.seed 15 | *.pid.lock 16 | 17 | # Directory for instrumented libs generated by jscoverage/JSCover 18 | lib-cov 19 | 20 | # Coverage directory used by tools like istanbul 21 | coverage 22 | 23 | # nyc test coverage 24 | .nyc_output 25 | 26 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 27 | .grunt 28 | 29 | # Bower dependency directory (https://bower.io/) 30 | bower_components 31 | 32 | # node-waf configuration 33 | .lock-wscript 34 | 35 | # Compiled binary addons (https://nodejs.org/api/addons.html) 36 | build/Release 37 | 38 | # Dependency directories 39 | node_modules/ 40 | jspm_packages/ 41 | 42 | # TypeScript v1 declaration files 43 | typings/ 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | 63 | # next.js build output 64 | .next 65 | -------------------------------------------------------------------------------- /lib/style.css: -------------------------------------------------------------------------------- 1 | html,body{ 2 | margin:0;padding:0; 3 | } 4 | body{background-color: #F4F4F4;} 5 | a{ 6 | text-decoration: none; color:#333; line-height:1.6; 7 | } 8 | a:hover{ 9 | text-decoration: underline; 10 | } 11 | i{ 12 | font-size: 12px; 13 | } 14 | ul{ 15 | list-style-type: none; 16 | } 17 | pre{ 18 | font:14px/ 1.6 Monaco, Consolas, 'Lucida Console', monospace; 19 | } 20 | h1,h2,h3{ 21 | font-family: "lucida grande","lucida sans unicode", sans-serif; 22 | font-weight: normal; 23 | } 24 | p{font: 14px/1.6 Arial, sans-serif} 25 | 26 | /* sidebar is directly taken from backbone.js*/ 27 | #sidebar { 28 | background: #fff; 29 | position: fixed; 30 | top: 0; left: 0; bottom: 0; 31 | width: 180px; 32 | overflow-y: auto; 33 | overflow-x: hidden; 34 | padding: 15px 0 15px 15px; 35 | border-right: 1px solid #ddd; 36 | box-shadow: 0 0 20px #ccc; -webkit-box-shadow: 0 0 20px #ccc; -moz-box-shadow: 0 0 20px #ccc; 37 | } 38 | #links{ 39 | list-style-position: inside; padding:15px 0 0 0; margin:0; 40 | } 41 | #intro{ 42 | max-width: 720px; 43 | margin:20px 0 10px 220px; 44 | } 45 | #a{ 46 | margin-left:190px; 47 | } 48 | .l{ 49 | border-bottom: 1px dotted #ccc; 50 | padding:15px 0; 51 | } 52 | .b{font-weight: bold;} 53 | -------------------------------------------------------------------------------- /mission.md: -------------------------------------------------------------------------------- 1 | # nanoJS Mission & Philosophy 2 | 3 | Many developers asked: why not use vanillaJS? 4 | 5 | If that works for you use vanillaJS. The problem is you will encounter the same problems over and over again like constant selector declaring or CSS injections. Don't repeat yourself. Probably the next step will be you will build some custom JS function that will help you dealing with vanillaJS. 6 | 7 | What kind of syntax will you use for your custom functions? 8 | 9 | Probably something that works for you, but why not use the syntax that most of the developers are familiar -> jQuery syntax. That is the origin story of nanoJS. 10 | 11 | Other important thing every method should be independent (standalone) of other methods. With that you can add or remove methods without compromising the integrity of the library. That means more code redundancy but also more customisable library directly from the main code. 12 | 13 | All methods should use native JavaScript if possible. 14 | 15 | All methods should have readable and clear syntax. 16 | 17 | Code readability has advantage over browser support. We need to push web technology forward. Currently almost all the library works in IE9. Some methods will not work in IE9 and that is fine. 18 | 19 | Most of JS libraries are “black box” meaning you shouldn’t interact with them directly. Not this one. We encourage you to interact with nanoJS.js directly and change whatever you like, add or remove methods, change the names of the methods .. go crazy make your own library :) 20 | -------------------------------------------------------------------------------- /lab/of-onn.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Off - On 7 | 8 | 26 | 71 | 72 | 73 | 74 |
75 |
On
76 |
Off
77 | 78 |
79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /of-onn.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Off - On 7 | 8 | 26 | 71 | 72 | 73 | 74 |
75 |
On
76 |
Off
77 | 78 |
79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /lib/docJS.js: -------------------------------------------------------------------------------- 1 | function docJS(d, n) { 2 | var keys = Object.keys(d).sort().reverse(); 3 | var i = keys.length; 4 | var list = ""; 5 | var list1 = ""; 6 | var numOfLines = ""; 7 | var numOfCharacters = ""; 8 | var numOfArguments = 0; 9 | var x = 0; 10 | var pp = (typeof prettyPrintOne === 'function'); 11 | while (i--) { 12 | if (typeof d[keys[i]] === "object") { 13 | x += 0; 14 | numOfLines = "undefined"; 15 | numOfCharacters = "undefined"; 16 | numOfArguments = 0; 17 | } else if (typeof d[keys[i]] === "function") { 18 | x += d[keys[i]].toString().length; 19 | numOfLines = d[keys[i]].toString().split('\n').length; 20 | numOfCharacters = d[keys[i]].toString().length; 21 | numOfArguments = d[keys[i]].length; 22 | } else { 23 | x += d[keys[i]].toString().length; 24 | numOfLines = d[keys[i]].toString().split('\n').length; 25 | numOfCharacters = d[keys[i]].toString().length; 26 | numOfArguments = 0; 27 | } 28 | list1 += "
  • - " + keys[i] + "
  • "; 29 | list += "
  • " + keys[i] + ": ( lines: " + numOfLines + " characters: " + numOfCharacters + " arguments: " + numOfArguments + " )


      " + (pp ? prettyPrintOne(String(d[keys[i]]).replace(/\n/g, '
    '), 'js', false) : d[keys[i]]) + "
  • "; 30 | } 31 | document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeEnd",''); 32 | console.log(x / 1024 + " Kb - It doesn't calculate nested objects"); 33 | } 34 | -------------------------------------------------------------------------------- /lab/nanoJS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |

    nanoJS

    24 |

    Minimal standalone JS library for DOM manipulation

    25 |

    nanoJS is around 100 lines of code (1.2 Kb compressed) JavaScript library for basic DOM manipulation. It has jQuery like syntax and supports chaining. 26 |

    27 | 28 |

    Because is so small and simple you can add or remove methods directly in the library, meaning is very customizable. All methods are unrelated so removing one will not affect the library in any way (except each method). 29 |

    30 |

    Use this library as starting point and personalise it so it can meet your needs. We often use huge JavaScript libraries and framework for basic tasks. 31 |

    32 |

    Here are some code examples:

    33 |
    $(".someClass").css("background-color:green;").html("Hello World");
    34 |
    $('#c').animate('2.3', '1.2','0','1','1','0','0', '0','0','1').css('background-color:red').text('Hello');
    35 |
    36 | 
    37 | $("#a").on("click", function(){
    38 | 
    39 |   $("#someDiv").css("background-color:green;color:#fff;");
    40 | 
    41 | })
    42 | 
    43 | 
    44 |

    It uses familiar jQuery like syntax.

    45 | 46 |

    It works in IE9 and later.

    47 |

    Download on Github

    48 | 49 |

    Here is the list of all the methods:

    50 |
    51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CSS 7 | 8 | 9 | 24 | 72 | 73 | 74 | 75 |
    Click Me
    76 |
    77 |
    78 |
    79 |
    80 |
    81 |
    82 |
    83 |
    84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /lab/css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CSS 7 | 8 | 9 | 24 | 72 | 73 | 74 | 75 |
    Click Me
    76 |
    77 |
    78 |
    79 |
    80 |
    81 |
    82 |
    83 |
    84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /nanoJS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |

    nanoJS

    24 |

    Minimal standalone JS library for DOM manipulation

    25 |

    nanoJS is around 100 lines of code (1.2 Kb compressed) JavaScript library for basic DOM manipulation. It has jQuery like syntax and supports chaining. 26 |

    27 | 28 |

    Because is so small and simple you can add or remove methods directly in the library, meaning is very customizable. All methods are unrelated so removing one will not affect the library in any way (except each method). 29 |

    30 |

    Use this library as starting point and personalise it so it can meet your needs. We often use huge JavaScript libraries and framework for basic tasks. 31 |

    32 |

    Here are some code examples:

    33 |
    $(".someClass").css("background-color:green;").html("Hello World");
    34 |
    $('#c').animate('2.3', '1.2','0','1','1','0','0', '0','0','1').css('background-color:red').text('Hello');
    35 |
    36 | 
    37 | $("#a").on("click", function(){
    38 | 
    39 |   $("#someDiv").css("background-color:green;color:#fff;");
    40 | 
    41 | })
    42 | 
    43 | 
    44 |

    It uses familiar jQuery like syntax.

    45 | 46 |

    It works in IE9 and later.

    47 |

    Download on Github

    48 | 49 |

    Here is the list of all the methods:

    50 |
    51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs.md: -------------------------------------------------------------------------------- 1 | # nanoJS Docs 2 | 3 | 4 | #### addClass 5 | ```js 6 | $("#a").addClass("newclass"); 7 | ``` 8 | 9 | #### animate 10 | ```js 11 | $('#c').animate('2.3', '1.2','0','1','1', '0', '0', '0', '0', '1'); 12 | ``` 13 | 14 | #### attr 15 | ```js 16 | $('#c').attr("class", "newclass"); 17 | ``` 18 | 19 | #### css 20 | ```js 21 | $(".someClass").css("background-color:green"); 22 | ``` 23 | 24 | #### cssdom 25 | ```js 26 | $("div").cssdom({backgroundColor:"red", color:"#fff"}); 27 | ``` 28 | 29 | #### empty 30 | ```js 31 | $('#c').empty(); 32 | ``` 33 | 34 | #### eq 35 | ```js 36 | $("div").eq(0).html("Hello World!"); 37 | ``` 38 | 39 | #### getAttr 40 | ```js 41 | $("#b").getAttr("class"); 42 | ``` 43 | 44 | #### html 45 | ```js 46 | $('#c').html("

    Hello World!

    "); 47 | ``` 48 | 49 | #### insertAfter, insertBefore, insertFirst insertLast 50 | ```js 51 | $('#c').insertAfter("

    Hello World!

    "); 52 | ``` 53 | #### offset 54 | ```js 55 | $("#b").offset(); 56 | $("#c").css("width:" + offset.width + "px"); 57 | ``` 58 | 59 | #### on 60 | ```js 61 | $("#a").on("click", function(){ 62 | 63 | $("#someDiv").css("background-color:green; color:#fff;"); 64 | 65 | }) 66 | ``` 67 | #### parent 68 | ```js 69 | $("p").parent().css("background-color:green"); 70 | ``` 71 | 72 | #### removeAttr 73 | ```js 74 | $('#c').removeAttr("class"); 75 | ``` 76 | 77 | #### removeClass 78 | ```js 79 | $('#c').removeClass("someClass"); 80 | ``` 81 | #### siblings 82 | ```js 83 | $("#active").siblings().css("background-color:green"); 84 | 85 | $("li").eq(2).siblings().css("background-color:red"); 86 | ``` 87 | 88 | #### text 89 | ```js 90 | $('#b').text("Hello World!"); 91 | ``` 92 | 93 | #### toggleClass 94 | ```js 95 | $('#c').toggleClass("someClass"); 96 | ``` 97 | 98 | #### $(this) 99 | ```js 100 | $("div").on("click", function(){ 101 | 102 | $(this).css("background-color:red"); 103 | 104 | }) 105 | ``` 106 | -------------------------------------------------------------------------------- /logos/png/vertical - logo/vertical.svg: -------------------------------------------------------------------------------- 1 | vertical -------------------------------------------------------------------------------- /logos/png/horizontal - logo/Horizontal.svg: -------------------------------------------------------------------------------- 1 | Horizontal -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nanoJS 2 | 3 | [![License MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](https://choosealicense.com/licenses/mit/) 4 | [![Gzip Size](https://img.badgesize.io/https://unpkg.com/@vladocar/nanojs@1.0.5/src/nanoJS.min.js?compression=gzip)](https://unpkg.com/@vladocar/nanojs@1.0.5/src/nanoJS.min.js) 5 | [![npm](https://img.shields.io/npm/v/@vladocar/nanojs.svg)](https://www.npmjs.com/package/@vladocar/nanojs) 6 | 7 | 8 | Minimal standalone JS library for DOM manipulation 9 | 10 | 11 | 12 | nanoJS is around 100 lines of code (0.9 Kb compressed) JavaScript library for basic DOM manipulation. It has jQuery like syntax and supports chaining. 13 | 14 | Syntax demos: 15 | 16 | ```javascript 17 | 18 | $(".someClass").css("background-color:green;").html("Hello World"); 19 | 20 | $('#c').animate('2.3', '1.2','0','1','1','0','0', '0','0','1').css('background-color:red').text('Hello'); 21 | 22 | $("#a").on("click", function(){ 23 | 24 | $("#someDiv").css("background-color:green;color:#fff;"); 25 | 26 | }) 27 | 28 | ``` 29 | 30 | [You can find it here some basic examples.](docs.md) also the [Mission & Philosophy of nanoJS](mission.md) 31 | 32 | 33 | It works in IE9 and later. (some methods addClass, removeClass and toggleClass will not work in IE9) 34 | 35 | Read more here: 36 | 37 | [https://vladocar.github.io/nanoJS/](https://vladocar.github.io/nanoJS/) 38 | 39 | or on my blog: 40 | 41 | [http://www.vcarrer.com/2018/05/nanojs-javascript-for-dom-manipulation.html](http://www.vcarrer.com/2018/05/nanojs-javascript-for-dom-manipulation.html) 42 | 43 | 44 | You can use direct download or: 45 | 46 | ```sh 47 | npm i @vladocar/nanojs 48 | ``` 49 | 50 | ```sh 51 | yarn add @vladocar/nanojs 52 | ``` 53 | 54 | ```html 55 | 56 | 57 | OR 58 | 59 | 60 | ``` 61 | 62 | ### Utils: 63 | 64 | addClass 65 | animate 66 | attr 67 | css 68 | cssdom 69 | empty 70 | eq 71 | getAttr 72 | html 73 | insertAfter, insertBefore, insertFirst insertLast 74 | offset 75 | on 76 | parent 77 | removeAttr 78 | removeClass 79 | siblings 80 | text 81 | toggleClass 82 | log 83 | -------------------------------------------------------------------------------- /src/nanoJS.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["nanoJS.js"],"names":["nano","s","this","value","Array","prototype","slice","call","document","querySelectorAll","eq","n","each","fn","forEach","css","v","i","style","cssText","cssdom","key","attr","a","setAttribute","getAttr","getAttribute","removeAttr","removeAttribute","animate","time","scale","rotate","rotateX","rotateY","translateX","translateY","skewX","skewY","opacity","on","type","addEventListener","addClass","classList","add","className","toggleClass","toggle","removeClass","remove","html","innerHTML","text","innerText","insertBefore","insertAdjacentHTML","insertAfter","insertFirst","insertLast","empty","offset","getBoundingClientRect","$","selector"],"mappings":"AAAA,GAAIA,MAAO,SAASC,GACC,gBAANA,KACPC,KAAKC,MAAQC,MAAMC,UAAUC,MAAMC,KAAKC,SAASC,iBAAiBR,KAErD,gBAANA,KACPC,KAAKC,OAASF,IAIrBD,MAAKK,WACJK,GAAI,SAASC,GAEX,MADAT,MAAKC,OAASD,KAAKC,MAAMQ,IAClBT,MAETU,KAAM,SAASC,GAEb,SADGC,QAAQP,KAAKL,KAAKC,MAAOU,GACrBX,MAETa,IAAK,SAAUC,GACb,MAAOd,MAAKU,KAAK,SAAUK,GACzBA,EAAEC,MAAMC,QAAUF,EAAEC,MAAMC,QAAUH,KAGxCI,OAAQ,SAAUJ,GAChB,MAAOd,MAAKU,KAAK,SAAUK,GACzB,IAAK,GAAII,KAAOL,GACdC,EAAEC,MAAMG,GAAOL,EAAEK,MAIvBC,KAAM,SAAUC,EAAGP,GACjB,MAAOd,MAAKU,KAAK,SAAUK,GACzBA,EAAEO,aAAaD,EAAGP,MAGtBS,QAAS,SAAUT,GACjB,MAAOd,MAAKC,MAAM,GAAGuB,aAAaV,IAEpCW,WAAY,SAAUX,GACpB,MAAOd,MAAKU,KAAK,SAAUK,GACzBA,EAAEW,gBAAgBZ,MAGtBa,QAAS,SAAU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,YAAYxC,MAGrC4C,MAAO,WACL,MAAO1D,MAAKU,KAAK,SAAUK,GACzBA,EAAEmC,UAAY,MAGlBS,OAAQ,WACL,MAAO3D,MAAKU,KAAK,SAAUK,GAC5B4C,OAAS5C,EAAE6C,2BAKf,IAAIC,GAAI,SAASC,GACf,MAAO,IAAIhE,MAAKgE"} -------------------------------------------------------------------------------- /animate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Animate 7 | 8 | 35 | 89 | 90 | 91 | 92 |
    Click Me
    93 | 94 |
    Color
    95 |
    96 |
    97 |
    98 |
    99 |
    100 |
    101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /lab/animate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Animate 7 | 8 | 35 | 89 | 90 | 91 | 92 |
    Click Me
    93 | 94 |
    Color
    95 |
    96 |
    97 |
    98 |
    99 |
    100 |
    101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/nanoJS.min.js: -------------------------------------------------------------------------------- 1 | !function(a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):window.$=a()}(function(){var a=function(a){"string"==typeof a&&(this.value=Array.prototype.slice.call(document.querySelectorAll(a))),"object"==typeof a&&(this.value=[a])};return a.prototype={eq:function(a){return this.value=[this.value[a]],this},each:function(a){return[].forEach.call(this.value,a),this},css:function(a){return this.each(function(b){b.style.cssText+=a})},cssdom:function(a){return this.each(function(b){for(var c in a)b.style[c]=a[c]})},attr:function(b,a){return this.each(function(c){c.setAttribute(b,a)})},getAttr:function(a){return this.value[0].getAttribute(a)},removeAttr:function(a){return this.each(function(b){b.removeAttribute(a)})},animate:function(a,b,c,d,e,f,g,h,j,k){return this.each(function(l){l.style.cssText=l.style.cssText+"transition: all "+a+"s ease-in-out; transform: scale("+b+") rotate("+c+"deg) rotateX("+d+"deg) rotateY("+e+"deg) translate("+f+"px, "+g+"px) skew("+h+"deg, "+j+"deg); opacity:"+k+";"})},on:function(a,b){return this.each(function(c){c.addEventListener(a,b,!1)})},addClass:function(b){var c=b.split(" ");return this.each(function(a){for(var b=0;ba!==this.value[0]),this},offset:function(){return this.each(function(a){offset=a.getBoundingClientRect()})},log:function(){console.log(this)}},function(b){return new a(b)}}); 2 | -------------------------------------------------------------------------------- /lab/src/nano.js: -------------------------------------------------------------------------------- 1 | function Nano(selector){ 2 | let self = this; 3 | let values = Array.prototype.slice.call(document.querySelectorAll(selector)); 4 | 5 | self.each = function(handler) { 6 | values.forEach(handler); 7 | return this; 8 | }; 9 | 10 | self.eq = function(position) { 11 | values = [values[position]]; 12 | return this; 13 | }; 14 | 15 | self.css = function (style) { 16 | return self.each(function (element) { 17 | element.style.cssText = element.style.cssText + style; 18 | }); 19 | }; 20 | 21 | self.attr = function (attribute, value) { 22 | return self.each(function (element) { 23 | element.setAttribute(attribute, value); 24 | }); 25 | }; 26 | 27 | self.getAttr = function (attribute) { 28 | let firstElement = values[0]; 29 | if( !values || !firstElement){ 30 | return ''; 31 | } 32 | let result = firstElement.getAttribute(attribute); 33 | if(!result){ 34 | return ''; 35 | } 36 | return result; 37 | }; 38 | 39 | self.removeAttr = function (attribute) { 40 | return self.each(function (element) { 41 | element.removeAttribute(attribute); 42 | }); 43 | }; 44 | 45 | self.animate = function (time, scale, rotate, rotateX, rotateY, translateX, translateY, skewX, skewY, opacity) { 46 | return self.each(function (element) { 47 | element.style.cssText = element.style.cssText + 'transition: all ' + time + 's ease-in-out; transform: scale(' + scale + ') rotate(' + rotate + 'deg) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg) translate(' + translateX + 'px, ' + translateY + 'px) skew(' + skewX + 'deg, ' + skewY + 'deg); opacity:' + opacity + ';)' 48 | }); 49 | }; 50 | 51 | self.on = function (type, handler) { 52 | return self.each(function (element) { 53 | element.addEventListener(type, handler, false); 54 | }); 55 | }; 56 | 57 | self.addClass = function (className) { 58 | return self.each(function (element) { 59 | if (element.classList) { 60 | element.classList.add(className) 61 | } 62 | else { 63 | element.className += ' ' + className; 64 | } 65 | }); 66 | }; 67 | 68 | self.toggleClass = function (className) { 69 | return self.each(function (element) { 70 | element.classList.toggle(className); 71 | }); 72 | }; 73 | 74 | self.removeClass = function (className) { 75 | return self.each(function (element) { 76 | element.classList.remove(className); 77 | }); 78 | }; 79 | 80 | self.html = function (html) { 81 | return self.each(function (element) { 82 | element.innerHTML = html; 83 | }); 84 | }; 85 | 86 | self.text = function (text) { 87 | return this.each(function (element) { 88 | element.innerText = text; 89 | }); 90 | }; 91 | 92 | self.empty = function () { 93 | return self.each(function (element) { 94 | element.innerHTML = ''; 95 | }); 96 | }; 97 | 98 | self.insertBefore = function (html) { 99 | return self.each(function (element) { 100 | element.insertAdjacentHTML('beforeBegin', html); 101 | }); 102 | }; 103 | 104 | self.insertAfter = function (html) { 105 | return self.each(function (element) { 106 | element.insertAdjacentHTML('afterEnd', html); 107 | }); 108 | }; 109 | 110 | self.insertFirst = function (html) { 111 | return self.each(function (element) { 112 | element.insertAdjacentHTML('afterBegin', html); 113 | }); 114 | }; 115 | 116 | self.insertLast = function (html) { 117 | return self.each(function (element) { 118 | element.insertAdjacentHTML('beforeEnd', html); 119 | }); 120 | }; 121 | 122 | self.offset = function () { 123 | return this.each(function (element) { 124 | offset = element.getBoundingClientRect(); 125 | }); 126 | }; 127 | } 128 | 129 | var $ = function(selector) { 130 | return new Nano(selector); 131 | }; -------------------------------------------------------------------------------- /lab/spec/nanoSpec.js: -------------------------------------------------------------------------------- 1 | describe('Nano JS', function(){ 2 | const elementId = 'a'; 3 | 4 | beforeEach(function(){ 5 | document.getElementById(elementId).removeAttribute("style"); 6 | document.getElementById(elementId).removeAttribute("class"); 7 | }); 8 | 9 | it('Applyies css style', function(){ 10 | const style = 'background-color: rgb(34, 34, 34);'; 11 | 12 | $('#' + elementId).css(style); 13 | 14 | expect(document.getElementById(elementId).style.cssText).toBe(style); 15 | }); 16 | 17 | it('Sets a value to an attribute', function(){ 18 | $('#' + elementId).attr('class', 'on'); 19 | 20 | expect(document.getElementById(elementId).outerHTML).toContain('class="on"'); 21 | }); 22 | 23 | it('sets eq', function(){ 24 | const elementId = 'b'; 25 | const html = 'Hello World!'; 26 | $('#' + elementId).eq(0).html(html); 27 | 28 | expect(document.getElementById(elementId).outerHTML).toContain(html); 29 | }); 30 | 31 | describe('when getting attribute is requested', function(){ 32 | it('Returns string empty if there is no attribute', function(){ 33 | let value = $('#' + elementId).getAttr('invalid-attribute'); 34 | 35 | expect('').toBe(value); 36 | }); 37 | 38 | it('Returns string empty if there is no element', function(){ 39 | let value = $('#' + 'invalid-element-id').getAttr('invalid-attribute'); 40 | 41 | expect('').toBe(value); 42 | }); 43 | 44 | it('Returns the value of an attribute', function(){ 45 | let attributeValue = 'on'; 46 | $('#' + elementId).attr('class', attributeValue); 47 | 48 | let value = $('#' + elementId).getAttr('class'); 49 | 50 | expect(value).toBe(attributeValue); 51 | }); 52 | 53 | }); 54 | 55 | it('Removes an attribute', function(){ 56 | const attributeValue = 'on'; 57 | const attribute = 'class'; 58 | $('#' + elementId).attr(attribute, attributeValue); 59 | expect(attributeValue).toBe($('#' + elementId).getAttr(attribute)); 60 | 61 | $('#' + elementId).removeAttr(attribute); 62 | 63 | expect('').toBe($('#' + elementId).getAttr(attribute)); 64 | }); 65 | 66 | it('Animates', function(){ 67 | const style = 'transition: all 2s ease-in-out; transform: scale(1) rotate(360deg) rotateX(1deg) rotateY(1deg) translate(0px, 0px) skew(0deg, 0deg); opacity: 1;'; 68 | 69 | $('#' + elementId).animate('2', '1','360','1','1','0','0', '0','0','1'); 70 | 71 | expect(document.getElementById(elementId).style.cssText).toBe(style); 72 | }); 73 | 74 | describe('When setting an event is requested', function(){ 75 | it('Does nothing if the element does not exist', function(){ 76 | let eventThrown = false; 77 | $('#' + 'invalid-elemet-id').on('click', function(){ eventThrown = true; }); 78 | 79 | document.getElementById(elementId).click(); 80 | 81 | expect(eventThrown).toBeFalsy(); 82 | }); 83 | 84 | it('Sets an event', function(){ 85 | let eventThrown = false; 86 | $('#' + elementId).on('click', function(){ eventThrown = true; }); 87 | 88 | document.getElementById(elementId).click(); 89 | 90 | expect(eventThrown).toBeTruthy(); 91 | }); 92 | }); 93 | 94 | it('Adds a class name', function(){ 95 | const className = 'class-name'; 96 | 97 | $('#' + elementId).addClass(className); 98 | 99 | expect(className).toBe(document.getElementById(elementId).className); 100 | }); 101 | 102 | it('Removes a class', function(){ 103 | const className = 'class-name'; 104 | $('#' + elementId).addClass(className); 105 | expect(className).toContain(document.getElementById(elementId).className); 106 | 107 | $('#' + elementId).removeClass(className); 108 | 109 | expect('').toBe(document.getElementById(elementId).className); 110 | }); 111 | 112 | it('Toggles a class name', function(){ 113 | const className = 'class-name'; 114 | 115 | $('#' + elementId).toggleClass(className); 116 | 117 | expect(className).toBe(document.getElementById(elementId).className); 118 | }); 119 | 120 | it('Sets html', function(){ 121 | var html = '

    '; 122 | 123 | $('#' + elementId).html(html); 124 | 125 | expect(document.getElementById(elementId).outerHTML).toContain(html); 126 | }); 127 | 128 | it('Sets text', function(){ 129 | var text = 'some text'; 130 | 131 | $('#' + elementId).text(text); 132 | 133 | expect(document.getElementById(elementId).outerText).toContain(text); 134 | }); 135 | 136 | it('Sets html empty', function(){ 137 | var html = '

    '; 138 | $('#' + elementId).html(html); 139 | 140 | $('#' + elementId).empty(); 141 | 142 | expect('').toBe(document.getElementById(elementId).innerHTML); 143 | }); 144 | }); -------------------------------------------------------------------------------- /lab/lib/jasmine-3.1.0/boot.js: -------------------------------------------------------------------------------- 1 | /** 2 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project. 3 | 4 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms. 5 | 6 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`. 7 | 8 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem 9 | */ 10 | 11 | (function() { 12 | 13 | /** 14 | * ## Require & Instantiate 15 | * 16 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. 17 | */ 18 | window.jasmine = jasmineRequire.core(jasmineRequire); 19 | 20 | /** 21 | * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. 22 | */ 23 | jasmineRequire.html(jasmine); 24 | 25 | /** 26 | * Create the Jasmine environment. This is used to run all specs in a project. 27 | */ 28 | var env = jasmine.getEnv(); 29 | 30 | /** 31 | * ## The Global Interface 32 | * 33 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. 34 | */ 35 | var jasmineInterface = jasmineRequire.interface(jasmine, env); 36 | 37 | /** 38 | * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. 39 | */ 40 | extend(window, jasmineInterface); 41 | 42 | /** 43 | * ## Runner Parameters 44 | * 45 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. 46 | */ 47 | 48 | var queryString = new jasmine.QueryString({ 49 | getWindowLocation: function() { return window.location; } 50 | }); 51 | 52 | var filterSpecs = !!queryString.getParam("spec"); 53 | 54 | var stoppingOnSpecFailure = queryString.getParam("failFast"); 55 | env.stopOnSpecFailure(stoppingOnSpecFailure); 56 | 57 | var throwingExpectationFailures = queryString.getParam("throwFailures"); 58 | env.throwOnExpectationFailure(throwingExpectationFailures); 59 | 60 | var random = queryString.getParam("random"); 61 | 62 | if (random !== undefined && random !== "") { 63 | env.randomizeTests(random); 64 | } 65 | 66 | var seed = queryString.getParam("seed"); 67 | if (seed) { 68 | env.seed(seed); 69 | } 70 | 71 | /** 72 | * ## Reporters 73 | * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). 74 | */ 75 | var htmlReporter = new jasmine.HtmlReporter({ 76 | env: env, 77 | navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); }, 78 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); }, 79 | getContainer: function() { return document.body; }, 80 | createElement: function() { return document.createElement.apply(document, arguments); }, 81 | createTextNode: function() { return document.createTextNode.apply(document, arguments); }, 82 | timer: new jasmine.Timer(), 83 | filterSpecs: filterSpecs 84 | }); 85 | 86 | /** 87 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. 88 | */ 89 | env.addReporter(jasmineInterface.jsApiReporter); 90 | env.addReporter(htmlReporter); 91 | 92 | /** 93 | * Filter which specs will be run by matching the start of the full name against the `spec` query param. 94 | */ 95 | var specFilter = new jasmine.HtmlSpecFilter({ 96 | filterString: function() { return queryString.getParam("spec"); } 97 | }); 98 | 99 | env.specFilter = function(spec) { 100 | return specFilter.matches(spec.getFullName()); 101 | }; 102 | 103 | /** 104 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack. 105 | */ 106 | window.setTimeout = window.setTimeout; 107 | window.setInterval = window.setInterval; 108 | window.clearTimeout = window.clearTimeout; 109 | window.clearInterval = window.clearInterval; 110 | 111 | /** 112 | * ## Execution 113 | * 114 | * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. 115 | */ 116 | var currentWindowOnload = window.onload; 117 | 118 | window.onload = function() { 119 | if (currentWindowOnload) { 120 | currentWindowOnload(); 121 | } 122 | htmlReporter.initialize(); 123 | env.execute(); 124 | }; 125 | 126 | /** 127 | * Helper function for readability above. 128 | */ 129 | function extend(destination, source) { 130 | for (var property in source) destination[property] = source[property]; 131 | return destination; 132 | } 133 | 134 | }()); 135 | -------------------------------------------------------------------------------- /src/nanoJS.js: -------------------------------------------------------------------------------- 1 | !(function (factory) { 2 | if (typeof exports === 'object' && typeof module !== 'undefined') { 3 | module.exports = factory(); 4 | } else if (typeof define === 'function' && define.amd) { 5 | define(factory); 6 | } else { 7 | window.$ = factory(); 8 | } 9 | })(function () { 10 | var nano = function (s) { 11 | if (typeof s === "string") { 12 | this.value = Array.prototype.slice.call(document.querySelectorAll(s)); 13 | } 14 | if (typeof s === "object") { 15 | this.value = [s]; 16 | } 17 | }; 18 | 19 | nano.prototype = { 20 | eq: function (n) { 21 | this.value = [this.value[n]]; 22 | return this; 23 | }, 24 | each: function (fn) { 25 | [].forEach.call(this.value, fn); 26 | return this; 27 | }, 28 | css: function (v) { 29 | return this.each(function (i) { 30 | i.style.cssText = i.style.cssText + v; 31 | }); 32 | }, 33 | cssdom: function (v) { 34 | return this.each(function (i) { 35 | for (var key in v) { 36 | i.style[key] = v[key]; 37 | } 38 | }); 39 | }, 40 | attr: function (a, v) { 41 | return this.each(function (i) { 42 | i.setAttribute(a, v); 43 | }); 44 | }, 45 | getAttr: function (v) { 46 | return this.value[0].getAttribute(v); 47 | }, 48 | removeAttr: function (v) { 49 | return this.each(function (i) { 50 | i.removeAttribute(v); 51 | }); 52 | }, 53 | animate: function (time, scale, rotate, rotateX, rotateY, translateX, translateY, skewX, skewY, opacity) { 54 | return this.each(function (i) { 55 | i.style.cssText = i.style.cssText + 'transition: all ' + time + 's ease-in-out; transform: scale(' + scale + ') rotate(' + rotate + 'deg) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg) translate(' + translateX + 'px, ' + translateY + 'px) skew(' + skewX + 'deg, ' + skewY + 'deg); opacity:' + opacity + ';' 56 | }); 57 | }, 58 | on: function (type, fn) { 59 | return this.each(function (i) { 60 | i.addEventListener(type, fn, false); 61 | }); 62 | }, 63 | addClass: function (v) { 64 | var a = v.split(' '); 65 | return this.each(function (i) { 66 | for (var x = 0; x < a.length; x++) { 67 | if (i.classList) { 68 | i.classList.add(a[x]); 69 | } 70 | else { 71 | i.className += ' ' + a[x]; 72 | } 73 | } 74 | }); 75 | }, 76 | toggleClass: function (v) { 77 | var a = v.split(' '); 78 | return this.each(function (i) { 79 | for (var x = 0; x < a.length; x++) { 80 | if (i.classList) { 81 | i.classList.toggle(a[x]); 82 | } 83 | else { 84 | if (new RegExp('\\b'+ a[x] +'\\b').test(i.className)) { 85 | i.className = i.className.replace(new RegExp('\\b'+ a[x] +'\\b', 'g'), ''); 86 | } else { 87 | i.className += ' ' + a[x]; 88 | } 89 | } 90 | } 91 | }); 92 | }, 93 | removeClass: function (v) { 94 | var a = v.split(' '); 95 | return this.each(function (i) { 96 | for (var x = 0; x < a.length; x++) { 97 | if (i.classList) { 98 | i.classList.remove(a[x]); 99 | } 100 | else { 101 | i.className = i.className.replace(new RegExp('\\b'+ a[x] +'\\b', 'g'), ''); 102 | } 103 | } 104 | }); 105 | }, 106 | html: function (v) { 107 | return (typeof v == 'undefined') ? this.value[0].innerHTML : this.each(function(i) { 108 | i.innerHTML = v; 109 | }); 110 | }, 111 | text: function (v) { 112 | return (typeof v == 'undefined') ? this.value[0].innerText || this.value[0].textContent : this.each(function(i) { 113 | i.innerText = v; 114 | i.textContent = v; 115 | }); 116 | }, 117 | insertBefore: function (v) { 118 | return this.each(function (i) { 119 | i.insertAdjacentHTML("beforeBegin", v); 120 | }); 121 | }, 122 | insertAfter: function (v) { 123 | return this.each(function (i) { 124 | i.insertAdjacentHTML("afterEnd", v); 125 | }); 126 | }, 127 | insertFirst: function (v) { 128 | return this.each(function (i) { 129 | i.insertAdjacentHTML("afterBegin", v); 130 | }); 131 | }, 132 | insertLast: function (v) { 133 | return this.each(function (i) { 134 | i.insertAdjacentHTML("beforeEnd", v); 135 | }); 136 | }, 137 | empty: function () { 138 | return this.each(function (i) { 139 | i.innerHTML = ""; 140 | }); 141 | }, 142 | parent: function () { 143 | return $(this.value[0].parentNode); 144 | }, 145 | siblings: function () { 146 | this.value = Array.prototype.filter.call(this.value[0].parentNode.children, (child) => 147 | child !== this.value[0]); 148 | return this; 149 | }, 150 | offset: function () { 151 | return this.each(function (i) { 152 | offset = i.getBoundingClientRect(); 153 | }); 154 | }, 155 | log: function () { 156 | console.log(this); 157 | }, 158 | }; 159 | 160 | return function (selector) { 161 | return new nano(selector); 162 | }; 163 | }); 164 | -------------------------------------------------------------------------------- /lab/lib/jasmine-3.1.0/jasmine.css: -------------------------------------------------------------------------------- 1 | body { overflow-y: scroll; } 2 | 3 | .jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; } 4 | .jasmine_html-reporter a { text-decoration: none; } 5 | .jasmine_html-reporter a:hover { text-decoration: underline; } 6 | .jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; } 7 | .jasmine_html-reporter .jasmine-banner, .jasmine_html-reporter .jasmine-symbol-summary, .jasmine_html-reporter .jasmine-summary, .jasmine_html-reporter .jasmine-result-message, .jasmine_html-reporter .jasmine-spec .jasmine-description, .jasmine_html-reporter .jasmine-spec-detail .jasmine-description, .jasmine_html-reporter .jasmine-alert .jasmine-bar, .jasmine_html-reporter .jasmine-stack-trace { padding-left: 9px; padding-right: 9px; } 8 | .jasmine_html-reporter .jasmine-banner { position: relative; } 9 | .jasmine_html-reporter .jasmine-banner .jasmine-title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPo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jEgNjM3LjkzLDkyNS41NjYgNjA3LjQ2NSw5MDMuNDQ1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDM4MC42ODgsNjIyLjEyOSAtMTEuNjI2LDM1LjgwMSAxNzUuNzU4LDU3LjA5IDExLjYyMSwtMzUuODAxIC0xNzUuNzUzLC01Ny4wOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDU0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA3MTYuMjg5LDM3Ni41OSAzNy42NDA2LDAgMCwxODQuODE2IC0zNy42NDA2LDAgMCwtMTg0LjgxNiB6IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=') no-repeat, none; -moz-background-size: 100%; -o-background-size: 100%; -webkit-background-size: 100%; background-size: 100%; display: block; float: left; width: 90px; height: 25px; } 10 | .jasmine_html-reporter .jasmine-banner .jasmine-version { margin-left: 14px; position: relative; top: 6px; } 11 | .jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; } 12 | .jasmine_html-reporter .jasmine-version { color: #aaa; } 13 | .jasmine_html-reporter .jasmine-banner { margin-top: 14px; } 14 | .jasmine_html-reporter .jasmine-duration { color: #fff; float: right; line-height: 28px; padding-right: 9px; } 15 | .jasmine_html-reporter .jasmine-symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; } 16 | .jasmine_html-reporter .jasmine-symbol-summary li { display: inline-block; height: 10px; width: 14px; font-size: 16px; } 17 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed { font-size: 14px; } 18 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before { color: #007069; content: "\02022"; } 19 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed { line-height: 9px; } 20 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; } 21 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded { font-size: 14px; } 22 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before { color: #bababa; content: "\02022"; } 23 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending { line-height: 17px; } 24 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before { color: #ba9d37; content: "*"; } 25 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty { font-size: 14px; } 26 | .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before { color: #ba9d37; content: "\02022"; } 27 | .jasmine_html-reporter .jasmine-run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; } 28 | .jasmine_html-reporter .jasmine-run-options .jasmine-trigger { cursor: pointer; padding: 8px 16px; } 29 | .jasmine_html-reporter .jasmine-run-options .jasmine-payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; } 30 | .jasmine_html-reporter .jasmine-run-options .jasmine-payload.jasmine-open { display: block; } 31 | .jasmine_html-reporter .jasmine-bar { line-height: 28px; font-size: 14px; display: block; color: #eee; } 32 | .jasmine_html-reporter .jasmine-bar.jasmine-failed, .jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; border-bottom: 1px solid #eee; } 33 | .jasmine_html-reporter .jasmine-bar.jasmine-passed { background-color: #007069; } 34 | .jasmine_html-reporter .jasmine-bar.jasmine-incomplete { background-color: #bababa; } 35 | .jasmine_html-reporter .jasmine-bar.jasmine-skipped { background-color: #bababa; } 36 | .jasmine_html-reporter .jasmine-bar.jasmine-warning { background-color: #ba9d37; color: #333; } 37 | .jasmine_html-reporter .jasmine-bar.jasmine-menu { background-color: #fff; color: #aaa; } 38 | .jasmine_html-reporter .jasmine-bar.jasmine-menu a { color: #333; } 39 | .jasmine_html-reporter .jasmine-bar a { color: white; } 40 | .jasmine_html-reporter.jasmine-spec-list .jasmine-bar.jasmine-menu.jasmine-failure-list, .jasmine_html-reporter.jasmine-spec-list .jasmine-results .jasmine-failures { display: none; } 41 | .jasmine_html-reporter.jasmine-failure-list .jasmine-bar.jasmine-menu.jasmine-spec-list, .jasmine_html-reporter.jasmine-failure-list .jasmine-summary { display: none; } 42 | .jasmine_html-reporter .jasmine-results { margin-top: 14px; } 43 | .jasmine_html-reporter .jasmine-summary { margin-top: 14px; } 44 | .jasmine_html-reporter .jasmine-summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; } 45 | .jasmine_html-reporter .jasmine-summary ul.jasmine-suite { margin-top: 7px; margin-bottom: 7px; } 46 | .jasmine_html-reporter .jasmine-summary li.jasmine-passed a { color: #007069; } 47 | .jasmine_html-reporter .jasmine-summary li.jasmine-failed a { color: #ca3a11; } 48 | .jasmine_html-reporter .jasmine-summary li.jasmine-empty a { color: #ba9d37; } 49 | .jasmine_html-reporter .jasmine-summary li.jasmine-pending a { color: #ba9d37; } 50 | .jasmine_html-reporter .jasmine-summary li.jasmine-excluded a { color: #bababa; } 51 | .jasmine_html-reporter .jasmine-description + .jasmine-suite { margin-top: 0; } 52 | .jasmine_html-reporter .jasmine-suite { margin-top: 14px; } 53 | .jasmine_html-reporter .jasmine-suite a { color: #333; } 54 | .jasmine_html-reporter .jasmine-failures .jasmine-spec-detail { margin-bottom: 28px; } 55 | .jasmine_html-reporter .jasmine-failures .jasmine-spec-detail .jasmine-description { background-color: #ca3a11; color: white; } 56 | .jasmine_html-reporter .jasmine-failures .jasmine-spec-detail .jasmine-description a { color: white; } 57 | .jasmine_html-reporter .jasmine-result-message { padding-top: 14px; color: #333; white-space: pre; } 58 | .jasmine_html-reporter .jasmine-result-message span.jasmine-result { display: block; } 59 | .jasmine_html-reporter .jasmine-stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666; border: 1px solid #ddd; background: white; white-space: pre; } 60 | -------------------------------------------------------------------------------- /lab/lib/jasmine-3.1.0/jasmine-html.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008-2018 Pivotal Labs 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | jasmineRequire.html = function(j$) { 24 | j$.ResultsNode = jasmineRequire.ResultsNode(); 25 | j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); 26 | j$.QueryString = jasmineRequire.QueryString(); 27 | j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); 28 | }; 29 | 30 | jasmineRequire.HtmlReporter = function(j$) { 31 | 32 | var noopTimer = { 33 | start: function() {}, 34 | elapsed: function() { return 0; } 35 | }; 36 | 37 | function ResultsStateBuilder() { 38 | this.topResults = new j$.ResultsNode({}, '', null); 39 | this.currentParent = this.topResults; 40 | this.specsExecuted = 0; 41 | this.failureCount = 0; 42 | this.pendingSpecCount = 0; 43 | } 44 | 45 | ResultsStateBuilder.prototype.suiteStarted = function(result) { 46 | this.currentParent.addChild(result, 'suite'); 47 | this.currentParent = this.currentParent.last(); 48 | }; 49 | 50 | ResultsStateBuilder.prototype.suiteDone = function(result) { 51 | this.currentParent.updateResult(result); 52 | if (this.currentParent !== this.topResults) { 53 | this.currentParent = this.currentParent.parent; 54 | } 55 | 56 | if (result.status === 'failed') { 57 | this.failureCount++; 58 | } 59 | }; 60 | 61 | ResultsStateBuilder.prototype.specStarted = function(result) { 62 | }; 63 | 64 | ResultsStateBuilder.prototype.specDone = function(result) { 65 | this.currentParent.addChild(result, 'spec'); 66 | 67 | if (result.status !== 'excluded') { 68 | this.specsExecuted++; 69 | } 70 | 71 | if (result.status === 'failed') { 72 | this.failureCount++; 73 | } 74 | 75 | if (result.status == 'pending') { 76 | this.pendingSpecCount++; 77 | } 78 | }; 79 | 80 | 81 | 82 | function HtmlReporter(options) { 83 | var env = options.env || {}, 84 | getContainer = options.getContainer, 85 | createElement = options.createElement, 86 | createTextNode = options.createTextNode, 87 | navigateWithNewParam = options.navigateWithNewParam || function() {}, 88 | addToExistingQueryString = options.addToExistingQueryString || defaultQueryString, 89 | filterSpecs = options.filterSpecs, 90 | timer = options.timer || noopTimer, 91 | htmlReporterMain, 92 | symbols, 93 | deprecationWarnings = []; 94 | 95 | this.initialize = function() { 96 | clearPrior(); 97 | htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'}, 98 | createDom('div', {className: 'jasmine-banner'}, 99 | createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}), 100 | createDom('span', {className: 'jasmine-version'}, j$.version) 101 | ), 102 | createDom('ul', {className: 'jasmine-symbol-summary'}), 103 | createDom('div', {className: 'jasmine-alert'}), 104 | createDom('div', {className: 'jasmine-results'}, 105 | createDom('div', {className: 'jasmine-failures'}) 106 | ) 107 | ); 108 | getContainer().appendChild(htmlReporterMain); 109 | }; 110 | 111 | var totalSpecsDefined; 112 | this.jasmineStarted = function(options) { 113 | totalSpecsDefined = options.totalSpecsDefined || 0; 114 | timer.start(); 115 | }; 116 | 117 | var summary = createDom('div', {className: 'jasmine-summary'}); 118 | 119 | var stateBuilder = new ResultsStateBuilder(); 120 | 121 | this.suiteStarted = function(result) { 122 | stateBuilder.suiteStarted(result); 123 | }; 124 | 125 | this.suiteDone = function(result) { 126 | stateBuilder.suiteDone(result); 127 | 128 | if (result.status === 'failed') { 129 | failures.push(failureDom(result)); 130 | } 131 | addDeprecationWarnings(result); 132 | }; 133 | 134 | this.specStarted = function(result) { 135 | stateBuilder.specStarted(result); 136 | }; 137 | 138 | var failures = []; 139 | this.specDone = function(result) { 140 | stateBuilder.specDone(result); 141 | 142 | if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') { 143 | console.error('Spec \'' + result.fullName + '\' has no expectations.'); 144 | } 145 | 146 | if (!symbols){ 147 | symbols = find('.jasmine-symbol-summary'); 148 | } 149 | 150 | symbols.appendChild(createDom('li', { 151 | className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status, 152 | id: 'spec_' + result.id, 153 | title: result.fullName 154 | } 155 | )); 156 | 157 | if (result.status === 'failed') { 158 | failures.push(failureDom(result)); 159 | } 160 | 161 | addDeprecationWarnings(result); 162 | }; 163 | 164 | this.jasmineDone = function(doneResult) { 165 | var banner = find('.jasmine-banner'); 166 | var alert = find('.jasmine-alert'); 167 | var order = doneResult && doneResult.order; 168 | alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's')); 169 | 170 | banner.appendChild(optionsMenu(env)); 171 | 172 | if (stateBuilder.specsExecuted < totalSpecsDefined) { 173 | var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all'; 174 | var skippedLink = addToExistingQueryString('spec', ''); 175 | alert.appendChild( 176 | createDom('span', {className: 'jasmine-bar jasmine-skipped'}, 177 | createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage) 178 | ) 179 | ); 180 | } 181 | var statusBarMessage = ''; 182 | var statusBarClassName = 'jasmine-overall-result jasmine-bar '; 183 | var globalFailures = (doneResult && doneResult.failedExpectations) || []; 184 | var failed = stateBuilder.failureCount + globalFailures.length > 0; 185 | 186 | if (totalSpecsDefined > 0 || failed) { 187 | statusBarMessage += pluralize('spec', stateBuilder.specsExecuted) + ', ' + pluralize('failure', stateBuilder.failureCount); 188 | if (stateBuilder.pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', stateBuilder.pendingSpecCount); } 189 | } 190 | 191 | if (doneResult.overallStatus === 'passed') { 192 | statusBarClassName += ' jasmine-passed '; 193 | } else if (doneResult.overallStatus === 'incomplete') { 194 | statusBarClassName += ' jasmine-incomplete '; 195 | statusBarMessage = 'Incomplete: ' + doneResult.incompleteReason + ', ' + statusBarMessage; 196 | } else { 197 | statusBarClassName += ' jasmine-failed '; 198 | } 199 | 200 | var seedBar; 201 | if (order && order.random) { 202 | seedBar = createDom('span', {className: 'jasmine-seed-bar'}, 203 | ', randomized with seed ', 204 | createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed) 205 | ); 206 | } 207 | 208 | alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar)); 209 | 210 | var errorBarClassName = 'jasmine-bar jasmine-errored'; 211 | var afterAllMessagePrefix = 'AfterAll '; 212 | 213 | for(i = 0; i < globalFailures.length; i++) { 214 | alert.appendChild(createDom('span', {className: errorBarClassName}, globalFailureMessage(globalFailures[i]))); 215 | } 216 | 217 | function globalFailureMessage(failure) { 218 | if (failure.globalErrorType === 'load') { 219 | var prefix = 'Error during loading: ' + failure.message; 220 | 221 | if (failure.filename) { 222 | return prefix + ' in ' + failure.filename + ' line ' + failure.lineno; 223 | } else { 224 | return prefix; 225 | } 226 | } else { 227 | return afterAllMessagePrefix + failure.message; 228 | } 229 | } 230 | 231 | addDeprecationWarnings(doneResult); 232 | 233 | var warningBarClassName = 'jasmine-bar jasmine-warning'; 234 | for(i = 0; i < deprecationWarnings.length; i++) { 235 | var warning = deprecationWarnings[i]; 236 | alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning)); 237 | } 238 | 239 | var results = find('.jasmine-results'); 240 | results.appendChild(summary); 241 | 242 | summaryList(stateBuilder.topResults, summary); 243 | 244 | if (failures.length) { 245 | alert.appendChild( 246 | createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'}, 247 | createDom('span', {}, 'Spec List | '), 248 | createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures'))); 249 | alert.appendChild( 250 | createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'}, 251 | createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'), 252 | createDom('span', {}, ' | Failures '))); 253 | 254 | find('.jasmine-failures-menu').onclick = function() { 255 | setMenuModeTo('jasmine-failure-list'); 256 | }; 257 | find('.jasmine-spec-list-menu').onclick = function() { 258 | setMenuModeTo('jasmine-spec-list'); 259 | }; 260 | 261 | setMenuModeTo('jasmine-failure-list'); 262 | 263 | var failureNode = find('.jasmine-failures'); 264 | for (i = 0; i < failures.length; i++) { 265 | failureNode.appendChild(failures[i]); 266 | } 267 | } 268 | }; 269 | 270 | return this; 271 | 272 | function failureDom(result) { 273 | var failure = 274 | createDom('div', {className: 'jasmine-spec-detail jasmine-failed'}, 275 | failureDescription(result, stateBuilder.currentParent), 276 | createDom('div', {className: 'jasmine-messages'}) 277 | ); 278 | var messages = failure.childNodes[1]; 279 | 280 | for (var i = 0; i < result.failedExpectations.length; i++) { 281 | var expectation = result.failedExpectations[i]; 282 | messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message)); 283 | messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack)); 284 | } 285 | 286 | return failure; 287 | } 288 | 289 | function summaryList(resultsTree, domParent) { 290 | var specListNode; 291 | for (var i = 0; i < resultsTree.children.length; i++) { 292 | var resultNode = resultsTree.children[i]; 293 | if (filterSpecs && !hasActiveSpec(resultNode)) { 294 | continue; 295 | } 296 | if (resultNode.type === 'suite') { 297 | var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id}, 298 | createDom('li', {className: 'jasmine-suite-detail jasmine-' + resultNode.result.status}, 299 | createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description) 300 | ) 301 | ); 302 | 303 | summaryList(resultNode, suiteListNode); 304 | domParent.appendChild(suiteListNode); 305 | } 306 | if (resultNode.type === 'spec') { 307 | if (domParent.getAttribute('class') !== 'jasmine-specs') { 308 | specListNode = createDom('ul', {className: 'jasmine-specs'}); 309 | domParent.appendChild(specListNode); 310 | } 311 | var specDescription = resultNode.result.description; 312 | if(noExpectations(resultNode.result)) { 313 | specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription; 314 | } 315 | if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') { 316 | specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason; 317 | } 318 | specListNode.appendChild( 319 | createDom('li', { 320 | className: 'jasmine-' + resultNode.result.status, 321 | id: 'spec-' + resultNode.result.id 322 | }, 323 | createDom('a', {href: specHref(resultNode.result)}, specDescription) 324 | ) 325 | ); 326 | } 327 | } 328 | } 329 | 330 | function optionsMenu(env) { 331 | var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' }, 332 | createDom('span', { className: 'jasmine-trigger' }, 'Options'), 333 | createDom('div', { className: 'jasmine-payload' }, 334 | createDom('div', { className: 'jasmine-stop-on-failure' }, 335 | createDom('input', { 336 | className: 'jasmine-fail-fast', 337 | id: 'jasmine-fail-fast', 338 | type: 'checkbox' 339 | }), 340 | createDom('label', { className: 'jasmine-label', 'for': 'jasmine-fail-fast' }, 'stop execution on spec failure')), 341 | createDom('div', { className: 'jasmine-throw-failures' }, 342 | createDom('input', { 343 | className: 'jasmine-throw', 344 | id: 'jasmine-throw-failures', 345 | type: 'checkbox' 346 | }), 347 | createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')), 348 | createDom('div', { className: 'jasmine-random-order' }, 349 | createDom('input', { 350 | className: 'jasmine-random', 351 | id: 'jasmine-random-order', 352 | type: 'checkbox' 353 | }), 354 | createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order')) 355 | ) 356 | ); 357 | 358 | var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast'); 359 | failFastCheckbox.checked = env.stoppingOnSpecFailure(); 360 | failFastCheckbox.onclick = function() { 361 | navigateWithNewParam('failFast', !env.stoppingOnSpecFailure()); 362 | }; 363 | 364 | var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures'); 365 | throwCheckbox.checked = env.throwingExpectationFailures(); 366 | throwCheckbox.onclick = function() { 367 | navigateWithNewParam('throwFailures', !env.throwingExpectationFailures()); 368 | }; 369 | 370 | var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order'); 371 | randomCheckbox.checked = env.randomTests(); 372 | randomCheckbox.onclick = function() { 373 | navigateWithNewParam('random', !env.randomTests()); 374 | }; 375 | 376 | var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'), 377 | optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'), 378 | isOpen = /\bjasmine-open\b/; 379 | 380 | optionsTrigger.onclick = function() { 381 | if (isOpen.test(optionsPayload.className)) { 382 | optionsPayload.className = optionsPayload.className.replace(isOpen, ''); 383 | } else { 384 | optionsPayload.className += ' jasmine-open'; 385 | } 386 | }; 387 | 388 | return optionsMenuDom; 389 | } 390 | 391 | function failureDescription(result, suite) { 392 | var wrapper = createDom('div', {className: 'jasmine-description'}, 393 | createDom('a', {title: result.description, href: specHref(result)}, result.description) 394 | ); 395 | var suiteLink; 396 | 397 | while (suite && suite.parent) { 398 | wrapper.insertBefore(createTextNode(' > '), wrapper.firstChild); 399 | suiteLink = createDom('a', {href: suiteHref(suite)}, suite.result.description); 400 | wrapper.insertBefore(suiteLink, wrapper.firstChild); 401 | 402 | suite = suite.parent; 403 | } 404 | 405 | return wrapper; 406 | } 407 | 408 | function suiteHref(suite) { 409 | var els = []; 410 | 411 | while (suite && suite.parent) { 412 | els.unshift(suite.result.description); 413 | suite = suite.parent; 414 | } 415 | 416 | return addToExistingQueryString('spec', els.join(' ')); 417 | } 418 | 419 | function addDeprecationWarnings(result) { 420 | if (result && result.deprecationWarnings) { 421 | for(var i = 0; i < result.deprecationWarnings.length; i++) { 422 | var warning = result.deprecationWarnings[i].message; 423 | if (!j$.util.arrayContains(warning)) { 424 | deprecationWarnings.push(warning); 425 | } 426 | } 427 | } 428 | } 429 | 430 | function find(selector) { 431 | return getContainer().querySelector('.jasmine_html-reporter ' + selector); 432 | } 433 | 434 | function clearPrior() { 435 | // return the reporter 436 | var oldReporter = find(''); 437 | 438 | if(oldReporter) { 439 | getContainer().removeChild(oldReporter); 440 | } 441 | } 442 | 443 | function createDom(type, attrs, childrenVarArgs) { 444 | var el = createElement(type); 445 | 446 | for (var i = 2; i < arguments.length; i++) { 447 | var child = arguments[i]; 448 | 449 | if (typeof child === 'string') { 450 | el.appendChild(createTextNode(child)); 451 | } else { 452 | if (child) { 453 | el.appendChild(child); 454 | } 455 | } 456 | } 457 | 458 | for (var attr in attrs) { 459 | if (attr == 'className') { 460 | el[attr] = attrs[attr]; 461 | } else { 462 | el.setAttribute(attr, attrs[attr]); 463 | } 464 | } 465 | 466 | return el; 467 | } 468 | 469 | function pluralize(singular, count) { 470 | var word = (count == 1 ? singular : singular + 's'); 471 | 472 | return '' + count + ' ' + word; 473 | } 474 | 475 | function specHref(result) { 476 | return addToExistingQueryString('spec', result.fullName); 477 | } 478 | 479 | function seedHref(seed) { 480 | return addToExistingQueryString('seed', seed); 481 | } 482 | 483 | function defaultQueryString(key, value) { 484 | return '?' + key + '=' + value; 485 | } 486 | 487 | function setMenuModeTo(mode) { 488 | htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode); 489 | } 490 | 491 | function noExpectations(result) { 492 | return (result.failedExpectations.length + result.passedExpectations.length) === 0 && 493 | result.status === 'passed'; 494 | } 495 | 496 | function hasActiveSpec(resultNode) { 497 | if (resultNode.type == 'spec' && resultNode.result.status != 'excluded') { 498 | return true; 499 | } 500 | 501 | if (resultNode.type == 'suite') { 502 | for (var i = 0, j = resultNode.children.length; i < j; i++) { 503 | if (hasActiveSpec(resultNode.children[i])) { 504 | return true; 505 | } 506 | } 507 | } 508 | } 509 | } 510 | 511 | return HtmlReporter; 512 | }; 513 | 514 | jasmineRequire.HtmlSpecFilter = function() { 515 | function HtmlSpecFilter(options) { 516 | var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); 517 | var filterPattern = new RegExp(filterString); 518 | 519 | this.matches = function(specName) { 520 | return filterPattern.test(specName); 521 | }; 522 | } 523 | 524 | return HtmlSpecFilter; 525 | }; 526 | 527 | jasmineRequire.ResultsNode = function() { 528 | function ResultsNode(result, type, parent) { 529 | this.result = result; 530 | this.type = type; 531 | this.parent = parent; 532 | 533 | this.children = []; 534 | 535 | this.addChild = function(result, type) { 536 | this.children.push(new ResultsNode(result, type, this)); 537 | }; 538 | 539 | this.last = function() { 540 | return this.children[this.children.length - 1]; 541 | }; 542 | 543 | this.updateResult = function(result) { 544 | this.result = result; 545 | }; 546 | } 547 | 548 | return ResultsNode; 549 | }; 550 | 551 | jasmineRequire.QueryString = function() { 552 | function QueryString(options) { 553 | 554 | this.navigateWithNewParam = function(key, value) { 555 | options.getWindowLocation().search = this.fullStringWithNewParam(key, value); 556 | }; 557 | 558 | this.fullStringWithNewParam = function(key, value) { 559 | var paramMap = queryStringToParamMap(); 560 | paramMap[key] = value; 561 | return toQueryString(paramMap); 562 | }; 563 | 564 | this.getParam = function(key) { 565 | return queryStringToParamMap()[key]; 566 | }; 567 | 568 | return this; 569 | 570 | function toQueryString(paramMap) { 571 | var qStrPairs = []; 572 | for (var prop in paramMap) { 573 | qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop])); 574 | } 575 | return '?' + qStrPairs.join('&'); 576 | } 577 | 578 | function queryStringToParamMap() { 579 | var paramStr = options.getWindowLocation().search.substring(1), 580 | params = [], 581 | paramMap = {}; 582 | 583 | if (paramStr.length > 0) { 584 | params = paramStr.split('&'); 585 | for (var i = 0; i < params.length; i++) { 586 | var p = params[i].split('='); 587 | var value = decodeURIComponent(p[1]); 588 | if (value === 'true' || value === 'false') { 589 | value = JSON.parse(value); 590 | } 591 | paramMap[decodeURIComponent(p[0])] = value; 592 | } 593 | } 594 | 595 | return paramMap; 596 | } 597 | 598 | } 599 | 600 | return QueryString; 601 | }; 602 | -------------------------------------------------------------------------------- /lib/prettify.js: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 16 | /** 17 | * @fileoverview 18 | * some functions for browser-side pretty printing of code contained in html. 19 | *

    20 | * 21 | * For a fairly comprehensive set of languages see the 22 | * README 23 | * file that came with this source. At a minimum, the lexer should work on a 24 | * number of languages including C and friends, Java, Python, Bash, SQL, HTML, 25 | * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk 26 | * and a subset of Perl, but, because of commenting conventions, doesn't work on 27 | * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class. 28 | *

    29 | * Usage:

      30 | *
    1. include this source file in an html page via 31 | * {@code } 32 | *
    2. define style rules. See the example page for examples. 33 | *
    3. mark the {@code
      } and {@code } tags in your source with
        34 |  *    {@code class=prettyprint.}
        35 |  *    You can also use the (html deprecated) {@code } tag, but the pretty
        36 |  *    printer needs to do more substantial DOM manipulations to support that, so
        37 |  *    some css styles may not be preserved.
        38 |  * </ol>
        39 |  * That's it.  I wanted to keep the API as simple as possible, so there's no
        40 |  * need to specify which language the code is in, but if you wish, you can add
        41 |  * another class to the {@code <pre>} or {@code <code>} element to specify the
        42 |  * language, as in {@code <pre class="prettyprint lang-java">}.  Any class that
        43 |  * starts with "lang-" followed by a file extension, specifies the file type.
        44 |  * See the "lang-*.js" files in this directory for code that implements
        45 |  * per-language file handlers.
        46 |  * <p>
        47 |  * Change log:<br>
        48 |  * cbeust, 2006/08/22
        49 |  * <blockquote>
        50 |  *   Java annotations (start with "@") are now captured as literals ("lit")
        51 |  * </blockquote>
        52 |  * @requires console
        53 |  * @overrides window
        54 |  */
        55 | 
        56 | // JSLint declarations
        57 | /*global console, document, navigator, setTimeout, window */
        58 | 
        59 | /**
        60 |  * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
        61 |  * UI events.
        62 |  * If set to {@code false}, {@code prettyPrint()} is synchronous.
        63 |  */
        64 | window['PR_SHOULD_USE_CONTINUATION'] = true;
        65 | 
        66 | /** the number of characters between tab columns */
        67 | window['PR_TAB_WIDTH'] = 8;
        68 | 
        69 | /** Walks the DOM returning a properly escaped version of innerHTML.
        70 |   * @param {Node} node
        71 |   * @param {Array.<string>} out output buffer that receives chunks of HTML.
        72 |   */
        73 | window['PR_normalizedHtml']
        74 | 
        75 | /** Contains functions for creating and registering new language handlers.
        76 |   * @type {Object}
        77 |   */
        78 |   = window['PR']
        79 | 
        80 | /** Pretty print a chunk of code.
        81 |   *
        82 |   * @param {string} sourceCodeHtml code as html
        83 |   * @return {string} code as html, but prettier
        84 |   */
        85 |   = window['prettyPrintOne']
        86 | /** Find all the {@code <pre>} and {@code <code>} tags in the DOM with
        87 |   * {@code class=prettyprint} and prettify them.
        88 |   * @param {Function?} opt_whenDone if specified, called when the last entry
        89 |   *     has been finished.
        90 |   */
        91 |   = window['prettyPrint'] = void 0;
        92 | 
        93 | /** browser detection. @extern @returns false if not IE, otherwise the major version. */
        94 | window['_pr_isIE6'] = function () {
        95 |   var ieVersion = navigator && navigator.userAgent &&
        96 |       navigator.userAgent.match(/\bMSIE ([678])\./);
        97 |   ieVersion = ieVersion ? +ieVersion[1] : false;
        98 |   window['_pr_isIE6'] = function () { return ieVersion; };
        99 |   return ieVersion;
       100 | };
       101 | 
       102 | 
       103 | (function () {
       104 |   // Keyword lists for various languages.
       105 |   var FLOW_CONTROL_KEYWORDS =
       106 |       "break continue do else for if return while ";
       107 |   var C_KEYWORDS = FLOW_CONTROL_KEYWORDS + "auto case char const default " +
       108 |       "double enum extern float goto int long register short signed sizeof " +
       109 |       "static struct switch typedef union unsigned void volatile ";
       110 |   var COMMON_KEYWORDS = C_KEYWORDS + "catch class delete false import " +
       111 |       "new operator private protected public this throw true try typeof ";
       112 |   var CPP_KEYWORDS = COMMON_KEYWORDS + "alignof align_union asm axiom bool " +
       113 |       "concept concept_map const_cast constexpr decltype " +
       114 |       "dynamic_cast explicit export friend inline late_check " +
       115 |       "mutable namespace nullptr reinterpret_cast static_assert static_cast " +
       116 |       "template typeid typename using virtual wchar_t where ";
       117 |   var JAVA_KEYWORDS = COMMON_KEYWORDS +
       118 |       "abstract boolean byte extends final finally implements import " +
       119 |       "instanceof null native package strictfp super synchronized throws " +
       120 |       "transient ";
       121 |   var CSHARP_KEYWORDS = JAVA_KEYWORDS +
       122 |       "as base by checked decimal delegate descending event " +
       123 |       "fixed foreach from group implicit in interface internal into is lock " +
       124 |       "object out override orderby params partial readonly ref sbyte sealed " +
       125 |       "stackalloc string select uint ulong unchecked unsafe ushort var ";
       126 |   var JSCRIPT_KEYWORDS = COMMON_KEYWORDS +
       127 |       "debugger eval export function get null set undefined var with " +
       128 |       "Infinity NaN ";
       129 |   var PERL_KEYWORDS = "caller delete die do dump elsif eval exit foreach for " +
       130 |       "goto if import last local my next no our print package redo require " +
       131 |       "sub undef unless until use wantarray while BEGIN END ";
       132 |   var PYTHON_KEYWORDS = FLOW_CONTROL_KEYWORDS + "and as assert class def del " +
       133 |       "elif except exec finally from global import in is lambda " +
       134 |       "nonlocal not or pass print raise try with yield " +
       135 |       "False True None ";
       136 |   var RUBY_KEYWORDS = FLOW_CONTROL_KEYWORDS + "alias and begin case class def" +
       137 |       " defined elsif end ensure false in module next nil not or redo rescue " +
       138 |       "retry self super then true undef unless until when yield BEGIN END ";
       139 |   var SH_KEYWORDS = FLOW_CONTROL_KEYWORDS + "case done elif esac eval fi " +
       140 |       "function in local set then until ";
       141 |   var ALL_KEYWORDS = (
       142 |       CPP_KEYWORDS + CSHARP_KEYWORDS + JSCRIPT_KEYWORDS + PERL_KEYWORDS +
       143 |       PYTHON_KEYWORDS + RUBY_KEYWORDS + SH_KEYWORDS);
       144 | 
       145 |   // token style names.  correspond to css classes
       146 |   /** token style for a string literal */
       147 |   var PR_STRING = 'str';
       148 |   /** token style for a keyword */
       149 |   var PR_KEYWORD = 'kwd';
       150 |   /** token style for a comment */
       151 |   var PR_COMMENT = 'com';
       152 |   /** token style for a type */
       153 |   var PR_TYPE = 'typ';
       154 |   /** token style for a literal value.  e.g. 1, null, true. */
       155 |   var PR_LITERAL = 'lit';
       156 |   /** token style for a punctuation string. */
       157 |   var PR_PUNCTUATION = 'pun';
       158 |   /** token style for a punctuation string. */
       159 |   var PR_PLAIN = 'pln';
       160 | 
       161 |   /** token style for an sgml tag. */
       162 |   var PR_TAG = 'tag';
       163 |   /** token style for a markup declaration such as a DOCTYPE. */
       164 |   var PR_DECLARATION = 'dec';
       165 |   /** token style for embedded source. */
       166 |   var PR_SOURCE = 'src';
       167 |   /** token style for an sgml attribute name. */
       168 |   var PR_ATTRIB_NAME = 'atn';
       169 |   /** token style for an sgml attribute value. */
       170 |   var PR_ATTRIB_VALUE = 'atv';
       171 | 
       172 |   /**
       173 |    * A class that indicates a section of markup that is not code, e.g. to allow
       174 |    * embedding of line numbers within code listings.
       175 |    */
       176 |   var PR_NOCODE = 'nocode';
       177 | 
       178 |   /** A set of tokens that can precede a regular expression literal in
       179 |     * javascript.
       180 |     * http://www.mozilla.org/js/language/js20/rationale/syntax.html has the full
       181 |     * list, but I've removed ones that might be problematic when seen in
       182 |     * languages that don't support regular expression literals.
       183 |     *
       184 |     * <p>Specifically, I've removed any keywords that can't precede a regexp
       185 |     * literal in a syntactically legal javascript program, and I've removed the
       186 |     * "in" keyword since it's not a keyword in many languages, and might be used
       187 |     * as a count of inches.
       188 |     *
       189 |     * <p>The link a above does not accurately describe EcmaScript rules since
       190 |     * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
       191 |     * very well in practice.
       192 |     *
       193 |     * @private
       194 |     */
       195 |   var REGEXP_PRECEDER_PATTERN = function () {
       196 |       var preceders = [
       197 |           "!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=",
       198 |           "&=", "(", "*", "*=", /* "+", */ "+=", ",", /* "-", */ "-=",
       199 |           "->", /*".", "..", "...", handled below */ "/", "/=", ":", "::", ";",
       200 |           "<", "<<", "<<=", "<=", "=", "==", "===", ">",
       201 |           ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[",
       202 |           "^", "^=", "^^", "^^=", "{", "|", "|=", "||",
       203 |           "||=", "~" /* handles =~ and !~ */,
       204 |           "break", "case", "continue", "delete",
       205 |           "do", "else", "finally", "instanceof",
       206 |           "return", "throw", "try", "typeof"
       207 |           ];
       208 |       var pattern = '(?:^^|[+-]';
       209 |       for (var i = 0; i < preceders.length; ++i) {
       210 |         pattern += '|' + preceders[i].replace(/([^=<>:&a-z])/g, '\\$1');
       211 |       }
       212 |       pattern += ')\\s*';  // matches at end, and matches empty string
       213 |       return pattern;
       214 |       // CAVEAT: this does not properly handle the case where a regular
       215 |       // expression immediately follows another since a regular expression may
       216 |       // have flags for case-sensitivity and the like.  Having regexp tokens
       217 |       // adjacent is not valid in any language I'm aware of, so I'm punting.
       218 |       // TODO: maybe style special characters inside a regexp as punctuation.
       219 |     }();
       220 | 
       221 |   // Define regexps here so that the interpreter doesn't have to create an
       222 |   // object each time the function containing them is called.
       223 |   // The language spec requires a new object created even if you don't access
       224 |   // the $1 members.
       225 |   var pr_amp = /&/g;
       226 |   var pr_lt = /</g;
       227 |   var pr_gt = />/g;
       228 |   var pr_quot = /\"/g;
       229 |   /** like textToHtml but escapes double quotes to be attribute safe. */
       230 |   function attribToHtml(str) {
       231 |     return str.replace(pr_amp, '&amp;')
       232 |         .replace(pr_lt, '&lt;')
       233 |         .replace(pr_gt, '&gt;')
       234 |         .replace(pr_quot, '&quot;');
       235 |   }
       236 | 
       237 |   /** escapest html special characters to html. */
       238 |   function textToHtml(str) {
       239 |     return str.replace(pr_amp, '&amp;')
       240 |         .replace(pr_lt, '&lt;')
       241 |         .replace(pr_gt, '&gt;');
       242 |   }
       243 | 
       244 | 
       245 |   var pr_ltEnt = /&lt;/g;
       246 |   var pr_gtEnt = /&gt;/g;
       247 |   var pr_aposEnt = /&apos;/g;
       248 |   var pr_quotEnt = /&quot;/g;
       249 |   var pr_ampEnt = /&amp;/g;
       250 |   var pr_nbspEnt = /&nbsp;/g;
       251 |   /** unescapes html to plain text. */
       252 |   function htmlToText(html) {
       253 |     var pos = html.indexOf('&');
       254 |     if (pos < 0) { return html; }
       255 |     // Handle numeric entities specially.  We can't use functional substitution
       256 |     // since that doesn't work in older versions of Safari.
       257 |     // These should be rare since most browsers convert them to normal chars.
       258 |     for (--pos; (pos = html.indexOf('&#', pos + 1)) >= 0;) {
       259 |       var end = html.indexOf(';', pos);
       260 |       if (end >= 0) {
       261 |         var num = html.substring(pos + 3, end);
       262 |         var radix = 10;
       263 |         if (num && num.charAt(0) === 'x') {
       264 |           num = num.substring(1);
       265 |           radix = 16;
       266 |         }
       267 |         var codePoint = parseInt(num, radix);
       268 |         if (!isNaN(codePoint)) {
       269 |           html = (html.substring(0, pos) + String.fromCharCode(codePoint) +
       270 |                   html.substring(end + 1));
       271 |         }
       272 |       }
       273 |     }
       274 | 
       275 |     return html.replace(pr_ltEnt, '<')
       276 |         .replace(pr_gtEnt, '>')
       277 |         .replace(pr_aposEnt, "'")
       278 |         .replace(pr_quotEnt, '"')
       279 |         .replace(pr_nbspEnt, ' ')
       280 |         .replace(pr_ampEnt, '&');
       281 |   }
       282 | 
       283 |   /** is the given node's innerHTML normally unescaped? */
       284 |   function isRawContent(node) {
       285 |     return 'XMP' === node.tagName;
       286 |   }
       287 | 
       288 |   var newlineRe = /[\r\n]/g;
       289 |   /**
       290 |    * Are newlines and adjacent spaces significant in the given node's innerHTML?
       291 |    */
       292 |   function isPreformatted(node, content) {
       293 |     // PRE means preformatted, and is a very common case, so don't create
       294 |     // unnecessary computed style objects.
       295 |     if ('PRE' === node.tagName) { return true; }
       296 |     if (!newlineRe.test(content)) { return true; }  // Don't care
       297 |     var whitespace = '';
       298 |     // For disconnected nodes, IE has no currentStyle.
       299 |     if (node.currentStyle) {
       300 |       whitespace = node.currentStyle.whiteSpace;
       301 |     } else if (window.getComputedStyle) {
       302 |       // Firefox makes a best guess if node is disconnected whereas Safari
       303 |       // returns the empty string.
       304 |       whitespace = window.getComputedStyle(node, null).whiteSpace;
       305 |     }
       306 |     return !whitespace || whitespace === 'pre';
       307 |   }
       308 | 
       309 |   function normalizedHtml(node, out) {
       310 |     switch (node.nodeType) {
       311 |       case 1:  // an element
       312 |         var name = node.tagName.toLowerCase();
       313 |         out.push('<', name);
       314 |         for (var i = 0; i < node.attributes.length; ++i) {
       315 |           var attr = node.attributes[i];
       316 |           if (!attr.specified) { continue; }
       317 |           out.push(' ');
       318 |           normalizedHtml(attr, out);
       319 |         }
       320 |         out.push('>');
       321 |         for (var child = node.firstChild; child; child = child.nextSibling) {
       322 |           normalizedHtml(child, out);
       323 |         }
       324 |         if (node.firstChild || !/^(?:br|link|img)$/.test(name)) {
       325 |           out.push('<\/', name, '>');
       326 |         }
       327 |         break;
       328 |       case 2: // an attribute
       329 |         out.push(node.name.toLowerCase(), '="', attribToHtml(node.value), '"');
       330 |         break;
       331 |       case 3: case 4: // text
       332 |         out.push(textToHtml(node.nodeValue));
       333 |         break;
       334 |     }
       335 |   }
       336 | 
       337 |   /**
       338 |    * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
       339 |    * matches the union o the sets o strings matched d by the input RegExp.
       340 |    * Since it matches globally, if the input strings have a start-of-input
       341 |    * anchor (/^.../), it is ignored for the purposes of unioning.
       342 |    * @param {Array.<RegExpr>} regexs non multiline, non-global regexs.
       343 |    * @return {RegExp} a global regex.
       344 |    */
       345 |   function combinePrefixPatterns(regexs) {
       346 |     var capturedGroupIndex = 0;
       347 | 
       348 |     var needToFoldCase = false;
       349 |     var ignoreCase = false;
       350 |     for (var i = 0, n = regexs.length; i < n; ++i) {
       351 |       var regex = regexs[i];
       352 |       if (regex.ignoreCase) {
       353 |         ignoreCase = true;
       354 |       } else if (/[a-z]/i.test(regex.source.replace(
       355 |                      /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
       356 |         needToFoldCase = true;
       357 |         ignoreCase = false;
       358 |         break;
       359 |       }
       360 |     }
       361 | 
       362 |     function decodeEscape(charsetPart) {
       363 |       if (charsetPart.charAt(0) !== '\\') { return charsetPart.charCodeAt(0); }
       364 |       switch (charsetPart.charAt(1)) {
       365 |         case 'b': return 8;
       366 |         case 't': return 9;
       367 |         case 'n': return 0xa;
       368 |         case 'v': return 0xb;
       369 |         case 'f': return 0xc;
       370 |         case 'r': return 0xd;
       371 |         case 'u': case 'x':
       372 |           return parseInt(charsetPart.substring(2), 16)
       373 |               || charsetPart.charCodeAt(1);
       374 |         case '0': case '1': case '2': case '3': case '4':
       375 |         case '5': case '6': case '7':
       376 |           return parseInt(charsetPart.substring(1), 8);
       377 |         default: return charsetPart.charCodeAt(1);
       378 |       }
       379 |     }
       380 | 
       381 |     function encodeEscape(charCode) {
       382 |       if (charCode < 0x20) {
       383 |         return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
       384 |       }
       385 |       var ch = String.fromCharCode(charCode);
       386 |       if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
       387 |         ch = '\\' + ch;
       388 |       }
       389 |       return ch;
       390 |     }
       391 | 
       392 |     function caseFoldCharset(charSet) {
       393 |       var charsetParts = charSet.substring(1, charSet.length - 1).match(
       394 |           new RegExp(
       395 |               '\\\\u[0-9A-Fa-f]{4}'
       396 |               + '|\\\\x[0-9A-Fa-f]{2}'
       397 |               + '|\\\\[0-3][0-7]{0,2}'
       398 |               + '|\\\\[0-7]{1,2}'
       399 |               + '|\\\\[\\s\\S]'
       400 |               + '|-'
       401 |               + '|[^-\\\\]',
       402 |               'g'));
       403 |       var groups = [];
       404 |       var ranges = [];
       405 |       var inverse = charsetParts[0] === '^';
       406 |       for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
       407 |         var p = charsetParts[i];
       408 |         switch (p) {
       409 |           case '\\B': case '\\b':
       410 |           case '\\D': case '\\d':
       411 |           case '\\S': case '\\s':
       412 |           case '\\W': case '\\w':
       413 |             groups.push(p);
       414 |             continue;
       415 |         }
       416 |         var start = decodeEscape(p);
       417 |         var end;
       418 |         if (i + 2 < n && '-' === charsetParts[i + 1]) {
       419 |           end = decodeEscape(charsetParts[i + 2]);
       420 |           i += 2;
       421 |         } else {
       422 |           end = start;
       423 |         }
       424 |         ranges.push([start, end]);
       425 |         // If the range might intersect letters, then expand it.
       426 |         if (!(end < 65 || start > 122)) {
       427 |           if (!(end < 65 || start > 90)) {
       428 |             ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
       429 |           }
       430 |           if (!(end < 97 || start > 122)) {
       431 |             ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
       432 |           }
       433 |         }
       434 |       }
       435 | 
       436 |       // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
       437 |       // -> [[1, 12], [14, 14], [16, 17]]
       438 |       ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1]  - a[1]); });
       439 |       var consolidatedRanges = [];
       440 |       var lastRange = [NaN, NaN];
       441 |       for (var i = 0; i < ranges.length; ++i) {
       442 |         var range = ranges[i];
       443 |         if (range[0] <= lastRange[1] + 1) {
       444 |           lastRange[1] = Math.max(lastRange[1], range[1]);
       445 |         } else {
       446 |           consolidatedRanges.push(lastRange = range);
       447 |         }
       448 |       }
       449 | 
       450 |       var out = ['['];
       451 |       if (inverse) { out.push('^'); }
       452 |       out.push.apply(out, groups);
       453 |       for (var i = 0; i < consolidatedRanges.length; ++i) {
       454 |         var range = consolidatedRanges[i];
       455 |         out.push(encodeEscape(range[0]));
       456 |         if (range[1] > range[0]) {
       457 |           if (range[1] + 1 > range[0]) { out.push('-'); }
       458 |           out.push(encodeEscape(range[1]));
       459 |         }
       460 |       }
       461 |       out.push(']');
       462 |       return out.join('');
       463 |     }
       464 | 
       465 |     function allowAnywhereFoldCaseAndRenumberGroups(regex) {
       466 |       // Split into character sets, escape sequences, punctuation strings
       467 |       // like ('(', '(?:', ')', '^'), and runs of characters that do not
       468 |       // include any of the above.
       469 |       var parts = regex.source.match(
       470 |           new RegExp(
       471 |               '(?:'
       472 |               + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]'  // a character set
       473 |               + '|\\\\u[A-Fa-f0-9]{4}'  // a unicode escape
       474 |               + '|\\\\x[A-Fa-f0-9]{2}'  // a hex escape
       475 |               + '|\\\\[0-9]+'  // a back-reference or octal escape
       476 |               + '|\\\\[^ux0-9]'  // other escape sequence
       477 |               + '|\\(\\?[:!=]'  // start of a non-capturing group
       478 |               + '|[\\(\\)\\^]'  // start/emd of a group, or line start
       479 |               + '|[^\\x5B\\x5C\\(\\)\\^]+'  // run of other characters
       480 |               + ')',
       481 |               'g'));
       482 |       var n = parts.length;
       483 | 
       484 |       // Maps captured group numbers to the number they will occupy in
       485 |       // the output or to -1 if that has not been determined, or to
       486 |       // undefined if they need not be capturing in the output.
       487 |       var capturedGroups = [];
       488 | 
       489 |       // Walk over and identify back references to build the capturedGroups
       490 |       // mapping.
       491 |       for (var i = 0, groupIndex = 0; i < n; ++i) {
       492 |         var p = parts[i];
       493 |         if (p === '(') {
       494 |           // groups are 1-indexed, so max group index is count of '('
       495 |           ++groupIndex;
       496 |         } else if ('\\' === p.charAt(0)) {
       497 |           var decimalValue = +p.substring(1);
       498 |           if (decimalValue && decimalValue <= groupIndex) {
       499 |             capturedGroups[decimalValue] = -1;
       500 |           }
       501 |         }
       502 |       }
       503 | 
       504 |       // Renumber groups and reduce capturing groups to non-capturing groups
       505 |       // where possible.
       506 |       for (var i = 1; i < capturedGroups.length; ++i) {
       507 |         if (-1 === capturedGroups[i]) {
       508 |           capturedGroups[i] = ++capturedGroupIndex;
       509 |         }
       510 |       }
       511 |       for (var i = 0, groupIndex = 0; i < n; ++i) {
       512 |         var p = parts[i];
       513 |         if (p === '(') {
       514 |           ++groupIndex;
       515 |           if (capturedGroups[groupIndex] === undefined) {
       516 |             parts[i] = '(?:';
       517 |           }
       518 |         } else if ('\\' === p.charAt(0)) {
       519 |           var decimalValue = +p.substring(1);
       520 |           if (decimalValue && decimalValue <= groupIndex) {
       521 |             parts[i] = '\\' + capturedGroups[groupIndex];
       522 |           }
       523 |         }
       524 |       }
       525 | 
       526 |       // Remove any prefix anchors so that the output will match anywhere.
       527 |       // ^^ really does mean an anchored match though.
       528 |       for (var i = 0, groupIndex = 0; i < n; ++i) {
       529 |         if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
       530 |       }
       531 | 
       532 |       // Expand letters to groupts to handle mixing of case-sensitive and
       533 |       // case-insensitive patterns if necessary.
       534 |       if (regex.ignoreCase && needToFoldCase) {
       535 |         for (var i = 0; i < n; ++i) {
       536 |           var p = parts[i];
       537 |           var ch0 = p.charAt(0);
       538 |           if (p.length >= 2 && ch0 === '[') {
       539 |             parts[i] = caseFoldCharset(p);
       540 |           } else if (ch0 !== '\\') {
       541 |             // TODO: handle letters in numeric escapes.
       542 |             parts[i] = p.replace(
       543 |                 /[a-zA-Z]/g,
       544 |                 function (ch) {
       545 |                   var cc = ch.charCodeAt(0);
       546 |                   return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
       547 |                 });
       548 |           }
       549 |         }
       550 |       }
       551 | 
       552 |       return parts.join('');
       553 |     }
       554 | 
       555 |     var rewritten = [];
       556 |     for (var i = 0, n = regexs.length; i < n; ++i) {
       557 |       var regex = regexs[i];
       558 |       if (regex.global || regex.multiline) { throw new Error('' + regex); }
       559 |       rewritten.push(
       560 |           '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
       561 |     }
       562 | 
       563 |     return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
       564 |   }
       565 | 
       566 |   var PR_innerHtmlWorks = null;
       567 |   function getInnerHtml(node) {
       568 |     // inner html is hopelessly broken in Safari 2.0.4 when the content is
       569 |     // an html description of well formed XML and the containing tag is a PRE
       570 |     // tag, so we detect that case and emulate innerHTML.
       571 |     if (null === PR_innerHtmlWorks) {
       572 |       var testNode = document.createElement('PRE');
       573 |       testNode.appendChild(
       574 |           document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
       575 |       PR_innerHtmlWorks = !/</.test(testNode.innerHTML);
       576 |     }
       577 | 
       578 |     if (PR_innerHtmlWorks) {
       579 |       var content = node.innerHTML;
       580 |       // XMP tags contain unescaped entities so require special handling.
       581 |       if (isRawContent(node)) {
       582 |         content = textToHtml(content);
       583 |       } else if (!isPreformatted(node, content)) {
       584 |         content = content.replace(/(<br\s*\/?>)[\r\n]+/g, '$1')
       585 |             .replace(/(?:[\r\n]+[ \t]*)+/g, ' ');
       586 |       }
       587 |       return content;
       588 |     }
       589 | 
       590 |     var out = [];
       591 |     for (var child = node.firstChild; child; child = child.nextSibling) {
       592 |       normalizedHtml(child, out);
       593 |     }
       594 |     return out.join('');
       595 |   }
       596 | 
       597 |   /** returns a function that expand tabs to spaces.  This function can be fed
       598 |     * successive chunks of text, and will maintain its own internal state to
       599 |     * keep track of how tabs are expanded.
       600 |     * @return {function (string) : string} a function that takes
       601 |     *   plain text and return the text with tabs expanded.
       602 |     * @private
       603 |     */
       604 |   function makeTabExpander(tabWidth) {
       605 |     var SPACES = '                ';
       606 |     var charInLine = 0;
       607 | 
       608 |     return function (plainText) {
       609 |       // walk over each character looking for tabs and newlines.
       610 |       // On tabs, expand them.  On newlines, reset charInLine.
       611 |       // Otherwise increment charInLine
       612 |       var out = null;
       613 |       var pos = 0;
       614 |       for (var i = 0, n = plainText.length; i < n; ++i) {
       615 |         var ch = plainText.charAt(i);
       616 | 
       617 |         switch (ch) {
       618 |           case '\t':
       619 |             if (!out) { out = []; }
       620 |             out.push(plainText.substring(pos, i));
       621 |             // calculate how much space we need in front of this part
       622 |             // nSpaces is the amount of padding -- the number of spaces needed
       623 |             // to move us to the next column, where columns occur at factors of
       624 |             // tabWidth.
       625 |             var nSpaces = tabWidth - (charInLine % tabWidth);
       626 |             charInLine += nSpaces;
       627 |             for (; nSpaces >= 0; nSpaces -= SPACES.length) {
       628 |               out.push(SPACES.substring(0, nSpaces));
       629 |             }
       630 |             pos = i + 1;
       631 |             break;
       632 |           case '\n':
       633 |             charInLine = 0;
       634 |             break;
       635 |           default:
       636 |             ++charInLine;
       637 |         }
       638 |       }
       639 |       if (!out) { return plainText; }
       640 |       out.push(plainText.substring(pos));
       641 |       return out.join('');
       642 |     };
       643 |   }
       644 | 
       645 |   var pr_chunkPattern = new RegExp(
       646 |       '[^<]+'  // A run of characters other than '<'
       647 |       + '|<\!--[\\s\\S]*?--\>'  // an HTML comment
       648 |       + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'  // a CDATA section
       649 |       // a probable tag that should not be highlighted
       650 |       + '|<\/?[a-zA-Z](?:[^>\"\']|\'[^\']*\'|\"[^\"]*\")*>'
       651 |       + '|<',  // A '<' that does not begin a larger chunk
       652 |       'g');
       653 |   var pr_commentPrefix = /^<\!--/;
       654 |   var pr_cdataPrefix = /^<!\[CDATA\[/;
       655 |   var pr_brPrefix = /^<br\b/i;
       656 |   var pr_tagNameRe = /^<(\/?)([a-zA-Z][a-zA-Z0-9]*)/;
       657 | 
       658 |   /** split markup into chunks of html tags (style null) and
       659 |     * plain text (style {@link #PR_PLAIN}), converting tags which are
       660 |     * significant for tokenization (<br>) into their textual equivalent.
       661 |     *
       662 |     * @param {string} s html where whitespace is considered significant.
       663 |     * @return {Object} source code and extracted tags.
       664 |     * @private
       665 |     */
       666 |   function extractTags(s) {
       667 |     // since the pattern has the 'g' modifier and defines no capturing groups,
       668 |     // this will return a list of all chunks which we then classify and wrap as
       669 |     // PR_Tokens
       670 |     var matches = s.match(pr_chunkPattern);
       671 |     var sourceBuf = [];
       672 |     var sourceBufLen = 0;
       673 |     var extractedTags = [];
       674 |     if (matches) {
       675 |       for (var i = 0, n = matches.length; i < n; ++i) {
       676 |         var match = matches[i];
       677 |         if (match.length > 1 && match.charAt(0) === '<') {
       678 |           if (pr_commentPrefix.test(match)) { continue; }
       679 |           if (pr_cdataPrefix.test(match)) {
       680 |             // strip CDATA prefix and suffix.  Don't unescape since it's CDATA
       681 |             sourceBuf.push(match.substring(9, match.length - 3));
       682 |             sourceBufLen += match.length - 12;
       683 |           } else if (pr_brPrefix.test(match)) {
       684 |             // <br> tags are lexically significant so convert them to text.
       685 |             // This is undone later.
       686 |             sourceBuf.push('\n');
       687 |             ++sourceBufLen;
       688 |           } else {
       689 |             if (match.indexOf(PR_NOCODE) >= 0 && isNoCodeTag(match)) {
       690 |               // A <span class="nocode"> will start a section that should be
       691 |               // ignored.  Continue walking the list until we see a matching end
       692 |               // tag.
       693 |               var name = match.match(pr_tagNameRe)[2];
       694 |               var depth = 1;
       695 |               var j;
       696 |               end_tag_loop:
       697 |               for (j = i + 1; j < n; ++j) {
       698 |                 var name2 = matches[j].match(pr_tagNameRe);
       699 |                 if (name2 && name2[2] === name) {
       700 |                   if (name2[1] === '/') {
       701 |                     if (--depth === 0) { break end_tag_loop; }
       702 |                   } else {
       703 |                     ++depth;
       704 |                   }
       705 |                 }
       706 |               }
       707 |               if (j < n) {
       708 |                 extractedTags.push(
       709 |                     sourceBufLen, matches.slice(i, j + 1).join(''));
       710 |                 i = j;
       711 |               } else {  // Ignore unclosed sections.
       712 |                 extractedTags.push(sourceBufLen, match);
       713 |               }
       714 |             } else {
       715 |               extractedTags.push(sourceBufLen, match);
       716 |             }
       717 |           }
       718 |         } else {
       719 |           var literalText = htmlToText(match);
       720 |           sourceBuf.push(literalText);
       721 |           sourceBufLen += literalText.length;
       722 |         }
       723 |       }
       724 |     }
       725 |     return { source: sourceBuf.join(''), tags: extractedTags };
       726 |   }
       727 | 
       728 |   /** True if the given tag contains a class attribute with the nocode class. */
       729 |   function isNoCodeTag(tag) {
       730 |     return !!tag
       731 |         // First canonicalize the representation of attributes
       732 |         .replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,
       733 |                  ' $1="$2$3$4"')
       734 |         // Then look for the attribute we want.
       735 |         .match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/);
       736 |   }
       737 | 
       738 |   /**
       739 |    * Apply the given language handler to sourceCode and add the resulting
       740 |    * decorations to out.
       741 |    * @param {number} basePos the index of sourceCode within the chunk of source
       742 |    *    whose decorations are already present on out.
       743 |    */
       744 |   function appendDecorations(basePos, sourceCode, langHandler, out) {
       745 |     if (!sourceCode) { return; }
       746 |     var job = {
       747 |       source: sourceCode,
       748 |       basePos: basePos
       749 |     };
       750 |     langHandler(job);
       751 |     out.push.apply(out, job.decorations);
       752 |   }
       753 | 
       754 |   /** Given triples of [style, pattern, context] returns a lexing function,
       755 |     * The lexing function interprets the patterns to find token boundaries and
       756 |     * returns a decoration list of the form
       757 |     * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
       758 |     * where index_n is an index into the sourceCode, and style_n is a style
       759 |     * constant like PR_PLAIN.  index_n-1 <= index_n, and style_n-1 applies to
       760 |     * all characters in sourceCode[index_n-1:index_n].
       761 |     *
       762 |     * The stylePatterns is a list whose elements have the form
       763 |     * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
       764 |     *
       765 |     * Style is a style constant like PR_PLAIN, or can be a string of the
       766 |     * form 'lang-FOO', where FOO is a language extension describing the
       767 |     * language of the portion of the token in $1 after pattern executes.
       768 |     * E.g., if style is 'lang-lisp', and group 1 contains the text
       769 |     * '(hello (world))', then that portion of the token will be passed to the
       770 |     * registered lisp handler for formatting.
       771 |     * The text before and after group 1 will be restyled using this decorator
       772 |     * so decorators should take care that this doesn't result in infinite
       773 |     * recursion.  For example, the HTML lexer rule for SCRIPT elements looks
       774 |     * something like ['lang-js', /<[s]cript>(.+?)<\/script>/].  This may match
       775 |     * '<script>foo()<\/script>', which would cause the current decorator to
       776 |     * be called with '<script>' which would not match the same rule since
       777 |     * group 1 must not be empty, so it would be instead styled as PR_TAG by
       778 |     * the generic tag rule.  The handler registered for the 'js' extension would
       779 |     * then be called with 'foo()', and finally, the current decorator would
       780 |     * be called with '<\/script>' which would not match the original rule and
       781 |     * so the generic tag rule would identify it as a tag.
       782 |     *
       783 |     * Pattern must only match prefixes, and if it matches a prefix, then that
       784 |     * match is considered a token with the same style.
       785 |     *
       786 |     * Context is applied to the last non-whitespace, non-comment token
       787 |     * recognized.
       788 |     *
       789 |     * Shortcut is an optional string of characters, any of which, if the first
       790 |     * character, gurantee that this pattern and only this pattern matches.
       791 |     *
       792 |     * @param {Array} shortcutStylePatterns patterns that always start with
       793 |     *   a known character.  Must have a shortcut string.
       794 |     * @param {Array} fallthroughStylePatterns patterns that will be tried in
       795 |     *   order if the shortcut ones fail.  May have shortcuts.
       796 |     *
       797 |     * @return {function (Object)} a
       798 |     *   function that takes source code and returns a list of decorations.
       799 |     */
       800 |   function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
       801 |     var shortcuts = {};
       802 |     var tokenizer;
       803 |     (function () {
       804 |       var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
       805 |       var allRegexs = [];
       806 |       var regexKeys = {};
       807 |       for (var i = 0, n = allPatterns.length; i < n; ++i) {
       808 |         var patternParts = allPatterns[i];
       809 |         var shortcutChars = patternParts[3];
       810 |         if (shortcutChars) {
       811 |           for (var c = shortcutChars.length; --c >= 0;) {
       812 |             shortcuts[shortcutChars.charAt(c)] = patternParts;
       813 |           }
       814 |         }
       815 |         var regex = patternParts[1];
       816 |         var k = '' + regex;
       817 |         if (!regexKeys.hasOwnProperty(k)) {
       818 |           allRegexs.push(regex);
       819 |           regexKeys[k] = null;
       820 |         }
       821 |       }
       822 |       allRegexs.push(/[\0-\uffff]/);
       823 |       tokenizer = combinePrefixPatterns(allRegexs);
       824 |     })();
       825 | 
       826 |     var nPatterns = fallthroughStylePatterns.length;
       827 |     var notWs = /\S/;
       828 | 
       829 |     /**
       830 |      * Lexes job.source and produces an output array job.decorations of style
       831 |      * classes preceded by the position at which they start in job.source in
       832 |      * order.
       833 |      *
       834 |      * @param {Object} job an object like {@code
       835 |      *    source: {string} sourceText plain text,
       836 |      *    basePos: {int} position of job.source in the larger chunk of
       837 |      *        sourceCode.
       838 |      * }
       839 |      */
       840 |     var decorate = function (job) {
       841 |       var sourceCode = job.source, basePos = job.basePos;
       842 |       /** Even entries are positions in source in ascending order.  Odd enties
       843 |         * are style markers (e.g., PR_COMMENT) that run from that position until
       844 |         * the end.
       845 |         * @type {Array.<number|string>}
       846 |         */
       847 |       var decorations = [basePos, PR_PLAIN];
       848 |       var pos = 0;  // index into sourceCode
       849 |       var tokens = sourceCode.match(tokenizer) || [];
       850 |       var styleCache = {};
       851 | 
       852 |       for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
       853 |         var token = tokens[ti];
       854 |         var style = styleCache[token];
       855 |         var match = void 0;
       856 | 
       857 |         var isEmbedded;
       858 |         if (typeof style === 'string') {
       859 |           isEmbedded = false;
       860 |         } else {
       861 |           var patternParts = shortcuts[token.charAt(0)];
       862 |           if (patternParts) {
       863 |             match = token.match(patternParts[1]);
       864 |             style = patternParts[0];
       865 |           } else {
       866 |             for (var i = 0; i < nPatterns; ++i) {
       867 |               patternParts = fallthroughStylePatterns[i];
       868 |               match = token.match(patternParts[1]);
       869 |               if (match) {
       870 |                 style = patternParts[0];
       871 |                 break;
       872 |               }
       873 |             }
       874 | 
       875 |             if (!match) {  // make sure that we make progress
       876 |               style = PR_PLAIN;
       877 |             }
       878 |           }
       879 | 
       880 |           isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
       881 |           if (isEmbedded && !(match && match[1])) {
       882 |             isEmbedded = false;
       883 |             style = PR_SOURCE;
       884 |           }
       885 | 
       886 |           if (!isEmbedded) { styleCache[token] = style; }
       887 |         }
       888 | 
       889 |         var tokenStart = pos;
       890 |         pos += token.length;
       891 | 
       892 |         if (!isEmbedded) {
       893 |           decorations.push(basePos + tokenStart, style);
       894 |         } else {  // Treat group 1 as an embedded block of source code.
       895 |           var embeddedSource = match[1];
       896 |           var embeddedSourceStart = token.indexOf(embeddedSource);
       897 |           var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
       898 |           var lang = style.substring(5);
       899 |           var size = decorations.length - 10;
       900 |           // Decorate the left of the embedded source
       901 |           appendDecorations(
       902 |               basePos + tokenStart,
       903 |               token.substring(0, embeddedSourceStart),
       904 |               decorate, decorations);
       905 |           // Decorate the embedded source
       906 |           appendDecorations(
       907 |               basePos + tokenStart + embeddedSourceStart,
       908 |               embeddedSource,
       909 |               langHandlerForExtension(lang, embeddedSource),
       910 |               decorations);
       911 |           // Decorate the right of the embedded section
       912 |           appendDecorations(
       913 |               basePos + tokenStart + embeddedSourceEnd,
       914 |               token.substring(embeddedSourceEnd),
       915 |               decorate, decorations);
       916 |         }
       917 |       }
       918 |       job.decorations = decorations;
       919 |     };
       920 |     return decorate;
       921 |   }
       922 | 
       923 |   /** returns a function that produces a list of decorations from source text.
       924 |     *
       925 |     * This code treats ", ', and ` as string delimiters, and \ as a string
       926 |     * escape.  It does not recognize perl's qq() style strings.
       927 |     * It has no special handling for double delimiter escapes as in basic, or
       928 |     * the tripled delimiters used in python, but should work on those regardless
       929 |     * although in those cases a single string literal may be broken up into
       930 |     * multiple adjacent string literals.
       931 |     *
       932 |     * It recognizes C, C++, and shell style comments.
       933 |     *
       934 |     * @param {Object} options a set of optional parameters.
       935 |     * @return {function (Object)} a function that examines the source code
       936 |     *     in the input job and builds the decoration list.
       937 |     */
       938 |   function sourceDecorator(options) {
       939 |     var shortcutStylePatterns = [], fallthroughStylePatterns = [];
       940 |     if (options['tripleQuotedStrings']) {
       941 |       // '''multi-line-string''', 'single-line-string', and double-quoted
       942 |       shortcutStylePatterns.push(
       943 |           [PR_STRING,  /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
       944 |            null, '\'"']);
       945 |     } else if (options['multiLineStrings']) {
       946 |       // 'multi-line-string', "multi-line-string"
       947 |       shortcutStylePatterns.push(
       948 |           [PR_STRING,  /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
       949 |            null, '\'"`']);
       950 |     } else {
       951 |       // 'single-line-string', "single-line-string"
       952 |       shortcutStylePatterns.push(
       953 |           [PR_STRING,
       954 |            /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
       955 |            null, '"\'']);
       956 |     }
       957 |     if (options['verbatimStrings']) {
       958 |       // verbatim-string-literal production from the C# grammar.  See issue 93.
       959 |       fallthroughStylePatterns.push(
       960 |           [PR_STRING, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]);
       961 |     }
       962 |     if (options['hashComments']) {
       963 |       if (options['cStyleComments']) {
       964 |         // Stop C preprocessor declarations at an unclosed open comment
       965 |         shortcutStylePatterns.push(
       966 |             [PR_COMMENT, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,
       967 |              null, '#']);
       968 |         fallthroughStylePatterns.push(
       969 |             [PR_STRING,
       970 |              /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
       971 |              null]);
       972 |       } else {
       973 |         shortcutStylePatterns.push([PR_COMMENT, /^#[^\r\n]*/, null, '#']);
       974 |       }
       975 |     }
       976 |     if (options['cStyleComments']) {
       977 |       fallthroughStylePatterns.push([PR_COMMENT, /^\/\/[^\r\n]*/, null]);
       978 |       fallthroughStylePatterns.push(
       979 |           [PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
       980 |     }
       981 |     if (options['regexLiterals']) {
       982 |       var REGEX_LITERAL = (
       983 |           // A regular expression literal starts with a slash that is
       984 |           // not followed by * or / so that it is not confused with
       985 |           // comments.
       986 |           '/(?=[^/*])'
       987 |           // and then contains any number of raw characters,
       988 |           + '(?:[^/\\x5B\\x5C]'
       989 |           // escape sequences (\x5C),
       990 |           +    '|\\x5C[\\s\\S]'
       991 |           // or non-nesting character sets (\x5B\x5D);
       992 |           +    '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
       993 |           // finally closed by a /.
       994 |           + '/');
       995 |       fallthroughStylePatterns.push(
       996 |           ['lang-regex',
       997 |            new RegExp('^' + REGEXP_PRECEDER_PATTERN + '(' + REGEX_LITERAL + ')')
       998 |            ]);
       999 |     }
      1000 | 
      1001 |     var keywords = options['keywords'].replace(/^\s+|\s+$/g, '');
      1002 |     if (keywords.length) {
      1003 |       fallthroughStylePatterns.push(
      1004 |           [PR_KEYWORD,
      1005 |            new RegExp('^(?:' + keywords.replace(/\s+/g, '|') + ')\\b'), null]);
      1006 |     }
      1007 | 
      1008 |     shortcutStylePatterns.push([PR_PLAIN,       /^\s+/, null, ' \r\n\t\xA0']);
      1009 |     fallthroughStylePatterns.push(
      1010 |         // TODO(mikesamuel): recognize non-latin letters and numerals in idents
      1011 |         [PR_LITERAL,     /^@[a-z_$][a-z_$@0-9]*/i, null],
      1012 |         [PR_TYPE,        /^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/, null],
      1013 |         [PR_PLAIN,       /^[a-z_$][a-z_$@0-9]*/i, null],
      1014 |         [PR_LITERAL,
      1015 |          new RegExp(
      1016 |              '^(?:'
      1017 |              // A hex number
      1018 |              + '0x[a-f0-9]+'
      1019 |              // or an octal or decimal number,
      1020 |              + '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
      1021 |              // possibly in scientific notation
      1022 |              + '(?:e[+\\-]?\\d+)?'
      1023 |              + ')'
      1024 |              // with an optional modifier like UL for unsigned long
      1025 |              + '[a-z]*', 'i'),
      1026 |          null, '0123456789'],
      1027 |         [PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#]*/, null]);
      1028 | 
      1029 |     return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
      1030 |   }
      1031 | 
      1032 |   var decorateSource = sourceDecorator({
      1033 |         'keywords': ALL_KEYWORDS,
      1034 |         'hashComments': true,
      1035 |         'cStyleComments': true,
      1036 |         'multiLineStrings': true,
      1037 |         'regexLiterals': true
      1038 |       });
      1039 | 
      1040 |   /** Breaks {@code job.source} around style boundaries in
      1041 |     * {@code job.decorations} while re-interleaving {@code job.extractedTags},
      1042 |     * and leaves the result in {@code job.prettyPrintedHtml}.
      1043 |     * @param {Object} job like {
      1044 |     *    source: {string} source as plain text,
      1045 |     *    extractedTags: {Array.<number|string>} extractedTags chunks of raw
      1046 |     *                   html preceded by their position in {@code job.source}
      1047 |     *                   in order
      1048 |     *    decorations: {Array.<number|string} an array of style classes preceded
      1049 |     *                 by the position at which they start in job.source in order
      1050 |     * }
      1051 |     * @private
      1052 |     */
      1053 |   function recombineTagsAndDecorations(job) {
      1054 |     var sourceText = job.source;
      1055 |     var extractedTags = job.extractedTags;
      1056 |     var decorations = job.decorations;
      1057 | 
      1058 |     var html = [];
      1059 |     // index past the last char in sourceText written to html
      1060 |     var outputIdx = 0;
      1061 | 
      1062 |     var openDecoration = null;
      1063 |     var currentDecoration = null;
      1064 |     var tagPos = 0;  // index into extractedTags
      1065 |     var decPos = 0;  // index into decorations
      1066 |     var tabExpander = makeTabExpander(window['PR_TAB_WIDTH']);
      1067 | 
      1068 |     var adjacentSpaceRe = /([\r\n ]) /g;
      1069 |     var startOrSpaceRe = /(^| ) /gm;
      1070 |     var newlineRe = /\r\n?|\n/g;
      1071 |     var trailingSpaceRe = /[ \r\n]$/;
      1072 |     var lastWasSpace = true;  // the last text chunk emitted ended with a space.
      1073 | 
      1074 |     // A helper function that is responsible for opening sections of decoration
      1075 |     // and outputing properly escaped chunks of source
      1076 |     function emitTextUpTo(sourceIdx) {
      1077 |       if (sourceIdx > outputIdx) {
      1078 |         if (openDecoration && openDecoration !== currentDecoration) {
      1079 |           // Close the current decoration
      1080 |           html.push('</span>');
      1081 |           openDecoration = null;
      1082 |         }
      1083 |         if (!openDecoration && currentDecoration) {
      1084 |           openDecoration = currentDecoration;
      1085 |           html.push('<span class="', openDecoration, '">');
      1086 |         }
      1087 |         // This interacts badly with some wikis which introduces paragraph tags
      1088 |         // into pre blocks for some strange reason.
      1089 |         // It's necessary for IE though which seems to lose the preformattedness
      1090 |         // of <pre> tags when their innerHTML is assigned.
      1091 |         // http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html
      1092 |         // and it serves to undo the conversion of <br>s to newlines done in
      1093 |         // chunkify.
      1094 |         var htmlChunk = textToHtml(
      1095 |             tabExpander(sourceText.substring(outputIdx, sourceIdx)))
      1096 |             .replace(lastWasSpace
      1097 |                      ? startOrSpaceRe
      1098 |                      : adjacentSpaceRe, '$1&nbsp;');
      1099 |         // Keep track of whether we need to escape space at the beginning of the
      1100 |         // next chunk.
      1101 |         lastWasSpace = trailingSpaceRe.test(htmlChunk);
      1102 |         // IE collapses multiple adjacient <br>s into 1 line break.
      1103 |         // Prefix every <br> with '&nbsp;' can prevent such IE's behavior.
      1104 |         var lineBreakHtml = window['_pr_isIE6']() ? '&nbsp;<br />' : '<br />';
      1105 |         html.push(htmlChunk.replace(newlineRe, lineBreakHtml));
      1106 |         outputIdx = sourceIdx;
      1107 |       }
      1108 |     }
      1109 | 
      1110 |     while (true) {
      1111 |       // Determine if we're going to consume a tag this time around.  Otherwise
      1112 |       // we consume a decoration or exit.
      1113 |       var outputTag;
      1114 |       if (tagPos < extractedTags.length) {
      1115 |         if (decPos < decorations.length) {
      1116 |           // Pick one giving preference to extractedTags since we shouldn't open
      1117 |           // a new style that we're going to have to immediately close in order
      1118 |           // to output a tag.
      1119 |           outputTag = extractedTags[tagPos] <= decorations[decPos];
      1120 |         } else {
      1121 |           outputTag = true;
      1122 |         }
      1123 |       } else {
      1124 |         outputTag = false;
      1125 |       }
      1126 |       // Consume either a decoration or a tag or exit.
      1127 |       if (outputTag) {
      1128 |         emitTextUpTo(extractedTags[tagPos]);
      1129 |         if (openDecoration) {
      1130 |           // Close the current decoration
      1131 |           html.push('</span>');
      1132 |           openDecoration = null;
      1133 |         }
      1134 |         html.push(extractedTags[tagPos + 1]);
      1135 |         tagPos += 2;
      1136 |       } else if (decPos < decorations.length) {
      1137 |         emitTextUpTo(decorations[decPos]);
      1138 |         currentDecoration = decorations[decPos + 1];
      1139 |         decPos += 2;
      1140 |       } else {
      1141 |         break;
      1142 |       }
      1143 |     }
      1144 |     emitTextUpTo(sourceText.length);
      1145 |     if (openDecoration) {
      1146 |       html.push('</span>');
      1147 |     }
      1148 |     job.prettyPrintedHtml = html.join('');
      1149 |   }
      1150 | 
      1151 |   /** Maps language-specific file extensions to handlers. */
      1152 |   var langHandlerRegistry = {};
      1153 |   /** Register a language handler for the given file extensions.
      1154 |     * @param {function (Object)} handler a function from source code to a list
      1155 |     *      of decorations.  Takes a single argument job which describes the
      1156 |     *      state of the computation.   The single parameter has the form
      1157 |     *      {@code {
      1158 |     *        source: {string} as plain text.
      1159 |     *        decorations: {Array.<number|string>} an array of style classes
      1160 |     *                     preceded by the position at which they start in
      1161 |     *                     job.source in order.
      1162 |     *                     The language handler should assigned this field.
      1163 |     *        basePos: {int} the position of source in the larger source chunk.
      1164 |     *                 All positions in the output decorations array are relative
      1165 |     *                 to the larger source chunk.
      1166 |     *      } }
      1167 |     * @param {Array.<string>} fileExtensions
      1168 |     */
      1169 |   function registerLangHandler(handler, fileExtensions) {
      1170 |     for (var i = fileExtensions.length; --i >= 0;) {
      1171 |       var ext = fileExtensions[i];
      1172 |       if (!langHandlerRegistry.hasOwnProperty(ext)) {
      1173 |         langHandlerRegistry[ext] = handler;
      1174 |       } else if ('console' in window) {
      1175 |         console.warn('cannot override language handler %s', ext);
      1176 |       }
      1177 |     }
      1178 |   }
      1179 |   function langHandlerForExtension(extension, source) {
      1180 |     if (!(extension && langHandlerRegistry.hasOwnProperty(extension))) {
      1181 |       // Treat it as markup if the first non whitespace character is a < and
      1182 |       // the last non-whitespace character is a >.
      1183 |       extension = /^\s*</.test(source)
      1184 |           ? 'default-markup'
      1185 |           : 'default-code';
      1186 |     }
      1187 |     return langHandlerRegistry[extension];
      1188 |   }
      1189 |   registerLangHandler(decorateSource, ['default-code']);
      1190 |   registerLangHandler(
      1191 |       createSimpleLexer(
      1192 |           [],
      1193 |           [
      1194 |            [PR_PLAIN,       /^[^<?]+/],
      1195 |            [PR_DECLARATION, /^<!\w[^>]*(?:>|$)/],
      1196 |            [PR_COMMENT,     /^<\!--[\s\S]*?(?:-\->|$)/],
      1197 |            // Unescaped content in an unknown language
      1198 |            ['lang-',        /^<\?([\s\S]+?)(?:\?>|$)/],
      1199 |            ['lang-',        /^<%([\s\S]+?)(?:%>|$)/],
      1200 |            [PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/],
      1201 |            ['lang-',        /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
      1202 |            // Unescaped content in javascript.  (Or possibly vbscript).
      1203 |            ['lang-js',      /^<script\b[^>]*>([\s\S]+?)<\/script\b[^>]*>/i],
      1204 |            // Contains unescaped stylesheet content
      1205 |            ['lang-css',     /^<style\b[^>]*>([\s\S]+?)<\/style\b[^>]*>/i],
      1206 |            ['lang-in.tag',  /^(<\/?[a-z][^<>]*>)/i]
      1207 |           ]),
      1208 |       ['default-markup', 'htm', 'html', 'mxml', 'xhtml', 'xml', 'xsl']);
      1209 |   registerLangHandler(
      1210 |       createSimpleLexer(
      1211 |           [
      1212 |            [PR_PLAIN,        /^[\s]+/, null, ' \t\r\n'],
      1213 |            [PR_ATTRIB_VALUE, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, '\"\'']
      1214 |            ],
      1215 |           [
      1216 |            [PR_TAG,          /^^<\/?[a-z](?:[\w:-]*\w)?|\/?>$/i],
      1217 |            [PR_ATTRIB_NAME,  /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],
      1218 |            ['lang-uq.val',   /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],
      1219 |            [PR_PUNCTUATION,  /^[=<>\/]+/],
      1220 |            ['lang-js',       /^on\w+\s*=\s*\"([^\"]+)\"/i],
      1221 |            ['lang-js',       /^on\w+\s*=\s*\'([^\']+)\'/i],
      1222 |            ['lang-js',       /^on\w+\s*=\s*([^\"\'>\s]+)/i],
      1223 |            ['lang-css',      /^style\s*=\s*\"([^\"]+)\"/i],
      1224 |            ['lang-css',      /^style\s*=\s*\'([^\']+)\'/i],
      1225 |            ['lang-css',      /^style\s*=\s*([^\"\'>\s]+)/i]
      1226 |            ]),
      1227 |       ['in.tag']);
      1228 |   registerLangHandler(
      1229 |       createSimpleLexer([], [[PR_ATTRIB_VALUE, /^[\s\S]+/]]), ['uq.val']);
      1230 |   registerLangHandler(sourceDecorator({
      1231 |           'keywords': CPP_KEYWORDS,
      1232 |           'hashComments': true,
      1233 |           'cStyleComments': true
      1234 |         }), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
      1235 |   registerLangHandler(sourceDecorator({
      1236 |           'keywords': 'null true false'
      1237 |         }), ['json']);
      1238 |   registerLangHandler(sourceDecorator({
      1239 |           'keywords': CSHARP_KEYWORDS,
      1240 |           'hashComments': true,
      1241 |           'cStyleComments': true,
      1242 |           'verbatimStrings': true
      1243 |         }), ['cs']);
      1244 |   registerLangHandler(sourceDecorator({
      1245 |           'keywords': JAVA_KEYWORDS,
      1246 |           'cStyleComments': true
      1247 |         }), ['java']);
      1248 |   registerLangHandler(sourceDecorator({
      1249 |           'keywords': SH_KEYWORDS,
      1250 |           'hashComments': true,
      1251 |           'multiLineStrings': true
      1252 |         }), ['bsh', 'csh', 'sh']);
      1253 |   registerLangHandler(sourceDecorator({
      1254 |           'keywords': PYTHON_KEYWORDS,
      1255 |           'hashComments': true,
      1256 |           'multiLineStrings': true,
      1257 |           'tripleQuotedStrings': true
      1258 |         }), ['cv', 'py']);
      1259 |   registerLangHandler(sourceDecorator({
      1260 |           'keywords': PERL_KEYWORDS,
      1261 |           'hashComments': true,
      1262 |           'multiLineStrings': true,
      1263 |           'regexLiterals': true
      1264 |         }), ['perl', 'pl', 'pm']);
      1265 |   registerLangHandler(sourceDecorator({
      1266 |           'keywords': RUBY_KEYWORDS,
      1267 |           'hashComments': true,
      1268 |           'multiLineStrings': true,
      1269 |           'regexLiterals': true
      1270 |         }), ['rb']);
      1271 |   registerLangHandler(sourceDecorator({
      1272 |           'keywords': JSCRIPT_KEYWORDS,
      1273 |           'cStyleComments': true,
      1274 |           'regexLiterals': true
      1275 |         }), ['js']);
      1276 |   registerLangHandler(
      1277 |       createSimpleLexer([], [[PR_STRING, /^[\s\S]+/]]), ['regex']);
      1278 | 
      1279 |   function applyDecorator(job) {
      1280 |     var sourceCodeHtml = job.sourceCodeHtml;
      1281 |     var opt_langExtension = job.langExtension;
      1282 | 
      1283 |     // Prepopulate output in case processing fails with an exception.
      1284 |     job.prettyPrintedHtml = sourceCodeHtml;
      1285 | 
      1286 |     try {
      1287 |       // Extract tags, and convert the source code to plain text.
      1288 |       var sourceAndExtractedTags = extractTags(sourceCodeHtml);
      1289 |       /** Plain text. @type {string} */
      1290 |       var source = sourceAndExtractedTags.source;
      1291 |       job.source = source;
      1292 |       job.basePos = 0;
      1293 | 
      1294 |       /** Even entries are positions in source in ascending order.  Odd entries
      1295 |         * are tags that were extracted at that position.
      1296 |         * @type {Array.<number|string>}
      1297 |         */
      1298 |       job.extractedTags = sourceAndExtractedTags.tags;
      1299 | 
      1300 |       // Apply the appropriate language handler
      1301 |       langHandlerForExtension(opt_langExtension, source)(job);
      1302 |       // Integrate the decorations and tags back into the source code to produce
      1303 |       // a decorated html string which is left in job.prettyPrintedHtml.
      1304 |       recombineTagsAndDecorations(job);
      1305 |     } catch (e) {
      1306 |       if ('console' in window) {
      1307 |         console.log(e);
      1308 |         console.trace();
      1309 |       }
      1310 |     }
      1311 |   }
      1312 | 
      1313 |   function prettyPrintOne(sourceCodeHtml, opt_langExtension) {
      1314 |     var job = {
      1315 |       sourceCodeHtml: sourceCodeHtml,
      1316 |       langExtension: opt_langExtension
      1317 |     };
      1318 |     applyDecorator(job);
      1319 |     return job.prettyPrintedHtml;
      1320 |   }
      1321 | 
      1322 |   function prettyPrint(opt_whenDone) {
      1323 |     var isIE678 = window['_pr_isIE6']();
      1324 |     var ieNewline = isIE678 === 6 ? '\r\n' : '\r';
      1325 |     // See bug 71 and http://stackoverflow.com/questions/136443/why-doesnt-ie7-
      1326 | 
      1327 |     // fetch a list of nodes to rewrite
      1328 |     var codeSegments = [
      1329 |         document.getElementsByTagName('pre'),
      1330 |         document.getElementsByTagName('code'),
      1331 |         document.getElementsByTagName('xmp') ];
      1332 |     var elements = [];
      1333 |     for (var i = 0; i < codeSegments.length; ++i) {
      1334 |       for (var j = 0, n = codeSegments[i].length; j < n; ++j) {
      1335 |         elements.push(codeSegments[i][j]);
      1336 |       }
      1337 |     }
      1338 |     codeSegments = null;
      1339 | 
      1340 |     var clock = Date;
      1341 |     if (!clock['now']) {
      1342 |       clock = { 'now': function () { return (new Date).getTime(); } };
      1343 |     }
      1344 | 
      1345 |     // The loop is broken into a series of continuations to make sure that we
      1346 |     // don't make the browser unresponsive when rewriting a large page.
      1347 |     var k = 0;
      1348 |     var prettyPrintingJob;
      1349 | 
      1350 |     function doWork() {
      1351 |       var endTime = (window['PR_SHOULD_USE_CONTINUATION'] ?
      1352 |                      clock.now() + 250 /* ms */ :
      1353 |                      Infinity);
      1354 |       for (; k < elements.length && clock.now() < endTime; k++) {
      1355 |         var cs = elements[k];
      1356 |         if (cs.className && cs.className.indexOf('prettyprint') >= 0) {
      1357 |           // If the classes includes a language extensions, use it.
      1358 |           // Language extensions can be specified like
      1359 |           //     <pre class="prettyprint lang-cpp">
      1360 |           // the language extension "cpp" is used to find a language handler as
      1361 |           // passed to PR_registerLangHandler.
      1362 |           var langExtension = cs.className.match(/\blang-(\w+)\b/);
      1363 |           if (langExtension) { langExtension = langExtension[1]; }
      1364 | 
      1365 |           // make sure this is not nested in an already prettified element
      1366 |           var nested = false;
      1367 |           for (var p = cs.parentNode; p; p = p.parentNode) {
      1368 |             if ((p.tagName === 'pre' || p.tagName === 'code' ||
      1369 |                  p.tagName === 'xmp') &&
      1370 |                 p.className && p.className.indexOf('prettyprint') >= 0) {
      1371 |               nested = true;
      1372 |               break;
      1373 |             }
      1374 |           }
      1375 |           if (!nested) {
      1376 |             // fetch the content as a snippet of properly escaped HTML.
      1377 |             // Firefox adds newlines at the end.
      1378 |             var content = getInnerHtml(cs);
      1379 |             content = content.replace(/(?:\r\n?|\n)$/, '');
      1380 | 
      1381 |             // do the pretty printing
      1382 |             prettyPrintingJob = {
      1383 |               sourceCodeHtml: content,
      1384 |               langExtension: langExtension,
      1385 |               sourceNode: cs
      1386 |             };
      1387 |             applyDecorator(prettyPrintingJob);
      1388 |             replaceWithPrettyPrintedHtml();
      1389 |           }
      1390 |         }
      1391 |       }
      1392 |       if (k < elements.length) {
      1393 |         // finish up in a continuation
      1394 |         setTimeout(doWork, 250);
      1395 |       } else if (opt_whenDone) {
      1396 |         opt_whenDone();
      1397 |       }
      1398 |     }
      1399 | 
      1400 |     function replaceWithPrettyPrintedHtml() {
      1401 |       var newContent = prettyPrintingJob.prettyPrintedHtml;
      1402 |       if (!newContent) { return; }
      1403 |       var cs = prettyPrintingJob.sourceNode;
      1404 | 
      1405 |       // push the prettified html back into the tag.
      1406 |       if (!isRawContent(cs)) {
      1407 |         // just replace the old html with the new
      1408 |         cs.innerHTML = newContent;
      1409 |       } else {
      1410 |         // we need to change the tag to a <pre> since <xmp>s do not allow
      1411 |         // embedded tags such as the span tags used to attach styles to
      1412 |         // sections of source code.
      1413 |         var pre = document.createElement('PRE');
      1414 |         for (var i = 0; i < cs.attributes.length; ++i) {
      1415 |           var a = cs.attributes[i];
      1416 |           if (a.specified) {
      1417 |             var aname = a.name.toLowerCase();
      1418 |             if (aname === 'class') {
      1419 |               pre.className = a.value;  // For IE 6
      1420 |             } else {
      1421 |               pre.setAttribute(a.name, a.value);
      1422 |             }
      1423 |           }
      1424 |         }
      1425 |         pre.innerHTML = newContent;
      1426 | 
      1427 |         // remove the old
      1428 |         cs.parentNode.replaceChild(pre, cs);
      1429 |         cs = pre;
      1430 |       }
      1431 | 
      1432 |       // Replace <br>s with line-feeds so that copying and pasting works
      1433 |       // on IE 6.
      1434 |       // Doing this on other browsers breaks lots of stuff since \r\n is
      1435 |       // treated as two newlines on Firefox, and doing this also slows
      1436 |       // down rendering.
      1437 |       if (isIE678 && cs.tagName === 'PRE') {
      1438 |         var lineBreaks = cs.getElementsByTagName('br');
      1439 |         for (var j = lineBreaks.length; --j >= 0;) {
      1440 |           var lineBreak = lineBreaks[j];
      1441 |           lineBreak.parentNode.replaceChild(
      1442 |               document.createTextNode(ieNewline), lineBreak);
      1443 |         }
      1444 |       }
      1445 |     }
      1446 | 
      1447 |     doWork();
      1448 |   }
      1449 | 
      1450 |   window['PR_normalizedHtml'] = normalizedHtml;
      1451 |   window['prettyPrintOne'] = prettyPrintOne;
      1452 |   window['prettyPrint'] = prettyPrint;
      1453 |   window['PR'] = {
      1454 |         'combinePrefixPatterns': combinePrefixPatterns,
      1455 |         'createSimpleLexer': createSimpleLexer,
      1456 |         'registerLangHandler': registerLangHandler,
      1457 |         'sourceDecorator': sourceDecorator,
      1458 |         'PR_ATTRIB_NAME': PR_ATTRIB_NAME,
      1459 |         'PR_ATTRIB_VALUE': PR_ATTRIB_VALUE,
      1460 |         'PR_COMMENT': PR_COMMENT,
      1461 |         'PR_DECLARATION': PR_DECLARATION,
      1462 |         'PR_KEYWORD': PR_KEYWORD,
      1463 |         'PR_LITERAL': PR_LITERAL,
      1464 |         'PR_NOCODE': PR_NOCODE,
      1465 |         'PR_PLAIN': PR_PLAIN,
      1466 |         'PR_PUNCTUATION': PR_PUNCTUATION,
      1467 |         'PR_SOURCE': PR_SOURCE,
      1468 |         'PR_STRING': PR_STRING,
      1469 |         'PR_TAG': PR_TAG,
      1470 |         'PR_TYPE': PR_TYPE
      1471 |       };
      1472 | })();
      1473 | 
      
      
      --------------------------------------------------------------------------------