«ميدياويكي:Common.js»: الفرق بين المراجعتين
من Sudan Memory
سطر ٤: | سطر ٤: | ||
$(function () { | $(function () { | ||
− | var script = document.createElement('script'); | + | if (document.querySelectorAll('.abyat').length > 0) { |
− | + | var script = document.createElement('script'); | |
− | + | script.src = "https://abdallagafar.github.io/poemFormat/poemFormat.js"; | |
− | + | script.addEventListener('load', function() { // Now the external script is loaded and its functions are ready to be used | |
− | + | document.querySelectorAll('.abyat').forEach(function(poem) { // Search for poems | |
− | + | poem.innerHTML = poemFormat(poem); | |
+ | }); | ||
}); | }); | ||
− | + | document.head.appendChild(script); // Append the script element to the document's head to start loading the script | |
− | + | } | |
var toggler = document.getElementsByClassName("treeBranch"); | var toggler = document.getElementsByClassName("treeBranch"); |
مراجعة ١٤:٥٤، ٢٣ مارس ٢٠٢٤
/* الجافاسكريبت الموضوع هنا سيتم تحميله لكل المستخدمين مع كل تحميل للصفحة. */ console.log("Entering Common.js"); $(function () { if (document.querySelectorAll('.abyat').length > 0) { var script = document.createElement('script'); script.src = "https://abdallagafar.github.io/poemFormat/poemFormat.js"; script.addEventListener('load', function() { // Now the external script is loaded and its functions are ready to be used document.querySelectorAll('.abyat').forEach(function(poem) { // Search for poems poem.innerHTML = poemFormat(poem); }); }); document.head.appendChild(script); // Append the script element to the document's head to start loading the script } var toggler = document.getElementsByClassName("treeBranch"); var i; for (i = 0; i < toggler.length; i++) { toggler[i].addEventListener("click", function() { this.parentElement.querySelector(".treeBranch-nested").classList.toggle("treeBranch-active"); this.classList.toggle("treeBranch-down"); }); } }());