function searchMenuFilter() {
var input, filter, ul, li, a, i, txtValue;
input = $(".search-input");
filter = input.val().toLowerCase();
ul = $("#doc-menu");
searchMore = $("#search-more");
li = $('#doc-menu .docLink');
if (filter != "") {
$(".GroupDocumentation").css("height", "auto");
searchMore.css("display", "block");
searchMore.text("Search for \""+input.val()+"\" in all the documentation");
searchMore.attr('href', "https://duckduckgo.com/?q="+ input.val() + ' site:smode.io/documentation')
} else {
$(".GroupDocumentation").css("height", "");
searchMore.css("display", "none");
}
//PARSING
$.each(li, function (i, val) {
a = li[i];
txtValue = a.textContent || a.innerText;
if (txtValue.toLowerCase().indexOf(filter) > -1) {
//$(li[i]).css("display","block");
$(val).css("display", "block");
//$(val).css("margin-left","0px");
$(val).parent().css("display", "block");
} else {
//$(li[i]).css("display","none");
$(val).css("display", "none");
$(val).css("margin-left", "");
}
});//end Parsing
}
function buildBreadcrumb(currentElement) {
var hierarchy = [];
hierarchy.push("" + currentElement.attr('title') + "");
currentElement.parentsUntil("#doc-nav", "nav").each(function () {
let domElement = $(this).find($(this).children()[1]); // we want the 2nd link in the nav
let link = "" + domElement.attr('title') + "";
if (link !== hierarchy[hierarchy.length - 1])
hierarchy.push(link);
});
hierarchy.pop(); // first level is irrelevant
var breadcrumb = hierarchy.pop();
while (hierarchy.length != 0) {
let parent = hierarchy.pop();
breadcrumb = breadcrumb + " > " + parent;
}
return (breadcrumb);
}
$(document).ready(function () {
var PageTitle = $("title").text();
var bodyClass = $("body").attr("class");
// keep the side menu opened on the right section + highlight it
let relativePath = document.URL.replace(document.baseURI, "");
let currentInMenu = $("a[href='" + relativePath + "']");
currentInMenu.addClass('opened currentInMenu');
currentInMenu.parentsUntil("#doc-nav").addClass('opened');
// build and display the breadcrumb
$("ol.pathDoc").append(buildBreadcrumb(currentInMenu));
$(".doc-wrapper .doc-sidebar").css("height", $(".doc-wrapper .container").height());
$(".doc-wrapper .doc-sidebar").css("max-height", $(".doc-wrapper .container").height());
if(($(window).width())<=800){
var screenHeight = $(window).height();
$(".doc-sidebar").css("max-height",screenHeight+"px");
$(".doc-sidebar").css("overflow","scroll");
}
});
/*Open and close the menu for laptop resolution */
$('a.GroupDocumentation').click(function () {
$(this).parent().toggleClass('opened');
});
/*Open and close the menu for laptop resolution */
$('#DisplayResponsiveMenu').click(function () {
$('.navigation').toggleClass('openedMenu');
});