Move custom javascript into custom.js

- May be affected by compressor layout
This commit is contained in:
Xevion
2022-04-10 22:21:13 -05:00
parent c54af4e4e3
commit 0b3e49be94
2 changed files with 13 additions and 14 deletions

View File

@@ -55,20 +55,7 @@ layout: compress
<!-- Prevent FireFox from displaying FOUC with fake script tag. --> <!-- Prevent FireFox from displaying FOUC with fake script tag. -->
<script>0</script> <script>0</script>
{% if page.layout == "posts" %} {% if page.layout == "posts" %}
<script> <script src="/assets/js/custom.js"></script>
window.onload = () => {
let commit = document.querySelector("#commit-id > a");
if (commit != null) {
let colorCode = commit.innerHTML.trim().substring(1, 7);
commit.addEventListener('mouseover', function handler() {
commit.style.color = `#${colorCode}`;
})
commit.addEventListener('mouseout', function handler() {
commit.style.color = '';
})
}
}
</script>
{% endif %} {% endif %}
</head> </head>
<body> <body>

12
assets/js/custom.js Normal file
View File

@@ -0,0 +1,12 @@
window.onload = () => {
let commit = document.querySelector("#commit-id > a");
if (commit != null) {
let colorCode = commit.innerHTML.trim().substring(1, 7);
commit.addEventListener('mouseover', function handler() {
commit.style.color = `#${colorCode}`;
})
commit.addEventListener('mouseout', function handler() {
commit.style.color = '';
})
}
}