-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.js
More file actions
52 lines (47 loc) · 1.65 KB
/
Copy pathcommon.js
File metadata and controls
52 lines (47 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
document.querySelectorAll('.main h1').forEach((x) => {
var node = document.createElement('a');
node.href = '#' + x.id;
var i = document.createElement('i');
i.dataset.feather = 'link';
node.appendChild(i);
//node.innerHTML = '§'; //🔗 works too, but needs font-size: .6em
x.appendChild(node);
});
feather.replace();
/*
async function writeClipboardText(text) {
try {
await navigator.clipboard.writeText(text);
} catch (error) {
console.error("Error attempting to copy string '" + text + "': " + error.message);
}
}
function clipboardAvailable() {
document.body.focus();
navigator.clipboard.readText().catch(e => {
console.error('Clipboard API gave following error, disabling clipboard functionality: ' + e.message);
return false;
});
return true;
}
navigator.clipboard.readText().then(() => {
document.querySelectorAll('.main pre:has(code)').forEach(x => {
var node = document.createElement('button');
var i = document.createElement('i');
i.classList.add("fa-regular");
i.classList.add("fa-copy");
node.appendChild(i);
node.addEventListener('click', () => {
writeClipboardText(x.querySelector('code').innerHTML);
});
x.appendChild(node);
});
}).catch(e => console.error('Clipboard API gave following error, disabling clipboard functionality: ' + e.message));
*/
addEventListener('scroll', () => {
if (document.querySelector('html').scrollTop < 10) {
document.querySelector('.nav').classList.add('expanded');
} else {
document.querySelector('.nav').classList.remove('expanded');
}
});