├── .eslintrc.json ├── .gitignore ├── .npmignore ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── app.js ├── dist ├── smiles-drawer.js ├── smiles-drawer.min.js └── smiles-drawer.min.js.map ├── doc ├── ArrayHelper.html ├── ArrayHelper.js.html ├── Atom.html ├── Atom.js.html ├── CanvasWrapper.html ├── CanvasWrapper.js.html ├── Drawer.html ├── Drawer.js.html ├── DrawerBase.html ├── DrawerBase.js.html ├── Edge.html ├── Edge.js.html ├── GaussDrawer.html ├── GaussDrawer.js.html ├── Graph.html ├── Graph.js.html ├── Line.html ├── Line.js.html ├── MathHelper.html ├── MathHelper.js.html ├── Options.js.html ├── Reaction.html ├── Reaction.js.html ├── ReactionDrawer.html ├── ReactionDrawer.js.html ├── ReactionParser.js.html ├── Ring.html ├── Ring.js.html ├── RingConnection.html ├── RingConnection.js.html ├── SSSR.html ├── SSSR.js.html ├── SmilesDrawer.js.html ├── SvgDrawer.js.html ├── SvgWrapper.js.html ├── ThemeManager.js.html ├── UtilityFunctions.js.html ├── Vector2.html ├── Vector2.js.html ├── Vertex.html ├── Vertex.js.html ├── fonts │ ├── Montserrat │ │ ├── Montserrat-Bold.eot │ │ ├── Montserrat-Bold.ttf │ │ ├── Montserrat-Bold.woff │ │ ├── Montserrat-Bold.woff2 │ │ ├── Montserrat-Regular.eot │ │ ├── Montserrat-Regular.ttf │ │ ├── Montserrat-Regular.woff │ │ └── Montserrat-Regular.woff2 │ └── Source-Sans-Pro │ │ ├── sourcesanspro-light-webfont.eot │ │ ├── sourcesanspro-light-webfont.svg │ │ ├── sourcesanspro-light-webfont.ttf │ │ ├── sourcesanspro-light-webfont.woff │ │ ├── sourcesanspro-light-webfont.woff2 │ │ ├── sourcesanspro-regular-webfont.eot │ │ ├── sourcesanspro-regular-webfont.svg │ │ ├── sourcesanspro-regular-webfont.ttf │ │ ├── sourcesanspro-regular-webfont.woff │ │ └── sourcesanspro-regular-webfont.woff2 ├── global.html ├── index.html ├── module-array-helper-ArrayHelper.html ├── module-array-helper.html ├── scripts │ ├── collapse.js │ ├── linenumber.js │ ├── nav.js │ ├── polyfill.js │ ├── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js │ └── search.js └── styles │ ├── jsdoc.css │ └── prettify.css ├── docs ├── ArrayHelper.html ├── ArrayHelper.js.html ├── Atom.html ├── Atom.js.html ├── CanvasWrapper.html ├── CanvasWrapper.js.html ├── Drawer.html ├── Drawer.js.html ├── DrawerBase.html ├── DrawerBase.js.html ├── Edge.html ├── Edge.js.html ├── GaussDrawer.html ├── GaussDrawer.js.html ├── Graph.html ├── Graph.js.html ├── Hanser.html ├── Hanser.js.html ├── Line.html ├── Line.js.html ├── MathHelper.html ├── MathHelper.js.html ├── Options.js.html ├── Pair.html ├── Pair.js.html ├── Reaction.html ├── Reaction.js.html ├── ReactionDrawer.html ├── ReactionDrawer.js.html ├── ReactionParser.js.html ├── Ring.html ├── Ring.js.html ├── RingConnection.html ├── RingConnection.js.html ├── SSSR.html ├── SSSR.js.html ├── SmilesDrawer.ArrayHelper.html ├── SmilesDrawer.Atom.html ├── SmilesDrawer.CanvasWrapper.html ├── SmilesDrawer.Drawer.html ├── SmilesDrawer.Edge.html ├── SmilesDrawer.Graph.html ├── SmilesDrawer.Hanser.html ├── SmilesDrawer.Line.html ├── SmilesDrawer.MathHelper.html ├── SmilesDrawer.Ring.html ├── SmilesDrawer.RingConnection.html ├── SmilesDrawer.SSSR.html ├── SmilesDrawer.Vector2.html ├── SmilesDrawer.Vertex.html ├── SmilesDrawer.html ├── SmilesDrawer.js.html ├── SvgDrawer.js.html ├── SvgWrapper.js.html ├── ThemeManager.js.html ├── UtilityFunctions.js.html ├── Vector2.html ├── Vector2.js.html ├── Vertex.html ├── Vertex.js.html ├── fonts │ ├── Montserrat │ │ ├── Montserrat-Bold.eot │ │ ├── Montserrat-Bold.ttf │ │ ├── Montserrat-Bold.woff │ │ ├── Montserrat-Bold.woff2 │ │ ├── Montserrat-Regular.eot │ │ ├── Montserrat-Regular.ttf │ │ ├── Montserrat-Regular.woff │ │ └── Montserrat-Regular.woff2 │ └── Source-Sans-Pro │ │ ├── sourcesanspro-light-webfont.eot │ │ ├── sourcesanspro-light-webfont.svg │ │ ├── sourcesanspro-light-webfont.ttf │ │ ├── sourcesanspro-light-webfont.woff │ │ ├── sourcesanspro-light-webfont.woff2 │ │ ├── sourcesanspro-regular-webfont.eot │ │ ├── sourcesanspro-regular-webfont.svg │ │ ├── sourcesanspro-regular-webfont.ttf │ │ ├── sourcesanspro-regular-webfont.woff │ │ └── sourcesanspro-regular-webfont.woff2 ├── global.html ├── index.html ├── index.rst ├── module.exports.html ├── scripts │ ├── collapse.js │ ├── linenumber.js │ ├── nav.js │ ├── polyfill.js │ ├── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js │ └── search.js └── styles │ ├── jsdoc.css │ └── prettify.css ├── example ├── .ipynb_checkpoints │ └── python_example-checkpoint.ipynb ├── draw.html ├── drugbank.css ├── drugbank.html ├── drugbank.js ├── index.html ├── index_experimental.html ├── index_light.html ├── index_sbs.html ├── index_svg.html ├── index_svg_scale.html ├── index_svgtocanvas.html ├── logo.png ├── next.html ├── oldschool.html ├── python_example.ipynb └── reaction.html ├── font.svg ├── gulpfile.js ├── jsdocConfig.json ├── package-lock.json ├── package.json ├── peg ├── smarts.pegjs └── smiles.pegjs ├── readme.hbs ├── readme ├── learn.png ├── logo.png ├── main.png ├── rxn_highlight.png └── style.png ├── src ├── ArrayHelper.js ├── Atom.js ├── CanvasWrapper.js ├── Drawer.js ├── DrawerBase.js ├── Edge.js ├── FormulaToCommonName.js ├── GaussDrawer.js ├── Graph.js ├── Line.js ├── MathHelper.js ├── Options.js ├── Parser.js ├── PixelsToSvg.js ├── Reaction.js ├── ReactionDrawer.js ├── ReactionParser.js ├── Ring.js ├── RingConnection.js ├── SSSR.js ├── SmilesDrawer.js ├── SvgDrawer.js ├── SvgWrapper.js ├── ThemeManager.js ├── UtilityFunctions.js ├── Vector2.js └── Vertex.js └── test ├── browser.html ├── chembl.js ├── drugbank.js ├── fdb.js ├── figure1.html ├── force.js ├── gausstest.html ├── gdb17.js ├── index.html └── schembl.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "ecmaFeatures": { 3 | "blockBindings": true, 4 | "modules": true, 5 | "superInFunctions": true 6 | }, 7 | "env": { 8 | "browser": true, 9 | "commonjs": true, 10 | "es6": true, 11 | "node": true 12 | }, 13 | "parserOptions": { 14 | "ecmaFeatures": { 15 | "jsx": true 16 | }, 17 | "sourceType": "module" 18 | }, 19 | "rules": { 20 | "no-const-assign": "warn", 21 | "no-this-before-super": "warn", 22 | "no-undef": "warn", 23 | "no-unreachable": "warn", 24 | "no-unused-vars": "warn", 25 | "constructor-super": "warn", 26 | "valid-typeof": "warn" 27 | } 28 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | yarn-error.log -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test 2 | 3 | logo.png 4 | .eslintrc.json 5 | .vscode -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "vsicons.presets.angular": false, 3 | "restructuredtext.confPath": "", 4 | "svg.preview.background": "transparent" 5 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | ## [1.0.7] - 2018-02-08 5 | ### Added 6 | ### Changed 7 | - Bugfixes 8 | ### Removed 9 | 10 | ## [1.0.6] - 2018-02-05 11 | ### Added 12 | - The method `getMolecularFormula()` has been added. See README for details. 13 | ### Changed 14 | ### Removed -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 GDB / Reymond Research Group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //@ts-check 2 | const Drawer = require('./src/Drawer') 3 | const Parser = require('./src/Parser') 4 | const ReactionParser = require('./src/ReactionParser') 5 | const SvgDrawer = require('./src/SvgDrawer') 6 | const ReactionDrawer = require('./src/ReactionDrawer') 7 | const SmiDrawer = require('./src/SmilesDrawer') 8 | const GaussDrawer = require('./src/GaussDrawer') 9 | 10 | // Detect SSR (server side rendering) 11 | var canUseDOM = !!( 12 | (typeof window !== 'undefined' && 13 | window.document && window.document.createElement) 14 | ); 15 | 16 | /** 17 | * The SmilesDrawer namespace. 18 | * @typicalname SmilesDrawer 19 | */ 20 | var SmilesDrawer = { 21 | Version: '2.1.10' 22 | }; 23 | 24 | SmilesDrawer.Drawer = Drawer; 25 | SmilesDrawer.Parser = Parser; 26 | SmilesDrawer.SvgDrawer = SvgDrawer; 27 | 28 | SmilesDrawer.ReactionDrawer = ReactionDrawer; 29 | SmilesDrawer.ReactionParser = ReactionParser; 30 | SmilesDrawer.GaussDrawer = GaussDrawer; 31 | 32 | /** 33 | * Cleans a SMILES string (removes non-valid characters) 34 | * 35 | * @static 36 | * @param {String} smiles A SMILES string. 37 | * @returns {String} The clean SMILES string. 38 | */ 39 | SmilesDrawer.clean = function (smiles) { 40 | return smiles.replace(/[^A-Za-z0-9@\.\+\-\?!\(\)\[\]\{\}/\\=#\$:\*]/g, ''); 41 | } 42 | 43 | /** 44 | * Applies the smiles drawer draw function to each canvas element that has a smiles string in the data-smiles attribute. 45 | * 46 | * @static 47 | * @param {Object} options SmilesDrawer options. 48 | * @param {String} [selector='canvas[data-smiles]'] Selectors for the draw areas (canvas elements). 49 | * @param {String} [themeName='light'] The theme to apply. 50 | * @param {Function} [onError='null'] A callback function providing an error object. 51 | */ 52 | SmilesDrawer.apply = function (options, selector = 'canvas[data-smiles]', themeName = 'light', onError = null) { 53 | let smilesDrawer = new Drawer(options); 54 | let elements = document.querySelectorAll(selector); 55 | 56 | for (var i = 0; i < elements.length; i++) { 57 | let element = elements[i]; 58 | 59 | SmilesDrawer.parse(element.getAttribute('data-smiles'), function (tree) { 60 | smilesDrawer.draw(tree, element, themeName, false); 61 | }, function (err) { 62 | if (onError) { 63 | onError(err); 64 | } 65 | }); 66 | } 67 | } 68 | 69 | /** 70 | * Parses the entered smiles string. 71 | * 72 | * @static 73 | * @param {String} smiles A SMILES string. 74 | * @param {Function} successCallback A callback that is called on success with the parse tree. 75 | * @param {Function} errorCallback A callback that is called with the error object on error. 76 | */ 77 | SmilesDrawer.parse = function (smiles, successCallback, errorCallback) { 78 | try { 79 | if (successCallback) { 80 | successCallback(Parser.parse(smiles)); 81 | } 82 | } catch (err) { 83 | if (errorCallback) { 84 | errorCallback(err); 85 | } 86 | } 87 | } 88 | 89 | /** 90 | * Parses the entered reaction smiles string. 91 | * 92 | * @static 93 | * @param {String} reactionSmiles A reaction SMILES string. 94 | * @param {Function} successCallback A callback that is called on success with the parse tree. 95 | * @param {Function} errorCallback A callback that is called with the error object on error. 96 | */ 97 | SmilesDrawer.parseReaction = function (reactionSmiles, successCallback, errorCallback) { 98 | try { 99 | if (successCallback) { 100 | successCallback(ReactionParser.parse(reactionSmiles)); 101 | } 102 | } catch (err) { 103 | if (errorCallback) { 104 | errorCallback(err); 105 | } 106 | } 107 | } 108 | 109 | if (canUseDOM) { 110 | window.SmilesDrawer = SmilesDrawer; 111 | window.SmiDrawer = SmiDrawer; 112 | } 113 | 114 | // Attach SmiDrawer to SmilesDrawer for npm imports 115 | SmilesDrawer.SmiDrawer = SmiDrawer; 116 | 117 | // There be dragons (polyfills) 118 | 119 | if (!Array.prototype.fill) { 120 | Object.defineProperty(Array.prototype, 'fill', { 121 | value: function (value) { 122 | 123 | // Steps 1-2. 124 | if (this == null) { 125 | throw new TypeError('this is null or not defined'); 126 | } 127 | 128 | var O = Object(this); 129 | 130 | // Steps 3-5. 131 | var len = O.length >>> 0; 132 | 133 | // Steps 6-7. 134 | var start = arguments[1]; 135 | var relativeStart = start >> 0; 136 | 137 | // Step 8. 138 | var k = relativeStart < 0 ? 139 | Math.max(len + relativeStart, 0) : 140 | Math.min(relativeStart, len); 141 | 142 | // Steps 9-10. 143 | var end = arguments[2]; 144 | var relativeEnd = end === undefined ? 145 | len : end >> 0; 146 | 147 | // Step 11. 148 | var final = relativeEnd < 0 ? 149 | Math.max(len + relativeEnd, 0) : 150 | Math.min(relativeEnd, len); 151 | 152 | // Step 12. 153 | while (k < final) { 154 | O[k] = value; 155 | k++; 156 | } 157 | 158 | // Step 13. 159 | return O; 160 | } 161 | }); 162 | } 163 | 164 | module.exports = SmilesDrawer; 165 | -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Bold.eot -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Bold.ttf -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Bold.woff -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Bold.woff2 -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Regular.eot -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Regular.ttf -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Regular.woff -------------------------------------------------------------------------------- /doc/fonts/Montserrat/Montserrat-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Montserrat/Montserrat-Regular.woff2 -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff -------------------------------------------------------------------------------- /doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reymond-group/smilesDrawer/0c4dd310b55b6529a3e2cd00d7e64cdadf23d3ab/doc/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 -------------------------------------------------------------------------------- /doc/scripts/collapse.js: -------------------------------------------------------------------------------- 1 | function hideAllButCurrent(){ 2 | //by default all submenut items are hidden 3 | //but we need to rehide them for search 4 | document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) { 5 | parent.style.display = "none"; 6 | }); 7 | 8 | //only current page (if it exists) should be opened 9 | var file = window.location.pathname.split("/").pop().replace(/\.html/, ''); 10 | document.querySelectorAll("nav > ul > li > a").forEach(function(parent) { 11 | var href = parent.attributes.href.value.replace(/\.html/, ''); 12 | if (file === href) { 13 | parent.parentNode.querySelectorAll("ul li").forEach(function(elem) { 14 | elem.style.display = "block"; 15 | }); 16 | } 17 | }); 18 | } 19 | 20 | hideAllButCurrent(); -------------------------------------------------------------------------------- /doc/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (function() { 3 | var source = document.getElementsByClassName('prettyprint source linenums'); 4 | var i = 0; 5 | var lineNumber = 0; 6 | var lineId; 7 | var lines; 8 | var totalLines; 9 | var anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = 'line' + lineNumber; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /doc/scripts/nav.js: -------------------------------------------------------------------------------- 1 | function scrollToNavItem() { 2 | var path = window.location.href.split('/').pop().replace(/\.html/, ''); 3 | document.querySelectorAll('nav a').forEach(function(link) { 4 | var href = link.attributes.href.value.replace(/\.html/, ''); 5 | if (path === href) { 6 | link.scrollIntoView({block: 'center'}); 7 | return; 8 | } 9 | }) 10 | } 11 | 12 | scrollToNavItem(); 13 | -------------------------------------------------------------------------------- /doc/scripts/polyfill.js: -------------------------------------------------------------------------------- 1 | //IE Fix, src: https://www.reddit.com/r/programminghorror/comments/6abmcr/nodelist_lacks_foreach_in_internet_explorer/ 2 | if (typeof(NodeList.prototype.forEach)!==typeof(alert)){ 3 | NodeList.prototype.forEach=Array.prototype.forEach; 4 | } -------------------------------------------------------------------------------- /doc/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /doc/scripts/search.js: -------------------------------------------------------------------------------- 1 | 2 | var searchAttr = 'data-search-mode'; 3 | function contains(a,m){ 4 | return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1; 5 | }; 6 | 7 | //on search 8 | document.getElementById("nav-search").addEventListener("keyup", function(event) { 9 | var search = this.value.toUpperCase(); 10 | 11 | if (!search) { 12 | //no search, show all results 13 | document.documentElement.removeAttribute(searchAttr); 14 | 15 | document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) { 16 | elem.style.display = "block"; 17 | }); 18 | 19 | if (typeof hideAllButCurrent === "function"){ 20 | //let's do what ever collapse wants to do 21 | hideAllButCurrent(); 22 | } else { 23 | //menu by default should be opened 24 | document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { 25 | elem.style.display = "block"; 26 | }); 27 | } 28 | } else { 29 | //we are searching 30 | document.documentElement.setAttribute(searchAttr, ''); 31 | 32 | //show all parents 33 | document.querySelectorAll("nav > ul > li").forEach(function(elem) { 34 | elem.style.display = "block"; 35 | }); 36 | //hide all results 37 | document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { 38 | elem.style.display = "none"; 39 | }); 40 | //show results matching filter 41 | document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) { 42 | if (!contains(elem.parentNode, search)) { 43 | return; 44 | } 45 | elem.parentNode.style.display = "block"; 46 | }); 47 | //hide parents without children 48 | document.querySelectorAll("nav > ul > li").forEach(function(parent) { 49 | var countSearchA = 0; 50 | parent.querySelectorAll("a").forEach(function(elem) { 51 | if (contains(elem, search)) { 52 | countSearchA++; 53 | } 54 | }); 55 | 56 | var countUl = 0; 57 | var countUlVisible = 0; 58 | parent.querySelectorAll("ul").forEach(function(ulP) { 59 | // count all elements that match the search 60 | if (contains(ulP, search)) { 61 | countUl++; 62 | } 63 | 64 | // count all visible elements 65 | var children = ulP.children 66 | for (i=0; i