From 27d1c97944e0f93a657c7cbaffa0eb34b04dc0a9 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 10 Oct 2016 12:02:31 -0400 Subject: [PATCH] Initial commit --- css/bundle.min.css | 1 + css/dlH.min.css | 1 + css/normalize.min.css | 1 + css/old-ie.css | 4 + css/src/dlH.css | 35 + css/src/normalize.css | 422 ++++++++++ css/src/style.css | 117 +++ css/style.min.css | 1 + index.html | 760 ++++++++++++++++++ js/index.min.js | 2 + js/index.min.js.map | 1 + js/load-scripts.js | 3 + js/load-scripts.js.map | 8 + js/loadScripts.js | 3 + js/loadScripts.js.map | 8 + js/polyfills/Dom/CSS_selector_engine.ielt8.js | 24 + js/polyfills/Dom/Element.outerHTML.js | 75 ++ js/polyfills/Dom/Element.outerHTML.min.js | 4 + js/polyfills/Dom/Element.outerHTML.min.js.map | 8 + js/polyfills/Dom/outerHTML.min.js | 1 + js/polyfills/EcmaScript/Array.from.js | 3 + js/polyfills/EcmaScript/Array.from.js.map | 8 + js/polyfills/EcmaScript/Array.isArray.js | 2 + js/polyfills/EcmaScript/Array.isArray.js.map | 8 + js/polyfills/EcmaScript/Array.of.js | 3 + .../EcmaScript/Array.prototype.every.js | 2 + .../EcmaScript/Array.prototype.every.js.map | 8 + .../EcmaScript/Array.prototype.filter.js | 2 + .../EcmaScript/Array.prototype.filter.js.map | 8 + .../EcmaScript/Array.prototype.forEach.js | 2 + .../EcmaScript/Array.prototype.forEach.js.map | 8 + .../EcmaScript/Array.prototype.includes.js | 2 + .../Array.prototype.includes.js.map | 8 + .../EcmaScript/Array.prototype.map.js | 2 + .../EcmaScript/Array.prototype.map.js.map | 8 + .../EcmaScript/Array.prototype.reduce.js | 2 + .../EcmaScript/Array.prototype.reduce.js.map | 8 + .../EcmaScript/String.prototype.includes.js | 2 + .../String.prototype.includes.js.map | 8 + .../EcmaScript/String.prototype.repeat.js | 2 + .../EcmaScript/String.prototype.repeat.js.map | 8 + .../EcmaScript/String.prototype.trim.js | 2 + .../EcmaScript/String.prototype.trim.js.map | 8 + js/polyfills/html5shiv.min.js | 4 + js/polyfills/ie-array-slice-shim.js | 64 ++ package.json | 72 ++ postcss.json | 14 + rollup.config.js | 46 ++ src/DlHighlight/highlight-xml-html.js | 554 +++++++++++++ src/doc.js | 65 ++ src/form-elements-each.js | 78 ++ src/format.js | 184 +++++ src/functions.js | 89 ++ src/index.js | 43 + src/load-scripts.js | 40 + src/old/doc.js | 88 ++ src/old/init.js | 202 +++++ src/polyfills/Array.from.js | 76 ++ src/polyfills/Array.isArray.js | 3 + src/polyfills/Array.prototype.every.js | 61 ++ src/polyfills/Array.prototype.filter.js | 32 + src/polyfills/Array.prototype.forEach.js | 58 ++ src/polyfills/Array.prototype.includes.js | 30 + src/polyfills/Array.prototype.map.js | 84 ++ src/polyfills/Array.prototype.reduce.js | 27 + src/polyfills/String.prototype.includes.js | 12 + src/polyfills/String.prototype.repeat.js | 41 + src/polyfills/String.prototype.trim.js | 3 + tools/min-all.js | 15 + tools/min-loader.js | 3 + tools/min.js | 41 + 71 files changed, 3622 insertions(+) create mode 100644 css/bundle.min.css create mode 100644 css/dlH.min.css create mode 100644 css/normalize.min.css create mode 100644 css/old-ie.css create mode 100644 css/src/dlH.css create mode 100644 css/src/normalize.css create mode 100644 css/src/style.css create mode 100644 css/style.min.css create mode 100644 index.html create mode 100644 js/index.min.js create mode 100644 js/index.min.js.map create mode 100644 js/load-scripts.js create mode 100644 js/load-scripts.js.map create mode 100644 js/loadScripts.js create mode 100644 js/loadScripts.js.map create mode 100644 js/polyfills/Dom/CSS_selector_engine.ielt8.js create mode 100644 js/polyfills/Dom/Element.outerHTML.js create mode 100644 js/polyfills/Dom/Element.outerHTML.min.js create mode 100644 js/polyfills/Dom/Element.outerHTML.min.js.map create mode 100644 js/polyfills/Dom/outerHTML.min.js create mode 100644 js/polyfills/EcmaScript/Array.from.js create mode 100644 js/polyfills/EcmaScript/Array.from.js.map create mode 100644 js/polyfills/EcmaScript/Array.isArray.js create mode 100644 js/polyfills/EcmaScript/Array.isArray.js.map create mode 100644 js/polyfills/EcmaScript/Array.of.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.every.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.every.js.map create mode 100644 js/polyfills/EcmaScript/Array.prototype.filter.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.filter.js.map create mode 100644 js/polyfills/EcmaScript/Array.prototype.forEach.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.forEach.js.map create mode 100644 js/polyfills/EcmaScript/Array.prototype.includes.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.includes.js.map create mode 100644 js/polyfills/EcmaScript/Array.prototype.map.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.map.js.map create mode 100644 js/polyfills/EcmaScript/Array.prototype.reduce.js create mode 100644 js/polyfills/EcmaScript/Array.prototype.reduce.js.map create mode 100644 js/polyfills/EcmaScript/String.prototype.includes.js create mode 100644 js/polyfills/EcmaScript/String.prototype.includes.js.map create mode 100644 js/polyfills/EcmaScript/String.prototype.repeat.js create mode 100644 js/polyfills/EcmaScript/String.prototype.repeat.js.map create mode 100644 js/polyfills/EcmaScript/String.prototype.trim.js create mode 100644 js/polyfills/EcmaScript/String.prototype.trim.js.map create mode 100644 js/polyfills/html5shiv.min.js create mode 100644 js/polyfills/ie-array-slice-shim.js create mode 100644 package.json create mode 100644 postcss.json create mode 100644 rollup.config.js create mode 100644 src/DlHighlight/highlight-xml-html.js create mode 100644 src/doc.js create mode 100644 src/form-elements-each.js create mode 100644 src/format.js create mode 100644 src/functions.js create mode 100644 src/index.js create mode 100644 src/load-scripts.js create mode 100644 src/old/doc.js create mode 100644 src/old/init.js create mode 100644 src/polyfills/Array.from.js create mode 100644 src/polyfills/Array.isArray.js create mode 100644 src/polyfills/Array.prototype.every.js create mode 100644 src/polyfills/Array.prototype.filter.js create mode 100644 src/polyfills/Array.prototype.forEach.js create mode 100644 src/polyfills/Array.prototype.includes.js create mode 100644 src/polyfills/Array.prototype.map.js create mode 100644 src/polyfills/Array.prototype.reduce.js create mode 100644 src/polyfills/String.prototype.includes.js create mode 100644 src/polyfills/String.prototype.repeat.js create mode 100644 src/polyfills/String.prototype.trim.js create mode 100644 tools/min-all.js create mode 100644 tools/min-loader.js create mode 100644 tools/min.js diff --git a/css/bundle.min.css b/css/bundle.min.css new file mode 100644 index 0000000..36f64da --- /dev/null +++ b/css/bundle.min.css @@ -0,0 +1 @@ +/*! normalize.css v4.2.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit;font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:700}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.DlHighlight pre{margin:0;padding:0}.DlHighlight .keyword{color:#d75f00;font-weight:700}.DlHighlight .builtin{color:#2aa198}.DlHighlight .string{color:#af8700}.DlHighlight .string .after,.DlHighlight .string .before{color:#5f5faf}.DlHighlight .hashkey{color:#a51}.DlHighlight .hasharrow{color:red}.DlHighlight .paren{font-weight:700}.DlHighlight .operator{color:#b58900}.DlHighlight .error{background-color:#c00;color:#fff}.DlHighlight .defun{font-weight:700}.DLHighlight .undefined,.DlHighlight .xml-tagangle{color:#268bd2}.DlHighlight .xml-tag-close .before{color:#52a}.DlHighlight .xml-entity{color:#b2a}.DlHighlight .xml-entity .after,.DlHighlight .xml-entity .before{color:#607}*{display:border-box}datalist,datalist option{visibility:hidden}hr{margin:1em 0}form>div,header,main{padding:1em}label{display:block;padding:.75em 0;text-shadow:#fff 3px 3px 10px}label:after{content:':'}fieldset{margin-bottom:1em;border-radius:.25em}fieldset fieldset{background:#eee}fieldset fieldset fieldset{background:#ddd}fieldset fieldset fieldset fieldset{background:#ccc}legend{padding:.25em;border:1px solid #ddd;border-radius:.25em}code{font-family:Consolas,Monaco,sans-serif;overflow-x:scroll;white-space:nowrap}code,legend{background:#fdf6e3}.form-field{display:block}.form-field .example,.form-field code{display:-moz-inline-box;display:inline-block;vertical-align:top;margin:.5em auto}.form-field .example{width:32%}.form-field code{border:1px solid #ddd;border-radius:.25em;margin-left:.5em;padding:.5em;width:64%}.example{text-align:center}.example>*{margin:0 auto;text-align:left;width:90%}.example>code{width:inherit}output{text-align:left}input:active+label,input:focus+label,input:hover+label{font-size:1.5em;font-weight:700}[type=checkbox]+label,[type=option]+label{font-weight:400}[type=checkbox]:checked+label,[type=option]:checked+label{font-weight:700}[required]:valid+label{color:green}[required]:invalid+label{font-weight:700;color:red}.antipattern{background:#c77}.antipattern fieldset{background:#a55} \ No newline at end of file diff --git a/css/dlH.min.css b/css/dlH.min.css new file mode 100644 index 0000000..262b2dc --- /dev/null +++ b/css/dlH.min.css @@ -0,0 +1 @@ +.DlHighlight pre{margin:0;padding:0}.DlHighlight .keyword{color:#d75f00;font-weight:700}.DlHighlight .builtin{color:#2aa198}.DlHighlight .string{color:#af8700}.DlHighlight .string .after,.DlHighlight .string .before{color:#5f5faf}.DlHighlight .hashkey{color:#a51}.DlHighlight .hasharrow{color:red}.DlHighlight .paren{font-weight:700}.DlHighlight .operator{color:#b58900}.DlHighlight .error{background-color:#c00;color:#fff}.DlHighlight .defun{font-weight:700}.DLHighlight .undefined,.DlHighlight .xml-tagangle{color:#268bd2}.DlHighlight .xml-tag-close .before{color:#52a}.DlHighlight .xml-entity{color:#b2a}.DlHighlight .xml-entity .after,.DlHighlight .xml-entity .before{color:#607} \ No newline at end of file diff --git a/css/normalize.min.css b/css/normalize.min.css new file mode 100644 index 0000000..2aab3db --- /dev/null +++ b/css/normalize.min.css @@ -0,0 +1 @@ +/*! normalize.css v4.2.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit;font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:700}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit} \ No newline at end of file diff --git a/css/old-ie.css b/css/old-ie.css new file mode 100644 index 0000000..c806bad --- /dev/null +++ b/css/old-ie.css @@ -0,0 +1,4 @@ +.form-field .example, .form-field code{ + zoom:1; + display: inline; +} \ No newline at end of file diff --git a/css/src/dlH.css b/css/src/dlH.css new file mode 100644 index 0000000..b03a5fe --- /dev/null +++ b/css/src/dlH.css @@ -0,0 +1,35 @@ +/* Generics */ +.DlHighlight pre { margin: 0; padding: 0; } + +.DlHighlight .keyword { color: #d75f00; font-weight: bold; } + +.DlHighlight .builtin { color: #2aa198; } + +.DlHighlight .string { color: #af8700; } +.DlHighlight .string .before, .DlHighlight .string .after { color: #5f5faf; } + +.DlHighlight .hashkey { color: #a51; } + +.DlHighlight .hasharrow { color: #f00; } + +.DlHighlight .paren { font-weight: bold; } + +.DlHighlight .operator { color: #b58900; } + +.DlHighlight .error { background-color: #c00; color: #fff; } + +.DlHighlight .defun { font-weight: bold; } + +.DLHighlight .undefined { + color: #268bd2; +} + +/* XML */ +.DlHighlight .xml-tagangle { + color: #268bd2; +} + +.DlHighlight .xml-tag-close .before { color: #52a; } + +.DlHighlight .xml-entity { color: #b2a; } +.DlHighlight .xml-entity .before, .DlHighlight .xml-entity .after { color: #607; } diff --git a/css/src/normalize.css b/css/src/normalize.css new file mode 100644 index 0000000..1e09e28 --- /dev/null +++ b/css/src/normalize.css @@ -0,0 +1,422 @@ +/*! normalize.css v4.2.0 | MIT License | github.com/necolas/normalize.css */ + +/** + * 1. Change the default font family in all browsers (opinionated). + * 2. Correct the line height in all browsers. + * 3. Prevent adjustments of font size after orientation changes in IE and iOS. + */ + +html { + font-family: sans-serif; /* 1 */ + line-height: 1.15; /* 2 */ + -ms-text-size-adjust: 100%; /* 3 */ + -webkit-text-size-adjust: 100%; /* 3 */ +} + +/** + * Remove the margin in all browsers (opinionated). + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Add the correct display in IE 9-. + * 1. Add the correct display in Edge, IE, and Firefox. + * 2. Add the correct display in IE. + */ + +article, +aside, +details, /* 1 */ +figcaption, +figure, +footer, +header, +main, /* 2 */ +menu, +nav, +section, +summary { /* 1 */ + display: block; +} + +/** + * Add the correct display in IE 9-. + */ + +audio, +canvas, +progress, +video { + display: inline-block; +} + +/** + * Add the correct display in iOS 4-7. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Add the correct vertical alignment in Chrome, Firefox, and Opera. + */ + +progress { + vertical-align: baseline; +} + +/** + * Add the correct display in IE 10-. + * 1. Add the correct display in IE. + */ + +template, /* 1 */ +[hidden] { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * 1. Remove the gray background on active links in IE 10. + * 2. Remove gaps in links underline in iOS 8+ and Safari 8+. + */ + +a { + background-color: transparent; /* 1 */ + -webkit-text-decoration-skip: objects; /* 2 */ +} + +/** + * Remove the outline on focused links when they are also active or hovered + * in all browsers (opinionated). + */ + +a:active, +a:hover { + outline-width: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * 1. Remove the bottom border in Firefox 39-. + * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. + */ + +abbr[title] { + border-bottom: none; /* 1 */ + text-decoration: underline; /* 2 */ + text-decoration: underline dotted; /* 2 */ +} + +/** + * Prevent the duplicate application of `bolder` by the next rule in Safari 6. + */ + +b, +strong { + font-weight: inherit; +} + +/** + * Add the correct font weight in Chrome, Edge, and Safari. + */ + +b, +strong { + font-weight: bolder; +} + +/** + * Add the correct font style in Android 4.3-. + */ + +dfn { + font-style: italic; +} + +/** + * Correct the font size and margin on `h1` elements within `section` and + * `article` contexts in Chrome, Firefox, and Safari. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Add the correct background and color in IE 9-. + */ + +mark { + background-color: #ff0; + color: #000; +} + +/** + * Add the correct font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` elements from affecting the line height in + * all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove the border on images inside links in IE 10-. + */ + +img { + border-style: none; +} + +/** + * Hide the overflow in IE. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * 1. Correct the inheritance and scaling of font size in all browsers. + * 2. Correct the odd `em` font sizing in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; /* 1 */ + font-size: 1em; /* 2 */ +} + +/** + * Add the correct margin in IE 8. + */ + +figure { + margin: 1em 40px; +} + +/** + * 1. Add the correct box sizing in Firefox. + * 2. Show the overflow in Edge and IE. + */ + +hr { + box-sizing: content-box; /* 1 */ + height: 0; /* 1 */ + overflow: visible; /* 2 */ +} + +/* Forms + ========================================================================== */ + +/** + * 1. Change font properties to `inherit` in all browsers (opinionated). + * 2. Remove the margin in Firefox and Safari. + */ + +button, +input, +optgroup, +select, +textarea { + font: inherit; /* 1 */ + margin: 0; /* 2 */ +} + +/** + * Restore the font weight unset by the previous rule. + */ + +optgroup { + font-weight: bold; +} + +/** + * Show the overflow in IE. + * 1. Show the overflow in Edge. + */ + +button, +input { /* 1 */ + overflow: visible; +} + +/** + * Remove the inheritance of text transform in Edge, Firefox, and IE. + * 1. Remove the inheritance of text transform in Firefox. + */ + +button, +select { /* 1 */ + text-transform: none; +} + +/** + * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video` + * controls in Android 4. + * 2. Correct the inability to style clickable types in iOS and Safari. + */ + +button, +html [type="button"], /* 1 */ +[type="reset"], +[type="submit"] { + -webkit-appearance: button; /* 2 */ +} + +/** + * Remove the inner border and padding in Firefox. + */ + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +/** + * Restore the focus styles unset by the previous rule. + */ + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +/** + * Change the border, margin, and padding in all browsers (opinionated). + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct the text wrapping in Edge and IE. + * 2. Correct the color inheritance from `fieldset` elements in IE. + * 3. Remove the padding so developers are not caught out when they zero out + * `fieldset` elements in all browsers. + */ + +legend { + box-sizing: border-box; /* 1 */ + color: inherit; /* 2 */ + display: table; /* 1 */ + max-width: 100%; /* 1 */ + padding: 0; /* 3 */ + white-space: normal; /* 1 */ +} + +/** + * Remove the default vertical scrollbar in IE. + */ + +textarea { + overflow: auto; +} + +/** + * 1. Add the correct box sizing in IE 10-. + * 2. Remove the padding in IE 10-. + */ + +[type="checkbox"], +[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Correct the cursor style of increment and decrement buttons in Chrome. + */ + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Correct the odd appearance in Chrome and Safari. + * 2. Correct the outline style in Safari. + */ + +[type="search"] { + -webkit-appearance: textfield; /* 1 */ + outline-offset: -2px; /* 2 */ +} + +/** + * Remove the inner padding and cancel buttons in Chrome and Safari on OS X. + */ + +[type="search"]::-webkit-search-cancel-button, +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Correct the text style of placeholders in Chrome, Edge, and Safari. + */ + +::-webkit-input-placeholder { + color: inherit; + opacity: 0.54; +} + +/** + * 1. Correct the inability to style clickable types in iOS and Safari. + * 2. Change font properties to `inherit` in Safari. + */ + +::-webkit-file-upload-button { + -webkit-appearance: button; /* 1 */ + font: inherit; /* 2 */ +} \ No newline at end of file diff --git a/css/src/style.css b/css/src/style.css new file mode 100644 index 0000000..9ca5468 --- /dev/null +++ b/css/src/style.css @@ -0,0 +1,117 @@ +* { + display: border-box; +} + +datalist, datalist option { + visibility:hidden; +} + +hr { + margin:1em 0; +} + +header, main, form > div { + padding:1em; +} +label { + display: block; + padding:0.75em 0; + text-shadow: #fff 3px 3px 10px; +} +label::after { + content: ':'; +} +fieldset { + margin-bottom: 1em; + border-radius: 0.25em; +} +fieldset fieldset { background: #eee;} +fieldset fieldset fieldset { background: #ddd; } +fieldset fieldset fieldset fieldset { background: #ccc; } + +legend { + padding: 0.25em; + border: 1px solid #ddd; + border-radius: 0.25em; +} + +code { + font-family: Consolas, Monaco, sans-serif; + overflow-x: scroll; + white-space:nowrap; +} + +code, legend { + background:#fdf6e3; +} + +.form-field { + display: block; +} + + .form-field .example, .form-field code { + /* Old Mozilla */ + display:-moz-inline-box; + /* Modern */ + display:inline-block; + vertical-align:top; + margin: 0.5em auto; + } + + .form-field .example { + width: 32%; + } + + .form-field code { + border: 1px solid #ddd; + border-radius:0.25em; + margin-left: 0.5em; + padding:0.5em; + width: 64%; + } + +.example { + text-align: center; +} + + .example > * { + margin: 0 auto; + text-align:left; + width:90%; + } + + .example > code { + width: inherit; + } + +output { + text-align:left; +} + +input:active + label, input:hover + label, input:focus + label { + font-size:1.5em; + font-weight:bold; +} + +[type="checkbox"] + label, [type="option"] + label{ + font-weight:normal; +} + +[type="checkbox"]:checked + label, [type="option"]:checked + label { + font-weight:bold; +} + +[required]:valid + label { + color: green; +} +[required]:invalid + label { + font-weight:bold; + color: red; +} + +.antipattern { + background: #c77; +} + .antipattern fieldset { + background: #a55; + } \ No newline at end of file diff --git a/css/style.min.css b/css/style.min.css new file mode 100644 index 0000000..a354dc2 --- /dev/null +++ b/css/style.min.css @@ -0,0 +1 @@ +*{display:border-box}datalist,datalist option{visibility:hidden}hr{margin:1em 0}form>div,header,main{padding:1em}label{display:block;padding:.75em 0;text-shadow:#fff 3px 3px 10px}label:after{content:':'}fieldset{margin-bottom:1em;border-radius:.25em}fieldset fieldset{background:#eee}fieldset fieldset fieldset{background:#ddd}fieldset fieldset fieldset fieldset{background:#ccc}legend{padding:.25em;border:1px solid #ddd;border-radius:.25em}code{font-family:Consolas,Monaco,sans-serif;overflow-x:scroll;white-space:nowrap}code,legend{background:#fdf6e3}.form-field{display:block}.form-field .example,.form-field code{display:-moz-inline-box;display:inline-block;vertical-align:top;margin:.5em auto}.form-field .example{width:32%}.form-field code{border:1px solid #ddd;border-radius:.25em;margin-left:.5em;padding:.5em;width:64%}.example{text-align:center}.example>*{margin:0 auto;text-align:left;width:90%}.example>code{width:inherit}output{text-align:left}input:active+label,input:focus+label,input:hover+label{font-size:1.5em;font-weight:700}[type=checkbox]+label,[type=option]+label{font-weight:400}[type=checkbox]:checked+label,[type=option]:checked+label{font-weight:700}[required]:valid+label{color:green}[required]:invalid+label{font-weight:700;color:red}.antipattern{background:#c77}.antipattern fieldset{background:#a55} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..dc04a1e --- /dev/null +++ b/index.html @@ -0,0 +1,760 @@ + + + + Form Fields Cheatsheet + + + + + + +
+

HTML Forms Best Practice Cheetsheet

+
+
+

Sections

+ +
+
+
+
+

User authentication / signup

+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+

Authentication Password duplication (For signup or reset)

+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+

Personal Information

+ +
+
+ + +
+
+ +
+ Split Name Fields + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ Split Birthday + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+
+

Organization / Business Information

+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+

Phone Numbers

+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ Split Phone Number + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ Split National Number + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ Split Local Number + +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+
+
+
+

Contact Information

+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+
+

Addresses

+ +
+
+ + +
+
+ +
+ Split Street Address + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+

Credit Card Information

+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ Split Credit Card Name + +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ Combined Month Expiration + +
+
+ + +
+
+
+ +
+ Separate Month / Year Expiration + +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+
+

Money / Currency

+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+

Date / Time

+ +
+
+ + +
+
+ +
+
+
+

Buttons

+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+
+

Other Form Elements

+ +
+ Input with Datalist + +

Note: set display:none on datalist element to hide options from browsers that don't understand the datalist element.

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ Multiselect without Option Groups + +
+
+ + +
+
+
+ +
+ Select w/ Optgroups + +
+
+ + +
+
+
+ + + +
+ Checkboxes + +
+
+

Select your favorite fruit(s)

+ + + + +
+
+
+ +
+ Output/Display Elements + +
+
+ + 70 % +
+
+ +
+
+ + 65 Degrees +
+
+ +
+ The Output Element + +
+

See the MDN article.

+
+ + * + = + 32 +
+
+
+ +
+
+
+
+

Anti-Patterns

+
+ Deprecated Elements + +
+
+ + +
+
+
+ +
+ Multiple Select with Optgroups + +

Note: Browser support varies. Recommend against for maximum compatibility.

+ +
+
+ + +
+
+
+
+
+
+ + + + + diff --git a/js/index.min.js b/js/index.min.js new file mode 100644 index 0000000..79a4d47 --- /dev/null +++ b/js/index.min.js @@ -0,0 +1,2 @@ +!function(){"use strict";function e(e,t){return void 0===t&&(t="/"),e.substr(e.lastIndexOf(t)+1)}function t(e,t){var n=e;return t.forEach(function(e){n=n.replace(e[0],e[1])}),n}function n(e){return new r({lang:"html"}).doItNow(e)}var r=function(){function e(e){return e.replace(/\b((https?|ftp):\x2f\x2f[^\s\x22]+)/g,function(e){return""+e+""})}function t(e,t,n,r,a){null!=r[t]&&("number"==typeof r[t]?a[t]=n[r[t]]:"function"==typeof r[t]?a[t]=r[t].call(e,n):a[t]=r[t])}function n(e){var t=e.index||0;return t||(e.before&&(t+=e.before.length),e.content&&(t+=e.content.length),e.after&&(t+=e.after.length)),t}function r(e){var t=/^\x2f?>/.exec(e);if(t){var n=this.inXmlTag;this.inXmlTag=!1;var r=[{content:t[0],style:"paren xml-tagangle"}];if(/^script$/i.test(n)&&!/><\x2fscript>/i.test(e)){f.lastIndex=1;var t=f.exec(e);if(t&&t[1]&&1==t.index){var o=t[1],i=f.lastIndex-10,s=new a({lang:"js",noTrim:!0}).doItNow(o),l={content:{escaped:s},style:"xml-inline-script",index:i};r.push(l)}}return r}}var a=function(e){function t(t,r){t in e&&(r=e[t]),n.args[t]=r}var n=this;this.args={},t("replaceTabs",null),t("lineNumbers",!1),t("noTrim",!1),t("showWhitespace",!1);var r=this.lang=a.LANG[e.lang];if(this.tokenParsers=r.tokens.slice(0).reverse(),null!=this.args.replaceTabs){for(var o=" ";--this.args.replaceTabs>0;)o+=" ";this.args.replaceTabs=o}};a.is_ie=/MSIE/.test(navigator.userAgent)&&!/Gecko|KHTML|Opera/.test(navigator.userAgent),a.BASE={COMMENT_CPP:function(e){if("/"==e.charAt(0)&&"/"==e.charAt(1)){var t=e.indexOf("\n");t==-1&&(t=e.length);var n=this.lang.onComment.call(this,this._he(e.substring(2,t)));return{content:{escaped:n},style:"comment comment-line",type:"comment",index:t,before:"//"}}},COMMENT_C:function(e){if("/"==e.charAt(0)&&"*"==e.charAt(1)){var t,n=e.indexOf("*/"),r=n;return n==-1?n=r=e.length:r+=2,t=this.lang.onComment.call(this,this._he(e.substring(2,n))),t=t.replace(/^\s*[*\\|]+/gm,function(e){return""+e+""}),{content:{escaped:t},before:"/*",after:"*/",index:r,style:"comment comment-multiline",type:"comment"}}},STRING:{regexp:/^(\x22(\\.|[^\x22\\])*\x22|\x27(\\.|[^\x27\\])*\x27)/g,content:function(e){return e=e[1],e=e.substr(1,e.length-2),this.args.showWhitespace&&(e=e.replace(/\x20/g,"_")),e},before:function(e){return e[1].charAt(0)},after:function(e){return e[1].charAt(0)},type:"string",style:"string"},PAREN:{regexp:/^[\](){}\[]/g,content:0,type:"paren",style:"paren"},OPERATOR:function(e){var t=/^[<>!+=%&*\x2f|?:-]+/.exec(e);if(t&&"!/"!=t[0])return{content:t[0],index:t.lastIndex,type:"operator",style:"operator"}}},a.prototype={formatToken:function(e){var t=e.style,n=l();return t instanceof Array&&(t=t.join(" ")),n(""),e.before&&n("",this._he(e.before),""),n(this._he(e.content)),e.after&&n("",this._he(e.after),""),n(""),n.get()},formatUnknown:function(e){return this._he(e)},getLastToken:function(e){return this.tokens[this.tokens.length-(e||0)-1]},lastTokenType:function(e){var t=this.getLastToken();return!!t&&e.test(t.type)},parseToken:function(e,n){var r,a;return e.regexp?(e.regexp.lastIndex=0,r=e.regexp.exec(n),r&&(a={type:e.type,style:e.style,index:e.regexp.lastIndex},t(this,"before",r,e,a),t(this,"after",r,e,a),t(this,"content",r,e,a))):a=e.call(this,n),a},doItNow:function(e){var t=this;this.lang.start.call(this,e),this.args.noTrim||(e=e.replace(/\s+$/,""));var r,a,o,i,s,l=[],c=this.tokenParsers,u=0;for(a="",s=this.tokens=[];e.length>0;){for(r=/^\s+/.exec(e),r&&(a+=r[0],e=e.substr(r[0].length)),i=c.length;--i>=0&&!(o=t.parseToken(c[i],e)););if(o){a&&(l[u++]=a),a="",o instanceof Array||(o=[o]);var f=0;s.push.apply(s,o);for(var g=0;g=0;)u=l[i],"string"==typeof u?l[i]=t.formatUnknown(u):l[i]=t.formatToken(u);var m=l.join("");return i=this.args.lineNumbers,i&&("number"!=typeof i&&(i=0),m=m.replace(/^/gm,function(){return""+ ++i+""}),this.args.lineNumbers=i),this.lang.stop.call(this),m},_he:function(e){return e.escaped?e.escaped:(e=e.replace(o,function(e){return i[e]}),this.args.replaceTabs&&(e=e.replace(/\t/g,this.args.replaceTabs)),e)}};var o=/[&<>]/g,i={"&":"&","<":"<",">":">"};a.LANG=function(e,t){arguments.length>0&&(a.LANG[e]=this,this.tokens=t)},a.registerLang=function(e,t){function n(){a.LANG.call(this,e,t)}return n.prototype=new a.LANG,n.prototype.constructor=n,new n};var s=a.LANG.prototype;s.start=s.stop=function(){},s.onComment=function(t){return e(t)};var l=a.is_ie?function(){var e=[],t=0,n=function(){for(var n=arguments,r=0;r",content:e.substring(4,t),index:t+3,type:"comment",style:"comment"}}},STRING:function(e){if(this.inXmlTag)return this.parseToken(a.BASE.STRING,e)},ATTRIBUTE:function(e){var t=null;if(this.inXmlTag){var n=/^([a-z0-9_-]+)(\s*)=/i.exec(e);if(n)return[{content:n[1],style:"builtin xml-attribute"},{content:n[2]},{content:"=",style:"operator"}]}return t},ENTITY:{regexp:/^&(\w+);/g,before:"&",after:";",content:1,type:"builtin",style:"builtin xml-entity"},START_TAG:function(e){var t=/^<([a-z0-9_-]+)/i.exec(e);if(t)return this.inXmlTag=t[1],[{content:"<",style:"paren xml-tagangle"},{content:t[1],style:"keyword xml-tag xml-tag-open"}]},END_TAG:function(e){var t=/^<\x2f([a-z0-9_-]+)(\s*>)/i.exec(e);if(t)return[{content:"/.exec(e);if(t)return this.inXmlTag=!1,{content:t[0],style:"paren xml-tagangle"}}},u=a.registerLang("xml",[c.COMMENT,c.STRING,c.ATTRIBUTE,c.ENTITY,c.START_TAG,c.END_TAG,c.END_ANGLE]);u.T=c,u.start=function(){this.inXmlTag=!1};var f=/([^\0]*?)<\x2fscript>/gi,g=a.LANG.xml;return a.registerLang("html",[g.T.COMMENT,g.T.STRING,g.T.ATTRIBUTE,g.T.ENTITY,g.T.START_TAG,g.T.END_TAG,r]),a}(),a=function(){};a.scripts=function(){return Array.from(document.scripts)},a.qs=function(e,t){return void 0===t&&(t=document.documentElement),document.OLD_IE?document.documentElement.querySelector.call(t,e):t.querySelector(e)},a.qsa=function(e,t){return void 0===t&&(t=document.documentElement),document.OLD_IE?Array.from(document.documentElement.querySelectorAll.call(t,e)):Array.from(t.querySelectorAll(e))},a.getById=function(e){return document.getElementById(e)},a.getByTag=function(e,t){return void 0===t&&(t=document.documentElement),Array.from(t.getElementsByTagName(e))};var o=/^\s+$/gi,i=/<(input)(.*?)>/gi,s=/>(?:\s+)?<\/option>/gi,l=/(\s+)([^in\s][a-z_\-]+=(?:"(?:.*?)"|[^"'`=<>\s]+))/gi,c=/(?:.*?)?(?:\s+)?(<.*?>)(?:.*?)?(?:\s+)?<\/label>/gi,u=1,f=3,g=function(){};g.input=function(e){var t="{s}".repeat(e.tagName.length+2),n="{n}"+t;return e.outerHTML.trim().replace(i,"<$1$2 />").replace(l,n+"$2")},g.option=function(e){var t=g.generic(e);return g.hasHtmlChildren(e)&&e.childNodes.length>0?t:(t=t.replace(o,""),t.replace(s," />"))},g.generic=function(e){return e.outerHTML.trim()},g.formatElement=function(e,t){var n=t>0?"{n}"+"{t}".repeat(t):"",r=["input","option"];if(e.nodeType===f)return n+e.nodeValue;if(e.nodeType===u){var a=e.nodeName.toLowerCase(),o=r.includes(a)?g[a]:g.generic;return n+o(e)}return e.nodeValue?(alert("What am I?"),e.nodeValue):(console.error("Empty form element :("),void console.error(e))},g.formatLabelWrappedElement=function(e){return e.outerHTML+"{n}"},g.hasHtmlChildren=function(e){for(var t=e.childNodes.length,n=0;n0&&n&&(l+="{n}"+"{t}".repeat(t-1)),a=a.replace(s,l)},g.isLabelWrapped=function(e){if(0===e.length)return!1;var t=Array.isArray(e)?e[0]:e;return c.test(t.outerHTML)};var p=/\{n}/g,m=/\{s}/g,h=/\{t}/g,T=function(e){var r=a.getByTag("label",e),o=[].concat(a.getByTag("input",e),a.getByTag("button",e),a.getByTag("textarea",e),a.getByTag("select",e),a.getByTag("datalist",e),a.getByTag("keygen",e),a.getByTag("meter",e),a.getByTag("output",e),a.getByTag("progress",e));if(!Array.isArray(o)&&null!=r)return void console.error("Missing required elements. {}",e);var i="",s="";g.isLabelWrapped(r)?r.forEach(function(e){s+=g.formatLabelWrappedElement(e)}):(i=g.formatHtml(r[0],0),o.forEach(function(e){s+="{n}{n}"+g.formatHtml(e,0)}));var l=i+s.trim(),c=n(l);c=t(c,[[p,"
"],[m," "],[h,"  "]]),c="
"+c+"
";var u=document.createElement("code");u.className="DlHighlight html",u.innerHTML=c,e.appendChild(u)};a.getByTag("form")[0].onsubmit=function(e){return e.preventDefault(),e.stopPropagation(),console.log("Form 'submit' event fired."),!1};var d=/\/polyfills\//,y=a.scripts().filter(function(e){return d.test(e.getAttribute("src"))});if(y.length>0){var v=[];y.forEach(function(t){var n=t.getAttribute("src"),r=e(n).replace(".js","").replace(".min",""),a="
  • "+r+"
  • ";v.includes(a)||v.push(a)});var x=a.getById("polyfills-loaded");x.innerHTML="

    Polyfills loaded by this browser:

    ",x.innerHTML+="
      "+v.join("\n")+"
    "}a.qsa(".form-field").forEach(T)}(); +//# sourceMappingURL=index.min.js.map diff --git a/js/index.min.js.map b/js/index.min.js.map new file mode 100644 index 0000000..55499a1 --- /dev/null +++ b/js/index.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":null,"sources":["../src/functions.js","../src/DlHighlight/highlight-xml-html.js","../src/doc.js","../src/format.js","../src/form-elements-each.js","../src/index.js"],"sourcesContent":["/**\n * Helper functions\n */\n\nimport DlHighlight from './DlHighlight/highlight-xml-html';\n\n/**\n * Returns the final segment of a string split by the specified\n * separator character(s)\n *\n * @param {string} str\n * @param {string} separator\n * @returns {string}\n */\nexport function basename(str, separator=\"/\") {\n\treturn str.substr(str.lastIndexOf(separator) + 1);\n}\n\n/**\n * Do multiple string replacements with a mapping array\n *\n * @param {string} str - The string to modify\n * @param {string[][]} replacements - map [search, replacement]\n * @return {string}\n */\nexport function replaceMultiple(str, replacements) {\n\tlet output = str;\n\n\treplacements.forEach(pair => {\n\t\toutput = output.replace(pair[0], pair[1]);\n\t});\n\n\treturn output;\n}\n\n/**\n * Highlight HTML code\n *\n * @param {string} html\n * @return {string}\n */\nexport function highlightHtml(html) {\n\treturn (new DlHighlight({lang: 'html'})).doItNow(html);\n}\n\n/**\n * Function : dump()\n * Arguments: The data - array,hash(associative array),object\n * The level - OPTIONAL\n * Returns : The textual representation of the array.\n * This function was inspired by the print_r function of PHP.\n * This will accept some data as the argument and return a\n * text that will be a more readable version of the\n * array/hash/object that is given.\n * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php\n */\nexport function dump(arr, level = 0) {\n\tlet dumped_text = \"\";\n\n\t//The padding given at the beginning of the line.\n\tlet level_padding = \"\";\n\tfor(let j=0;j \\\"\" + value + \"\\\"\\n\";\n\t\t\t}\n\t\t}\n\t} else { //Stings/Chars/Numbers etc.\n\t\tdumped_text = \"===>\"+arr+\"<===(\"+typeof(arr)+\")\";\n\t}\n\treturn dumped_text;\n}\n\n/**\n * Default export map\n */\nexport default {\n\tbasename: basename,\n\tdump: dump,\n\thighlightHtml: highlightHtml,\n\treplaceMultiple: replaceMultiple\n};","/**************\\\n * ____ _____\n * DlHighlight -- a JavaScript-based syntax highlighting engine. \\ /_ / /\n * \\ / / /\n * Author: Mihai Bazon, http://mihai.bazon.net/blog \\/ /_ /\n * Copyright: (c) Dynarch.com 2007. All rights reserved. \\ / /\n * http://www.dynarch.com/ / /\n * \\/\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the Free\n * Software Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * This program is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n * more details.\n *\n * You should have received a copy of the GNU General Public License along\n * with this program; if not, write to the Free Software Foundation, Inc., 51\n * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n \\******************************************************************************/\n\n\n/*\n *\n * This thing only cares to colorize a piece of text. It has nothing to do\n * with the DOM, with reading existing text from the DOM and to insert the\n * formatted code back. This facility is present in helpers.js.\n *\n * Assuming the unformatted code is in the \"code\" variable, use DlHighlight\n * this way:\n *\n * var hl = new DlHighlight({ lang : \"js\",\n * lineNumbers : true });\n *\n * formatted = hl.doItNow(code);\n *\n * Now you have in \"formatted\" the colored version.\n *\n * Supported parameters are:\n *\n * - \"lang\" (required) to declare the language\n * - \"lineNumbers\" (optional) if you want line numbers\n * - \"showWhitespace\" (optional) if you want to display whitespace\n * in strings as underscores\n * - \"noTrim\" (optional) pass *true* if you want not to ignore empty\n * newlines at the end of the code\n *\n */\n\nvar DlHighlight = (function(){\n\n\tvar H = function(args) {\n\t\tvar self = this;\n\t\tthis.args = {};\n\t\tfunction D(name, val) {\n\t\t\tif (name in args)\n\t\t\t\tval = args[name];\n\t\t\tself.args[name] = val;\n\t\t}\n\t\tD(\"replaceTabs\", null);\n\t\tD(\"lineNumbers\", false);\n\t\tD(\"noTrim\", false);\n\t\tD(\"showWhitespace\", false);\n\t\tvar lang = this.lang = H.LANG[args.lang];\n\t\tthis.tokenParsers = lang.tokens.slice(0).reverse();\n\t\tif (this.args.replaceTabs != null) {\n\t\t\tvar tab = \" \";\n\t\t\twhile (--this.args.replaceTabs > 0)\n\t\t\t\ttab += \" \";\n\t\t\tthis.args.replaceTabs = tab;\n\t\t}\n\t};\n\n\tH.is_ie = /MSIE/.test(navigator.userAgent) && !/Gecko|KHTML|Opera/.test(navigator.userAgent);\n\n\t// definitions useful for most languages out there\n\tH.BASE = {\n\n\t\tCOMMENT_CPP : function(txt) {\n\t\t\tif (txt.charAt(0) == \"/\" && txt.charAt(1) == \"/\") {\n\t\t\t\tvar nl = txt.indexOf(\"\\n\");\n\t\t\t\tif (nl == -1)\n\t\t\t\t\tnl = txt.length;\n\t\t\t\tvar c = this.lang.onComment.call(this, this._he(txt.substring(2, nl)));\n\t\t\t\treturn {\n\t\t\t\t\tcontent\t: { escaped: c },\n\t\t\t\t\tstyle\t: \"comment comment-line\",\n\t\t\t\t\ttype\t: \"comment\",\n\t\t\t\t\tindex\t: nl,\n\t\t\t\t\tbefore\t: \"//\"\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\tCOMMENT_C : function(txt) {\n\t\t\tif (txt.charAt(0) == \"/\" && txt.charAt(1) == \"*\") {\n\t\t\t\tvar nl = txt.indexOf(\"*/\"), c, index = nl;\n\t\t\t\tif (nl == -1)\n\t\t\t\t\tnl = index = txt.length;\n\t\t\t\telse\n\t\t\t\t\tindex += 2;\n\t\t\t\tc = this.lang.onComment.call(this, this._he(txt.substring(2, nl)));\n\t\t\t\tc = c.replace(/^\\s*[*\\\\|]+/mg, function(s) {\n\t\t\t\t\treturn \"\" + s + \"\";\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tcontent\t: { escaped: c },\n\t\t\t\t\tbefore\t: \"/*\",\n\t\t\t\t\tafter\t: \"*/\",\n\t\t\t\t\tindex\t: index,\n\t\t\t\t\tstyle\t: \"comment comment-multiline\",\n\t\t\t\t\ttype\t: \"comment\"\n\t\t\t\t};\n\n\t\t\t}\n\t\t},\n\n\t\tSTRING : {\n\t\t\tregexp\t: /^(\\x22(\\\\.|[^\\x22\\\\])*\\x22|\\x27(\\\\.|[^\\x27\\\\])*\\x27)/g,\n\t\t\tcontent\t: function(m) {\n\t\t\t\tm = m[1];\n\t\t\t\tm = m.substr(1, m.length - 2);\n\t\t\t\tif (this.args.showWhitespace)\n\t\t\t\t\tm = m.replace(/\\x20/g, \"_\");\n\t\t\t\treturn m;\n\t\t\t},\n\t\t\tbefore : function(m) { return m[1].charAt(0); },\n\t\t\tafter : function(m) { return m[1].charAt(0); },\n\t\t\ttype\t: \"string\",\n\t\t\tstyle\t: \"string\"\n\t\t},\n\n\t\tPAREN : {\n\t\t\tregexp\t: /^[\\](){}\\[]/g,\n\t\t\tcontent\t: 0,\n\t\t\ttype\t: \"paren\",\n\t\t\tstyle\t: \"paren\"\n\t\t},\n\n\t\tOPERATOR : function(txt) {\n\t\t\tvar m = /^[<>!+=%&*\\x2f|?:-]+/.exec(txt);\n\t\t\tif (m && m[0] != \"!/\") return {\n\t\t\t\tcontent\t: m[0],\n\t\t\t\tindex : m.lastIndex,\n\t\t\t\ttype\t: \"operator\",\n\t\t\t\tstyle\t: \"operator\"\n\t\t\t};\n\t\t}\n\n\t};\n\n\tH.prototype = {\n\n\t\tformatToken : function(tok) {\n\t\t\tvar cls = tok.style, html = buffer();\n\t\t\tif (cls instanceof Array)\n\t\t\t\tcls = cls.join(\" \");\n\t\t\thtml(\"\");\n\t\t\tif (tok.before)\n\t\t\t\thtml(\"\", this._he(tok.before), \"\");\n\t\t\thtml(this._he(tok.content));\n\t\t\tif (tok.after)\n\t\t\t\thtml(\"\", this._he(tok.after), \"\");\n\t\t\thtml(\"\");\n\t\t\treturn html.get();\n\t\t},\n\n\t\tformatUnknown : function(txt) {\n\t\t\treturn this._he(txt);\n\t\t},\n\n\t\tgetLastToken : function(pos) {\n\t\t\treturn this.tokens[this.tokens.length - (pos || 0) - 1];\n\t\t},\n\n\t\tlastTokenType : function(re) {\n\t\t\tvar t = this.getLastToken();\n\t\t\tif (t)\n\t\t\t\treturn re.test(t.type);\n\t\t\treturn false;\n\t\t},\n\n\t\tparseToken : function(test, code) {\n\t\t\tvar m, tok;\n\t\t\tif (test.regexp) {\n\t\t\t\ttest.regexp.lastIndex = 0;\n\t\t\t\tm = test.regexp.exec(code);\n\t\t\t\tif (m) {\n\t\t\t\t\ttok = { type : test.type,\n\t\t\t\t\t\tstyle : test.style,\n\t\t\t\t\t\tindex : test.regexp.lastIndex\n\t\t\t\t\t};\n\t\t\t\t\treAdd(this, \"before\", m, test, tok);\n\t\t\t\t\treAdd(this, \"after\", m, test, tok);\n\t\t\t\t\treAdd(this, \"content\", m, test, tok);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttok = test.call(this, code);\n\t\t\t}\n\t\t\treturn tok;\n\t\t},\n\n\t\tdoItNow : function(code) {\n\t\t\tthis.lang.start.call(this, code);\n\t\t\tif (!this.args.noTrim)\n\t\t\t\tcode = code.replace(/\\s+$/, \"\");\n\t\t\tvar formatted = [], T = this.tokenParsers, m, unknown, tok, i, f = 0, tokens;\n\t\t\tunknown = \"\";\n\t\t\ttokens = this.tokens = [];\n\t\t\twhile (code.length > 0) {\n\t\t\t\t// jumping whitespace one character at a time\n\t\t\t\t// might eat a lot of time, let's skip it\n\t\t\t\t// quickly\n\t\t\t\tm = /^\\s+/.exec(code);\n\t\t\t\tif (m) {\n\t\t\t\t\tunknown += m[0];\n\t\t\t\t\tcode = code.substr(m[0].length);\n\t\t\t\t}\n\t\t\t\tfor (i = T.length; --i >= 0;) {\n\t\t\t\t\ttok = this.parseToken(T[i], code);\n\t\t\t\t\tif (tok)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (tok) {\n\t\t\t\t\tif (unknown)\n\t\t\t\t\t\tformatted[f++] = unknown;\n\t\t\t\t\tunknown = \"\";\n\t\t\t\t\tif (!(tok instanceof Array))\n\t\t\t\t\t\ttok = [ tok ];\n\t\t\t\t\tvar index = 0;\n\t\t\t\t\ttokens.push.apply(tokens, tok);\n\t\t\t\t\tfor (var j = 0; j < tok.length; ++j) {\n\t\t\t\t\t\tvar t = tok[j];\n\t\t\t\t\t\tformatted[f++] = t;\n\t\t\t\t\t\tindex += getNextIndex(t);\n\t\t\t\t\t}\n\t\t\t\t\tcode = code.substr(index);\n\t\t\t\t} else {\n\t\t\t\t\tunknown += code.charAt(0);\n\t\t\t\t\tcode = code.substr(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (unknown)\n\t\t\t\tformatted[f++] = unknown;\n\t\t\tfor (i = formatted.length; --i >= 0;) {\n\t\t\t\tf = formatted[i];\n\t\t\t\tif (typeof f == \"string\")\n\t\t\t\t\tformatted[i] = this.formatUnknown(f);\n\t\t\t\telse\n\t\t\t\t\tformatted[i] = this.formatToken(f);\n\t\t\t}\n\t\t\tvar html = formatted.join(\"\");\n\t\t\ti = this.args.lineNumbers;\n\t\t\tif (i) {\n\t\t\t\tif (typeof i != \"number\")\n\t\t\t\t\ti = 0;\n\t\t\t\thtml = html.replace(/^/mg, function() {\n\t\t\t\t\treturn \"\" + (++i) + \"\";\n\t\t\t\t});\n\t\t\t\tthis.args.lineNumbers = i;\n\t\t\t}\n\t\t\t// html = html.replace(/\\n/g, \"
    \");\n\t\t\tthis.lang.stop.call(this);\n\t\t\treturn html;\n\t\t},\n\n\t\t_he : function(str) {\n\t\t\tif (str.escaped)\n\t\t\t\treturn str.escaped;\n\t\t\tstr = str.replace(he_re, function(c) {\n\t\t\t\treturn he_re_val[c];\n\t\t\t});\n\t\t\tif (this.args.replaceTabs)\n\t\t\t\tstr = str.replace(/\\t/g, this.args.replaceTabs);\n\t\t\treturn str;\n\t\t}\n\n\t};\n\n\tvar he_re = /[&<>]/g, he_re_val = {\n\t\t\"&\" : \"&\",\n\t\t\"<\" : \"<\",\n\t\t\">\" : \">\"\n\t};\n\n\tH.LANG = function(id, tokens) {\n\t\tif (arguments.length > 0) {\n\t\t\tH.LANG[id] = this;\n\t\t\tthis.tokens = tokens;\n\t\t}\n\t};\n\n\tH.registerLang = function(type, tokens) {\n\t\tF.prototype = new H.LANG;\n\t\tF.prototype.constructor = F;\n\t\tfunction F() { H.LANG.call(this, type, tokens); };\n\t\treturn new F();\n\t};\n\n\tvar P = H.LANG.prototype;\n\tP.start = P.stop = function(){};\n\n\tP.onComment = function(c) {\n\t\treturn makeUrls(c);\n\t};\n\n\tfunction makeUrls(s) {\n\t\treturn s.replace(/\\b((https?|ftp):\\x2f\\x2f[^\\s\\x22]+)/g, function(url) {\n\t\t\treturn \"\" + url + \"\";\n\t\t});\n\t};\n\n\tfunction reAdd(self, c, m, test, tok) {\n\t\tif (test[c] != null) {\n\t\t\tif (typeof test[c] == \"number\") {\n\t\t\t\ttok[c] = m[test[c]];\n\t\t\t} else if (typeof test[c] == \"function\") {\n\t\t\t\ttok[c] = test[c].call(self, m);\n\t\t\t} else {\n\t\t\t\ttok[c] = test[c];\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getNextIndex(tok) {\n\t\tvar index = tok.index || 0;\n\t\tif (!index) {\n\t\t\t// console.log(\"No index in %s\", tok.style);\n\t\t\tif (tok.before)\n\t\t\t\tindex += tok.before.length;\n\t\t\tif (tok.content)\n\t\t\t\tindex += tok.content.length;\n\t\t\tif (tok.after)\n\t\t\t\tindex += tok.after.length;\n\t\t}\n\t\treturn index;\n\t}\n\n\tvar buffer = H.is_ie\n\t\t? function() {\n\t\tvar a = [], idx = 0, f = function() {\n\t\t\tfor (var i = 0; i < arguments.length; ++i)\n\t\t\t\ta[idx++] = arguments[i];\n\t\t};\n\t\tf.get = function() { return a.join(\"\"); };\n\t\treturn f;\n\t} : function() {\n\t\tvar str = \"\", f = function() {\n\t\t\tstr = str.concat.apply(str, arguments);\n\t\t};\n\t\tf.get = function() { return str; };\n\t\treturn f;\n\t};\n\n/**************\\\n * ____ _____\n * DlHighlight -- a JavaScript-based syntax highlighting engine. \\ /_ / /\n * \\ / / /\n * Author: Mihai Bazon, http://mihai.bazon.net/blog \\/ /_ /\n * Copyright: (c) Dynarch.com 2007. All rights reserved. \\ / /\n * http://www.dynarch.com/ / /\n * \\/\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the Free\n * Software Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * This program is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n * more details.\n *\n * You should have received a copy of the GNU General Public License along\n * with this program; if not, write to the Free Software Foundation, Inc., 51\n * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n \\******************************************************************************/\n\n\tvar T = {\n\n\t\tCOMMENT: function(txt) {\n\t\t\tif (txt.indexOf(\"\",\n\t\t\t\t\tcontent\t: txt.substring(4, nl),\n\t\t\t\t\tindex\t: nl + 3,\n\t\t\t\t\ttype\t: \"comment\",\n\t\t\t\t\tstyle\t: \"comment\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tSTRING: function(txt) {\n\t\t\tif (this.inXmlTag)\n\t\t\t\treturn this.parseToken(H.BASE.STRING, txt);\n\t\t},\n\n\t\tATTRIBUTE: function(txt) {\n\t\t\tvar r = null;\n\t\t\tif (this.inXmlTag) {\n\t\t\t\tvar m = /^([a-z0-9_-]+)(\\s*)=/i.exec(txt);\n\t\t\t\tif (m) {\n\t\t\t\t\treturn [ { content : m[1],\n\t\t\t\t\t\tstyle : \"builtin xml-attribute\" },\n\t\t\t\t\t\t{ content : m[2] }, // whitespace\n\t\t\t\t\t\t{ content : \"=\",\n\t\t\t\t\t\t\tstyle : \"operator\" }\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn r;\n\t\t},\n\n\t\tENTITY: {\n\t\t\tregexp\t: /^&(\\w+);/g,\n\t\t\tbefore\t: \"&\",\n\t\t\tafter\t: \";\",\n\t\t\tcontent\t: 1,\n\t\t\ttype\t: \"builtin\",\n\t\t\tstyle\t: \"builtin xml-entity\"\n\t\t},\n\n\t\tSTART_TAG: function(txt) {\n\t\t\tvar m = /^<([a-z0-9_-]+)/i.exec(txt);\n\t\t\tif (m) {\n\t\t\t\tthis.inXmlTag = m[1];\n\t\t\t\treturn [ { content : \"<\",\n\t\t\t\t\tstyle : \"paren xml-tagangle\" },\n\t\t\t\t\t{ content : m[1],\n\t\t\t\t\t\tstyle : \"keyword xml-tag xml-tag-open\" } ];\n\t\t\t}\n\t\t},\n\n\t\tEND_TAG: function(txt) {\n\t\t\tvar m = /^<\\x2f([a-z0-9_-]+)(\\s*>)/i.exec(txt);\n\t\t\tif (m) {\n\t\t\t\treturn [ { content : \"/.exec(txt);\n\t\t\tif (m) {\n\t\t\t\tthis.inXmlTag = false;\n\t\t\t\treturn {\n\t\t\t\t\tcontent\t: m[0],\n\t\t\t\t\tstyle\t: \"paren xml-tagangle\"\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t};\n\n\tvar lang = H.registerLang(\n\t\t\"xml\", [ T.COMMENT,\n\t\t\tT.STRING,\n\t\t\tT.ATTRIBUTE,\n\t\t\tT.ENTITY,\n\t\t\tT.START_TAG,\n\t\t\tT.END_TAG,\n\t\t\tT.END_ANGLE ]);\n\n\tlang.T = T;\n\n\tlang.start = function() {\n\t\tthis.inXmlTag = false;\n\t};\n\n/**************\\\n * ____ _____\n * DlHighlight -- a JavaScript-based syntax highlighting engine. \\ /_ / /\n * \\ / / /\n * Author: Mihai Bazon, http://mihai.bazon.net/blog \\/ /_ /\n * Copyright: (c) Dynarch.com 2007. All rights reserved. \\ / /\n * http://www.dynarch.com/ / /\n * \\/\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the Free\n * Software Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * This program is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n * more details.\n *\n * You should have received a copy of the GNU General Public License along\n * with this program; if not, write to the Free Software Foundation, Inc., 51\n * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n \\******************************************************************************/\n\n// Inherits most parsers from XML, but modifies END_ANGLE to highlight SCRIPT tags\n\n\tvar re_get_script = /([^\\0]*?)<\\x2fscript>/gi;\n\n\tvar xml = H.LANG.xml;\n\n\tfunction END_ANGLE(txt) {\n\t\tvar m = /^\\x2f?>/.exec(txt);\n\t\tif (m) {\n\t\t\tvar tag = this.inXmlTag;\n\t\t\tthis.inXmlTag = false;\n\t\t\tvar tok = [{ content : m[0],\n\t\t\t\tstyle : \"paren xml-tagangle\" }];\n\t\t\tif (/^script$/i.test(tag) && !/><\\x2fscript>/i.test(txt)) {\n\t\t\t\tre_get_script.lastIndex = 1;\n\t\t\t\tvar m = re_get_script.exec(txt);\n\t\t\t\tif (m && m[1] && m.index == 1) {\n\t\t\t\t\tvar code = m[1];\n\t\t\t\t\tvar index = re_get_script.lastIndex - 10;\n\t\t\t\t\tvar js = new H({ lang: \"js\",\n\t\t\t\t\t\tnoTrim: true }).doItNow(code);\n\t\t\t\t\tvar jstok = {\n\t\t\t\t\t\tcontent\t: { escaped: js },\n\t\t\t\t\t\tstyle\t: \"xml-inline-script\",\n\t\t\t\t\t\tindex\t: index\n\t\t\t\t\t};\n\t\t\t\t\ttok.push(jstok);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tok;\n\t\t}\n\t}\n\n\tH.registerLang(\"html\", [ xml.T.COMMENT,\n\t\txml.T.STRING,\n\t\txml.T.ATTRIBUTE,\n\t\txml.T.ENTITY,\n\t\txml.T.START_TAG,\n\t\txml.T.END_TAG,\n\t\tEND_ANGLE\n\t]);\n\n\treturn H;\n\n})();\n\nexport default DlHighlight;","/**\n * Simple DOM helper methods\n */\nclass Doc {\n\t/**\n\t * Get the list of script elements currently loaded\n\t *\n\t * @return {Element[]}\n\t */\n\tstatic scripts() {\n\t\treturn Array.from(document.scripts);\n\t}\n\t/**\n\t * Search for an HTML element by css selector\n\t *\n\t * @param {string} sel - The css selector\n\t * @param {Element} [context] - An optional parent element to search from\n\t * @return {Element}\n\t */\n\tstatic qs(sel, context = document.documentElement) {\n\t\tif (document.OLD_IE) {\n\t\t\treturn document.documentElement.querySelector.call(context, sel);\n\t\t}\n\n\t\treturn context.querySelector(sel);\n\t}\n\n\t/**\n\t * Get an array of HTML elements by css selector\n\t *\n\t * @param {string} sel - The css selector\n\t * @param {Element} [context] - An optional parent element to search from\n\t * @return {Element[]}\n\t */\n\tstatic qsa(sel, context = document.documentElement) {\n\t\tif (document.OLD_IE) {\n\t\t\treturn Array.from(document.documentElement.querySelectorAll.call(context, sel));\n\t\t}\n\n\t\treturn Array.from(context.querySelectorAll(sel));\n\t}\n\n\t/**\n\t * Get an HTML element by its id attribute\n\t *\n\t * @param {string} id\n\t * @return {Element}\n\t */\n\tstatic getById(id) {\n\t\treturn document.getElementById(id);\n\t}\n\n\t/**\n\t * Get an array of HTML elements by their tag (element) name\n\t *\n\t * @param {string} tagName\n\t * @param {Element} [context] - An optional parent element to search from\n\t * @return {Element[]}\n\t */\n\tstatic getByTag(tagName, context = document.documentElement) {\n\t\treturn Array.from(context.getElementsByTagName(tagName));\n\t}\n}\n\nexport default Doc;\n","// Make sure regex patterns are only parsed once\nconst $whiteSpacePattern = /^\\s+$/ig;\nconst $inputTagPattern = /<(input)(.*?)>/ig;\nconst $optionClosingTagPattern = />(?:\\s+)?<\\/option>/ig;\nconst $htmlAttributeSpacingPattern = /(\\s+)([^in\\s][a-z_\\-]+=(?:\"(?:.*?)\"|[^\"'`=<>\\s]+))/ig;\nconst $labelWrapPattern = /(?:.*?)?(?:\\s+)?(<.*?>)(?:.*?)?(?:\\s+)?<\\/label>/ig;\n\nconst ELEMENT_NODE = 1;\nconst TEXT_NODE = 3;\n\nclass Format {\n\t/**\n\t * Format the display of an input element, and align the attributes\n\t * on separate lines\n\t *\n\t * @param {HTMLInputElement} formElement\n\t * @return {string}\n\t */\n\tstatic input(formElement) {\n\t\t// Let's do some ugly DOM manipulation to make the output of the\n\t\t// highlighted have lined up attributes.\n\t\t// For the spacing, we replace normal whitespace characters with\n\t\t// {x} placeholders so the highlighter doesn't mangle them\n\t\tconst formElementSpaces = '{s}'.repeat(formElement.tagName.length + 2);\n\t\tconst formElementReplace = '{n}' + formElementSpaces;\n\t\treturn formElement.outerHTML\n\t\t\t.trim()\n\t\t\t.replace($inputTagPattern, `<$1$2 />`)\n\t\t\t.replace($htmlAttributeSpacingPattern, formElementReplace + '$2');\n\t}\n\n\t/**\n\t * Format the display of an option element\n\t *\n\t * @param {HTMLOptionElement} formElement\n\t * @return {string}\n\t */\n\tstatic option(formElement) {\n\t\tlet raw = Format.generic(formElement);\n\n\t\tif (Format.hasHtmlChildren(formElement) && formElement.childNodes.length > 0) {\n\t\t\treturn raw;\n\t\t}\n\n\t\traw = raw.replace($whiteSpacePattern, '');\n\t\treturn raw.replace($optionClosingTagPattern, ' />');\n\t}\n\n\t/**\n\t * Format the display of elements without specific formatting methods\n\t *\n\t * @param {HTMLElement} formElement\n\t * @return {string}\n\t */\n\tstatic generic(formElement) {\n\t\treturn formElement.outerHTML.trim();\n\t}\n\n\t/**\n\t * Format the current element\n\t *\n\t * @param {HTMLElement} formElement\n\t * @param {number} i\n\t * @return string\n\t */\n\tstatic formatElement(formElement, i) {\n\t\tconst elementPrefix = (i > 0)\n\t\t\t? '{n}' + '{t}'.repeat(i)\n\t\t\t: '';\n\n\t\tconst formattingMethods = ['input', 'option'];\n\n\t\t// Attempt to indent text nodes\n\t\tif (formElement.nodeType === TEXT_NODE) {\n\t\t\t//alert('Attempting to format a text node');\n\t\t\treturn elementPrefix + formElement.nodeValue;\n\t\t} else if (formElement.nodeType === ELEMENT_NODE) {\n\t\t\tconst tagName = formElement.nodeName.toLowerCase();\n\t\t\tconst formattingMethod = (formattingMethods.includes(tagName))\n\t\t\t\t? Format[tagName]\n\t\t\t\t: Format.generic;\n\n\t\t\treturn elementPrefix + formattingMethod(formElement);\n\t\t} else if (formElement.nodeValue) {\n\t\t\talert('What am I?');\n\t\t\treturn formElement.nodeValue;\n\t\t}\n\n\t\tconsole.error('Empty form element :(');\n\t\tconsole.error(formElement);\n\t}\n\n\t/**\n\t * Format a label-wrapped element\n\t *\n\t * @param {HTMLElement} formElement\n\t * @returns {string}\n\t */\n\tstatic formatLabelWrappedElement(formElement) {\n\t\treturn formElement.outerHTML + '{n}';\n\t}\n\n\t/**\n\t * Check whether an element has an other elements as children\n\t *\n\t * @param {HTMLElement} element\n\t * @return {boolean}\n\t */\n\tstatic hasHtmlChildren(element) {\n\t\tconst numChildren = element.childNodes.length;\n\t\tfor (let x = 0; x < numChildren; x++) {\n\t\t\tconst node = element.childNodes.item(x);\n\n\t\t\t// Only count as a child if the node is an element\n\t\t\tif (node.nodeType === ELEMENT_NODE) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Recursively format the form elements for better alignment\n\t *\n\t * @param {HTMLElement} formElement\n\t * @param {number} level\n\t * @return {string}\n\t */\n\tstatic formatHtml(formElement, level = 0) {\n\t\tconst hasChildren = Format.hasHtmlChildren(formElement);\n\t\tconst isLabelWrapped = Format.isLabelWrapped(formElement);\n\n\t\tlet formattedHTML = (isLabelWrapped)\n\t\t\t? Format.formatLabelWrappedElement(formElement)\n\t\t\t: Format.formatElement(formElement, level);\n\n\t\t// If there are no children, just return the formatted element\n\t\tif (!hasChildren) {\n\t\t\treturn formattedHTML;\n\t\t}\n\n\t\tlet children = Array.from(formElement.childNodes);\n\t\tconst rawChildren = formElement.innerHTML;\n\n\t\t// Discard text nodes if they only contain whitespace\n\t\tchildren = children.filter(node => (!(node.nodeType === TEXT_NODE || $whiteSpacePattern.test(node.nodeValue))));\n\n\t\tlevel++;\n\t\tlet newChildrenHTML = children.reduce((prevHTML, node) => {\n\t\t\treturn prevHTML + Format.formatHtml(node, level);\n\t\t}, '');\n\n\n\t\t// Format those closing tags\n\t\tif (level > 0 && hasChildren) {\n\t\t\tnewChildrenHTML += '{n}' + '{t}'.repeat(level - 1);\n\t\t}\n\n\t\tformattedHTML = formattedHTML.replace(rawChildren, newChildrenHTML);\n\n\t\treturn formattedHTML;\n\t}\n\n\t/**\n\t * Check whether an element\n\t *\n\t * @param {Element|Element[]} labelElements\n\t * @returns {boolean}\n\t */\n\tstatic isLabelWrapped(labelElements) {\n\t\tif (labelElements.length === 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst labelElement = (Array.isArray(labelElements))\n\t\t\t? labelElements[0]\n\t\t\t: labelElements;\n\n\t\treturn $labelWrapPattern.test(labelElement.outerHTML);\n\t}\n}\n\nexport default Format;\n","import Doc from './doc';\nimport Format from './format';\nimport {highlightHtml, replaceMultiple} from './functions';\n\nconst $newLinePattern = /\\{n}/g;\nconst $spacePattern = /\\{s}/g;\nconst $tabPattern = /\\{t}/g;\n\n/**\n * Callback for form element iteration\n *\n * Formats each form element section\n *\n * @param {Element} parent\n */\nconst each = parent => {\n\t// Get the elements required to display\n\tconst labelElements = Doc.getByTag('label', parent);\n\tconst formElements = [].concat(\n\t\tDoc.getByTag('input', parent),\n\t\tDoc.getByTag('button', parent),\n\t\tDoc.getByTag('textarea', parent),\n\t\tDoc.getByTag('select', parent),\n\t\tDoc.getByTag('datalist', parent),\n\t\tDoc.getByTag('keygen', parent),\n\t\tDoc.getByTag('meter', parent),\n\t\tDoc.getByTag('output', parent),\n\t\tDoc.getByTag('progress', parent)\n\t);\n\n\t// If the required elements do not exist, bail out early\n\tif (!(Array.isArray(formElements)) && labelElements != null) {\n\t\tconsole.error('Missing required elements. {}', parent);\n\t\treturn;\n\t}\n\n\tlet labelHTML = '';\n\tlet formElementHTML = '';\n\n\tif (Format.isLabelWrapped(labelElements)) {\n\t\t// If there are labels wrapping the form elements, treat them\n\t\t// a little differently.\n\t\t// Since the elements are wrapped in labels, the label elements are what we want\n\t\t// to work with.\n\t\tlabelElements.forEach(element => {\n\t\t\tformElementHTML += Format.formatLabelWrappedElement(element);\n\t\t});\n\t} else {\n\t\tlabelHTML = Format.formatHtml(labelElements[0], 0);\n\n\t\tformElements.forEach(formElement => {\n\t\t\tformElementHTML += '{n}{n}' + Format.formatHtml(formElement, 0);\n\t\t});\n\t}\n\n\t// Join the label markup with the form element markup\n\tconst formCode = labelHTML + formElementHTML.trim();\n\n\t// Now replace the placeholders with proper whitespace equivalent markup\n\t// Setup up the highlighter\n\tlet highLighted = highlightHtml(formCode);\n\thighLighted = replaceMultiple(highLighted, [\n\t\t[$newLinePattern, '
    '],\n\t\t[$spacePattern, ' '],\n\t\t[$tabPattern, '  ']\n\t]);\n\thighLighted = `
    ${highLighted}
    `;\n\n\t// Piece together the HTML for the prettier HTML examples\n\tconst codeElement = document.createElement('code');\n\tcodeElement.className = 'DlHighlight html';\n\tcodeElement.innerHTML = highLighted;\n\n\t// Append the prettified HTML to the parent element\n\tparent.appendChild(codeElement);\n};\n\nexport default each;","import {basename} from './functions';\nimport each from './form-elements-each';\nimport Doc from './doc';\n\n// Just kill form submission\nDoc.getByTag('form')[0].onsubmit = function (e) {\n\te.preventDefault();\n\te.stopPropagation();\n\n\tconsole.log(`Form 'submit' event fired.`);\n\n\treturn false;\n};\n\n// What polyfills did we have to load?\nconst $polyfillPattern = /\\/polyfills\\//;\nconst scriptList = Doc.scripts().filter(file => {\n\treturn $polyfillPattern.test(file.getAttribute('src'))\n});\nif (scriptList.length > 0) {\n\tconst polyfillList = [];\n\tscriptList.forEach(file => {\n\t\tconst src = file.getAttribute('src');\n\t\tconst name = basename(src).replace('.js', '')\n\t\t\t.replace('.min', '');\n\n\t\tconst el = `
  • ${name}
  • `;\n\n\t\tif (!polyfillList.includes(el)) {\n\t\t\tpolyfillList.push(el);\n\t\t}\n\t});\n\n\tconst tag = Doc.getById('polyfills-loaded');\n\ttag.innerHTML = '

    Polyfills loaded by this browser:

    ';\n\ttag.innerHTML += `
      ${polyfillList.join(\"\\n\")}
    `;\n}\n\n// Get each form field's html and syntax highlight it\nDoc.qsa('.form-field').forEach(each);\n\n\n\n"],"names":["basename","str","separator","substr","lastIndexOf","replaceMultiple","replacements","let","output","forEach","pair","replace","highlightHtml","html","DlHighlight","lang","doItNow","makeUrls","s","url","reAdd","self","c","m","test","tok","call","getNextIndex","index","before","length","content","after","END_ANGLE","txt","exec","tag","this","inXmlTag","style","re_get_script","lastIndex","code","js","H","noTrim","jstok","escaped","push","args","D","name","val","LANG","tokenParsers","tokens","slice","reverse","replaceTabs","tab","is_ie","navigator","userAgent","BASE","COMMENT_CPP","charAt","nl","indexOf","onComment","_he","substring","type","COMMENT_C","STRING","regexp","showWhitespace","PAREN","OPERATOR","prototype","formatToken","cls","buffer","Array","join","get","formatUnknown","getLastToken","pos","lastTokenType","re","t","parseToken","start","unknown","i","formatted","T","f","apply","j","lineNumbers","stop","he_re","he_re_val","&","<",">","id","arguments","registerLang","F","constructor","P","a","idx","concat","COMMENT","ATTRIBUTE","r","ENTITY","START_TAG","END_TAG","xml","Doc","scripts","from","document","qs","sel","context","documentElement","OLD_IE","querySelector","qsa","querySelectorAll","getById","getElementById","getByTag","tagName","getElementsByTagName","const","$whiteSpacePattern","$inputTagPattern","$optionClosingTagPattern","$htmlAttributeSpacingPattern","$labelWrapPattern","ELEMENT_NODE","TEXT_NODE","Format","input","formElement","formElementSpaces","repeat","formElementReplace","outerHTML","trim","option","raw","generic","hasHtmlChildren","childNodes","formatElement","elementPrefix","formattingMethods","nodeType","nodeValue","nodeName","toLowerCase","formattingMethod","includes","alert","console","error","formatLabelWrappedElement","element","numChildren","x","node","item","formatHtml","level","hasChildren","isLabelWrapped","formattedHTML","children","rawChildren","innerHTML","filter","newChildrenHTML","reduce","prevHTML","labelElements","labelElement","isArray","$newLinePattern","$spacePattern","$tabPattern","each","parent","formElements","labelHTML","formElementHTML","formCode","highLighted","codeElement","createElement","className","appendChild","onsubmit","e","preventDefault","stopPropagation","log","$polyfillPattern","scriptList","file","getAttribute","polyfillList","src","el"],"mappings":"wBAcA,SAAgBA,GAASC,EAAKC,GAC7B,sBADuC,KAChCD,EAAIE,OAAOF,EAAIG,YAAYF,GAAa,GAUhD,QAAgBG,GAAgBJ,EAAKK,GACpCC,GAAIC,GAASP,CAMb,OAJAK,GAAaG,QAAQ,SAAAC,GACpBF,EAASA,EAAOG,QAAQD,EAAK,GAAIA,EAAK,MAGhCF,EASR,QAAgBI,GAAcC,GAC7B,MAAO,IAAKC,IAAaC,KAAM,SAAUC,QAAQH,GCWlD,GAAIC,GAAc,WAiQjB,QAASG,GAASC,GACjB,MAAOA,GAAEP,QAAQ,uCAAwC,SAASQ,GACjE,MAAO,YAAcA,EAAM,KAAOA,EAAM,SAI1C,QAASC,GAAMC,EAAMC,EAAGC,EAAGC,EAAMC,GACjB,MAAXD,EAAKF,KACc,gBAAXE,GAAKF,GACfG,EAAIH,GAAKC,EAAEC,EAAKF,IACY,kBAAXE,GAAKF,GACtBG,EAAIH,GAAKE,EAAKF,GAAGI,KAAKL,EAAME,GAE5BE,EAAIH,GAAKE,EAAKF,IAKjB,QAASK,GAAaF,GACrB,GAAIG,GAAQH,EAAIG,OAAS,C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ACfC,EAAa,kBAEfO,EAAc,QAAQA,UAGtB/D,IAAMgE,GAAc9E,SAAS+E,cAAc,OAC3CD,GAAYE,UAAY,mBACxBF,EAAYlB,UAAYiB,EAGxBL,EAAOS,YAAYH,GCrEpBjF,GAAIc,SAAS,QAAQ,GAAGuE,SAAW,SAAUC,GAM5C,MALAA,GAAEC,iBACFD,EAAEE,kBAEFxC,QAAQyC,IAAI,+BAEL,EAIRxE,IAAMyE,GAAmB,gBACnBC,EAAa3F,EAAIC,UAAU+D,OAAO,SAAA4B,GACvC,MAAOF,GAAiB7L,KAAK+L,EAAKC,aAAa,SAEhD,IAAIF,EAAWxL,OAAS,EAAG,CAC1B8G,GAAM6E,KACNH,GAAW7M,QAAQ,SAAA8M,GAClB3E,GAAM8E,GAAMH,EAAKC,aAAa,OACxBrK,EAAOnD,EAAS0N,GAAK/M,QAAQ,MAAO,IACxCA,QAAQ,OAAQ,IAEZgN,EAAK,OAAOxK,SAEbsK,GAAahD,SAASkD,IAC1BF,EAAazK,KAAK2K,IAIpB/E,IAAMxG,GAAMuF,EAAIY,QAAQ,mBACxBnG,GAAIsJ,UAAY,6CAChBtJ,EAAIsJ,WAAa,OAAO+B,EAAatI,KAAK,cAI3CwC,EAAIU,IAAI,eAAe5H,QAAQ4L"} \ No newline at end of file diff --git a/js/load-scripts.js b/js/load-scripts.js new file mode 100644 index 0000000..7972865 --- /dev/null +++ b/js/load-scripts.js @@ -0,0 +1,3 @@ +(function(){function c(b){var a=document.createElement("script");a.src=b;a.async=!1;document.body.appendChild(a)}for(var a=[[!document.body.outerHTML,"js/polyfills/Dom/Element.outerHTML.min.js"],[!Array.from,"js/polyfills/EcmaScript/Array.from.js"],[!Array.isArray,"js/polyfills/EcmaScript/Array.isArray.js"],[!Array.from,"js/polyfills/EcmaScript/Array.from.js"],[!Array.prototype.filter,"js/polyfills/EcmaScript/Array.prototype.filter.js"],[!Array.prototype.forEach,"js/polyfills/EcmaScript/Array.prototype.forEach.js"], +[!Array.prototype.includes,"js/polyfills/EcmaScript/Array.prototype.includes.js"],[!Array.prototype.reduce,"js/polyfills/EcmaScript/Array.prototype.reduce.js"],[!String.prototype.repeat,"js/polyfills/EcmaScript/String.prototype.repeat.js"],[!String.prototype.trim,"js/polyfills/EcmaScript/String.prototype.trim.js"]],d=a.length,b=0;bp&&h[2])ma.test(h[2])?"even"===h[2]?h[2]=[s,2]:"odd"===h[2]?h[2]=[s,2,"%",1]:(h[2]=h[2].match(na),h[2][0]=s):h[2]=[s,0,"%",h[2]],h[3]=p?"nodeIndexLast":"nodeIndex",h[4]=p?"lastChild":"firstChild",h[5]=p?"previousSibling":"nextSibling"; + else if(17===p)f||C(),q=j,g=x?c:[c],a[r]=s;else if(12==p&&(m=h[2]))oa.test(m.charAt(0))&&oa.test(m.charAt(m.length-1))&&(h[2]=m.substr(1,m.length-2));1==a.length&&a[0]===s&&(a=s)}q&&(J=0);if(1==J)if(L){L=9===n.nodeType?n:n.ownerDocument;if(pa){g=L.getElementsByName(F);H=[];for(r=-1;b=g[++r];)b.id==F&&H.push(b)}else{H=[];for(g=[];b=L.getElementById(F);)g.push(b),m="id"in b?b.id:b.getAttribute("id"),m==F&&H.push(b),b.setAttribute("id",F+" _");for(r=-1;b=g[++r];)b.setAttribute("id",F)}g=s;L=u}else M= + M&&!I,R=R&&I&&!!G;q=(!x||1===c.length)&&!t&&!i&&!A&&!a&&!R&&!M&&!L&&!z;do{switch(J){case 0:b=g[0];break;case 1:if(F)if(g=[],H.length)if(1+~\s])\s*/g,Ca=/~=/g,Fa=/(^|,|>|\+|~|\s).*?(?=[,>+~\s]|$)/g,da=/\./g,ra=/\s/g,Ga=/^([,>+~\s])?([\w\-\|\*]*)#?([\w-]*)((?:\.?[\w-])*)(\[.+\])?(?::([^!]+))?(!)?$/,ia=/^\[?['"]?(.*?)['"]?(?:([\*~&\^\$@!]?=)['"]?(.*?)['"]?)?\]?$/,ka=/^([^(]+)(?:\((.+)\))?$/,Da=/\-child\((\dn)\+(\d)\)/g,Ea="-child\\($1%$2\\)",na=/(?:([-]?\d*)n)?(?:(%|-)(\d*))?/,Ia=/([,>+~\s])/,Ja=/^\s+/, + ca=/\s/,ma=/\D/,oa=/['"]/,ba={"":1,",":1,">":2,"~":3,"+":4},ja={"":1,"=":2,"&=":3,"^=":4,"$=":5,"*=":6,"|=":7,"!=":8,"@=":9},la={"nth-child":0,"nth-last-child":1,"only-child":2,"first-child":3,"last-child":4,root:5,empty:6,checked:7,lang:8,enabled:9,disabled:10,selected:11,contains:12,not:13,matches:14,"read-only":15,"read-write":16,scope:17,focus:18,"nth-match":19,column:20,"nth-column":21},Ka={checked:s,disabled:s,ismap:s,multiple:s,readonly:s,selected:s},La={value:"defaultValue",checked:"defaultChecked", + selected:"defaultSelected"},Ma={action:s,cite:s,codebase:s,data:s,href:s,longdesc:s,lowsrc:s,src:s,usemap:s},Y=document.documentElement;function U(a){for(var c=a.length>>>0,e=new Z,i=0;iparent.NodeList=Array;<\/script>"),Z=w.NodeList);I||(Na=function(a){var c=[],e=this.all,i,g=-1;if(e.length)for(a=RegExp((a+"").replace(K,O));i=e[++g];)i.className&&a.test(i.className)&&c.push(i);return c}); + qa=Oa?function(a,c){c=c.toLowerCase();return La[c]!==d?a[La[c]]||"":Ma[c]!==d?a.getAttribute(c,2)||"":Ka[c]!==d?a.getAttribute(c)?c:"":(a=a.getAttributeNode(c))&&a.value||""}:function(a,c){return a.getAttribute(c)}; + T=Y.matches||Y.webkitMatchesSelector||Y.mozMatchesSelector||Y.msMatchesSelector||Y.oMatchesSelector?function(a){if(!a)return u;if("*"===a||":root"===a&&this===Y||"body"===a&&this===document.body)return j;var c,e,i=u;if(!Ia.test(a)&&(c=this.parentNode)&&"querySelector"in c)i=c.querySelector(a),i!==s&&(i=i===this);if(!i&&i!==s&&(c=this.ownerDocument))for(e in a=c.querySelectorAll(a),a)if(Object.prototype.hasOwnProperty.call(a,e)&&(i=a[e]===this))return j;return!!i}:function(a){if(!a)return u;if("*"=== + a||this===Y&&":root"===a||this===document.body&&"BODY"===a.toUpperCase())return j;var c,e,i=u,g,a=Aa.call(a);if(c=a.match(Ha))switch(a.charAt(0)){case "#":return this.id===a.slice(1);default:return i=!(e=c[2])||this.className&&RegExp(e.replace(da," ").replace(K,O)).test(this.className),!!(i&&!(e=c[1])||this.tagName&&this.tagName.toUpperCase()===e.toUpperCase())}else{if(Ia.test(a)){e=ta.call(this.ownerDocument,a);for(g in e)if(Object.prototype.hasOwnProperty.call(e,g)&&(i=e[g]===this))return j;return u}e= + aa(a.match(Ga),s,s,u,this,j);return e[0]===this}};$="matchesSelector";Y[$]||(V.matches=Y.matches=V[$]=Y[$]=T);$="matches";$ in V||(V[$]=document.documentElement[$]=V.matchesSelector);$="querySelectorAll";V[$]=Y[$]=document[$]=function(a,c){return ta.call(this,a,u,c)};$="querySelector";V[$]=Y[$]=document[$]=function(a,c){return ta.call(this,a,j,c)||s};$="getElementsByClassName";document[$]||(V[$]=Y[$]=document[$]=Na);V=$=s; +})(); diff --git a/js/polyfills/Dom/Element.outerHTML.js b/js/polyfills/Dom/Element.outerHTML.js new file mode 100644 index 0000000..b504527 --- /dev/null +++ b/js/polyfills/Dom/Element.outerHTML.js @@ -0,0 +1,75 @@ +/* + * outerHTML.js + * Cross-browser full HTMLElement.outerHTML implementation. + * + * 2011-11-14 + * + * By Eli Grey, http://eligrey.com + * Public Domain. + * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + */ + +if (typeof document !== "undefined" && typeof document.createElementNS !== "undefined" && !("outerHTML" in document.createElementNS("http://www.w3.org/1999/xhtml", "_"))) { + +(function(view) { +"use strict"; + +var + container = document.createElementNS("http://www.w3.org/1999/xhtml", "_") + , elem_proto = (view.HTMLElement || view.Element).prototype + , xml_serializer = new XMLSerializer + , outerHTML_getter = function() { + var + node = this + , html + ; + if (document.xmlVersion) { + return xml_serializer.serializeToString(node); + } else { + container.appendChild(node.cloneNode(false)); + html = container.innerHTML.replace("><", ">" + node.innerHTML + "<"); + container.innerHTML = ""; + return html; + } + } + , outerHTML_setter = function(html) { + var + node = this + , parent = node.parentNode + , child + ; + if (parent === null) { + DOMException.code = DOMException.NOT_FOUND_ERR; + throw DOMException; + } + container.innerHTML = html; + while ((child = container.firstChild)) { + parent.insertBefore(child, node); + } + parent.removeChild(node); + } +; + +if (Object.defineProperty) { + var outerHTML_prop_desc = { + get: outerHTML_getter + , set: outerHTML_setter + , enumerable: true + , configurable: true + }; + try { + Object.defineProperty(elem_proto, "outerHTML", outerHTML_prop_desc); + } catch (ex) { // IE 8 doesn't support enumerable:true + if (ex.number === -0x7FF5EC54) { + outerHTML_prop_desc.enumerable = false; + Object.defineProperty(elem_proto, "outerHTML", outerHTML_prop_desc); + } + } +} else if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) { + elem_proto.__defineGetter__("outerHTML", outerHTML_getter); + elem_proto.__defineSetter__("outerHTML", outerHTML_setter); +} + +}(self)); + +} \ No newline at end of file diff --git a/js/polyfills/Dom/Element.outerHTML.min.js b/js/polyfills/Dom/Element.outerHTML.min.js new file mode 100644 index 0000000..595ea6b --- /dev/null +++ b/js/polyfills/Dom/Element.outerHTML.min.js @@ -0,0 +1,4 @@ +"undefined"===typeof document||"undefined"===typeof document.createElementNS||"outerHTML"in document.createElementNS("http://www.w3.org/1999/xhtml","_")||function(a){function e(b){var a=this.parentNode;if(null===a)throw DOMException.a=DOMException.NOT_FOUND_ERR,DOMException;for(c.innerHTML=b;b=c.firstChild;)a.insertBefore(b,this);a.removeChild(this)}function f(){var a;if(document.xmlVersion)return g.serializeToString(this);c.appendChild(this.cloneNode(!1));a=c.innerHTML.replace("><",">"+this.innerHTML+ +"<");c.innerHTML="";return a}var c=document.createElementNS("http://www.w3.org/1999/xhtml","_");a=(a.HTMLElement||a.Element).prototype;var g=new XMLSerializer;if(Object.defineProperty){var d={get:f,set:e,enumerable:!0,configurable:!0};try{Object.defineProperty(a,"outerHTML",d)}catch(b){-2146823252===b.b&&(d.enumerable=!1,Object.defineProperty(a,"outerHTML",d))}}else Object.prototype.__defineGetter__&&Object.prototype.__defineSetter__&&(a.__defineGetter__("outerHTML",f),a.__defineSetter__("outerHTML", +e))}(self); +//# sourceMappingURL=Element.outerHTML.min.js.map \ No newline at end of file diff --git a/js/polyfills/Dom/Element.outerHTML.min.js.map b/js/polyfills/Dom/Element.outerHTML.min.js.map new file mode 100644 index 0000000..0a8b972 --- /dev/null +++ b/js/polyfills/Dom/Element.outerHTML.min.js.map @@ -0,0 +1,8 @@ +{ +"version":3, +"file":"js/polyfills/Dom/Element.outerHTML.min.js", +"lineCount":3, +"mappings":"AAWwB,WAAxB,GAAI,MAAOA,SAAX,EAA2E,WAA3E,GAAuC,MAAOA,SAAAC,gBAA9C,EAA4F,WAA5F,EAA2GD,SAAAC,gBAAA,CAAyB,8BAAzB,CAAyD,GAAzD,CAA3G,EAEC,QAAQ,CAACC,CAAD,CAAO,CAqBMC,QAAA,EAAQ,CAACC,CAAD,CAAO,CAAA,IAGhCC,EADOC,IACEC,WAGZ,IAAe,IAAf,GAAIF,CAAJ,CAEC,KADAG,aAAAC,EACMD,CADcA,YAAAE,cACdF,CAAAA,YAAN,CAGD,IADAG,CAAAC,UACA,CADsBR,CACtB,CAAQS,CAAR,CAAgBF,CAAAG,WAAhB,CAAA,CACCT,CAAAU,aAAA,CAAoBF,CAApB,CAVSP,IAUT,CAEDD,EAAAW,YAAA,CAZUV,IAYV,CAdmC,CAdfW,QAAA,EAAQ,EAAG,CAC/B,IAEGb,CAEH,IAAIJ,QAAAkB,WAAJ,CACC,MAAOC,EAAAC,kBAAA,CAJEd,IAIF,CAEPK,EAAAU,YAAA,CANSf,IAMagB,UAAA,CAAe,CAAA,CAAf,CAAtB,CACAlB,EAAA,CAAOO,CAAAC,UAAAW,QAAA,CAA4B,IAA5B,CAAkC,GAAlC,CAPEjB,IAOsCM,UAAxC;AAAyD,GAAzD,CACPD,EAAAC,UAAA,CAAsB,EACtB,OAAOR,EAXuB,CAPjB,IAIbO,EAAYX,QAAAC,gBAAA,CAAyB,8BAAzB,CAAyD,GAAzD,CACZuB,EAAAA,CAAaC,CAACvB,CAAAwB,YAADD,EAAqBvB,CAAAyB,QAArBF,WALA,KAMbN,EAAiB,IAAIS,aAiCxB,IAAIC,MAAAC,eAAJ,CAA2B,CAC1B,IAAIC,EAAsB,CACvBC,IAAKf,CADkB,CAEvBgB,IAAK9B,CAFkB,CAGvB+B,WAAY,CAAA,CAHW,CAIvBC,aAAc,CAAA,CAJS,CAM1B,IAAI,CACHN,MAAAC,eAAA,CAAsBN,CAAtB,CAAkC,WAAlC,CAA+CO,CAA/C,CADG,CAEF,MAAOK,CAAP,CAAW,CACO,WAAnB,GAAIA,CAAAC,EAAJ,GACCN,CAAAG,WACA,CADiC,CAAA,CACjC,CAAAL,MAAAC,eAAA,CAAsBN,CAAtB,CAAkC,WAAlC,CAA+CO,CAA/C,CAFD,CADY,CATa,CAA3B,IAeWF,OAAAJ,UAAAa,iBAAJ,EAAyCT,MAAAJ,UAAAc,iBAAzC,GACNf,CAAAc,iBAAA,CAA4B,WAA5B,CAAyCrB,CAAzC,CACA,CAAAO,CAAAe,iBAAA,CAA4B,WAA5B;AAAyCpC,CAAzC,CAFM,CAtDS,CAAf,CA2DCqC,IA3DD;", +"sources":["js/polyfills/Dom/Element.outerHTML.js"], +"names":["document","createElementNS","view","outerHTML_setter","html","parent","node","parentNode","DOMException","code","NOT_FOUND_ERR","container","innerHTML","child","firstChild","insertBefore","removeChild","outerHTML_getter","xmlVersion","xml_serializer","serializeToString","appendChild","cloneNode","replace","elem_proto","prototype","HTMLElement","Element","XMLSerializer","Object","defineProperty","outerHTML_prop_desc","get","set","enumerable","configurable","ex","number","__defineGetter__","__defineSetter__","self"] +} diff --git a/js/polyfills/Dom/outerHTML.min.js b/js/polyfills/Dom/outerHTML.min.js new file mode 100644 index 0000000..562d165 --- /dev/null +++ b/js/polyfills/Dom/outerHTML.min.js @@ -0,0 +1 @@ +//# sourceMappingURL=outerHTML.min.js.map \ No newline at end of file diff --git a/js/polyfills/EcmaScript/Array.from.js b/js/polyfills/EcmaScript/Array.from.js new file mode 100644 index 0000000..41afbd9 --- /dev/null +++ b/js/polyfills/EcmaScript/Array.from.js @@ -0,0 +1,3 @@ +Array.from=function(){function h(c){return"function"===typeof c||"[object Function]"===l.call(c)}var l=Object.prototype.toString,m=Math.pow(2,53)-1;return function(c){var k=Object(c);if(null==c)throw new TypeError("Array.from requires an array-like object - not null or undefined");var d=1>>0;if("function"!==typeof c)throw new TypeError;1>>0;if("function"!==typeof c)throw new TypeError;for(var d=[],g=2<=arguments.length?arguments[1]:void 0,a=0;a>>0;if("function"!==typeof c)throw new TypeError(c+" is not a function");1a&&(a=0));for(var b;a>>0;if("function"!==typeof d)throw new TypeError(d+" is not a function");1>>0,a=0,c;if(2==arguments.length)c=arguments[1];else{for(;a=e)throw new TypeError("Reduce of empty array with no initial value");c=b[a++]}for(;athis.length?!1:-1!==this.indexOf(b,a)}; +//# sourceMappingURL=String.prototype.includes.js.map \ No newline at end of file diff --git a/js/polyfills/EcmaScript/String.prototype.includes.js.map b/js/polyfills/EcmaScript/String.prototype.includes.js.map new file mode 100644 index 0000000..07ea5b4 --- /dev/null +++ b/js/polyfills/EcmaScript/String.prototype.includes.js.map @@ -0,0 +1,8 @@ +{ +"version":3, +"file":"js/polyfills/EcmaScript/String.prototype.includes.js", +"lineCount":1, +"mappings":"AAAAA,MAAAC,UAAAC,SAAA,CAA4BC,QAAQ,CAACC,CAAD,CAASC,CAAT,CAAgB,CAE7B,QAArB,GAAI,MAAOA,EAAX,GACDA,CADC,CACO,CADP,CAIA,OAAIA,EAAJ,CAAYD,CAAAE,OAAZ,CAA4B,IAAAA,OAA5B,CACM,CAAA,CADN,CAGuC,EAHvC,GAGM,IAAAC,QAAA,CAAaH,CAAb,CAAqBC,CAArB,CAT4C;", +"sources":["src/polyfills/String.prototype.includes.js"], +"names":["String","prototype","includes","String.prototype.includes","search","start","length","indexOf"] +} diff --git a/js/polyfills/EcmaScript/String.prototype.repeat.js b/js/polyfills/EcmaScript/String.prototype.repeat.js new file mode 100644 index 0000000..12b039d --- /dev/null +++ b/js/polyfills/EcmaScript/String.prototype.repeat.js @@ -0,0 +1,2 @@ +String.prototype.repeat=function(a){if(!this)throw new TypeError("can't convert "+this+" to object");var b=""+this;a=+a;a!=a&&(a=0);if(0>a)throw new RangeError("repeat count must be non-negative");if(Infinity==a)throw new RangeError("repeat count must be less than infinity");a=Math.floor(a);if(!b.length||!a)return"";if(268435456<=b.length*a)throw new RangeError("repeat count must not overflow maximum string size");for(var c="";;){1==(a&1)&&(c+=b);a>>>=1;if(!a)break;b+=b}return c}; +//# sourceMappingURL=String.prototype.repeat.js.map \ No newline at end of file diff --git a/js/polyfills/EcmaScript/String.prototype.repeat.js.map b/js/polyfills/EcmaScript/String.prototype.repeat.js.map new file mode 100644 index 0000000..3a79c60 --- /dev/null +++ b/js/polyfills/EcmaScript/String.prototype.repeat.js.map @@ -0,0 +1,8 @@ +{ +"version":3, +"file":"js/polyfills/EcmaScript/String.prototype.repeat.js", +"lineCount":1, +"mappings":"AAAAA,MAAAC,UAAAC,OAAA,CAA0BC,QAAQ,CAACC,CAAD,CAAQ,CAEzC,GAAI,CAAA,IAAJ,CACC,KAAM,KAAIC,SAAJ,CAAc,gBAAd,CAAkC,IAAlC,CAAyC,YAAzC,CAAN,CAED,IAAIC,EAAM,EAANA,CAAW,IACfF,EAAA,CAAQ,CAACA,CACLA,EAAJ,EAAaA,CAAb,GACCA,CADD,CACS,CADT,CAGA,IAAY,CAAZ,CAAIA,CAAJ,CACC,KAAM,KAAIG,UAAJ,CAAe,mCAAf,CAAN,CAED,GAAaC,QAAb,EAAIJ,CAAJ,CACC,KAAM,KAAIG,UAAJ,CAAe,yCAAf,CAAN,CAEDH,CAAA,CAAQK,IAAAC,MAAA,CAAWN,CAAX,CACR,IAAIO,CAAAL,CAAAK,OAAJ,EAAuBP,CAAAA,CAAvB,CACC,MAAO,EAKR,IAA0B,SAA1B,EAAIE,CAAAK,OAAJ,CAAiBP,CAAjB,CACC,KAAM,KAAIG,UAAJ,CAAe,oDAAf,CAAN,CAGD,IADA,IAAIK,EAAM,EACV,CAAA,CAAA,CAAS,CACW,CAAnB,GAAKR,CAAL,CAAa,CAAb,IACCQ,CADD,EACQN,CADR,CAGAF,EAAA,IAAW,CACX,IAAIA,CAAAA,CAAJ,CACC,KAEDE,EAAA,EAAOA,CARC,CAYT,MAAOM,EAvCkC;", +"sources":["src/polyfills/String.prototype.repeat.js"], +"names":["String","prototype","repeat","String.prototype.repeat","count","TypeError","str","RangeError","Infinity","Math","floor","length","rpt"] +} diff --git a/js/polyfills/EcmaScript/String.prototype.trim.js b/js/polyfills/EcmaScript/String.prototype.trim.js new file mode 100644 index 0000000..19adff1 --- /dev/null +++ b/js/polyfills/EcmaScript/String.prototype.trim.js @@ -0,0 +1,2 @@ +String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}; +//# sourceMappingURL=String.prototype.trim.js.map \ No newline at end of file diff --git a/js/polyfills/EcmaScript/String.prototype.trim.js.map b/js/polyfills/EcmaScript/String.prototype.trim.js.map new file mode 100644 index 0000000..a021880 --- /dev/null +++ b/js/polyfills/EcmaScript/String.prototype.trim.js.map @@ -0,0 +1,8 @@ +{ +"version":3, +"file":"js/polyfills/EcmaScript/String.prototype.trim.js", +"lineCount":1, +"mappings":"AAAAA,MAAAC,UAAAC,KAAA,CAAwBC,QAAS,EAAG,CACnC,MAAO,KAAAC,QAAA,CAAa,oCAAb,CAAmD,EAAnD,CAD4B;", +"sources":["src/polyfills/String.prototype.trim.js"], +"names":["String","prototype","trim","String.prototype.trim","replace"] +} diff --git a/js/polyfills/html5shiv.min.js b/js/polyfills/html5shiv.min.js new file mode 100644 index 0000000..355afd1 --- /dev/null +++ b/js/polyfills/html5shiv.min.js @@ -0,0 +1,4 @@ +/** +* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); \ No newline at end of file diff --git a/js/polyfills/ie-array-slice-shim.js b/js/polyfills/ie-array-slice-shim.js new file mode 100644 index 0000000..399e0a5 --- /dev/null +++ b/js/polyfills/ie-array-slice-shim.js @@ -0,0 +1,64 @@ +/** + * Shim for "fixing" IE's lack of support (IE < 9) for applying slice + * on host objects like NamedNodeMap, NodeList, and HTMLCollection + * (technically, since host objects have been implementation-dependent, + * at least before ES6, IE hasn't needed to work this way). + * Also works on strings, fixes IE < 9 to allow an explicit undefined + * for the 2nd argument (as in Firefox), and prevents errors when + * called on other DOM objects. + */ +(function () { + 'use strict'; + var _slice = Array.prototype.slice; + + try { + // Can't be used with DOM elements in IE < 9 + _slice.call(document.documentElement); + } catch (e) { // Fails in IE < 9 + // This will work for genuine arrays, array-like objects, + // NamedNodeMap (attributes, entities, notations), + // NodeList (e.g., getElementsByTagName), HTMLCollection (e.g., childNodes), + // and will not fail on other DOM objects (as do DOM elements in IE < 9) + Array.prototype.slice = function(begin, end) { + // IE < 9 gets unhappy with an undefined end argument + end = (typeof end !== 'undefined') ? end : this.length; + + // For native Array objects, we use the native slice function + if (Object.prototype.toString.call(this) === '[object Array]'){ + return _slice.call(this, begin, end); + } + + // For array like object we handle it ourselves. + var i, cloned = [], + size, len = this.length; + + // Handle negative value for "begin" + var start = begin || 0; + start = (start >= 0) ? start : Math.max(0, len + start); + + // Handle negative value for "end" + var upTo = (typeof end == 'number') ? Math.min(end, len) : len; + if (end < 0) { + upTo = len + end; + } + + // Actual expected size of the slice + size = upTo - start; + + if (size > 0) { + cloned = new Array(size); + if (this.charAt) { + for (i = 0; i < size; i++) { + cloned[i] = this.charAt(start + i); + } + } else { + for (i = 0; i < size; i++) { + cloned[i] = this[start + i]; + } + } + } + + return cloned; + }; + } +}()); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..814d841 --- /dev/null +++ b/package.json @@ -0,0 +1,72 @@ +{ + "name": "html5-forms-cheatsheet", + "version": "1.0.0", + "description": "Examples of best practices for HTML forms", + "main": "index.html", + "devDependencies": { + "autoprefixer": "^6.4.1", + "ava": "^0.16.0", + "cssnano": "^3.7.5", + "glob": "^7.1.0", + "google-closure-compiler": "^20160911.0.0", + "happiness": "^7.1.2", + "postcss": "^5.2.2", + "postcss-cli": "^2.6.0", + "postcss-css-variables": "^0.6.0", + "rollup": "^0.35.11", + "rollup-plugin-buble": "^0.13.0", + "rollup-plugin-cleanup": "^0.1.4", + "rollup-plugin-commonjs": "^4.1.0", + "rollup-plugin-filesize": "^0.5.5", + "rollup-plugin-node-resolve": "^2.0.0", + "rollup-plugin-sizes": "^0.2.3", + "rollup-plugin-strip": "^1.1.1", + "rollup-plugin-uglify": "^1.0.1", + "rollup-watch": "^2.5.0", + "xo": "^0.16.0" + }, + "dependencies": {}, + "scripts": { + "build": "NODE_ENV=production rollup -c", + "build:css": "postcss -c postcss.json && cat css/normalize.min.css > css/bundle.min.css && cat css/dlH.min.css >> css/bundle.min.css && cat css/style.min.css >> css/bundle.min.css", + "build:dev": "rollup -c", + "lint": "xo src/*.js rollup.config.js", + "min-all": "node ./tools/min-all.js", + "test": "ava", + "watch:js": "rollup -c --watch", + "watch:css": "postcss -w -c postcss.json" + }, + "keywords": [ + "html5", + "html", + "forms" + ], + "author": "Timothy J. Warren ", + "license": "MIT", + "xo": { + "esnext": true, + "envs": [ + "browser" + ], + "ignore": [ + "src/polyfills/*.js", + "src/old/*.js", + "src/DlHighlight/*.js", + "src/load-scripts.js" + ], + "rules": { + "camelcase": 0, + "operator-linebreak": ["error", "before"] + }, + "overrides": [ + { + "files": "src/loadScripts.js", + "esnext": false + }, + { + "files": "tools/min.js", + "camelcase": "ignore" + } + ] + } +} diff --git a/postcss.json b/postcss.json new file mode 100644 index 0000000..4fdee34 --- /dev/null +++ b/postcss.json @@ -0,0 +1,14 @@ +{ + "use": ["autoprefixer", "postcss-css-variables", "cssnano"], + "input": "css/src/style.css", + "output": "css/style.min.css", + "autoprefixer": { + "browsers": "> 1%" + }, + "cssnano": { + "autoprefixer": false + }, + "postcss-css-variables": { + "preserve": true + } +} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..c9486aa --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,46 @@ +// Rollup plugins +import buble from 'rollup-plugin-buble'; +import cleanup from 'rollup-plugin-cleanup'; +import commonjs from 'rollup-plugin-commonjs'; +import filesize from 'rollup-plugin-filesize'; +import resolve from 'rollup-plugin-node-resolve'; +import sizes from 'rollup-plugin-sizes'; +import strip from 'rollup-plugin-strip'; +import uglify from 'rollup-plugin-uglify'; + +export default { + entry: 'src/index.js', + dest: 'js/index.min.js', + format: 'iife', + sourceMap: true, + useStrict: true, + plugins: [ + resolve({ + jsnext: true, + main: true, + browser: true + }), + commonjs({ + include: 'node_modules/**', + exclude: [] + }), + buble({ + exclude: 'node_modules/**' + }), + /*strip({ + debugger: false, + functions: ['console.*', 'assert.*', 'debug', 'alert'] + }),*/ + (process.env.NODE_ENV === 'production') + ? uglify({ + negate_iife: false, + support_ie8: true + }) + : cleanup({ + maxEmptyLines: 0, + comments: 'none' + }), + filesize(), + sizes() + ] +}; diff --git a/src/DlHighlight/highlight-xml-html.js b/src/DlHighlight/highlight-xml-html.js new file mode 100644 index 0000000..b2cd58c --- /dev/null +++ b/src/DlHighlight/highlight-xml-html.js @@ -0,0 +1,554 @@ +/**************\ + * ____ _____ + * DlHighlight -- a JavaScript-based syntax highlighting engine. \ /_ / / + * \ / / / + * Author: Mihai Bazon, http://mihai.bazon.net/blog \/ /_ / + * Copyright: (c) Dynarch.com 2007. All rights reserved. \ / / + * http://www.dynarch.com/ / / + * \/ + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + \******************************************************************************/ + + +/* + * + * This thing only cares to colorize a piece of text. It has nothing to do + * with the DOM, with reading existing text from the DOM and to insert the + * formatted code back. This facility is present in helpers.js. + * + * Assuming the unformatted code is in the "code" variable, use DlHighlight + * this way: + * + * var hl = new DlHighlight({ lang : "js", + * lineNumbers : true }); + * + * formatted = hl.doItNow(code); + * + * Now you have in "formatted" the colored version. + * + * Supported parameters are: + * + * - "lang" (required) to declare the language + * - "lineNumbers" (optional) if you want line numbers + * - "showWhitespace" (optional) if you want to display whitespace + * in strings as underscores + * - "noTrim" (optional) pass *true* if you want not to ignore empty + * newlines at the end of the code + * + */ + +var DlHighlight = (function(){ + + var H = function(args) { + var self = this; + this.args = {}; + function D(name, val) { + if (name in args) + val = args[name]; + self.args[name] = val; + } + D("replaceTabs", null); + D("lineNumbers", false); + D("noTrim", false); + D("showWhitespace", false); + var lang = this.lang = H.LANG[args.lang]; + this.tokenParsers = lang.tokens.slice(0).reverse(); + if (this.args.replaceTabs != null) { + var tab = " "; + while (--this.args.replaceTabs > 0) + tab += " "; + this.args.replaceTabs = tab; + } + }; + + H.is_ie = /MSIE/.test(navigator.userAgent) && !/Gecko|KHTML|Opera/.test(navigator.userAgent); + + // definitions useful for most languages out there + H.BASE = { + + COMMENT_CPP : function(txt) { + if (txt.charAt(0) == "/" && txt.charAt(1) == "/") { + var nl = txt.indexOf("\n"); + if (nl == -1) + nl = txt.length; + var c = this.lang.onComment.call(this, this._he(txt.substring(2, nl))); + return { + content : { escaped: c }, + style : "comment comment-line", + type : "comment", + index : nl, + before : "//" + }; + } + }, + + COMMENT_C : function(txt) { + if (txt.charAt(0) == "/" && txt.charAt(1) == "*") { + var nl = txt.indexOf("*/"), c, index = nl; + if (nl == -1) + nl = index = txt.length; + else + index += 2; + c = this.lang.onComment.call(this, this._he(txt.substring(2, nl))); + c = c.replace(/^\s*[*\\|]+/mg, function(s) { + return "" + s + ""; + }); + return { + content : { escaped: c }, + before : "/*", + after : "*/", + index : index, + style : "comment comment-multiline", + type : "comment" + }; + + } + }, + + STRING : { + regexp : /^(\x22(\\.|[^\x22\\])*\x22|\x27(\\.|[^\x27\\])*\x27)/g, + content : function(m) { + m = m[1]; + m = m.substr(1, m.length - 2); + if (this.args.showWhitespace) + m = m.replace(/\x20/g, "_"); + return m; + }, + before : function(m) { return m[1].charAt(0); }, + after : function(m) { return m[1].charAt(0); }, + type : "string", + style : "string" + }, + + PAREN : { + regexp : /^[\](){}\[]/g, + content : 0, + type : "paren", + style : "paren" + }, + + OPERATOR : function(txt) { + var m = /^[<>!+=%&*\x2f|?:-]+/.exec(txt); + if (m && m[0] != "!/") return { + content : m[0], + index : m.lastIndex, + type : "operator", + style : "operator" + }; + } + + }; + + H.prototype = { + + formatToken : function(tok) { + var cls = tok.style, html = buffer(); + if (cls instanceof Array) + cls = cls.join(" "); + html(""); + if (tok.before) + html("", this._he(tok.before), ""); + html(this._he(tok.content)); + if (tok.after) + html("", this._he(tok.after), ""); + html(""); + return html.get(); + }, + + formatUnknown : function(txt) { + return this._he(txt); + }, + + getLastToken : function(pos) { + return this.tokens[this.tokens.length - (pos || 0) - 1]; + }, + + lastTokenType : function(re) { + var t = this.getLastToken(); + if (t) + return re.test(t.type); + return false; + }, + + parseToken : function(test, code) { + var m, tok; + if (test.regexp) { + test.regexp.lastIndex = 0; + m = test.regexp.exec(code); + if (m) { + tok = { type : test.type, + style : test.style, + index : test.regexp.lastIndex + }; + reAdd(this, "before", m, test, tok); + reAdd(this, "after", m, test, tok); + reAdd(this, "content", m, test, tok); + } + } else { + tok = test.call(this, code); + } + return tok; + }, + + doItNow : function(code) { + this.lang.start.call(this, code); + if (!this.args.noTrim) + code = code.replace(/\s+$/, ""); + var formatted = [], T = this.tokenParsers, m, unknown, tok, i, f = 0, tokens; + unknown = ""; + tokens = this.tokens = []; + while (code.length > 0) { + // jumping whitespace one character at a time + // might eat a lot of time, let's skip it + // quickly + m = /^\s+/.exec(code); + if (m) { + unknown += m[0]; + code = code.substr(m[0].length); + } + for (i = T.length; --i >= 0;) { + tok = this.parseToken(T[i], code); + if (tok) + break; + } + if (tok) { + if (unknown) + formatted[f++] = unknown; + unknown = ""; + if (!(tok instanceof Array)) + tok = [ tok ]; + var index = 0; + tokens.push.apply(tokens, tok); + for (var j = 0; j < tok.length; ++j) { + var t = tok[j]; + formatted[f++] = t; + index += getNextIndex(t); + } + code = code.substr(index); + } else { + unknown += code.charAt(0); + code = code.substr(1); + } + } + if (unknown) + formatted[f++] = unknown; + for (i = formatted.length; --i >= 0;) { + f = formatted[i]; + if (typeof f == "string") + formatted[i] = this.formatUnknown(f); + else + formatted[i] = this.formatToken(f); + } + var html = formatted.join(""); + i = this.args.lineNumbers; + if (i) { + if (typeof i != "number") + i = 0; + html = html.replace(/^/mg, function() { + return "" + (++i) + ""; + }); + this.args.lineNumbers = i; + } + // html = html.replace(/\n/g, "
    "); + this.lang.stop.call(this); + return html; + }, + + _he : function(str) { + if (str.escaped) + return str.escaped; + str = str.replace(he_re, function(c) { + return he_re_val[c]; + }); + if (this.args.replaceTabs) + str = str.replace(/\t/g, this.args.replaceTabs); + return str; + } + + }; + + var he_re = /[&<>]/g, he_re_val = { + "&" : "&", + "<" : "<", + ">" : ">" + }; + + H.LANG = function(id, tokens) { + if (arguments.length > 0) { + H.LANG[id] = this; + this.tokens = tokens; + } + }; + + H.registerLang = function(type, tokens) { + F.prototype = new H.LANG; + F.prototype.constructor = F; + function F() { H.LANG.call(this, type, tokens); }; + return new F(); + }; + + var P = H.LANG.prototype; + P.start = P.stop = function(){}; + + P.onComment = function(c) { + return makeUrls(c); + }; + + function makeUrls(s) { + return s.replace(/\b((https?|ftp):\x2f\x2f[^\s\x22]+)/g, function(url) { + return "" + url + ""; + }); + }; + + function reAdd(self, c, m, test, tok) { + if (test[c] != null) { + if (typeof test[c] == "number") { + tok[c] = m[test[c]]; + } else if (typeof test[c] == "function") { + tok[c] = test[c].call(self, m); + } else { + tok[c] = test[c]; + } + } + } + + function getNextIndex(tok) { + var index = tok.index || 0; + if (!index) { + // console.log("No index in %s", tok.style); + if (tok.before) + index += tok.before.length; + if (tok.content) + index += tok.content.length; + if (tok.after) + index += tok.after.length; + } + return index; + } + + var buffer = H.is_ie + ? function() { + var a = [], idx = 0, f = function() { + for (var i = 0; i < arguments.length; ++i) + a[idx++] = arguments[i]; + }; + f.get = function() { return a.join(""); }; + return f; + } : function() { + var str = "", f = function() { + str = str.concat.apply(str, arguments); + }; + f.get = function() { return str; }; + return f; + }; + +/**************\ + * ____ _____ + * DlHighlight -- a JavaScript-based syntax highlighting engine. \ /_ / / + * \ / / / + * Author: Mihai Bazon, http://mihai.bazon.net/blog \/ /_ / + * Copyright: (c) Dynarch.com 2007. All rights reserved. \ / / + * http://www.dynarch.com/ / / + * \/ + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + \******************************************************************************/ + + var T = { + + COMMENT: function(txt) { + if (txt.indexOf("", + content : txt.substring(4, nl), + index : nl + 3, + type : "comment", + style : "comment" + } + } + }, + + STRING: function(txt) { + if (this.inXmlTag) + return this.parseToken(H.BASE.STRING, txt); + }, + + ATTRIBUTE: function(txt) { + var r = null; + if (this.inXmlTag) { + var m = /^([a-z0-9_-]+)(\s*)=/i.exec(txt); + if (m) { + return [ { content : m[1], + style : "builtin xml-attribute" }, + { content : m[2] }, // whitespace + { content : "=", + style : "operator" } + ]; + } + } + return r; + }, + + ENTITY: { + regexp : /^&(\w+);/g, + before : "&", + after : ";", + content : 1, + type : "builtin", + style : "builtin xml-entity" + }, + + START_TAG: function(txt) { + var m = /^<([a-z0-9_-]+)/i.exec(txt); + if (m) { + this.inXmlTag = m[1]; + return [ { content : "<", + style : "paren xml-tagangle" }, + { content : m[1], + style : "keyword xml-tag xml-tag-open" } ]; + } + }, + + END_TAG: function(txt) { + var m = /^<\x2f([a-z0-9_-]+)(\s*>)/i.exec(txt); + if (m) { + return [ { content : "/.exec(txt); + if (m) { + this.inXmlTag = false; + return { + content : m[0], + style : "paren xml-tagangle" + }; + } + } + + }; + + var lang = H.registerLang( + "xml", [ T.COMMENT, + T.STRING, + T.ATTRIBUTE, + T.ENTITY, + T.START_TAG, + T.END_TAG, + T.END_ANGLE ]); + + lang.T = T; + + lang.start = function() { + this.inXmlTag = false; + }; + +/**************\ + * ____ _____ + * DlHighlight -- a JavaScript-based syntax highlighting engine. \ /_ / / + * \ / / / + * Author: Mihai Bazon, http://mihai.bazon.net/blog \/ /_ / + * Copyright: (c) Dynarch.com 2007. All rights reserved. \ / / + * http://www.dynarch.com/ / / + * \/ + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + \******************************************************************************/ + +// Inherits most parsers from XML, but modifies END_ANGLE to highlight SCRIPT tags + + var re_get_script = /([^\0]*?)<\x2fscript>/gi; + + var xml = H.LANG.xml; + + function END_ANGLE(txt) { + var m = /^\x2f?>/.exec(txt); + if (m) { + var tag = this.inXmlTag; + this.inXmlTag = false; + var tok = [{ content : m[0], + style : "paren xml-tagangle" }]; + if (/^script$/i.test(tag) && !/><\x2fscript>/i.test(txt)) { + re_get_script.lastIndex = 1; + var m = re_get_script.exec(txt); + if (m && m[1] && m.index == 1) { + var code = m[1]; + var index = re_get_script.lastIndex - 10; + var js = new H({ lang: "js", + noTrim: true }).doItNow(code); + var jstok = { + content : { escaped: js }, + style : "xml-inline-script", + index : index + }; + tok.push(jstok); + } + } + return tok; + } + } + + H.registerLang("html", [ xml.T.COMMENT, + xml.T.STRING, + xml.T.ATTRIBUTE, + xml.T.ENTITY, + xml.T.START_TAG, + xml.T.END_TAG, + END_ANGLE + ]); + + return H; + +})(); + +export default DlHighlight; \ No newline at end of file diff --git a/src/doc.js b/src/doc.js new file mode 100644 index 0000000..955a14a --- /dev/null +++ b/src/doc.js @@ -0,0 +1,65 @@ +/** + * Simple DOM helper methods + */ +class Doc { + /** + * Get the list of script elements currently loaded + * + * @return {Element[]} + */ + static scripts() { + return Array.from(document.scripts); + } + /** + * Search for an HTML element by css selector + * + * @param {string} sel - The css selector + * @param {Element} [context] - An optional parent element to search from + * @return {Element} + */ + static qs(sel, context = document.documentElement) { + if (document.OLD_IE) { + return document.documentElement.querySelector.call(context, sel); + } + + return context.querySelector(sel); + } + + /** + * Get an array of HTML elements by css selector + * + * @param {string} sel - The css selector + * @param {Element} [context] - An optional parent element to search from + * @return {Element[]} + */ + static qsa(sel, context = document.documentElement) { + if (document.OLD_IE) { + return Array.from(document.documentElement.querySelectorAll.call(context, sel)); + } + + return Array.from(context.querySelectorAll(sel)); + } + + /** + * Get an HTML element by its id attribute + * + * @param {string} id + * @return {Element} + */ + static getById(id) { + return document.getElementById(id); + } + + /** + * Get an array of HTML elements by their tag (element) name + * + * @param {string} tagName + * @param {Element} [context] - An optional parent element to search from + * @return {Element[]} + */ + static getByTag(tagName, context = document.documentElement) { + return Array.from(context.getElementsByTagName(tagName)); + } +} + +export default Doc; diff --git a/src/form-elements-each.js b/src/form-elements-each.js new file mode 100644 index 0000000..eda0189 --- /dev/null +++ b/src/form-elements-each.js @@ -0,0 +1,78 @@ +import Doc from './doc'; +import Format from './format'; +import {highlightHtml, replaceMultiple} from './functions'; + +const $newLinePattern = /\{n}/g; +const $spacePattern = /\{s}/g; +const $tabPattern = /\{t}/g; + +/** + * Callback for form element iteration + * + * Formats each form element section + * + * @param {Element} parent + */ +const each = parent => { + // Get the elements required to display + const labelElements = Doc.getByTag('label', parent); + const formElements = [].concat( + Doc.getByTag('input', parent), + Doc.getByTag('button', parent), + Doc.getByTag('textarea', parent), + Doc.getByTag('select', parent), + Doc.getByTag('datalist', parent), + Doc.getByTag('keygen', parent), + Doc.getByTag('meter', parent), + Doc.getByTag('output', parent), + Doc.getByTag('progress', parent) + ); + + // If the required elements do not exist, bail out early + if (!(Array.isArray(formElements)) && labelElements != null) { + console.error('Missing required elements. {}', parent); + return; + } + + let labelHTML = ''; + let formElementHTML = ''; + + if (Format.isLabelWrapped(labelElements)) { + // If there are labels wrapping the form elements, treat them + // a little differently. + // Since the elements are wrapped in labels, the label elements are what we want + // to work with. + labelElements.forEach(element => { + formElementHTML += Format.formatLabelWrappedElement(element); + }); + } else { + labelHTML = Format.formatHtml(labelElements[0], 0); + + formElements.forEach(formElement => { + formElementHTML += '{n}{n}' + Format.formatHtml(formElement, 0); + }); + } + + // Join the label markup with the form element markup + const formCode = labelHTML + formElementHTML.trim(); + + // Now replace the placeholders with proper whitespace equivalent markup + // Setup up the highlighter + let highLighted = highlightHtml(formCode); + highLighted = replaceMultiple(highLighted, [ + [$newLinePattern, '
    '], + [$spacePattern, ' '], + [$tabPattern, '  '] + ]); + highLighted = `
    ${highLighted}
    `; + + // Piece together the HTML for the prettier HTML examples + const codeElement = document.createElement('code'); + codeElement.className = 'DlHighlight html'; + codeElement.innerHTML = highLighted; + + // Append the prettified HTML to the parent element + parent.appendChild(codeElement); +}; + +export default each; \ No newline at end of file diff --git a/src/format.js b/src/format.js new file mode 100644 index 0000000..8b95465 --- /dev/null +++ b/src/format.js @@ -0,0 +1,184 @@ +// Make sure regex patterns are only parsed once +const $whiteSpacePattern = /^\s+$/ig; +const $inputTagPattern = /<(input)(.*?)>/ig; +const $optionClosingTagPattern = />(?:\s+)?<\/option>/ig; +const $htmlAttributeSpacingPattern = /(\s+)([^in\s][a-z_\-]+=(?:"(?:.*?)"|[^"'`=<>\s]+))/ig; +const $labelWrapPattern = /(?:.*?)?(?:\s+)?(<.*?>)(?:.*?)?(?:\s+)?<\/label>/ig; + +const ELEMENT_NODE = 1; +const TEXT_NODE = 3; + +class Format { + /** + * Format the display of an input element, and align the attributes + * on separate lines + * + * @param {HTMLInputElement} formElement + * @return {string} + */ + static input(formElement) { + // Let's do some ugly DOM manipulation to make the output of the + // highlighted have lined up attributes. + // For the spacing, we replace normal whitespace characters with + // {x} placeholders so the highlighter doesn't mangle them + const formElementSpaces = '{s}'.repeat(formElement.tagName.length + 2); + const formElementReplace = '{n}' + formElementSpaces; + return formElement.outerHTML + .trim() + .replace($inputTagPattern, `<$1$2 />`) + .replace($htmlAttributeSpacingPattern, formElementReplace + '$2'); + } + + /** + * Format the display of an option element + * + * @param {HTMLOptionElement} formElement + * @return {string} + */ + static option(formElement) { + let raw = Format.generic(formElement); + + if (Format.hasHtmlChildren(formElement) && formElement.childNodes.length > 0) { + return raw; + } + + raw = raw.replace($whiteSpacePattern, ''); + return raw.replace($optionClosingTagPattern, ' />'); + } + + /** + * Format the display of elements without specific formatting methods + * + * @param {HTMLElement} formElement + * @return {string} + */ + static generic(formElement) { + return formElement.outerHTML.trim(); + } + + /** + * Format the current element + * + * @param {HTMLElement} formElement + * @param {number} i + * @return string + */ + static formatElement(formElement, i) { + const elementPrefix = (i > 0) + ? '{n}' + '{t}'.repeat(i) + : ''; + + const formattingMethods = ['input', 'option']; + + // Attempt to indent text nodes + if (formElement.nodeType === TEXT_NODE) { + //alert('Attempting to format a text node'); + return elementPrefix + formElement.nodeValue; + } else if (formElement.nodeType === ELEMENT_NODE) { + const tagName = formElement.nodeName.toLowerCase(); + const formattingMethod = (formattingMethods.includes(tagName)) + ? Format[tagName] + : Format.generic; + + return elementPrefix + formattingMethod(formElement); + } else if (formElement.nodeValue) { + alert('What am I?'); + return formElement.nodeValue; + } + + console.error('Empty form element :('); + console.error(formElement); + } + + /** + * Format a label-wrapped element + * + * @param {HTMLElement} formElement + * @returns {string} + */ + static formatLabelWrappedElement(formElement) { + return formElement.outerHTML + '{n}'; + } + + /** + * Check whether an element has an other elements as children + * + * @param {HTMLElement} element + * @return {boolean} + */ + static hasHtmlChildren(element) { + const numChildren = element.childNodes.length; + for (let x = 0; x < numChildren; x++) { + const node = element.childNodes.item(x); + + // Only count as a child if the node is an element + if (node.nodeType === ELEMENT_NODE) { + return true; + } + } + + return false; + } + + /** + * Recursively format the form elements for better alignment + * + * @param {HTMLElement} formElement + * @param {number} level + * @return {string} + */ + static formatHtml(formElement, level = 0) { + const hasChildren = Format.hasHtmlChildren(formElement); + const isLabelWrapped = Format.isLabelWrapped(formElement); + + let formattedHTML = (isLabelWrapped) + ? Format.formatLabelWrappedElement(formElement) + : Format.formatElement(formElement, level); + + // If there are no children, just return the formatted element + if (!hasChildren) { + return formattedHTML; + } + + let children = Array.from(formElement.childNodes); + const rawChildren = formElement.innerHTML; + + // Discard text nodes if they only contain whitespace + children = children.filter(node => (!(node.nodeType === TEXT_NODE || $whiteSpacePattern.test(node.nodeValue)))); + + level++; + let newChildrenHTML = children.reduce((prevHTML, node) => { + return prevHTML + Format.formatHtml(node, level); + }, ''); + + + // Format those closing tags + if (level > 0 && hasChildren) { + newChildrenHTML += '{n}' + '{t}'.repeat(level - 1); + } + + formattedHTML = formattedHTML.replace(rawChildren, newChildrenHTML); + + return formattedHTML; + } + + /** + * Check whether an element + * + * @param {Element|Element[]} labelElements + * @returns {boolean} + */ + static isLabelWrapped(labelElements) { + if (labelElements.length === 0) { + return false; + } + + const labelElement = (Array.isArray(labelElements)) + ? labelElements[0] + : labelElements; + + return $labelWrapPattern.test(labelElement.outerHTML); + } +} + +export default Format; diff --git a/src/functions.js b/src/functions.js new file mode 100644 index 0000000..ec7285c --- /dev/null +++ b/src/functions.js @@ -0,0 +1,89 @@ +/** + * Helper functions + */ + +import DlHighlight from './DlHighlight/highlight-xml-html'; + +/** + * Returns the final segment of a string split by the specified + * separator character(s) + * + * @param {string} str + * @param {string} separator + * @returns {string} + */ +export function basename(str, separator="/") { + return str.substr(str.lastIndexOf(separator) + 1); +} + +/** + * Do multiple string replacements with a mapping array + * + * @param {string} str - The string to modify + * @param {string[][]} replacements - map [search, replacement] + * @return {string} + */ +export function replaceMultiple(str, replacements) { + let output = str; + + replacements.forEach(pair => { + output = output.replace(pair[0], pair[1]); + }); + + return output; +} + +/** + * Highlight HTML code + * + * @param {string} html + * @return {string} + */ +export function highlightHtml(html) { + return (new DlHighlight({lang: 'html'})).doItNow(html); +} + +/** + * Function : dump() + * Arguments: The data - array,hash(associative array),object + * The level - OPTIONAL + * Returns : The textual representation of the array. + * This function was inspired by the print_r function of PHP. + * This will accept some data as the argument and return a + * text that will be a more readable version of the + * array/hash/object that is given. + * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php + */ +export function dump(arr, level = 0) { + let dumped_text = ""; + + //The padding given at the beginning of the line. + let level_padding = ""; + for(let j=0;j \"" + value + "\"\n"; + } + } + } else { //Stings/Chars/Numbers etc. + dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; + } + return dumped_text; +} + +/** + * Default export map + */ +export default { + basename: basename, + dump: dump, + highlightHtml: highlightHtml, + replaceMultiple: replaceMultiple +}; \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0c22e0a --- /dev/null +++ b/src/index.js @@ -0,0 +1,43 @@ +import {basename} from './functions'; +import each from './form-elements-each'; +import Doc from './doc'; + +// Just kill form submission +Doc.getByTag('form')[0].onsubmit = function (e) { + e.preventDefault(); + e.stopPropagation(); + + console.log(`Form 'submit' event fired.`); + + return false; +}; + +// What polyfills did we have to load? +const $polyfillPattern = /\/polyfills\//; +const scriptList = Doc.scripts().filter(file => { + return $polyfillPattern.test(file.getAttribute('src')) +}); +if (scriptList.length > 0) { + const polyfillList = []; + scriptList.forEach(file => { + const src = file.getAttribute('src'); + const name = basename(src).replace('.js', '') + .replace('.min', ''); + + const el = `
  • ${name}
  • `; + + if (!polyfillList.includes(el)) { + polyfillList.push(el); + } + }); + + const tag = Doc.getById('polyfills-loaded'); + tag.innerHTML = '

    Polyfills loaded by this browser:

    '; + tag.innerHTML += `
      ${polyfillList.join("\n")}
    `; +} + +// Get each form field's html and syntax highlight it +Doc.qsa('.form-field').forEach(each); + + + diff --git a/src/load-scripts.js b/src/load-scripts.js new file mode 100644 index 0000000..586763c --- /dev/null +++ b/src/load-scripts.js @@ -0,0 +1,40 @@ +(function () { + 'use strict'; + + function loadBodyScript(src) { + var tag = document.createElement('script'); + tag.src = src; + tag.async = false; + document.body.appendChild(tag); + } + + // Polyfill feature checks + // [, ] + var ESPath = 'js/polyfills/EcmaScript/'; + var polyfills = [ + [!document.body.outerHTML, 'js/polyfills/Dom/Element.outerHTML.min.js'], + [!Array.from, ESPath + 'Array.from.js'], + [!Array.isArray, ESPath + 'Array.isArray.js'], + [!Array.from, ESPath + 'Array.from.js'], + [!Array.prototype.filter, ESPath + 'Array.prototype.filter.js'], + [!Array.prototype.forEach, ESPath + 'Array.prototype.forEach.js'], + [!Array.prototype.includes, ESPath + 'Array.prototype.includes.js'], + //[!Array.prototype.map, ESPath + 'Array.prototype.map.js'], + [!Array.prototype.reduce, ESPath + 'Array.prototype.reduce.js'], + [!String.prototype.repeat, ESPath + 'String.prototype.repeat.js'], + [!String.prototype.trim, ESPath + 'String.prototype.trim.js'] + ]; + + var polyfillCount = polyfills.length; + var i = 0; + + // Load polyfills based on feature checks + for (; i < polyfillCount; i++) { + if (polyfills[i][0]) { + loadBodyScript(polyfills[i][1]); + } + } + + // Load the actual code + loadBodyScript('js/index.min.js'); +})(); diff --git a/src/old/doc.js b/src/old/doc.js new file mode 100644 index 0000000..45f77b4 --- /dev/null +++ b/src/old/doc.js @@ -0,0 +1,88 @@ +(this || window).doc = (function() { + "use strict"; + + var docProto = { + /** + * Create a proper JavaScript array from an array-like object + * + * @param {object} arrayLike + * @return {array} + */ + toArray: function(arrayLike) { + return [].slice.call(arrayLike); + }, + /** + * Search for an HTML element by css selector + * + * @param {string} sel - The css selector + * @param {Element} [context] - An optional parent element to search from + * @return {Element} + */ + qs: function(sel, context) { + context = context || document; + return context.querySelector(sel); + }, + /** + * Get an array of HTML elements by css selector + * + * @param {string} sel - The css selector + * @param {Element} [context] - An optional parent element to search from + * @return {Element[]} + */ + qsa: function(sel, context) { + context = context || document; + return this.toArray(context.querySelectorAll(sel)); + }, + /** + * Get an HTML element by its id attribute + * + * @param {string} id + * @param {Element} [context] - An optional parent element to search from + * @return {Element} + */ + getById: function(id, context) { + context = context || document; + return context.getElementById(id); + }, + /** + * Get an array of HTML elements by their tag (element) name + * + * @param {string} tagName + * @param {Element} [context] - An optional parent element to search from + * @return {Element[]} + */ + getByTag: function(tagName, context) { + context = context || document; + return this.toArray(context.getElementsByTagName(tagName)); + }, + /** + * Get an array of HTML elements searching by a class + * + * @param {string} className + * @param {Element} [context] - An optional parent element to search from + * @return {Element[]} + */ + getByClass: function(className, context) { + context = context || document; + return this.toArray(context.getElementsByClassName(className)); + }, + /** + * Do multiple string replacements with a mapping array + * + * @param {string} str - The string to modify + * @param {string[][]} replacements - map [search, replacement] + * @return {string} + */ + replaceMultiple: function(str, replacements) { + var output = str; + + replacements.forEach(function(pair) { + output = output.replace(pair[0], pair[1]); + }); + + return output; + } + }; + + return Object.create(docProto); +}()); \ No newline at end of file diff --git a/src/old/init.js b/src/old/init.js new file mode 100644 index 0000000..f4c7cfc --- /dev/null +++ b/src/old/init.js @@ -0,0 +1,202 @@ +(function ($) { + "use strict"; + + // Make sure regex patterns are only parsed once + var $newLinePattern = /\{n}/g, + $spacePattern = /\{s}/g, + $tabPattern = /\{t}/g, + $whiteSpacePattern = /^(?:\s+)?$/g, + $inputTagPattern = //g, + $optionClosingTagPattern = />(?:\s+)?<\/option>/g, + $htmlAttributeSpacingPattern = /(\s+)([^id][a-z_\-]+="(?:.*?)")/ig; + + // Just kill form submission + $.qs('form').onsubmit = function(e) { + e.preventDefault(); + e.stopPropagation(); + + console.log("Form 'submit' event fired."); + + return false; + }; + + var format = { + /** + * Format the display of an input element, and align the attributes + * on separate lines + * + * @param {HTMLInputElement} formElement + * @return {string} + */ + input: function (formElement) { + // Let's do some ugly DOM manipulation to make the output of the + // highlighted have lined up attributes. + // For the spacing, we replace normal whitespace characters with + // {x} placeholders so the highlighter doesn't mangle them + var formElementSpaces = '{s}'.repeat(formElement.tagName.length + 2); + var formElementReplace = '{n}' + formElementSpaces; + var formElementHTML = formElement.outerHTML + .trim() + .replace($inputTagPattern, '') + .replace($htmlAttributeSpacingPattern, formElementReplace + '$2'); + + return formElementHTML; + }, + /** + * Format the display of an option element + * + * @param {HTMLOptionElement} formElement + * @return {string} + */ + option: function (formElement) { + var raw = format.generic(formElement); + + if (hasHtmlChildren(formElement) && formElement.childNodes.length > 0) { + return raw; + } + + raw = raw.replace($whiteSpacePattern, ''); + return raw.replace($optionClosingTagPattern, ' />'); + }, + /** + * Format the display of elements without specific formatting methods + * + * @param {HTMLElement} formElement + * @return {string} + */ + generic: function (formElement) { + return formElement.outerHTML.trim(); + } + }; + + /** + * Format the current element + * + * @param {HTMLElement} formElement + * @param {number} i + * @return string + */ + function formatElement (formElement, i) { + var elementPrefix = (i > 0) + ? '{n}' + '{t}'.repeat(i) + : ''; + + if (formElement.nodeType === 3) { + return elementPrefix + formElement.nodeValue; + } + + var tagName = formElement.tagName.toLowerCase(); + var formattingMethod = (Object.keys(format).indexOf(tagName) !== -1) + ? format[tagName] + : format.generic; + + return elementPrefix + formattingMethod(formElement); + } + + /** + * Check whether an element has an other elements as children + * + * @param {HTMLElement} element + * @return {boolean} + */ + function hasHtmlChildren (element) { + var x = 0; + var node; + var numChildren = element.childNodes.length; + + if (numChildren === 0) { + return false; + } + + for (; x < numChildren; x++) { + node = element.childNodes.item(x); + + // Only count as a child if the node is an element + if (node.nodeType === 1) { + return true; + } + } + + return false; + } + + /** + * Recursively format the form elements for better alignment + * + * @param {HTMLElement} formElement + * @param {number} level + * @return {string} + */ + function formatHtml(formElement, level) { + level = level || 0; + + var children = $.toArray(formElement.childNodes); + var hasChildren = hasHtmlChildren(formElement); + + var rawChildren = formElement.innerHTML; + var formattedHTML = formatElement(formElement, level); + + // If there are no children, just return the formatted element + if (!hasChildren) { + return formattedHTML; + } + + children = children.filter(function (node) { + // Discard text nodes if they only contain whitespace + if (node.nodeType === 3 && node.nodeValue.match($whiteSpacePattern)) { + return false; + } + + // Keep other nodes + return true; + }); + + level++; + var newChildrenHTML = children.reduce(function (prevHTML, node) { + return prevHTML + formatHtml(node, level); + }, ''); + + // Format those closing tags + if (level > 0 && hasChildren) { + newChildrenHTML += '{n}' + '{t}'.repeat(level - 1); + } + + formattedHTML = formattedHTML.replace(rawChildren, newChildrenHTML); + + return formattedHTML; + } + + // Get each form field's html and syntax highlight it + $.getByClass('form-field').forEach(function(parent) { + // Setup up the highligher + var hl = new DlHighlight({lang: 'html'}); + + var labelHTML = formatHtml($.qs('label', parent), 0); + var formElements = $.qsa('button, input, datalist, keygen, meter, output, progress, select, textarea', parent); + + var formElementHTML = ''; + formElements.forEach(function (formElement) { + formElementHTML += '{n}{n}' + formatHtml(formElement, 0); + }); + + // Join the label markup with the form element markup + var formCode = labelHTML + formElementHTML.trim(); + + // Now replace the placeholders with proper whitespace equvalent markup + var highLighted = hl.doItNow(formCode); + highLighted = $.replaceMultiple(highLighted, [ + [$newLinePattern, '
    '], + [$spacePattern, ' '], + [$tabPattern, ' '.repeat(4)] + ]); + + // Piece together the HTML for the prettier HTML examples + var codeElement = document.createElement('code'); + codeElement.className = 'DlHighlight html'; + codeElement.innerHTML = highLighted; + + // Append the prettified HTML to the parent element + parent.appendChild(codeElement); + }); + +}(doc)); \ No newline at end of file diff --git a/src/polyfills/Array.from.js b/src/polyfills/Array.from.js new file mode 100644 index 0000000..81719ac --- /dev/null +++ b/src/polyfills/Array.from.js @@ -0,0 +1,76 @@ +// Production steps of ECMA-262, Edition 6, 22.1.2.1 +// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from +Array.from = (function () { + var toStr = Object.prototype.toString; + var isCallable = function (fn) { + return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; + }; + var toInteger = function (value) { + var number = Number(value); + if (isNaN(number)) { return 0; } + if (number === 0 || !isFinite(number)) { return number; } + return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); + }; + var maxSafeInteger = Math.pow(2, 53) - 1; + var toLength = function (value) { + var len = toInteger(value); + return Math.min(Math.max(len, 0), maxSafeInteger); + }; + + // The length property of the from method is 1. + return function from(arrayLike/*, mapFn, thisArg */) { + // 1. Let C be the this value. + var C = this; + + // 2. Let items be ToObject(arrayLike). + var items = Object(arrayLike); + + // 3. ReturnIfAbrupt(items). + if (arrayLike == null) { + throw new TypeError("Array.from requires an array-like object - not null or undefined"); + } + + // 4. If mapfn is undefined, then let mapping be false. + var mapFn = arguments.length > 1 ? arguments[1] : void undefined; + var T; + if (typeof mapFn !== 'undefined') { + // 5. else + // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. + if (!isCallable(mapFn)) { + throw new TypeError('Array.from: when provided, the second argument must be a function'); + } + + // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. + if (arguments.length > 2) { + T = arguments[2]; + } + } + + // 10. Let lenValue be Get(items, "length"). + // 11. Let len be ToLength(lenValue). + var len = toLength(items.length); + + // 13. If IsConstructor(C) is true, then + // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len. + // 14. a. Else, Let A be ArrayCreate(len). + var A = isCallable(C) ? Object(new C(len)) : new Array(len); + + // 16. Let k be 0. + var k = 0; + // 17. Repeat, while k < len… (also steps a - h) + var kValue; + while (k < len) { + kValue = items[k]; + if (mapFn) { + A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); + } else { + A[k] = kValue; + } + k += 1; + } + // 18. Let putStatus be Put(A, "length", len, true). + A.length = len; + // 20. Return A. + return A; + }; +}()); \ No newline at end of file diff --git a/src/polyfills/Array.isArray.js b/src/polyfills/Array.isArray.js new file mode 100644 index 0000000..a355fd3 --- /dev/null +++ b/src/polyfills/Array.isArray.js @@ -0,0 +1,3 @@ +Array.isArray = function(arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; +}; \ No newline at end of file diff --git a/src/polyfills/Array.prototype.every.js b/src/polyfills/Array.prototype.every.js new file mode 100644 index 0000000..443eefa --- /dev/null +++ b/src/polyfills/Array.prototype.every.js @@ -0,0 +1,61 @@ +Array.prototype.every = function(callbackfn, thisArg) { + 'use strict'; + var T, k; + + if (this == null) { + throw new TypeError('this is null or not defined'); + } + + // 1. Let O be the result of calling ToObject passing the this + // value as the argument. + var O = Object(this); + + // 2. Let lenValue be the result of calling the Get internal method + // of O with the argument "length". + // 3. Let len be ToUint32(lenValue). + var len = O.length >>> 0; + + // 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + if (typeof callbackfn !== 'function') { + throw new TypeError(); + } + + // 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + if (arguments.length > 1) { + T = thisArg; + } + + // 6. Let k be 0. + k = 0; + + // 7. Repeat, while k < len + while (k < len) { + + var kValue; + + // a. Let Pk be ToString(k). + // This is implicit for LHS operands of the in operator + // b. Let kPresent be the result of calling the HasProperty internal + // method of O with argument Pk. + // This step can be combined with c + // c. If kPresent is true, then + if (k in O) { + + // i. Let kValue be the result of calling the Get internal method + // of O with argument Pk. + kValue = O[k]; + + // ii. Let testResult be the result of calling the Call internal method + // of callbackfn with T as the this value and argument list + // containing kValue, k, and O. + var testResult = callbackfn.call(T, kValue, k, O); + + // iii. If ToBoolean(testResult) is false, return false. + if (!testResult) { + return false; + } + } + k++; + } + return true; +}; diff --git a/src/polyfills/Array.prototype.filter.js b/src/polyfills/Array.prototype.filter.js new file mode 100644 index 0000000..4da74a4 --- /dev/null +++ b/src/polyfills/Array.prototype.filter.js @@ -0,0 +1,32 @@ +Array.prototype.filter = function(fun/*, thisArg*/) { + 'use strict'; + + if (this === void 0 || this === null) { + throw new TypeError(); + } + + var t = Object(this); + var len = t.length >>> 0; + if (typeof fun !== 'function') { + throw new TypeError(); + } + + var res = []; + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + for (var i = 0; i < len; i++) { + if (i in t) { + var val = t[i]; + + // NOTE: Technically this should Object.defineProperty at + // the next index, as push can be affected by + // properties on Object.prototype and Array.prototype. + // But that method's new, and collisions should be + // rare, so use the more-compatible alternative. + if (fun.call(thisArg, val, i, t)) { + res.push(val); + } + } + } + + return res; +}; diff --git a/src/polyfills/Array.prototype.forEach.js b/src/polyfills/Array.prototype.forEach.js new file mode 100644 index 0000000..2c8a861 --- /dev/null +++ b/src/polyfills/Array.prototype.forEach.js @@ -0,0 +1,58 @@ +Array.prototype.forEach = function(callback, thisArg) { + + var T, k; + + if (this === null) { + throw new TypeError(' this is null or not defined'); + } + + // 1. Let O be the result of calling toObject() passing the + // |this| value as the argument. + var O = Object(this); + + // 2. Let lenValue be the result of calling the Get() internal + // method of O with the argument "length". + // 3. Let len be toUint32(lenValue). + var len = O.length >>> 0; + + // 4. If isCallable(callback) is false, throw a TypeError exception. + // See: http://es5.github.com/#x9.11 + if (typeof callback !== "function") { + throw new TypeError(callback + ' is not a function'); + } + + // 5. If thisArg was supplied, let T be thisArg; else let + // T be undefined. + if (arguments.length > 1) { + T = thisArg; + } + + // 6. Let k be 0 + k = 0; + + // 7. Repeat, while k < len + while (k < len) { + + var kValue; + + // a. Let Pk be ToString(k). + // This is implicit for LHS operands of the in operator + // b. Let kPresent be the result of calling the HasProperty + // internal method of O with argument Pk. + // This step can be combined with c + // c. If kPresent is true, then + if (k in O) { + + // i. Let kValue be the result of calling the Get internal + // method of O with argument Pk. + kValue = O[k]; + + // ii. Call the Call internal method of callback with T as + // the this value and argument list containing kValue, k, and O. + callback.call(T, kValue, k, O); + } + // d. Increase k by 1. + k++; + } + // 8. return undefined +}; \ No newline at end of file diff --git a/src/polyfills/Array.prototype.includes.js b/src/polyfills/Array.prototype.includes.js new file mode 100644 index 0000000..275f1b6 --- /dev/null +++ b/src/polyfills/Array.prototype.includes.js @@ -0,0 +1,30 @@ +Array.prototype.includes = function(searchElement /*, fromIndex*/) { + 'use strict'; + if (this == null) { + throw new TypeError('Array.prototype.includes called on null or undefined'); + } + + var O = Object(this); + var len = parseInt(O.length, 10) || 0; + if (len === 0) { + return false; + } + var n = parseInt(arguments[1], 10) || 0; + var k; + if (n >= 0) { + k = n; + } else { + k = len + n; + if (k < 0) {k = 0;} + } + var currentElement; + while (k < len) { + currentElement = O[k]; + if (searchElement === currentElement || + (searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN + return true; + } + k++; + } + return false; +}; \ No newline at end of file diff --git a/src/polyfills/Array.prototype.map.js b/src/polyfills/Array.prototype.map.js new file mode 100644 index 0000000..41a5770 --- /dev/null +++ b/src/polyfills/Array.prototype.map.js @@ -0,0 +1,84 @@ +Array.prototype.map = function(callback, thisArg) { + + var T, A, k; + + if (this == null) { + throw new TypeError(' this is null or not defined'); + } + + // 1. Let O be the result of calling ToObject passing the |this| + // value as the argument. + var O = Object(this); + + // 2. Let lenValue be the result of calling the Get internal + // method of O with the argument "length". + // 3. Let len be ToUint32(lenValue). + var len = O.length >>> 0; + + // 4. If IsCallable(callback) is false, throw a TypeError exception. + // See: http://es5.github.com/#x9.11 + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); + } + + // 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + if (arguments.length > 1) { + T = thisArg; + } + + // 6. Let A be a new array created as if by the expression new Array(len) + // where Array is the standard built-in constructor with that name and + // len is the value of len. + A = new Array(len); + + // 7. Let k be 0 + k = 0; + + // 8. Repeat, while k < len + while (k < len) { + + var kValue, mappedValue; + + // a. Let Pk be ToString(k). + // This is implicit for LHS operands of the in operator + // b. Let kPresent be the result of calling the HasProperty internal + // method of O with argument Pk. + // This step can be combined with c + // c. If kPresent is true, then + if (k in O) { + + // i. Let kValue be the result of calling the Get internal + // method of O with argument Pk. + kValue = O[k]; + + // ii. Let mappedValue be the result of calling the Call internal + // method of callback with T as the this value and argument + // list containing kValue, k, and O. + mappedValue = callback.call(T, kValue, k, O); + + // iii. Call the DefineOwnProperty internal method of A with arguments + // Pk, Property Descriptor + // { Value: mappedValue, + // Writable: true, + // Enumerable: true, + // Configurable: true }, + // and false. + + // In browsers that support Object.defineProperty, use the following: + // Object.defineProperty(A, k, { + // value: mappedValue, + // writable: true, + // enumerable: true, + // configurable: true + // }); + + // For best browser support, use the following: + A[k] = mappedValue; + } + // d. Increase k by 1. + k++; + } + + // 9. return A + return A; +}; \ No newline at end of file diff --git a/src/polyfills/Array.prototype.reduce.js b/src/polyfills/Array.prototype.reduce.js new file mode 100644 index 0000000..ac39d4b --- /dev/null +++ b/src/polyfills/Array.prototype.reduce.js @@ -0,0 +1,27 @@ +Array.prototype.reduce = function(callback /*, initialValue*/) { + 'use strict'; + if (this === null) { + throw new TypeError('Array.prototype.reduce called on null or undefined'); + } + if (typeof callback !== 'function') { + throw new TypeError(callback + ' is not a function'); + } + var t = Object(this), len = t.length >>> 0, k = 0, value; + if (arguments.length == 2) { + value = arguments[1]; + } else { + while (k < len && !(k in t)) { + k++; + } + if (k >= len) { + throw new TypeError('Reduce of empty array with no initial value'); + } + value = t[k++]; + } + for (; k < len; k++) { + if (k in t) { + value = callback(value, t[k], k, t); + } + } + return value; +}; \ No newline at end of file diff --git a/src/polyfills/String.prototype.includes.js b/src/polyfills/String.prototype.includes.js new file mode 100644 index 0000000..645cf8c --- /dev/null +++ b/src/polyfills/String.prototype.includes.js @@ -0,0 +1,12 @@ +String.prototype.includes = function(search, start) { + 'use strict'; + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > this.length) { + return false; + } else { + return this.indexOf(search, start) !== -1; + } +}; \ No newline at end of file diff --git a/src/polyfills/String.prototype.repeat.js b/src/polyfills/String.prototype.repeat.js new file mode 100644 index 0000000..1c4f9ea --- /dev/null +++ b/src/polyfills/String.prototype.repeat.js @@ -0,0 +1,41 @@ +String.prototype.repeat = function(count) { + 'use strict'; + if (this == null) { + throw new TypeError('can\'t convert ' + this + ' to object'); + } + var str = '' + this; + count = +count; + if (count != count) { + count = 0; + } + if (count < 0) { + throw new RangeError('repeat count must be non-negative'); + } + if (count == Infinity) { + throw new RangeError('repeat count must be less than infinity'); + } + count = Math.floor(count); + if (str.length == 0 || count == 0) { + return ''; + } + // Ensuring count is a 31-bit integer allows us to heavily optimize the + // main part. But anyway, most current (August 2014) browsers can't handle + // strings 1 << 28 chars or longer, so: + if (str.length * count >= 1 << 28) { + throw new RangeError('repeat count must not overflow maximum string size'); + } + var rpt = ''; + for (;;) { + if ((count & 1) == 1) { + rpt += str; + } + count >>>= 1; + if (count == 0) { + break; + } + str += str; + } + // Could we try: + // return Array(count + 1).join(this); + return rpt; +} \ No newline at end of file diff --git a/src/polyfills/String.prototype.trim.js b/src/polyfills/String.prototype.trim.js new file mode 100644 index 0000000..0023867 --- /dev/null +++ b/src/polyfills/String.prototype.trim.js @@ -0,0 +1,3 @@ +String.prototype.trim = function () { + return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); +}; \ No newline at end of file diff --git a/tools/min-all.js b/tools/min-all.js new file mode 100644 index 0000000..ac0d250 --- /dev/null +++ b/tools/min-all.js @@ -0,0 +1,15 @@ +const glob = require('glob'); +const minify = require('./min'); + +// Minify the polyfills +const ESpolyfills = glob.sync('src/polyfills/*.js'); +ESpolyfills.forEach(inFile => { + const outFile = inFile.replace('src/polyfills/', 'js/polyfills/EcmaScript/'); + minify(inFile, outFile); +}); + +// Minify outerHTML polyfill +minify('js/polyfills/Dom/Element.outerHTML.js', 'js/polyfills/Dom/Element.outerHTML.min.js'); + +// Minify the javascript loader script +minify('src/load-scripts.js', 'js/load-scripts.js'); diff --git a/tools/min-loader.js b/tools/min-loader.js new file mode 100644 index 0000000..76c4ed7 --- /dev/null +++ b/tools/min-loader.js @@ -0,0 +1,3 @@ +const minify = require('./min'); +// Minify the javascript loader script +minify('src/load-scripts.js', 'js/load-scripts.js'); \ No newline at end of file diff --git a/tools/min.js b/tools/min.js new file mode 100644 index 0000000..36f4220 --- /dev/null +++ b/tools/min.js @@ -0,0 +1,41 @@ +const fs = require('fs'); +const path = require('path'); +const ClosureCompiler = require('google-closure-compiler').compiler; + +/** + * Minify a javascript file + * + * @param {string} inputFile + * @param {string} outputFile + * @param {object} options + */ +module.exports = function minify(inFile, outFile, options) { + const defaultOptions = { + js: inFile, + js_output_file: outFile, + compilation_level: 'ADVANCED', + language_in: 'ECMASCRIPT5', + language_out: 'ECMASCRIPT5', + warning_level: 'VERBOSE', + create_source_map: `${outFile}.map`, + rewrite_polyfills: false + }; + + options = options || {}; + Object.keys(options).forEach(opt => { + defaultOptions[opt] = options[opt]; + }); + + const compiler = new ClosureCompiler(defaultOptions); + + compiler.run((exitCode, stdOut, stdErr) => { + if (stdErr) { + console.error(stdErr); + } else { + console.log(stdOut); + } + + // Append the source map maping line to the minified file + fs.appendFileSync(outFile, '//# sourceMappingURL=' + path.basename(outFile) + '.map'); + }); +};