미디어위키:Common.js: 두 판 사이의 차이

S.T.E.L.L.A.-WIKI
(새 문서: →‎이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다.: document.addEventListener('DOMContentLoaded', function() { var footnotes = document.querySelectorAll('.fake-footnote'); footnotes.forEach(function(footnote) { footnote.addEventListener('mouseover', function() { var id = footnote.getAttribute('data-footnote-id'); document.getElementById(id).style.display = 'block'; }); footnote.addEventListener('mouseout',...)
 
편집 요약 없음
1번째 줄: 1번째 줄:
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener('DOMContentLoaded', function() {
   var customRefs = document.querySelectorAll(".custom-ref");
   var footnotes = document.querySelectorAll('.fake-footnote');
   customRefs.forEach(function(ref) {
    
     var refName = ref.getAttribute("id").replace("custom-ref-", "");
  footnotes.forEach(function(footnote) {
    var actualRef = document.querySelector("ref[name='" + refName + "']");
     footnote.addEventListener('mouseover', function() {
     if (actualRef) {
      var id = footnote.getAttribute('data-footnote-id');
      ref.setAttribute("data-tooltip", actualRef.innerHTML);
      document.getElementById(id).style.display = 'block';
      ref.addEventListener("click", function() {
     });
        actualRef.scrollIntoView();
 
       });
    footnote.addEventListener('mouseout', function() {
     }
      var id = footnote.getAttribute('data-footnote-id');
       document.getElementById(id).style.display = 'none';
     });
   });
   });
});
});

2024년 5월 28일 (화) 05:17 판

document.addEventListener("DOMContentLoaded", function() {
  var customRefs = document.querySelectorAll(".custom-ref");
  customRefs.forEach(function(ref) {
    var refName = ref.getAttribute("id").replace("custom-ref-", "");
    var actualRef = document.querySelector("ref[name='" + refName + "']");
    if (actualRef) {
      ref.setAttribute("data-tooltip", actualRef.innerHTML);
      ref.addEventListener("click", function() {
        actualRef.scrollIntoView();
      });
    }
  });
});