Skip to content

Commit ae42861

Browse files
authored
Add files via upload
1 parent 90f8215 commit ae42861

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

notes/osy.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<html>
22
<head>
33
<link rel="stylesheet" href="styles.css">
4+
<script src="script.js"></script>
45
</head>
56
<body>
67

notes/pos.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<html>
22
<head>
33
<link rel="stylesheet" href="styles.css">
4+
<script src="script.js"></script>
45
</head>
56
<body>
67

notes/script.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//CHATGPT generated code to add little copy link to header icon
2+
document.addEventListener("DOMContentLoaded", function () {
3+
// Loop through all heading tags
4+
const headings = document.querySelectorAll("h1, h2, h3, h4, h5, h6");
5+
6+
headings.forEach((heading) => {
7+
// Ensure each heading has an id
8+
if (!heading.id) {
9+
heading.id = heading.textContent.trim().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]/g, "");
10+
}
11+
12+
const link = document.createElement("a");
13+
link.href = `#${heading.id}`;
14+
link.textContent = "🔗";
15+
link.style.marginLeft = "8px";
16+
link.style.textDecoration = "none";
17+
link.style.cursor = "pointer";
18+
link.title = "Copy link to clipboard";
19+
20+
link.addEventListener("click", function (e) {
21+
e.preventDefault();
22+
const url = `${location.origin}${location.pathname}#${heading.id}`;
23+
navigator.clipboard.writeText(url).then(() => {
24+
link.textContent = "✅";
25+
setTimeout(() => {
26+
link.textContent = "🔗";
27+
}, 1000);
28+
});
29+
});
30+
31+
heading.appendChild(link);
32+
});
33+
});

0 commit comments

Comments
 (0)