This commit is contained in:
github-actions[bot]
2023-01-22 01:15:27 +00:00
parent 4c01b8b601
commit 28288343cd
65 changed files with 407 additions and 120 deletions
+40 -1
View File
@@ -58,7 +58,7 @@ function initSearch() {
request.onload = function(){
if (request.status >= 200 && request.status < 400) {
var docs = JSON.parse(request.responseText);
lunr.tokenizer.separator = /[\s\-/]+/
var index = lunr(function(){
@@ -69,6 +69,7 @@ function initSearch() {
this.metadataWhitelist = ['position']
for (var i in docs) {
this.add({
id: i,
title: docs[i].title,
@@ -197,6 +198,7 @@ function searchLoaded(index, docs) {
resultTitle.classList.add('search-result-title');
resultLink.appendChild(resultTitle);
// note: the SVG svg-doc is only loaded as a Jekyll include if site.search_enabled is true; see _includes/icons/icons.html
var resultDoc = document.createElement('div');
resultDoc.classList.add('search-result-doc');
resultDoc.innerHTML = '<svg viewBox="0 0 24 24" class="search-result-icon"><use xlink:href="#svg-doc"></use></svg>';
@@ -453,6 +455,43 @@ jtd.onReady(function(){
scrollNav();
});
// Copy button on code
jtd.onReady(function(){
var codeBlocks = document.querySelectorAll('div.highlighter-rouge, div.listingblock, figure.highlight');
// note: the SVG svg-copied and svg-copy is only loaded as a Jekyll include if site.enable_copy_code_button is true; see _includes/icons/icons.html
var svgCopied = '<svg viewBox="0 0 24 24" class="copy-icon"><use xlink:href="#svg-copied"></use></svg>';
var svgCopy = '<svg viewBox="0 0 24 24" class="copy-icon"><use xlink:href="#svg-copy"></use></svg>';
codeBlocks.forEach(codeBlock => {
var copyButton = document.createElement('button');
var timeout = null;
copyButton.type = 'button';
copyButton.ariaLabel = 'Copy code to clipboard';
copyButton.innerHTML = svgCopy;
codeBlock.append(copyButton);
copyButton.addEventListener('click', function () {
if(timeout === null) {
var code = codeBlock.querySelector('pre:not(.lineno)').innerText;
window.navigator.clipboard.writeText(code);
copyButton.innerHTML = svgCopied;
var timeoutSetting = 4000;
timeout = setTimeout(function () {
copyButton.innerHTML = svgCopy;
timeout = null;
}, timeoutSetting);
}
});
});
});
})(window.jtd = window.jtd || {});
File diff suppressed because one or more lines are too long
+58 -3
View File
File diff suppressed because one or more lines are too long