Initial commit
This commit is contained in:
2
build/docs/javadoc/script-files/jquery-3.7.1.min.js
vendored
Normal file
2
build/docs/javadoc/script-files/jquery-3.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
build/docs/javadoc/script-files/jquery-ui.min.js
vendored
Normal file
6
build/docs/javadoc/script-files/jquery-ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
585
build/docs/javadoc/script-files/script.js
Normal file
585
build/docs/javadoc/script-files/script.js
Normal file
@@ -0,0 +1,585 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
||||
*/
|
||||
|
||||
var moduleSearchIndex;
|
||||
var packageSearchIndex;
|
||||
var typeSearchIndex;
|
||||
var memberSearchIndex;
|
||||
var tagSearchIndex;
|
||||
|
||||
var oddRowColor = "odd-row-color";
|
||||
var evenRowColor = "even-row-color";
|
||||
var sortAsc = "sort-asc";
|
||||
var sortDesc = "sort-desc";
|
||||
var tableTab = "table-tab";
|
||||
var activeTableTab = "active-table-tab";
|
||||
|
||||
const linkIcon = "Link icon";
|
||||
const linkToSection = "Link to this section";
|
||||
|
||||
if (typeof hljs !== "undefined") {
|
||||
try {
|
||||
hljs.highlightAll();
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
function loadScripts(doc, tag) {
|
||||
createElem(doc, tag, 'script-files/search.js');
|
||||
|
||||
createElem(doc, tag, 'module-search-index.js');
|
||||
createElem(doc, tag, 'package-search-index.js');
|
||||
createElem(doc, tag, 'type-search-index.js');
|
||||
createElem(doc, tag, 'member-search-index.js');
|
||||
createElem(doc, tag, 'tag-search-index.js');
|
||||
}
|
||||
|
||||
function createElem(doc, tag, path) {
|
||||
var script = doc.createElement(tag);
|
||||
var scriptElement = doc.getElementsByTagName(tag)[0];
|
||||
script.src = pathtoroot + path;
|
||||
scriptElement.parentNode.insertBefore(script, scriptElement);
|
||||
}
|
||||
|
||||
// Helper for making content containing release names comparable lexicographically
|
||||
function makeComparable(s) {
|
||||
return s.toLowerCase().replace(/(\d+)/g,
|
||||
function(n, m) {
|
||||
return ("000" + m).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// Switches between two styles depending on a condition
|
||||
function toggleStyle(classList, condition, trueStyle, falseStyle) {
|
||||
if (condition) {
|
||||
classList.remove(falseStyle);
|
||||
classList.add(trueStyle);
|
||||
} else {
|
||||
classList.remove(trueStyle);
|
||||
classList.add(falseStyle);
|
||||
}
|
||||
}
|
||||
|
||||
// Sorts the rows in a table lexicographically by the content of a specific column
|
||||
function sortTable(header, columnIndex, columns) {
|
||||
var container = header.parentElement;
|
||||
var descending = header.classList.contains(sortAsc);
|
||||
container.querySelectorAll("div.table-header").forEach(
|
||||
function(header) {
|
||||
header.classList.remove(sortAsc);
|
||||
header.classList.remove(sortDesc);
|
||||
}
|
||||
)
|
||||
var cells = container.children;
|
||||
var rows = [];
|
||||
for (var i = columns; i < cells.length; i += columns) {
|
||||
rows.push(Array.prototype.slice.call(cells, i, i + columns));
|
||||
}
|
||||
var comparator = function(a, b) {
|
||||
var ka = makeComparable(a[columnIndex].textContent);
|
||||
var kb = makeComparable(b[columnIndex].textContent);
|
||||
if (ka < kb)
|
||||
return descending ? 1 : -1;
|
||||
if (ka > kb)
|
||||
return descending ? -1 : 1;
|
||||
return 0;
|
||||
};
|
||||
var sorted = rows.sort(comparator);
|
||||
var visible = 0;
|
||||
sorted.forEach(function(row) {
|
||||
if (row[0].style.display !== 'none') {
|
||||
var isEvenRow = visible++ % 2 === 0;
|
||||
}
|
||||
row.forEach(function(cell) {
|
||||
toggleStyle(cell.classList, isEvenRow, evenRowColor, oddRowColor);
|
||||
container.appendChild(cell);
|
||||
})
|
||||
});
|
||||
toggleStyle(header.classList, descending, sortDesc, sortAsc);
|
||||
}
|
||||
|
||||
// Toggles the visibility of a table category in all tables in a page
|
||||
function toggleGlobal(checkbox, selected, columns) {
|
||||
const display = checkbox.checked ? '' : 'none';
|
||||
const selectOther = selected === "other";
|
||||
const selectAll = selected === "all";
|
||||
if (selectAll) {
|
||||
document.querySelectorAll('.checkboxes input[type="checkbox"]').forEach(c => {
|
||||
c.checked = checkbox.checked;
|
||||
});
|
||||
}
|
||||
document.querySelectorAll("div.table-tabs").forEach(t => {
|
||||
const id = t.parentElement.getAttribute("id");
|
||||
const selectedClass = id + "-tab" + (selectOther ? "" : selected);
|
||||
var visible = 0;
|
||||
t.parentElement.querySelectorAll('div.' + id)
|
||||
.forEach(function(elem) {
|
||||
if (selectAll
|
||||
|| (!selectOther && elem.classList.contains(selectedClass))
|
||||
|| (selectOther && elem.className.indexOf(selectedClass) < 0)) {
|
||||
elem.style.display = display;
|
||||
}
|
||||
if (elem.style.display === '') {
|
||||
var isEvenRow = visible++ % (columns * 2) < columns;
|
||||
toggleStyle(elem.classList, isEvenRow, evenRowColor, oddRowColor);
|
||||
}
|
||||
});
|
||||
var displaySection = visible === 0 ? 'none' : '';
|
||||
t.parentElement.style.display = displaySection;
|
||||
document.querySelector("li#contents-" + id).style.display = displaySection;
|
||||
})
|
||||
}
|
||||
|
||||
// Shows the elements of a table belonging to a specific category
|
||||
function show(tableId, selected, columns) {
|
||||
if (tableId !== selected) {
|
||||
document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')')
|
||||
.forEach(function(elem) {
|
||||
elem.style.display = 'none';
|
||||
});
|
||||
}
|
||||
document.querySelectorAll('div.' + selected)
|
||||
.forEach(function(elem, index) {
|
||||
elem.style.display = '';
|
||||
var isEvenRow = index % (columns * 2) < columns;
|
||||
toggleStyle(elem.classList, isEvenRow, evenRowColor, oddRowColor);
|
||||
});
|
||||
updateTabs(tableId, selected);
|
||||
}
|
||||
|
||||
function updateTabs(tableId, selected) {
|
||||
document.getElementById(tableId + '.tabpanel')
|
||||
.setAttribute('aria-labelledby', selected);
|
||||
document.querySelectorAll('button[id^="' + tableId + '"]')
|
||||
.forEach(function(tab, index) {
|
||||
if (selected === tab.id || (tableId === selected && index === 0)) {
|
||||
tab.className = activeTableTab;
|
||||
tab.setAttribute('aria-selected', true);
|
||||
tab.setAttribute('tabindex',0);
|
||||
} else {
|
||||
tab.className = tableTab;
|
||||
tab.setAttribute('aria-selected', false);
|
||||
tab.setAttribute('tabindex',-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function switchTab(e) {
|
||||
var selected = document.querySelector('[aria-selected=true]');
|
||||
if (selected) {
|
||||
if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) {
|
||||
// left or up arrow key pressed: move focus to previous tab
|
||||
selected.previousSibling.click();
|
||||
selected.previousSibling.focus();
|
||||
e.preventDefault();
|
||||
} else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) {
|
||||
// right or down arrow key pressed: move focus to next tab
|
||||
selected.nextSibling.click();
|
||||
selected.nextSibling.focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var updateSearchResults = function() {};
|
||||
|
||||
function indexFilesLoaded() {
|
||||
return moduleSearchIndex
|
||||
&& packageSearchIndex
|
||||
&& typeSearchIndex
|
||||
&& memberSearchIndex
|
||||
&& tagSearchIndex;
|
||||
}
|
||||
// Copy the contents of the local snippet to the clipboard
|
||||
function copySnippet(button) {
|
||||
copyToClipboard(button.nextElementSibling.innerText);
|
||||
switchCopyLabel(button, button.firstElementChild);
|
||||
}
|
||||
function copyToClipboard(content) {
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.style.height = 0;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.value = content;
|
||||
textarea.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
function resetInput(input, event, blur) {
|
||||
if (input.value) {
|
||||
input.value = "";
|
||||
input.dispatchEvent(new InputEvent("input"));
|
||||
} else if (blur) {
|
||||
input.blur();
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
function isInput(elem) {
|
||||
return elem instanceof HTMLInputElement && elem.type === "text";
|
||||
}
|
||||
function switchCopyLabel(button, span) {
|
||||
var copied = span.getAttribute("data-copied");
|
||||
button.classList.add("visible");
|
||||
var initialLabel = span.innerHTML;
|
||||
span.innerHTML = copied;
|
||||
setTimeout(function() {
|
||||
button.classList.remove("visible");
|
||||
setTimeout(function() {
|
||||
if (initialLabel !== copied) {
|
||||
span.innerHTML = initialLabel;
|
||||
}
|
||||
}, 100);
|
||||
}, 1900);
|
||||
}
|
||||
function makeFilterWidget(sidebar, updateToc) {
|
||||
if (!sidebar) {
|
||||
return null;
|
||||
}
|
||||
const filterInput = sidebar.querySelector("input.filter-input");
|
||||
const resetInput = sidebar.querySelector("input.reset-filter");
|
||||
sidebar.addEventListener("keydown", e => {
|
||||
if (e.ctrlKey || e.altKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
||||
handleTocFocus(e);
|
||||
} else if (filterInput && e.target !== filterInput) {
|
||||
if (e.key === "Enter" && isTocLink(sidebar, e.target)) {
|
||||
filterInput.value = "";
|
||||
filterInput.dispatchEvent(new InputEvent("input"));
|
||||
} else if (e.key.length === 1 || e.key === "Backspace") {
|
||||
filterInput.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (filterInput) {
|
||||
filterInput.removeAttribute("disabled");
|
||||
filterInput.setAttribute("autocapitalize", "off");
|
||||
filterInput.value = "";
|
||||
filterInput.addEventListener("input", function(e) {
|
||||
resetInput.style.visibility = filterInput.value ? "visible" : "hidden";
|
||||
const pattern = filterInput.value ? filterInput.value.trim()
|
||||
.replace(/[\[\]{}()*+?.\\^$|]/g, '\\$&')
|
||||
.replace(/\s+/g, ".*") : "";
|
||||
const filter = new RegExp(pattern, "i");
|
||||
sidebar.querySelectorAll("ol.toc-list li").forEach((li) => {
|
||||
if (filter.test(li.innerText)) {
|
||||
// li.removeAttribute("style");
|
||||
const selfMatch = filter.test(li.firstElementChild.innerText);
|
||||
li.style.display = "block";
|
||||
li.firstElementChild.style.opacity = selfMatch ? "100%" : "70%";
|
||||
li.firstElementChild.tabIndex = selfMatch ? 0 : -1;
|
||||
} else {
|
||||
li.style.display = "none";
|
||||
}
|
||||
});
|
||||
updateToc();
|
||||
});
|
||||
}
|
||||
if (resetInput) {
|
||||
resetInput.removeAttribute("disabled");
|
||||
resetInput.addEventListener("click", (e) => {
|
||||
filterInput.value = "";
|
||||
filterInput.focus();
|
||||
filterInput.dispatchEvent(new InputEvent("input"));
|
||||
});
|
||||
}
|
||||
function handleTocFocus(event) {
|
||||
let links = Array.from(sidebar.querySelectorAll("ol > li > a"))
|
||||
.filter(link => link.offsetParent && link.tabIndex === 0);
|
||||
let current = links.indexOf(document.activeElement);
|
||||
if (event.key === "ArrowUp") {
|
||||
if (current > 0) {
|
||||
links[current - 1].focus({focusVisible: true});
|
||||
} else if (filterInput) {
|
||||
filterInput.focus();
|
||||
}
|
||||
} else if (event.key === "ArrowDown" && current < links.length - 1) {
|
||||
links[current + 1].focus({focusVisible: true});
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
function isTocLink(sidebar, elem) {
|
||||
let links = Array.from(sidebar.querySelectorAll("ol > li > a"))
|
||||
.filter(link => link.offsetParent && link.tabIndex === 0);
|
||||
return links.indexOf(elem) > -1;
|
||||
}
|
||||
return sidebar;
|
||||
}
|
||||
|
||||
function setTopMargin() {
|
||||
// Dynamically set scroll margin to accomodate for draft header
|
||||
var headerHeight = Math.ceil(document.querySelector("header").offsetHeight);
|
||||
document.querySelector(":root")
|
||||
.style.setProperty("--nav-height", headerHeight + "px");
|
||||
}
|
||||
document.addEventListener("readystatechange", (e) => {
|
||||
if (document.readyState === "interactive") {
|
||||
setTopMargin();
|
||||
}
|
||||
if (sessionStorage.getItem("sidebar") === "hidden") {
|
||||
const sidebar = document.querySelector(".main-grid nav.toc");
|
||||
if (sidebar) sidebar.classList.add("hide-sidebar");
|
||||
}
|
||||
});
|
||||
document.addEventListener("DOMContentLoaded", function(e) {
|
||||
setTopMargin();
|
||||
// Make sure current element is visible in breadcrumb navigation on small displays
|
||||
const subnav = document.querySelector("ol.sub-nav-list");
|
||||
if (subnav && subnav.lastElementChild) {
|
||||
subnav.lastElementChild.scrollIntoView({ behavior: "instant", inline: "start", block: "nearest" });
|
||||
}
|
||||
const keymap = new Map();
|
||||
const searchInput = document.getElementById("search-input")
|
||||
|| document.getElementById("page-search-input");
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener("focus", collapse);
|
||||
keymap.set("/", searchInput);
|
||||
}
|
||||
const filterInput = document.querySelector("input.filter-input");
|
||||
if (filterInput) {
|
||||
keymap.set(".", filterInput);
|
||||
}
|
||||
// Clone TOC sidebar to header for mobile navigation
|
||||
const navbar = document.querySelector("div#navbar-top");
|
||||
const sidebar = document.querySelector(".main-grid nav.toc");
|
||||
const main = document.querySelector(".main-grid main");
|
||||
const mainnav = navbar.querySelector("ul.nav-list");
|
||||
const toggleButton = document.querySelector("button#navbar-toggle-button");
|
||||
const tocMenu = sidebar ? sidebar.cloneNode(true) : null;
|
||||
makeFilterWidget(sidebar, updateToc);
|
||||
if (tocMenu) {
|
||||
navbar.appendChild(tocMenu);
|
||||
makeFilterWidget(tocMenu, updateToc);
|
||||
var menuInput = tocMenu.querySelector("input.filter-input");
|
||||
}
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey || e.altKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
if (!isInput(e.target) && keymap.has(e.key)) {
|
||||
var elem = keymap.get(e.key);
|
||||
if (elem === filterInput && !elem.offsetParent) {
|
||||
elem = getVisibleFilterInput(true);
|
||||
}
|
||||
elem.focus();
|
||||
elem.select();
|
||||
e.preventDefault();
|
||||
} else if (e.key === "Escape") {
|
||||
if (expanded) {
|
||||
collapse();
|
||||
e.preventDefault();
|
||||
} else if (e.target.id === "page-search-input") {
|
||||
resetInput(e.target, e, false);
|
||||
} else if (isInput(e.target)) {
|
||||
resetInput(e.target, e, true);
|
||||
} else {
|
||||
var filter = getVisibleFilterInput(false);
|
||||
if (filter && filter.value) {
|
||||
resetInput(filterInput, e, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
var expanded = false;
|
||||
var windowWidth;
|
||||
var bodyHeight;
|
||||
function collapse() {
|
||||
if (expanded) {
|
||||
mainnav.removeAttribute("style");
|
||||
if (tocMenu) {
|
||||
tocMenu.removeAttribute("style");
|
||||
if (filterInput) {
|
||||
keymap.set(".", filterInput);
|
||||
}
|
||||
}
|
||||
toggleButton.classList.remove("expanded")
|
||||
toggleButton.setAttribute("aria-expanded", "false");
|
||||
expanded = false;
|
||||
}
|
||||
}
|
||||
function expand() {
|
||||
expanded = true;
|
||||
mainnav.style.display = "block";
|
||||
mainnav.style.removeProperty("height");
|
||||
var maxHeight = window.innerHeight - subnav.offsetTop + 4;
|
||||
var expandedHeight = Math.min(maxHeight, mainnav.scrollHeight + 10);
|
||||
if (tocMenu) {
|
||||
tocMenu.style.display = "flex";
|
||||
expandedHeight = Math.min(maxHeight,
|
||||
Math.max(expandedHeight, tocMenu.querySelector("div.toc-header").offsetHeight
|
||||
+ tocMenu.querySelector("ol.toc-list").scrollHeight + 10));
|
||||
tocMenu.style.height = expandedHeight + "px";
|
||||
if (menuInput) {
|
||||
keymap.set(".", menuInput);
|
||||
}
|
||||
}
|
||||
mainnav.style.height = expandedHeight + "px";
|
||||
toggleButton.classList.add("expanded");
|
||||
toggleButton.setAttribute("aria-expanded", "true");
|
||||
windowWidth = window.innerWidth;
|
||||
}
|
||||
function updateToc() {
|
||||
if (expanded) {
|
||||
expand();
|
||||
} else {
|
||||
prevHash = null;
|
||||
handleScroll();
|
||||
}
|
||||
}
|
||||
function getVisibleFilterInput(show) {
|
||||
if (sidebar && sidebar.offsetParent) {
|
||||
if (show) {
|
||||
showSidebar();
|
||||
}
|
||||
return filterInput;
|
||||
} else {
|
||||
if (show) {
|
||||
expand();
|
||||
}
|
||||
return menuInput;
|
||||
}
|
||||
}
|
||||
toggleButton.addEventListener("click", (e) => {
|
||||
if (expanded) {
|
||||
collapse();
|
||||
} else {
|
||||
expand();
|
||||
}
|
||||
});
|
||||
if (tocMenu) {
|
||||
tocMenu.querySelectorAll("a").forEach((link) => {
|
||||
link.addEventListener("click", collapse);
|
||||
});
|
||||
}
|
||||
document.querySelector("main").addEventListener("click", collapse);
|
||||
document.querySelectorAll("h1, h2, h3, h4, h5, h6")
|
||||
.forEach((hdr, idx) => {
|
||||
// Create anchor links for headers with an associated id attribute
|
||||
var id = hdr.parentElement.getAttribute("id") || hdr.getAttribute("id")
|
||||
|| (hdr.querySelector("a") && hdr.querySelector("a").getAttribute("id"));
|
||||
if (id) {
|
||||
var template = document.createElement('template');
|
||||
template.innerHTML =" <a href='#" + encodeURI(id) + "' class='anchor-link' aria-label='" + linkToSection
|
||||
+ "'><img src='" + pathtoroot + "resource-files/link.svg' alt='" + linkIcon +"' tabindex='0'"
|
||||
+ " width='16' height='16'></a>";
|
||||
hdr.append(...template.content.childNodes);
|
||||
}
|
||||
});
|
||||
var sections;
|
||||
var scrollTimeout;
|
||||
var prevHash;
|
||||
function initSectionData() {
|
||||
bodyHeight = document.body.offsetHeight;
|
||||
sections = [{ id: "", top: 0 }].concat(Array.from(main.querySelectorAll(
|
||||
"section[id], h2[id], h2 a[id], h3[id], h3 a[id], div[id]"))
|
||||
.filter((e) => {
|
||||
return sidebar.querySelector("a[href=\"#" + encodeURI(e.getAttribute("id")) + "\"]") !== null
|
||||
}).map((e) => {
|
||||
return {
|
||||
id: e.getAttribute("id"),
|
||||
top: e.offsetTop
|
||||
};
|
||||
}));
|
||||
}
|
||||
function setScrollTimeout() {
|
||||
if (scrollTimeout) {
|
||||
clearTimeout(scrollTimeout);
|
||||
}
|
||||
scrollTimeout = setTimeout(() => {
|
||||
scrollTimeout = null;
|
||||
}, 100);
|
||||
}
|
||||
function handleScroll() {
|
||||
if (!sidebar || !sidebar.offsetParent || sidebar.classList.contains("hide-sidebar")) {
|
||||
return;
|
||||
}
|
||||
if (scrollTimeout) {
|
||||
setScrollTimeout();
|
||||
return;
|
||||
}
|
||||
var scrollTop = document.documentElement.scrollTop;
|
||||
var scrollHeight = document.documentElement.scrollHeight;
|
||||
var currHash = null;
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var top = sections[i].top;
|
||||
var bottom = sections[i + 1] ? sections[i + 1].top : scrollHeight;
|
||||
if (top + ((bottom - top) / 2) > scrollTop || bottom > scrollTop + (window.innerHeight / 3)) {
|
||||
currHash = "#" + encodeURI(sections[i].id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currHash !== prevHash) {
|
||||
setSelected(currHash);
|
||||
}
|
||||
}
|
||||
function setSelected(hash) {
|
||||
var prev = sidebar.querySelector("a.current-selection");
|
||||
if (prev)
|
||||
prev.classList.remove("current-selection");
|
||||
prevHash = hash;
|
||||
if (hash) {
|
||||
var curr = sidebar.querySelector("ol.toc-list a[href=\"" + hash + "\"]");
|
||||
if (curr) {
|
||||
curr.classList.add("current-selection");
|
||||
curr.scrollIntoView({ behavior: "instant", block: "nearest" });
|
||||
}
|
||||
}
|
||||
}
|
||||
function hideSidebar() {
|
||||
sidebar.classList.add("hide-sidebar");
|
||||
sessionStorage.setItem("sidebar", "hidden");
|
||||
}
|
||||
function showSidebar() {
|
||||
sidebar.classList.remove("hide-sidebar");
|
||||
sessionStorage.removeItem("sidebar");
|
||||
initSectionData();
|
||||
handleScroll();
|
||||
}
|
||||
if (sidebar) {
|
||||
initSectionData();
|
||||
document.querySelectorAll("a[href^='#']").forEach((link) => {
|
||||
link.addEventListener("click", (e) => {
|
||||
link.blur();
|
||||
setScrollTimeout();
|
||||
setSelected(link.getAttribute("href"));
|
||||
})
|
||||
});
|
||||
sidebar.querySelector("button.hide-sidebar").addEventListener("click", hideSidebar);
|
||||
sidebar.querySelector("button.show-sidebar").addEventListener("click", showSidebar);
|
||||
window.addEventListener("hashchange", (e) => {
|
||||
setScrollTimeout();
|
||||
const hash = e.newURL.indexOf("#");
|
||||
if (hash > -1) {
|
||||
setSelected(e.newURL.substring(hash));
|
||||
}
|
||||
});
|
||||
if (document.location.hash) {
|
||||
setScrollTimeout();
|
||||
setSelected(document.location.hash);
|
||||
} else {
|
||||
handleScroll();
|
||||
}
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
}
|
||||
// Resize handler
|
||||
new ResizeObserver((entries) => {
|
||||
if (expanded) {
|
||||
if (windowWidth !== window.innerWidth) {
|
||||
collapse();
|
||||
} else {
|
||||
expand();
|
||||
}
|
||||
}
|
||||
if (sections && document.body.offsetHeight !== bodyHeight) {
|
||||
initSectionData();
|
||||
prevHash = null;
|
||||
handleScroll();
|
||||
}
|
||||
setTopMargin();
|
||||
}).observe(document.body);
|
||||
});
|
||||
348
build/docs/javadoc/script-files/search-page.js
Normal file
348
build/docs/javadoc/script-files/search-page.js
Normal file
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
$(function() {
|
||||
var copy = $("#page-search-copy");
|
||||
var expand = $("#page-search-expand");
|
||||
var searchLink = $("span#page-search-link");
|
||||
var redirect = $("input#search-redirect");
|
||||
function setSearchUrlTemplate() {
|
||||
var href = document.location.href.split(/[#?]/)[0];
|
||||
href += "?q=" + "%s";
|
||||
if (redirect.is(":checked")) {
|
||||
href += "&r=1";
|
||||
}
|
||||
searchLink.html(href);
|
||||
copy[0].onmouseenter();
|
||||
}
|
||||
function copyLink(e) {
|
||||
copyToClipboard(this.previousSibling.innerText);
|
||||
switchCopyLabel(this, this.lastElementChild);
|
||||
}
|
||||
copy.on("click", copyLink);
|
||||
copy[0].onmouseenter = function() {};
|
||||
redirect.on("click", setSearchUrlTemplate);
|
||||
setSearchUrlTemplate();
|
||||
copy.prop("disabled", false);
|
||||
redirect.prop("disabled", false);
|
||||
expand.on("click", function (e) {
|
||||
var searchInfo = $("div.page-search-info");
|
||||
if(this.parentElement.hasAttribute("open")) {
|
||||
searchInfo.attr("style", " display:none;");
|
||||
} else {
|
||||
searchInfo.attr("style", "display:block;");
|
||||
}
|
||||
});
|
||||
});
|
||||
$(window).on("load", function() {
|
||||
var input = $("#page-search-input");
|
||||
var reset = $("#page-search-reset");
|
||||
var modules = $("#search-modules");
|
||||
var notify = $("#page-search-notify");
|
||||
var resultSection = $("div#result-section");
|
||||
var resultContainer = $("div#result-container");
|
||||
var selectedLink;
|
||||
var searchTerm = "";
|
||||
var activeTab = "";
|
||||
var fixedTab = false;
|
||||
var visibleTabs = [];
|
||||
var feelingLucky = false;
|
||||
const MIN_TABBED_RESULTS = 10;
|
||||
function renderResults(result) {
|
||||
if (!result.length) {
|
||||
notify.html(messages.noResult);
|
||||
} else if (result.length === 1) {
|
||||
notify.html(messages.oneResult);
|
||||
} else {
|
||||
notify.html(messages.manyResults.replace("{0}", result.length));
|
||||
}
|
||||
resultContainer.empty();
|
||||
var r = {
|
||||
"types": [],
|
||||
"members": [],
|
||||
"packages": [],
|
||||
"modules": [],
|
||||
"searchTags": []
|
||||
};
|
||||
for (var i in result) {
|
||||
var item = result[i];
|
||||
var arr = r[item.category];
|
||||
arr.push(item);
|
||||
}
|
||||
if (!activeTab || r[activeTab].length === 0) {
|
||||
activeTab = Object.keys(r).find(category => r[category].length > 0);
|
||||
}
|
||||
if (feelingLucky && activeTab) {
|
||||
notify.html(messages.redirecting)
|
||||
var firstItem = r[activeTab][0];
|
||||
window.location = getURL(firstItem.indexItem, firstItem.category);
|
||||
return;
|
||||
}
|
||||
if (searchTerm.endsWith(".") && result.length > MIN_TABBED_RESULTS) {
|
||||
if (activeTab === "types" && r["members"].length > r["types"].length) {
|
||||
activeTab = "members";
|
||||
} else if (activeTab === "packages" && r["types"].length > r["packages"].length) {
|
||||
activeTab = "types";
|
||||
}
|
||||
}
|
||||
var categoryCount = Object.keys(r).reduce(function(prev, curr) {
|
||||
return prev + (r[curr].length > 0 ? 1 : 0);
|
||||
}, 0);
|
||||
visibleTabs = [];
|
||||
var tabContainer = $("<div class='table-tabs'></div>").appendTo(resultContainer);
|
||||
for (var key in r) {
|
||||
var id = "#result-tab-" + key.replace("searchTags", "search_tags");
|
||||
if (r[key].length) {
|
||||
var count = r[key].length >= 1000 ? "999+" : r[key].length;
|
||||
if (result.length > MIN_TABBED_RESULTS && categoryCount > 1) {
|
||||
let button = $("<button/>")
|
||||
.attr("id", "result-tab-" + key)
|
||||
.attr("tabIndex", "-1")
|
||||
.addClass("page-search-header")
|
||||
.append($("<span/>")
|
||||
.html(categories[key])
|
||||
.append($("<span/>")
|
||||
.attr("style", "font-weight:normal;")
|
||||
.html(" (" + count + ")")))
|
||||
.on("click", null, key, function(e) {
|
||||
fixedTab = true;
|
||||
renderResult(e.data, $(this));
|
||||
}).appendTo(tabContainer);
|
||||
visibleTabs.push(key);
|
||||
} else {
|
||||
$("<span class='page-search-header'>" + categories[key]
|
||||
+ "<span style='font-weight: normal'> (" + count + ")</span></span>").appendTo(tabContainer);
|
||||
renderTable(key, r[key]).appendTo(resultContainer);
|
||||
tabContainer = $("<div class='table-tabs'></div>").appendTo(resultContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (activeTab && result.length > MIN_TABBED_RESULTS && categoryCount > 1) {
|
||||
$("button#result-tab-" + activeTab).addClass("active-table-tab").attr("tabIndex", "0");
|
||||
renderTable(activeTab, r[activeTab]).appendTo(resultContainer);
|
||||
}
|
||||
resultSection.show();
|
||||
function renderResult(category, button) {
|
||||
activeTab = category;
|
||||
setSearchUrl();
|
||||
resultContainer.find("div.result-table").remove();
|
||||
renderTable(activeTab, r[activeTab]).appendTo(resultContainer);
|
||||
button.siblings().removeClass("active-table-tab").attr("tabIndex", "-1");
|
||||
button.addClass("active-table-tab").attr("tabIndex", "0");
|
||||
}
|
||||
}
|
||||
function selectTab(category) {
|
||||
$("button#result-tab-" + category).focus().trigger("click");
|
||||
}
|
||||
function renderTable(category, items) {
|
||||
var table = $("<div class='result-table'>");
|
||||
var col1, col2;
|
||||
if (category === "modules") {
|
||||
col1 = mdlDesc;
|
||||
} else if (category === "packages") {
|
||||
col1 = pkgDesc;
|
||||
} else if (category === "types") {
|
||||
col1 = clsDesc;
|
||||
} else if (category === "members") {
|
||||
col1 = mbrDesc;
|
||||
} else if (category === "searchTags") {
|
||||
col1 = tagDesc;
|
||||
}
|
||||
col2 = descDesc;
|
||||
$("<div class='table-header'/>")
|
||||
.append($("<span class='table-header'/>").html(col1))
|
||||
.append($("<span class='table-header'/>").html(col2))
|
||||
.appendTo(table);
|
||||
$.each(items, function(index, item) {
|
||||
renderItem(item, table);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
function select() {
|
||||
if (!this.classList.contains("selected")) {
|
||||
setSelected(this);
|
||||
}
|
||||
}
|
||||
function unselect() {
|
||||
if (this.classList.contains("selected")) {
|
||||
setSelected(null);
|
||||
}
|
||||
}
|
||||
function renderItem(item, table) {
|
||||
var label = getResultLabel(item);
|
||||
var desc = getResultDescription(item);
|
||||
var link = $("<a/>")
|
||||
.attr("href", getURL(item.indexItem, item.category))
|
||||
.attr("tabindex", "0")
|
||||
.addClass("search-result-link");
|
||||
link.on("mousemove", select.bind(link[0]))
|
||||
.on("focus", select.bind(link[0]))
|
||||
.on("mouseleave", unselect.bind(link[0]))
|
||||
.on("blur", unselect.bind(link[0]))
|
||||
.append($("<span/>").addClass("search-result-label").html(label))
|
||||
.append($("<span/>").addClass("search-result-desc").html(desc))
|
||||
.appendTo(table);
|
||||
}
|
||||
var timeout;
|
||||
function schedulePageSearch() {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
timeout = setTimeout(function () {
|
||||
doPageSearch()
|
||||
}, 100);
|
||||
}
|
||||
function doPageSearch() {
|
||||
setSearchUrl();
|
||||
var term = searchTerm = input.val().trim();
|
||||
if (term === "") {
|
||||
notify.html(messages.enterTerm);
|
||||
activeTab = "";
|
||||
fixedTab = false;
|
||||
resultContainer.empty();
|
||||
resultSection.hide();
|
||||
} else {
|
||||
notify.html(messages.searching);
|
||||
var module = modules.val();
|
||||
doSearch({ term: term, maxResults: 1200, module: module}, renderResults);
|
||||
}
|
||||
}
|
||||
function setSearchUrl() {
|
||||
var query = input.val().trim();
|
||||
var url = document.location.pathname;
|
||||
if (query) {
|
||||
url += "?q=" + encodeURI(query);
|
||||
if (activeTab && fixedTab) {
|
||||
url += "&c=" + activeTab;
|
||||
}
|
||||
if (modules.val()) {
|
||||
url += "&m=" + modules.val();
|
||||
}
|
||||
}
|
||||
history.replaceState({query: query}, "", url);
|
||||
}
|
||||
input.on("input", function(e) {
|
||||
feelingLucky = false;
|
||||
reset.css("visibility", input.val() ? "visible" : "hidden");
|
||||
schedulePageSearch();
|
||||
});
|
||||
function setSelected(link) {
|
||||
if (selectedLink) {
|
||||
selectedLink.classList.remove("selected");
|
||||
selectedLink.blur();
|
||||
}
|
||||
if (link) {
|
||||
link.classList.add("selected");
|
||||
link.focus({focusVisible: true});
|
||||
}
|
||||
selectedLink = link;
|
||||
}
|
||||
document.addEventListener("keydown", e => {
|
||||
if (e.ctrlKey || e.altKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
if (e.key === "Escape" && input.val()) {
|
||||
input.val("").focus();
|
||||
doPageSearch();
|
||||
e.preventDefault();
|
||||
}
|
||||
if (e.target === modules[0]) {
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
||||
if (activeTab && visibleTabs.length > 1 && e.target !== input[0]) {
|
||||
var tab = visibleTabs.indexOf(activeTab);
|
||||
var newTab = e.key === "ArrowLeft"
|
||||
? Math.max(0, tab - 1)
|
||||
: Math.min(visibleTabs.length - 1, tab + 1);
|
||||
if (newTab !== tab) {
|
||||
selectTab(visibleTabs[newTab]);
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
||||
let links = Array.from(
|
||||
document.querySelectorAll("div.result-table > a.search-result-link"));
|
||||
let current = links.indexOf(selectedLink);
|
||||
let activeButton = document.querySelector("button.active-table-tab");
|
||||
if (e.key === "ArrowUp" || (e.key === "Tab" && e.shiftKey)) {
|
||||
if (current > 0) {
|
||||
setSelected(links[current - 1]);
|
||||
} else {
|
||||
setSelected(null);
|
||||
if (activeButton && current === 0) {
|
||||
activeButton.focus();
|
||||
} else {
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
} else if (e.key === "ArrowDown") {
|
||||
if (document.activeElement === input[0] && activeButton) {
|
||||
activeButton.focus();
|
||||
} else if (current < links.length - 1) {
|
||||
setSelected(links[current + 1]);
|
||||
}
|
||||
}
|
||||
e.preventDefault();
|
||||
} else if (e.key.length === 1 || e.key === "Backspace") {
|
||||
setSelected(null);
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
reset.on("click", function() {
|
||||
notify.html(messages.enterTerm);
|
||||
resultSection.hide();
|
||||
activeTab = "";
|
||||
fixedTab = false;
|
||||
resultContainer.empty();
|
||||
input.val('').focus();
|
||||
setSearchUrl();
|
||||
});
|
||||
modules.on("change", function() {
|
||||
if (input.val()) {
|
||||
doPageSearch();
|
||||
}
|
||||
input.focus();
|
||||
try {
|
||||
localStorage.setItem("search-modules", modules.val());
|
||||
} catch (unsupported) {}
|
||||
});
|
||||
|
||||
input.prop("disabled", false);
|
||||
input.attr("autocapitalize", "off");
|
||||
reset.prop("disabled", false);
|
||||
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.has("m")) {
|
||||
modules.val(urlParams.get("m"));
|
||||
} else {
|
||||
try {
|
||||
var searchModules = localStorage.getItem("search-modules");
|
||||
if (searchModules) {
|
||||
modules.val(searchModules);
|
||||
}
|
||||
} catch (unsupported) {}
|
||||
}
|
||||
if (urlParams.has("q")) {
|
||||
input.val(urlParams.get("q"));
|
||||
reset.css("visibility", input.val() ? "visible" : "hidden");
|
||||
}
|
||||
if (urlParams.has("c")) {
|
||||
activeTab = urlParams.get("c");
|
||||
fixedTab = true;
|
||||
}
|
||||
if (urlParams.get("r")) {
|
||||
feelingLucky = true;
|
||||
}
|
||||
if (input.val()) {
|
||||
doPageSearch();
|
||||
} else {
|
||||
notify.html(messages.enterTerm);
|
||||
}
|
||||
input.select().focus();
|
||||
});
|
||||
549
build/docs/javadoc/script-files/search.js
Normal file
549
build/docs/javadoc/script-files/search.js
Normal file
@@ -0,0 +1,549 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
||||
*/
|
||||
"use strict";
|
||||
const messages = {
|
||||
enterTerm: "Enter a search term",
|
||||
noResult: "No results found",
|
||||
oneResult: "Found one result",
|
||||
manyResults: "Found {0} results",
|
||||
loading: "Loading search index...",
|
||||
searching: "Searching...",
|
||||
redirecting: "Redirecting to first result...",
|
||||
}
|
||||
const categories = {
|
||||
modules: "Modules",
|
||||
packages: "Packages",
|
||||
types: "Classes and Interfaces",
|
||||
members: "Members",
|
||||
searchTags: "Search Tags"
|
||||
};
|
||||
// Localized element descriptors must match values in enum IndexItem.Kind.
|
||||
const itemDesc = [
|
||||
// Members
|
||||
["Enum constant in {0}"],
|
||||
["Variable in {0}"],
|
||||
["Static variable in {0}"],
|
||||
["Constructor for {0}"],
|
||||
["Element in {0}"],
|
||||
["Method in {0}"],
|
||||
["Static method in {0}"],
|
||||
["Record component of {0}"],
|
||||
// Types in upper and lower case
|
||||
["Annotation Interface", "annotation interface"],
|
||||
["Enum Class", "enum class"],
|
||||
["Interface", "interface"],
|
||||
["Record Class", "record class"],
|
||||
["Class", "class"],
|
||||
["Exception Class", "exception class"],
|
||||
// Tags
|
||||
["Search tag in {0}"],
|
||||
["System property in {0}"],
|
||||
["Section in {0}"],
|
||||
["External specification in {0}"],
|
||||
// Other
|
||||
["Summary Page"],
|
||||
];
|
||||
const mbrDesc = "Member";
|
||||
const clsDesc = "Class"
|
||||
const pkgDesc = "Package";
|
||||
const mdlDesc = "Module";
|
||||
const pkgDescLower = "package";
|
||||
const mdlDescLower = "module";
|
||||
const tagDesc = "Search Tag";
|
||||
const inDesc = "{0} in {1}";
|
||||
const descDesc = "Description";
|
||||
const linkLabel = "Go to search page";
|
||||
const NO_MATCH = {};
|
||||
const MAX_RESULTS = 300;
|
||||
const UNICODE_LETTER = 0;
|
||||
const UNICODE_DIGIT = 1;
|
||||
const UNICODE_OTHER = 2;
|
||||
function checkUnnamed(name, separator) {
|
||||
return name === "<Unnamed>" || !name ? "" : name + separator;
|
||||
}
|
||||
function escapeHtml(str) {
|
||||
return str.replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
function getHighlightedText(str, boundaries, from, to) {
|
||||
var start = from;
|
||||
var text = "";
|
||||
for (var i = 0; i < boundaries.length; i += 2) {
|
||||
var b0 = boundaries[i];
|
||||
var b1 = boundaries[i + 1];
|
||||
if (b0 >= to || b1 <= from) {
|
||||
continue;
|
||||
}
|
||||
text += escapeHtml(str.slice(start, Math.max(start, b0)));
|
||||
text += "<span class='result-highlight'>";
|
||||
text += escapeHtml(str.slice(Math.max(start, b0), Math.min(to, b1)));
|
||||
text += "</span>";
|
||||
start = Math.min(to, b1);
|
||||
}
|
||||
text += escapeHtml(str.slice(start, to));
|
||||
return text;
|
||||
}
|
||||
function getURLPrefix(item, category) {
|
||||
var urlPrefix = "";
|
||||
var slash = "/";
|
||||
if (category === "modules") {
|
||||
return item.l + slash;
|
||||
} else if (category === "packages" && item.m) {
|
||||
return item.m + slash;
|
||||
} else if (category === "types" || category === "members") {
|
||||
if (item.m) {
|
||||
urlPrefix = item.m + slash;
|
||||
} else {
|
||||
$.each(packageSearchIndex, function(index, it) {
|
||||
if (it.m && item.p === it.l) {
|
||||
urlPrefix = it.m + slash;
|
||||
item.m = it.m;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return urlPrefix;
|
||||
}
|
||||
function getURL(item, category) {
|
||||
if (item.url) {
|
||||
return item.url;
|
||||
}
|
||||
var url = getURLPrefix(item, category);
|
||||
if (category === "modules") {
|
||||
url += "module-summary.html";
|
||||
} else if (category === "packages") {
|
||||
if (item.u) {
|
||||
url = item.u;
|
||||
} else {
|
||||
url += item.l.replace(/\./g, '/') + "/package-summary.html";
|
||||
}
|
||||
} else if (category === "types") {
|
||||
if (item.u) {
|
||||
url = item.u;
|
||||
} else {
|
||||
url += checkUnnamed(item.p, "/").replace(/\./g, '/') + item.l + ".html";
|
||||
}
|
||||
} else if (category === "members") {
|
||||
url += checkUnnamed(item.p, "/").replace(/\./g, '/') + item.c + ".html" + "#";
|
||||
if (item.u) {
|
||||
url += item.u;
|
||||
} else {
|
||||
url += item.l;
|
||||
}
|
||||
} else if (category === "searchTags") {
|
||||
url += item.u;
|
||||
}
|
||||
item.url = url;
|
||||
return url;
|
||||
}
|
||||
function createMatcher(term, camelCase) {
|
||||
if (camelCase && !isUpperCase(term)) {
|
||||
return null; // no need for camel-case matcher for lower case query
|
||||
}
|
||||
var pattern = "";
|
||||
var upperCase = [];
|
||||
term.trim().split(/\s+/).forEach(function(w, index, array) {
|
||||
var tokens = w.split(/(?=[\p{Lu},.()<>?[\/])/u);
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var s = tokens[i];
|
||||
// ',' and '?' are the only delimiters commonly followed by space in java signatures
|
||||
pattern += "(" + escapeUnicodeRegex(s).replace(/[,?]/g, "$&\\s*?") + ")";
|
||||
upperCase.push(false);
|
||||
if (i === tokens.length - 1 && index < array.length - 1) {
|
||||
// space in query string matches all delimiters
|
||||
pattern += "(.*?)";
|
||||
upperCase.push(isUpperCase(s[0]));
|
||||
} else {
|
||||
if (!camelCase && isUpperCase(s) && s.length === 1) {
|
||||
pattern += "()";
|
||||
} else {
|
||||
pattern += "([\\p{L}\\p{Nd}\\p{Sc}<>?[\\]]*?)";
|
||||
}
|
||||
upperCase.push(isUpperCase(s[0]));
|
||||
}
|
||||
}
|
||||
});
|
||||
var re = new RegExp(pattern, camelCase ? "gu" : "gui");
|
||||
re.upperCase = upperCase;
|
||||
return re;
|
||||
}
|
||||
// Unicode regular expressions do not allow certain characters to be escaped
|
||||
function escapeUnicodeRegex(pattern) {
|
||||
return pattern.replace(/[\[\]{}()*+?.\\^$|\s]/g, '\\$&');
|
||||
}
|
||||
function findMatch(matcher, input, startOfName, endOfName, prefixLength) {
|
||||
var from = startOfName;
|
||||
matcher.lastIndex = from;
|
||||
var match = matcher.exec(input);
|
||||
// Expand search area until we get a valid result or reach the beginning of the string
|
||||
while (!match || match.index + match[0].length < startOfName || endOfName < match.index) {
|
||||
if (from === 0) {
|
||||
return NO_MATCH;
|
||||
}
|
||||
from = input.lastIndexOf(".", from - 2) + 1;
|
||||
matcher.lastIndex = from;
|
||||
match = matcher.exec(input);
|
||||
}
|
||||
var boundaries = [];
|
||||
var matchEnd = match.index + match[0].length;
|
||||
var score = 5;
|
||||
var start = match.index;
|
||||
var prevEnd = -1;
|
||||
for (var i = 1; i < match.length; i += 2) {
|
||||
var charType = getCharType(input[start]);
|
||||
// capturing groups come in pairs, match and non-match
|
||||
boundaries.push(start, start + match[i].length);
|
||||
var prevChar = input[start - 1] || "";
|
||||
var nextChar = input[start + 1] || "";
|
||||
// make sure group is anchored on a word boundary
|
||||
if (start !== 0 && start !== startOfName) {
|
||||
if (charType === UNICODE_DIGIT && getCharType(prevChar) === UNICODE_DIGIT) {
|
||||
return NO_MATCH; // Numeric token must match at first digit
|
||||
} else if (charType === UNICODE_LETTER && getCharType(prevChar) === UNICODE_LETTER) {
|
||||
if (!isUpperCase(input[start]) || (!isLowerCase(prevChar) && !isLowerCase(nextChar))) {
|
||||
// Not returning NO_MATCH below is to enable upper-case query strings
|
||||
if (!matcher.upperCase[i] || start !== prevEnd) {
|
||||
return NO_MATCH;
|
||||
} else if (!isUpperCase(input[start])) {
|
||||
score -= 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
prevEnd = start + match[i].length;
|
||||
start += match[i].length + match[i + 1].length;
|
||||
|
||||
// Lower score for unmatched parts between matches
|
||||
if (match[i + 1]) {
|
||||
score -= rateDistance(match[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Lower score for unmatched leading part of name
|
||||
if (startOfName < match.index) {
|
||||
score -= rateDistance(input.substring(startOfName, match.index));
|
||||
}
|
||||
// Favor child or parent variety depending on whether parent is included in search
|
||||
var matchIncludesContaining = match.index < startOfName;
|
||||
// Lower score for unmatched trailing part of name, but exclude member listings
|
||||
if (matchEnd < endOfName && input[matchEnd - 1] !== ".") {
|
||||
let factor = matchIncludesContaining ? 0.1 : 0.8;
|
||||
score -= rateDistance(input.substring(matchEnd, endOfName)) * factor;
|
||||
}
|
||||
// Lower score for unmatched prefix in member class name
|
||||
if (prefixLength < match.index && prefixLength < startOfName) {
|
||||
let factor = matchIncludesContaining ? 0.8 : 0.4;
|
||||
score -= rateDistance(input.substring(prefixLength, Math.min(match.index, startOfName))) * factor;
|
||||
}
|
||||
// Rank qualified names by package name
|
||||
if (prefixLength > 0) {
|
||||
score -= rateDistance(input.substring(0, prefixLength)) * 0.2;
|
||||
}
|
||||
// Reduce score of constructors in member listings
|
||||
if (matchEnd === prefixLength) {
|
||||
score -= 0.1;
|
||||
}
|
||||
|
||||
return score > 0 ? {
|
||||
input: input,
|
||||
score: score,
|
||||
boundaries: boundaries
|
||||
} : NO_MATCH;
|
||||
}
|
||||
function isLetter(s) {
|
||||
return /\p{L}/u.test(s);
|
||||
}
|
||||
function isUpperCase(s) {
|
||||
return /\p{Lu}/u.test(s);
|
||||
}
|
||||
function isLowerCase(s) {
|
||||
return /\p{Ll}/u.test(s);
|
||||
}
|
||||
function isDigit(s) {
|
||||
return /\p{Nd}/u.test(s);
|
||||
}
|
||||
function getCharType(s) {
|
||||
if (isLetter(s)) {
|
||||
return UNICODE_LETTER;
|
||||
} else if (isDigit(s)) {
|
||||
return UNICODE_DIGIT;
|
||||
} else {
|
||||
return UNICODE_OTHER;
|
||||
}
|
||||
}
|
||||
function rateDistance(str) {
|
||||
// Rate distance of string by counting word boundaries and camel-case tokens
|
||||
return !str ? 0
|
||||
: (str.split(/\b|(?<=[\p{Ll}_])\p{Lu}/u).length * 0.1
|
||||
+ (isUpperCase(str[0]) ? 0.08 : 0));
|
||||
}
|
||||
function doSearch(request, response) {
|
||||
var term = request.term.trim();
|
||||
var maxResults = request.maxResults || MAX_RESULTS;
|
||||
var module = checkUnnamed(request.module, "/");
|
||||
var matcher = {
|
||||
plainMatcher: createMatcher(term, false),
|
||||
camelCaseMatcher: createMatcher(term, true)
|
||||
}
|
||||
var indexLoaded = indexFilesLoaded();
|
||||
|
||||
function getPrefix(item, category) {
|
||||
switch (category) {
|
||||
case "packages":
|
||||
return checkUnnamed(item.m, "/");
|
||||
case "types":
|
||||
case "members":
|
||||
return checkUnnamed(item.p, ".");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
function getClassPrefix(item, category) {
|
||||
if (category === "members" && (!item.k || (item.k < 8 && item.k !== "3"))) {
|
||||
return item.c + ".";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
function searchIndex(indexArray, category) {
|
||||
var matches = [];
|
||||
if (!indexArray) {
|
||||
if (!indexLoaded) {
|
||||
matches.push({ l: messages.loading, category: category });
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
$.each(indexArray, function (i, item) {
|
||||
if (module) {
|
||||
var modulePrefix = getURLPrefix(item, category) || item.u;
|
||||
if (modulePrefix.indexOf("/") > -1 && !modulePrefix.startsWith(module)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var prefix = getPrefix(item, category);
|
||||
var classPrefix = getClassPrefix(item, category);
|
||||
var simpleName = classPrefix + item.l;
|
||||
if (item.d) {
|
||||
simpleName += " - " + item.d;
|
||||
}
|
||||
var qualName = prefix + simpleName;
|
||||
var startOfName = classPrefix.length + prefix.length;
|
||||
var endOfName = category === "members" && qualName.indexOf("(", startOfName) > -1
|
||||
? qualName.indexOf("(", startOfName) : qualName.length;
|
||||
var m = findMatch(matcher.plainMatcher, qualName, startOfName, endOfName, prefix.length);
|
||||
if (m === NO_MATCH && matcher.camelCaseMatcher) {
|
||||
m = findMatch(matcher.camelCaseMatcher, qualName, startOfName, endOfName, prefix.length);
|
||||
}
|
||||
if (m !== NO_MATCH) {
|
||||
m.indexItem = item;
|
||||
m.name = simpleName;
|
||||
m.category = category;
|
||||
if (m.boundaries[0] < prefix.length) {
|
||||
m.name = qualName;
|
||||
} else {
|
||||
m.boundaries = m.boundaries.map(function(b) {
|
||||
return b - prefix.length;
|
||||
});
|
||||
}
|
||||
// m.name = m.name + " " + m.score.toFixed(3);
|
||||
matches.push(m);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return matches.sort(function(e1, e2) {
|
||||
return e2.score - e1.score
|
||||
|| (category !== "members"
|
||||
? e1.name.localeCompare(e2.name) : 0);
|
||||
}).slice(0, maxResults);
|
||||
}
|
||||
|
||||
var result = searchIndex(moduleSearchIndex, "modules")
|
||||
.concat(searchIndex(packageSearchIndex, "packages"))
|
||||
.concat(searchIndex(typeSearchIndex, "types"))
|
||||
.concat(searchIndex(memberSearchIndex, "members"))
|
||||
.concat(searchIndex(tagSearchIndex, "searchTags"));
|
||||
|
||||
if (!indexLoaded) {
|
||||
updateSearchResults = function() {
|
||||
doSearch(request, response);
|
||||
}
|
||||
} else {
|
||||
updateSearchResults = function() {};
|
||||
}
|
||||
response(result);
|
||||
}
|
||||
// JQuery search menu implementation
|
||||
$.widget("custom.catcomplete", $.ui.autocomplete, {
|
||||
_create: function() {
|
||||
this._super();
|
||||
this.widget().menu("option", "items", "> .result-item");
|
||||
// workaround for search result scrolling
|
||||
this.menu._scrollIntoView = function _scrollIntoView( item ) {
|
||||
var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
|
||||
if ( this._hasScroll() ) {
|
||||
borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
|
||||
paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
|
||||
offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
|
||||
scroll = this.activeMenu.scrollTop();
|
||||
elementHeight = this.activeMenu.height() - 26;
|
||||
itemHeight = item.outerHeight();
|
||||
|
||||
if ( offset < 0 ) {
|
||||
this.activeMenu.scrollTop( scroll + offset );
|
||||
} else if ( offset + itemHeight > elementHeight ) {
|
||||
this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
_renderMenu: function(ul, items) {
|
||||
var currentCategory = "";
|
||||
var widget = this;
|
||||
widget.menu.bindings = $();
|
||||
$.each(items, function(index, item) {
|
||||
if (item.category && item.category !== currentCategory) {
|
||||
ul.append("<li class='ui-autocomplete-category'>" + categories[item.category] + "</li>");
|
||||
currentCategory = item.category;
|
||||
}
|
||||
var li = widget._renderItemData(ul, item);
|
||||
if (item.category) {
|
||||
li.attr("aria-label", categories[item.category] + " : " + item.l);
|
||||
} else {
|
||||
li.attr("aria-label", item.l);
|
||||
}
|
||||
li.attr("class", "result-item");
|
||||
});
|
||||
ul.append("<li class='ui-static-link'><div><a href='" + pathtoroot + "search.html?q="
|
||||
+ encodeURI(widget.term) + "'>" + linkLabel + "</a></div></li>");
|
||||
},
|
||||
_renderItem: function(ul, item) {
|
||||
var label = getResultLabel(item);
|
||||
var resultDesc = getResultDescription(item);
|
||||
return $("<li/>")
|
||||
.append($("<div/>")
|
||||
.append($("<span/>").addClass("search-result-label").html(label))
|
||||
.append($("<span/>").addClass("search-result-desc").html(resultDesc)))
|
||||
.appendTo(ul);
|
||||
},
|
||||
_resizeMenu: function () {
|
||||
var ul = this.menu.element;
|
||||
var missing = 0;
|
||||
ul.children().each((i, e) => {
|
||||
if (e.hasChildNodes() && e.firstChild.hasChildNodes()) {
|
||||
var label = e.firstChild.firstChild;
|
||||
missing = Math.max(missing, label.scrollWidth - label.clientWidth);
|
||||
}
|
||||
});
|
||||
ul.outerWidth( Math.max(
|
||||
ul.width("").outerWidth() + missing + 40,
|
||||
this.element.outerWidth()
|
||||
));
|
||||
}
|
||||
});
|
||||
function getResultLabel(item) {
|
||||
if (item.l) {
|
||||
return item.l;
|
||||
}
|
||||
return getHighlightedText(item.name, item.boundaries, 0, item.name.length);
|
||||
}
|
||||
function getResultDescription(item) {
|
||||
if (!item.indexItem) {
|
||||
return "";
|
||||
}
|
||||
var kind;
|
||||
switch (item.category) {
|
||||
case "members":
|
||||
var typeName = checkUnnamed(item.indexItem.p, ".") + item.indexItem.c;
|
||||
var typeDesc = getEnclosingTypeDesc(item.indexItem);
|
||||
kind = itemDesc[item.indexItem.k || 5][0];
|
||||
return kind.replace("{0}", typeDesc + " " + typeName);
|
||||
case "types":
|
||||
var pkgName = checkUnnamed(item.indexItem.p, "");
|
||||
kind = itemDesc[item.indexItem.k || 12][0];
|
||||
if (!pkgName) {
|
||||
// Handle "All Classes" summary page and unnamed package
|
||||
return item.indexItem.k === "18" ? kind : kind + " " + item.indexItem.l;
|
||||
}
|
||||
return getEnclosingDescription(kind, pkgDescLower, pkgName);
|
||||
case "packages":
|
||||
if (item.indexItem.k === "18") {
|
||||
return itemDesc[item.indexItem.k][0]; // "All Packages" summary page
|
||||
} else if (!item.indexItem.m) {
|
||||
return pkgDesc + " " + item.indexItem.l;
|
||||
}
|
||||
var mdlName = item.indexItem.m;
|
||||
return getEnclosingDescription(pkgDesc, mdlDescLower, mdlName);
|
||||
case "modules":
|
||||
return mdlDesc + " " + item.indexItem.l;
|
||||
case "searchTags":
|
||||
if (item.indexItem) {
|
||||
var holder = item.indexItem.h;
|
||||
kind = itemDesc[item.indexItem.k || 14][0];
|
||||
return holder ? kind.replace("{0}", holder) : kind;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
function getEnclosingDescription(elem, desc, label) {
|
||||
return inDesc.replace("{0}", elem).replace("{1}", desc + " " + label);
|
||||
}
|
||||
function getEnclosingTypeDesc(item) {
|
||||
if (!item.typeDesc) {
|
||||
$.each(typeSearchIndex, function(index, it) {
|
||||
if (it.l === item.c && it.p === item.p && it.m === item.m) {
|
||||
item.typeDesc = itemDesc[it.k || 12][1];
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return item.typeDesc || "";
|
||||
}
|
||||
$(function() {
|
||||
var search = $("#search-input");
|
||||
var reset = $("#reset-search");
|
||||
search.catcomplete({
|
||||
minLength: 1,
|
||||
delay: 200,
|
||||
source: function(request, response) {
|
||||
if (request.term.trim() === "") {
|
||||
return this.close();
|
||||
}
|
||||
// Prevent selection of item at current mouse position
|
||||
this.menu.previousFilter = "_";
|
||||
this.menu.filterTimer = this.menu._delay(function() {
|
||||
delete this.previousFilter;
|
||||
}, 1000);
|
||||
return doSearch(request, response);
|
||||
},
|
||||
response: function(event, ui) {
|
||||
if (!ui.content.length) {
|
||||
ui.content.push({ l: messages.noResult });
|
||||
}
|
||||
},
|
||||
autoFocus: true,
|
||||
focus: function(event, ui) {
|
||||
return false;
|
||||
},
|
||||
position: {
|
||||
collision: "flip"
|
||||
},
|
||||
select: function(event, ui) {
|
||||
if (ui.item.indexItem) {
|
||||
var url = getURL(ui.item.indexItem, ui.item.category);
|
||||
window.location.href = pathtoroot + url;
|
||||
search.blur();
|
||||
}
|
||||
}
|
||||
});
|
||||
search.val('');
|
||||
search.on("input", () => reset.css("visibility", search.val() ? "visible" : "hidden"))
|
||||
search.prop("disabled", false);
|
||||
search.attr("autocapitalize", "off");
|
||||
reset.prop("disabled", false);
|
||||
reset.click(function() {
|
||||
search.val('').focus();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user