问题
The following global JavaScript code is the only JavaScript code I use in my entire all-core, Hebrew, MediaWiki 1.33.0 website:
/* כל הסקריפטים הנכתבים כאן ייטענו עבור כל המשתמשים בכל טעינת עמוד. */
const list = document.querySelector("#footnotes_list");
document.querySelectorAll(".footnote>sup").forEach((footnote, i) => {
const li = document.createElement("li");
li.append(...footnote.childNodes); // move content
list.appendChild(li);
footnote.textContent = i+1;
});
Related templates
The above JavaScript code is related to the following two templates.
The following Hebrew template names mean "footnote" and "footnotes" respectively:
תבנית:הערה
<p><span class="footnote"><sup>{{{1}}}</sup></span></p><noinclude>
[[קטגוריה:תבניות עריכה]]
</noinclude>
תבנית:הערות שוליים
<ol id="footnotes_list"></ol><noinclude>
[[קטגוריה:תבניות עריכה]]
</noinclude>
Purpose
This HTML-WIKI-JavaScript combo serves as potential substitute to common references extensions as it allows each footnote to appear sorted in a footnotes section.
I think it should be useful for people desiring to avoid installing any extensions or skins from various reasons such as the desire to reduce PHP complexity, minimalism philosophy, personal comfortability and possibly more.
My problem
If I try to execute the JavaScript code from browser console it works fine --- Every footnote inserted to article body appears sorted (respective) under the "footnotes" ol
chapter.
Yet, if I try to execute that JavaScript code from https://example.com//index.php?title=מדיה_ויקי:Common.js
, it doesn't work; clearing Chrome cache with CTRL+F5 didn't help.
My question
What causes MediaWiki to fail running the JavaScript code and how could that be fixed?
Side note: credit goes to user:trincot for developing the utilized JavaScript.
回答1:
It seems to me that MediaWiki's latest release for now (1.33.0) allegedly can only execute ES3.
This session - question and accepted answer details more and include a solution.
来源:https://stackoverflow.com/questions/57638079/mediawiki-fails-executing-javascript-which-gets-executed-fine-in-browser-console