MediaWiki:Common.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 264: | Line 264: | ||
/* */ | /* */ | ||
(function () { | (function () { | ||
function | function jakeAddFeedbackToNamespaces() { | ||
var list = document.querySelector("#p-associated-pages .vector-menu-content-list"); | |||
if ( | if (!list) return; | ||
var | var existing = document.getElementById("jake-feedback-btn"); | ||
if (! | if (existing && !existing.closest("#p-associated-pages")) { | ||
var oldLi = existing.closest("li"); | |||
if (oldLi) oldLi.remove(); | |||
else existing.remove(); | |||
} | |||
var | if (document.getElementById("ca-jake-feedback")) return; | ||
var li = document.createElement("li"); | |||
li.id = "ca-jake-feedback"; | |||
li.className = "vector-tab-noicon mw-list-item"; | |||
var a = document.createElement("a"); | var a = document.createElement("a"); | ||
a.id = "jake-feedback-btn"; | a.id = "jake-feedback-btn"; | ||
a.className = "jake-feedback-btn"; | a.className = "jake-feedback-btn"; | ||
a.href = mw.util.getUrl("Consumer_Rights_Wiki:Feedback", { | |||
a.href = mw.util.getUrl( | from: mw.config.get("wgPageName") | ||
}); | |||
a.title = "Give feedback"; | |||
var span = document.createElement("span"); | |||
span.textContent = "Feedback"; | |||
a.appendChild(span); | |||
li.appendChild(a); | |||
list.appendChild(li); | |||
} | } | ||
mw. | function jakeInit() { | ||
if (!window.mw || !mw.util || !mw.config) return; | |||
jakeAddFeedbackToNamespaces(); | |||
} | |||
if (document.readyState === "loading") { | |||
document.addEventListener("DOMContentLoaded", jakeInit); | |||
} else { | |||
jakeInit(); | |||
} | |||
})(); | })(); | ||