Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.

MediaWiki:Common.js: Unterschied zwischen den Versionen

MediaWiki-Schnittstellenseite
KKeine Bearbeitungszusammenfassung
K Test
Zeile 48: Zeile 48:
   }
   }
})
})
addOnloadHook(function()
{
  if (wgAction != "edit") return;
  var label = document.createElement("label");
  label.for = "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 != "")
      document.getElementById("wpSummary").value = 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 == "")
        opt.disabled = "disabled";
      opt.appendChild(document.createTextNode(lines[i]));
      sel.appendChild(opt);
    }
    sel.selectedIndex = 0;
  }, "text");
});