/////////////////////////// // Configure Titlization // /////////////////////////// var TITLEIZE = false; (function(document) { 'use strict'; /** * Support for document ready */ function documentReady(fn) { if (document.readyState != 'loading') { fn(); } else { document.addEventListener('DOMContentLoaded', fn); } } /** * Underscore string's titleize. */ function titleize(str) { return decodeURI(str).toLowerCase().replace(/(?:^|\s|-)\S/g, c => c.toUpperCase()); } /** * Set the title and build breadcrumb according to * current location. */ function setTitle() { let cleanPath = decodeURI(window.location.pathname.replace(/\/$/g, '')), titleText, breadcrumbHtml = '', index = 0, origin = window.location.origin + '/'; if (cleanPath) { let parts = cleanPath.split('/'); cleanPath = parts[parts.length - 1]; titleText = (TITLEIZE) ? titleize(cleanPath).replace(/-|_/g, ' ') : cleanPath; breadcrumbHtml += 'Home/' parts.forEach((name) => { if (name){ origin += name + '/'; breadcrumbHtml += '' + name + '/' } index++; }); } else { titleText = window.location.host; } titleText = `Index of ${titleText}`; const titleContainer = document.querySelector('h1#title'); const breadContainer = document.querySelector('div#breadcrumb'); if (titleContainer) titleContainer.innerHTML = titleText; if (breadContainer) breadContainer.innerHTML = breadcrumbHtml; document.title = titleText; } /** * Handle search input change. */ function onSearchInputChange(e) { let input = e.target, closeButton = document.querySelector('.close-search'), hidden = 0, matchs = 0, val = input.value.toLowerCase(), rowNoItem = document.querySelector('table#list tBody tr.no-items'); if (!rowNoItem){ let row = document.createElement('tr'); row.classList.add('no-items'); row.innerHTML = '