Content deleted Content added
change link |
wrap with anonymous function |
||
Line 4:
// Edited version [[User:MC10/stubtagtab.js]]
(function
function stubTagTab() {
var h, hb, newa;
// A list of subpages of WikiProject Stub sorting/Stub types/ that are relevant to this var a = ['Commerce', 'Culture', 'Education', 'Geography', 'Government, law, and politics', 'History', 'Leisure', 'Military and weaponry', 'Miscellaneous', 'Organizations', 'People', 'Religion, mythology, faiths, and beliefs', 'Science', 'Sports', 'Technology', 'Transport'];
h = $("<div></div>");
h.css({
"color": "#000000",
"background-color": "#fff8f8"
});▼
newa = $("<a href=\"#\"></a>");▼
newa.click(function (e) {▼
e.preventDefault();▼
stubTagMenu($(this).text());▼
});
▲ stubTagMenu($(this).text());
}▼
$("#contentSub").append(h);▼
hb.css({▼
"color": "#000000",▼
"background-color": "#fffff8"▼
});▼
$("#contentSub").append(hb);▼
var parseData = $(data.parse.text["*"]);▼
parseData.find("a").each(function () {▼
var link = $(this).attr("href"),▼
if (index === -1) {▼
$(this).attr({▼
"href": null,▼
"title": null▼
});
if ((i + 1)
} else {▼
$(this).attr("href", mw.config.get("wgServer") + mw.config.get("wgScript") + "?title=" + encodeURIComponent(mw.config.get("wgPageName"))▼
+ "&action=edit&autoaddstubtag=" + encodeURIComponent(link.slice(index + 9)));▼
}
▲ $("#contentSub").append(h);
});▼
$('#stubtagmenu').html(parseData);▼
function stubTagMenu(stubType) {▼
▲ hb.css({
// Fetch the relevant subpage of the WikiProject▼
▲ "color": "#000000",
$.ajax({▼
▲ "background-color": "#fffff8"
url: mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/api.php?action=parse&prop=text&text=' + encodeURIComponent('__NOTOC____NOEDITSECTION__{{Wikipedia:WikiProject Stub sorting/Stub types/' + stubType + '}}') + '&format=json',▼
▲ $("#contentSub").append(hb);
});▼
▲ }
▲ var parseData = $(data.parse.text["*"]);
if (mw.config.get("wgNamespaceNumber") === 0 && mw.config.get("wgAction") === "view" && document.getElementById("ca-edit")) {▼
▲ parseData.find("a").each(function () {
var portletLink = mw.util.addPortletLink('p-cactions', '#', 'Stub', 'ca-stubtag', 'Add a stub tag to this page', '');▼
var link = $(
▲ "href": null,
▲ "title": null
});
"color": "#000000",
"text-decoration": "none"
});
▲ } else {
▲ $(this).attr("href", mw.config.get("wgServer") + mw.config.get("wgScript") + "?title=" + encodeURIComponent(mw.config.get("wgPageName"))
▲ + "&action=edit&autoaddstubtag=" + encodeURIComponent(link.slice(index + 9)));
});
▲ $('#stubtagmenu').html(parseData);
}
if (___location.href.indexOf("&autoaddstubtag=") !== -1 && document.getElementById('wpTextbox1') != null) {▼
▲ function stubTagMenu(stubType) {
var x = decodeURIComponent(___location.href.split("&autoaddstubtag=")[1]);▼
▲ // Fetch the relevant subpage of the WikiProject
if (x.indexOf("-stub") === -1) x += "-stub";▼
▲ $.ajax({
document.getElementById('wpTextbox1').value += "\n{" + "{" + x + "}}"; // add to the end of the article▼
▲ url: mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/api.php?action=parse&prop=text&text=' + encodeURIComponent('__NOTOC____NOEDITSECTION__{{Wikipedia:WikiProject Stub sorting/Stub types/' + stubType + '}}') + '&format=json',
document.getElementById('wpSummary').value = "Tagging with {" + "{" + x + "}} using [[User:MC10/stubtagtab.js|stubtagtab.js]]";▼
dataType: "json", // "text"
document.getElementById('wpPreview').click();▼
success: stubTagMenuRender
▲ });
}
$(function () {
▲ if (mw.config.get("wgNamespaceNumber") === 0 && mw.config.get("wgAction") === "view" && document.getElementById("ca-edit")) {
▲ var portletLink = mw.util.addPortletLink('p-cactions', '#', 'Stub', 'ca-stubtag', 'Add a stub tag to this page', '');
▲ e.preventDefault();
stubTagTab();
▲ });
▲ if (___location.href.indexOf("&autoaddstubtag=") !== -1 && document.getElementById('wpTextbox1') != null) {
▲ var x = decodeURIComponent(___location.href.split("&autoaddstubtag=")[1]);
▲ if (x.indexOf("-stub") === -1) x += "-stub";
▲ document.getElementById('wpTextbox1').value += "\n{" + "{" + x + "}}"; // add to the end of the article
▲ document.getElementById('wpSummary').value = "Tagging with {" + "{" + x + "}} using [[User:MC10/stubtagtab.js|stubtagtab.js]]";
▲ document.getElementById('wpPreview').click();
}
▲ });
} (jQuery)) // End wrap with anonymous function
// [[Category:Wikipedia scripts]]
|