MediaWiki:Gadget-Zusammenfassung.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K Seit MW1.17: jQuery anstatt addOnloadHook |
K $ (oder jQuery) statt $j |
||
| Zeile 2: | Zeile 2: | ||
{ | { | ||
if (wgAction != "edit" && wgAction != "submit") return; | if (wgAction != "edit" && wgAction != "submit") return; | ||
if ($ | if ($(".noSummary").length > 0) return; | ||
var label = document.createElement("label"); | var label = document.createElement("label"); | ||
label.htmlFor = "stdSummaries"; | label.htmlFor = "stdSummaries"; | ||
| Zeile 31: | Zeile 31: | ||
eo.insertBefore(label, sel); | eo.insertBefore(label, sel); | ||
$ | $.get(wgScript+"?title=Vorlage:Stdsummaries&action=raw&ctype=text/plain", function(text) | ||
{ | { | ||
var sel = document.getElementById("stdSummaries"); | var sel = document.getElementById("stdSummaries"); | ||
Version vom 22. Dezember 2014, 17:40 Uhr
$(function()
{
if (wgAction != "edit" && wgAction != "submit") return;
if ($(".noSummary").length > 0) return;
var label = document.createElement("label");
label.htmlFor = "stdSummaries";
label.appendChild(document.createTextNode("Standard-Zusammenfassungen:"));
var sel = document.createElement("select");
sel.id = "stdSummaries";
sel.name = "stdSummaries";
sel.onchange = function()
{
var sel = document.getElementById("stdSummaries");
var value = sel.options[sel.selectedIndex].value;
if (value != "")
var z = document.getElementById("wpSummary").value;
if (z != "")
if (z.substring((z.length - 3)) == "*/ ")
var c = "";
else
var c = ", ";
else
var c = "";
document.getElementById("wpSummary").value += c+value;
};
var eo = document.getElementById("wpSummaryLabel").parentNode;
eo.insertBefore(document.createElement("br"), eo.firstChild);
eo.insertBefore(sel, eo.firstChild);
eo.insertBefore(label, sel);
$.get(wgScript+"?title=Vorlage:Stdsummaries&action=raw&ctype=text/plain", function(text)
{
var sel = document.getElementById("stdSummaries");
var lines = text.split("\n");
for (var i=0; i<lines.length; i++)
{
if (lines[i].indexOf("<!--") == 0) continue;
var value = lines[i].indexOf("-- ") == 0 ? lines[i].substring(3) : "";
var opt = document.createElement("option");
opt.value = value;
if (value == "" && i)
opt.disabled = "disabled";
opt.appendChild(document.createTextNode(lines[i]));
sel.appendChild(opt);
}
sel.selectedIndex = 0;
}, "text");
});