Fix Codersrank stuff

This commit is contained in:
2022-03-22 19:14:19 +01:00
parent 659ab29186
commit 56cb76b83a
3 changed files with 29 additions and 24 deletions

View File

@@ -25,4 +25,4 @@ In my spare time I do quite [some modding]({% link modding.html %}) to the sandb
- [<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-linkedin" viewBox="0 0 16 16" role="presentation"><path d="M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016a5.54 5.54 0 0 1 .016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z"/></svg> LinkedIn](https://linkedin.com/in/{{ site.author.linkedin }}) - [<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-linkedin" viewBox="0 0 16 16" role="presentation"><path d="M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016a5.54 5.54 0 0 1 .016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z"/></svg> LinkedIn](https://linkedin.com/in/{{ site.author.linkedin }})
<script>prepareCodersrank("skills")</script> <script>var crTypes="skills";</script>

View File

@@ -35,29 +35,34 @@
cbox.checked = !cbox.checked; cbox.checked = !cbox.checked;
} }
}); });
})();
function prepareCodersrank(type) { if (crTypes) {
var placeholders = document.getElementsByClassName("cr-placeholder"); // Codersrank
if (localStorage.getItem("load-codersrank")) { const placeholders = document.getElementsByClassName("cr-placeholder");
loadCodersrank(type); if (localStorage.getItem("load-codersrank")) {
} else { loadCodersrank(crTypes);
for (ph of placeholders) { } else {
ph.addEventListener("click", e => { for (ph of placeholders) {
e.preventDefault(); ph.addEventListener("click", e => {
console.log(e); e.preventDefault();
localStorage.setItem("load-codersrank", true); console.log(e);
loadCodersrank(type); localStorage.setItem("load-codersrank", true);
}); loadCodersrank(crTypes);
});
}
} }
} }
}
function loadCodersrank(type) { function loadCodersrank(types) {
var script = document.createElement("script"); const scriptElems = [];
script.src = "https://unpkg.com/@codersrank/activity/codersrank-" + type + ".min.js"; for (type of types) {
for (ph of document.getElementsByClassName("cr-placeholder")) { const script = document.createElement("script");
ph.parentElement.innerHTML = ph.childNodes[0].data; script.src = "https://unpkg.com/@codersrank/activity/codersrank-" + type + ".min.js";
} scriptElems.push(script);
document.head.appendChild(script); }
} for (ph of document.getElementsByClassName("cr-placeholder")) {
ph.parentElement.innerHTML = ph.childNodes[0].data;
}
document.head.append(...scriptElems);
}
})();

View File

@@ -11,4 +11,4 @@ layout: home
</span> </span>
</a> </a>
<script>prepareCodersrank("activity")</script> <script>var crTypes="activity";</script>