41 lines
1.2 KiB
HTML
41 lines
1.2 KiB
HTML
<!--
|
|
Author: Ray-Eldath
|
|
-->
|
|
<style>
|
|
.markdown-body .anchor{
|
|
float: left;
|
|
margin-top: -8px;
|
|
margin-left: -20px;
|
|
padding-right: 4px;
|
|
line-height: 1;
|
|
opacity: 0;
|
|
}
|
|
|
|
.markdown-body .anchor .anchor-icon{
|
|
font-size: 15px
|
|
}
|
|
</style>
|
|
<script>
|
|
$(document).ready(function() {
|
|
let nodes = document.querySelector(".markdown-body").querySelectorAll("h1,h2,h3")
|
|
for(let node of nodes) {
|
|
var anchor = document.createElement("a")
|
|
var anchorIcon = document.createElement("i")
|
|
anchorIcon.setAttribute("class", "fa fa-anchor fa-lg anchor-icon")
|
|
anchorIcon.setAttribute("aria-hidden", true)
|
|
anchor.setAttribute("class", "anchor")
|
|
anchor.setAttribute("href", "#" + node.getAttribute("id"))
|
|
|
|
anchor.onmouseover = function() {
|
|
this.style.opacity = "0.4"
|
|
}
|
|
|
|
anchor.onmouseout = function() {
|
|
this.style.opacity = "0"
|
|
}
|
|
|
|
anchor.appendChild(anchorIcon)
|
|
node.appendChild(anchor)
|
|
}
|
|
})
|
|
</script> |