Zum Inhalt springen

„Benutzer:Bernardissimo/monobook.js/rv2version.js“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
Inhalt gelöscht Inhalt hinzugefügt
(=undefinedRevert: Test)
Keine Bearbeitungszusammenfassung
Zeile 7: Zeile 7:
function AddLinksToOldVersionLinks()
function AddLinksToOldVersionLinks()
{
{
// Set up the text of your Edit Link
// Set up the text of your Revert Link
var Rv = '(Revert)';
var Rv = '(Revert)';
// Iterate over all "<a"
// Iterate over all "<a"
Zeile 19: Zeile 19:
{ // Create RV Link
{ // Create RV Link
var Rvnode = document.createElement('a');
var Rvnode = document.createElement('a');
Rvnode.setAttribute('href', 'javascript:revertme("'+href+'")');
Rvnode.setAttribute('href', 'javascript:revertme("'+href+','+document.getElementsByTagName("a")[i+10].firstChild.data+'")');
var RvTextNode = document.createTextNode(Rv);
var RvTextNode = document.createTextNode(Rv);
Rvnode.appendChild(RvTextNode);
Rvnode.appendChild(RvTextNode);
Zeile 30: Zeile 30:
}
}


function revertme (href) {
function revertme (href, doofie) {
var grund=prompt('Grund des Reverts:','');
var grund=prompt('Grund des Reverts:','');
if (grund != null) {
if (grund != null) {
href=encodeURI(href+"&action=edit&"+speichernp+"&"+subjp) +
href=encodeURI(href+"&action=edit&"+speichernp+"&"+subjp+"&doofie="+doofie) +
encodeURIComponent("Revert: "+grund);
encodeURIComponent("Revert: "+grund);
top.location.href = href;
top.location.href = href;
Zeile 51: Zeile 51:
if (params[i].substring(0,subjp.length) == subjp) {
if (params[i].substring(0,subjp.length) == subjp) {
var subj=decodeURIComponent ( params[i].substring(subjp.length,9999) );
var subj=decodeURIComponent ( params[i].substring(subjp.length,9999) );
document.editform.wpSummary.value=subj; //und einfuegen
document.editform.wpSummary.value+=subj; //und einfuegen
}
}
Zeile 60: Zeile 60:
if (params[i].substring(0,speichernp.length) == speichernp) { speichern = true; }
if (params[i].substring(0,speichernp.length) == speichernp) { speichern = true; }

if (params[i].substring(0,6) == "doofie"){
var doofie=decodeURIComponent ( params[i].substring(6,9999) );
document.editform.wpSummary.value+=" ("+doofie+")";
}


} //for
} //for

Version vom 21. September 2006, 22:34 Uhr

//Kopiert von Berlin-Jurist. - Ich hab's bloß alles gerne zusammen...

var subjp      = 'subj=';
var textp      = 'txt=';
var speichernp = 'speichern=1';

function AddLinksToOldVersionLinks()
{ 
// Set up the text of your Revert Link
  var Rv   = '(Revert)';
  // Iterate over all "<a"
  for (var i=0; aNode = document.getElementsByTagName("a")[i]; i++)
  { // if it's a link to an old version but not a diff-link and no edit-link
    if ( (href = aNode.getAttribute("href")) && 
         (href.search(/oldid=/) != -1) && 
         (href.search(/diff=/) == -1) && 
         (href.search(/action=edit/) == -1) 
       )
    {  // Create RV Link
      var Rvnode = document.createElement('a');
      Rvnode.setAttribute('href', 'javascript:revertme("'+href+','+document.getElementsByTagName("a")[i+10].firstChild.data+'")');     
      var RvTextNode = document.createTextNode(Rv);
      Rvnode.appendChild(RvTextNode);
      aNode.parentNode.insertBefore( Rvnode, aNode.nextSibling );
      aNode.parentNode.insertBefore( document.createTextNode(' '), aNode.nextSibling );      
      // jump over inserted <a-Link
      i++;
    }
  }
}

function revertme (href, doofie) {
  var grund=prompt('Grund des Reverts:','');
  if (grund != null) {	
   href=encodeURI(href+"&action=edit&"+speichernp+"&"+subjp+"&doofie="+doofie) + 
        encodeURIComponent("Revert: "+grund);
   top.location.href = href;
  }  
}	

function aktion() {
 var href=document.URL;
 if ( href.indexOf (subjp) > 0)  //sind wir auf der richtigen Seite ?
 { 
  href = decodeURI(href);
  var params = href.split ('&');
  var speichern = false;

  for (var i=1; i<params.length; i++) //parameter suchen
   { 
    if (params[i].substring(0,subjp.length) == subjp) {
       var subj=decodeURIComponent ( params[i].substring(subjp.length,9999) );
       document.editform.wpSummary.value+=subj; //und einfuegen
     }
    
    if (params[i].substring(0,textp.length) == textp) {
       var text=decodeURIComponent ( params[i].substring(textp.length,9999) );
       document.editform.wpTextbox1.value=text; //und einfuegen
     }
 
    if (params[i].substring(0,speichernp.length) == speichernp) { speichern = true; }

    if (params[i].substring(0,6) == "doofie"){
       var doofie=decodeURIComponent ( params[i].substring(6,9999) );
       document.editform.wpSummary.value+=" ("+doofie+")";
     }

   } //for
   if (speichern) { document.editform.wpSave.click(); }
   
 }  
} //function aktion

function init_links(){
if ( (document.URL.indexOf('diff') > 0) || (document.URL.indexOf('history') > 0)){
AddLinksToOldVersionLinks();
}
else{
aktion();
}
}

 if (window.addEventListener) window.addEventListener("load", init_links, false);
 else if (window.attachEvent) window.attachEvent("onload", init_links);