This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/bbcode/script.js

21 lines
728 B
JavaScript
Raw Normal View History

2020-03-02 17:12:43 +00:00
document.addEventListener('DOMContentLoaded', () => {
2023-12-30 13:59:27 +00:00
document.querySelectorAll(".shm-clink").forEach(function(el) {
var target_id = el.getAttribute("data-clink-sel");
if(target_id && document.querySelectorAll(target_id).length > 0) {
2018-11-05 22:59:53 +00:00
// if the target comment is already on this page, don't bother
// switching pages
2023-12-30 13:59:27 +00:00
el.setAttribute("href", target_id);
2018-11-05 22:59:53 +00:00
// highlight it when clicked
2023-12-30 13:59:27 +00:00
el.addEventListener("click", function(e) {
2018-11-05 22:59:53 +00:00
// This needs jQuery UI
$(target_id).highlight();
});
2023-12-30 13:59:27 +00:00
2018-11-05 22:59:53 +00:00
// vanilla target name should already be in the URL tag, but this
// will include the anon ID as displayed on screen
2023-12-30 13:59:27 +00:00
el.innerHTML = "@"+document.querySelector(target_id+" .username").innerHTML;
2018-11-05 22:59:53 +00:00
}
});
});