/** * * Darkfish Page Functions * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ * * Author: Michael Granger * */ /* Provide console simulation for firebug-less environments */ /* if (!("console" in window) || !("firebug" in console)) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; window.console = {}; for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {}; }; */ function showSource( e ) { var target = e.target; while (!target.classList.contains('method-detail')) { target = target.parentNode; } if (typeof target !== "undefined" && target !== null) { target = target.querySelector('.method-source-code'); } if (typeof target !== "undefined" && target !== null) { target.classList.toggle('active-menu') } }; function hookSourceViews() { document.querySelectorAll('.toggle-source').forEach(function (codeObject) { codeObject.addEventListener('click', showSource); }); }; function hookSearch() { const searchButton = document.querySelector('button[aria-label="Search"]'); const searchDialog = document.getElementById('search-dialog'); if (searchButton && searchDialog) { searchButton.addEventListener('click', function(event) { event.preventDefault(); searchDialog.showModal(); searchDialog.querySelector('input[name="q"]').focus(); }); } // Close dialog when clicking on the backdrop searchDialog.addEventListener('click', function(event) { const rect = this.getBoundingClientRect(); const isInDialog = (rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width); if (!isInDialog) { this.close(); } }); var input = document.querySelector('#search-field'); var result = document.querySelector('#search-results'); result.classList.remove("initially-hidden"); var search_section = document.querySelector('#search-dialog'); search_section.classList.remove("initially-hidden"); var search = new Search(search_data, input, result); search.renderItem = function(result) { var li = document.createElement('li'); var html = ''; // TODO add relative path to