var nodemcu = nodemcu || {}; (function () { 'use strict'; //var languageCodeToNameMap = {en: 'English', de: 'Deutsch'}; var languageCodeToNameMap = {en: 'English'}; var languageNames = values(languageCodeToNameMap); var defaultLanguageCode = 'en'; $(document).ready(function () { addToc(); hideNavigationForAllButSelectedLanguage(); addLanguageSelectorToRtdFlyOutMenu(); replaceRelativeLinksWithStaticGitHubUrl(); }); /** * Adds a TOC-style table to each page in the 'Modules' section. */ function addToc() { var func, intro, tocHtmlTable; if (isModulePage()) { tocHtmlTable = ''; $('h2').each(function (index) { // 'slice' cuts off the single permalink character at the end of the text (e.g. '¶') func = $(this).text().slice(0, -1); // get the first sentence of the paragraph directly below h2 intro = $(this).next().text(); intro = intro.substring(0, intro.indexOf('.') + 1); tocHtmlTable += createTocTableRow(func, intro); }); tocHtmlTable += '
'; $(tocHtmlTable).insertBefore($('h2').first()) } function isModulePage() { // if the breadcrumb contains 'Modules »' it must be an API page return $("ul.wy-breadcrumbs li:contains('Modules »')").size() > 0; } function createTocTableRow(func, intro) { // fragile attempt to auto-create the in-page anchor var href = func.replace(/\.|:/g, '').replace('()', '').replace(' --', '-').replace(/ /g, '-'); var link = '' + func + ''; return '' + link + '' + intro + ''; } } function hideNavigationForAllButSelectedLanguage() { var selectedLanguageCode = determineSelectedLanguageCode(); var selectedLanguageName = languageCodeToNameMap[selectedLanguageCode]; // Finds all subnav elements and hides them if they're /language/ subnavs. Hence, all 'Modules' subnav elements // won't be hidden. //