MediaWiki:Onlyifediting.js

aus Wikisource, der freien Quellensammlung

Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Strg+F5
/* <pre><nowiki> */
 // wird in [[MediaWiki:Monobook.js]] ganz unten eingebunden

 //================================================================================

if ( mw.config.get( "wgUserName" )  !==  "PerfektesChaos" ) {
   mw.loader.load( "ext.gadget.Sonderzeichenauswahl" );
}

 //## replace

// anscheinend ungenutzt, siehe Ende dieses abschnitts



// Replace-Button
function AddReplaceButton() {
   var ButtonHTML = "<a href=\"javascript:stringReplaceBox();\"><img src=\"//upload.wikimedia.org/wikipedia/commons/5/59/Button_replace.png\" alt=\"Text ersetzen\" title=\"Text ersetzen\" border=\"0\" height=\"22\" width=\"23\"></a>",
       toolbar = document.getElementById("toolbar");
   if (toolbar) {
      toolbar.innerHTML += ButtonHTML;
   }
}   // AddReplaceButton()



function stringReplaceBox() {
   Valreplace = GetCookieOnWS("StrReplace");
   Valreplacement = GetCookieOnWS("StrReplacement");
   if (Valreplace && Valreplacement) {
      //Anführungszeichen ersetzen
      Valreplace = Valreplace.replace(/"/g,"&#34;");
      Valreplacement = Valreplacement.replace(/"/g,"&#34;");
   } else {
      Valreplace="";
      Valreplacement="";
   }

   PromptWin = window.open("about:blank", "PromptWin", "width=280,height=120,dependent=yes,location=no,menubar=no,resizable=yes,status=no,toolbar=no");
   PromptWin.focus();

   PromptWin.document.open();
   PromptWin.document.write( "<title>Text ersetzen</title>"
                           + "<body style=\"background-color: threedface;\">"
                           + "<form id=\"replaceform\" name=\"replaceform\" method=POST action=\"javascript:void(0)\">"
                           + "<center><table border=\"0\">"
                           + "<tr><td style=\"font: message-box\">ersetzen:</td> <td><input type=TEXT name=\"valreplace\" value=\"" + Valreplace + "\" size=25 tabindex=\"1\"></td></tr>"
                           + "<tr><td style=\"font: message-box\">durch:</td> <td><input type=TEXT name=\"valreplacement\" value=\"" + Valreplacement + "\" size=25 tabindex=\"2\"></td></tr></table>"
                           + "<p><input type=SUBMIT value=\"&nbsp;OK&nbsp;\" tabindex=\"3\" onclick=\"opener.stringReplace(document.replaceform.valreplace.value,document.replaceform.valreplacement.value); self.close()\"> "
                           + "<input type=RESET value=\"Abbrechen\" tabindex=\"4\" onclick=\"self.close()\"></p>"
                           + "</center></form></body>" );
   PromptWin.document.close();
   PromptWin.document.replaceform.valreplace.select();
}   // stringReplaceBox()



function stringReplace(inReplace, inReplacement) {
   var areas, StrReplace, StrReplacement, txtarea;
   SetCookieOnWS("StrReplace", inReplace);
   SetCookieOnWS("StrReplacement", inReplacement);
   StrReplace = new RegExp(inReplace, "g");
   StrReplacement = inReplacement;

   if (document.editform) {
      txtarea = document.editform.wpTextbox1;
   }
   else {
      // some alternate form? take the first one we can find
      areas = document.getElementsByTagName('textarea');
      txtarea = areas[0];
   }
   txtarea.value = txtarea.value.replace(StrReplace, StrReplacement);
}   // stringReplace()



// Achtung! Wenn man den hier einschaltet, funktioniert die Toolbar nicht mehr!
 //$(document).ready(AddReplaceButton);

//================================================================================
 //## proofreading

//Height of ProofReadDiv
var DivHeight = 0;



function ProofReading () {
   var ImageFrame, ImageString;
   if (window.location.search.indexOf("image=") != -1) {
      if (window.location.search.indexOf("image=/wiki/") != -1) {
         ImageString = window.location.search.substring(window.location.search.indexOf("image=/wiki/")+12,window.location.search.length);
      }
      else {
         ImageString = window.location.search.substring(window.location.search.indexOf("image=")+6,window.location.search.length);
      }
      if (ImageString != "") {
         TextBoxRows= document.getElementsByName("wpTextbox1")[0].getAttribute('rows');
         TextBoxRows=Math.ceil(TextBoxRows/2);
         document.getElementsByName("wpTextbox1")[0].setAttribute('rows',TextBoxRows);

         ImageFrame = "<div id=\"ImageFrame\">" + ImageFrameContent(ImageString) + "</div>";
         document.getElementById("contentSub").innerHTML += ImageFrame;
      }
   }
}   // ProofReading()



function ImageFrameContent(ImageString) {
   var ImageApp, ImageFrame, ZoomInIcon, ZoomOutIcon, ZoomStdIcon;
   if ( ! DivHeight ) {
      if ( document.selection ) {
         //IE:
         DivHeight=Math.ceil(document.body.clientHeight*0.5)+"px";
      }
      else {
         //andere:
         DivHeight=Math.ceil(window.innerHeight*0.4)+"px";
      }
   }

   ZoomInIcon = "<a href=\"javascript:Zoom(50)\"><img src=\"//upload.wikimedia.org/wikipedia/commons/0/04/Button_zoom_in.png\" title=\"vergrö&szlig;ern\" width=24 height=24></a>";
   ZoomOutIcon = "<a href=\"javascript:Zoom(-50)\"><img src=\"//upload.wikimedia.org/wikipedia/commons/0/03/Button_zoom_out.png\" title=\"verkleinern\" width=24 height=24></a>";
   ZoomStdIcon = "<a href=\"javascript:Zoom(0)\"><img src=\"//upload.wikimedia.org/wikipedia/commons/2/2a/Button_examine.png\" title=\"Fensterbreite\" width=24 height=24></a>";

   ImageFrame = ZoomOutIcon + " " + ZoomStdIcon + " " + ZoomInIcon;

   ImageApp = /\.png$|\.jpeg$|\.jpg$|\.gif$|\.PNG$|\.JPEG$|\.JPG$|\.GIF$/;
   if (ImageApp.test(ImageString) === true) {
      ImageFrame += "<div style=\"overflow: scroll; height: " + DivHeight + "; width: 100%;\">";
      ImageFrame += "<img onerror=\"ImageError('"+ ImageString+"')\" id=\"ProofReadImage\" src=\""+ GetImageUrl(ImageString) +"\" alt=\""+ GetImageUrl(ImageString) +"\"";
      if (GetCookieOnWS("PrImageWidth")) {
         ImageFrame +="width = \"" + GetCookieOnWS("PrImageWidth") +"\"";
      }
      ImageFrame += "></div>";
   }
   else {
      ImageFrame += "<iframe id=\"ProofReadImage\" src=\""+ GetImageUrl(ImageString) +"\" style=\"height: " + DivHeight + "; width: 100%;\">";
   }
   return ImageFrame;
}   // ImageFrameContent()



function GetImageUrl(name) {
   // don't change absolute URLs
    if (name.toLowerCase().indexOf("//") !== -1)   return name;
   return "//de.wikisource.org/wiki/Special:Filepath/" + name;
   /*
    var retval = name;
    if (name.indexOf("http:") != 0) retval = "index.php/Special:Filepath/" + name;
    return retval;
   */
}   // GetImageUrl()



function ImageError(imagename) {
   if (document.getElementById("ProofReadImage").src.indexOf("commons") === -1 && document.getElementById("ProofReadImage").src.indexOf("Special:Filepath") !== -1) {
      //image not from commons
      document.getElementById("ProofReadImage").src = "//commons.wikimedia.org/wiki/Special:Filepath/" + imagename;
   }
}   // ImageError()



function Zoom(value) {
   PrImage = document.getElementById("ProofReadImage");

   if (value === 0) {
      PrImage.width = document.getElementById("ImageFrame").offsetWidth-15;
   }
   else {
      PrImage.width=PrImage.width+value;
   }
   SetCookieOnWS("PrImageWidth",PrImage.width);
   if ( document.selection ) {
      //IE:
      document.getElementById("ImageFrame").innerHTML = ImageFrameContent(PrImage.src);
    }
}   // Zoom()



// onload einbinden
$(document).ready(ProofReading);



/* </nowiki> */