MediaWiki:ProofreadImage.js
Erscheinungsbild
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
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
/*******************************************************************************************/
/* <pre><nowiki> MediaWiki:ProofreadImage.js */
/*-----------------------------------------------------------------------------------------*/
/* - proofread for intern and extern images */
/* - implements the navipoint "Korrekturlesen" */
/*******************************************************************************************/
function ProofReadLink () {
// iterate over all < span >-elements until class "ProofRead" is found
var spans = document.getElementsByTagName("span");
for (var i=0; i<spans.length; i++) {
var SpanElem = spans[i];
// if found a page number
if (SpanElem.className == "ProofRead") {
ImageSrc=SpanElem.title;
var ProofReadTab = document.createElement("li");
ProofReadTab.setAttribute('id', 'ca-proofread');
var ProofReadTabLink = document.createElement("a");
var caEdit = document.getElementById("ca-edit");
Console.log(caEdit);
if (!caEdit) break;
ProofReadTabLink.href= caEdit.firstChild.href + "&image="+ImageSrc;
ProofReadTabSpan = document.createElement("span");
ProofReadTabText = document.createTextNode("Korrekturlesen");
ProofReadTabSpan.appendChild(ProofReadTabText);
ProofReadTabLink.appendChild(ProofReadTabSpan);
ProofReadTab.appendChild(ProofReadTabLink);
var VersionLink = document.getElementById("ca-history");
VersionLink.parentNode.appendChild(ProofReadTab);
break;
}
}
}
var DivHeight = 0;
var ImgWidth;
function ProofReading () {
if (!document.URL.indexOf("action=edit") > 0 || !document.URL.indexOf("action=submit") > 0) return;
if (window.location.search.indexOf("image=") != -1)
{
if (window.location.search.indexOf("image=/wiki/") != -1) {
StringPos = window.location.search.indexOf("image=/wiki/");
ImageString = window.location.search.substring(StringPos + 12, window.location.search.length);
} else {
StringPos = window.location.search.indexOf("image=");
ImageString = window.location.search.substring(StringPos + 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);
document.getElementById("contentSub").appendChild(proofread_toolbar());
var ImageContainer = document.createElement("div");
ImageContainer.setAttribute("id", "ImageContainer");
ImageContainer.innerHTML = proofread_content(ImageString);
document.getElementById("contentSub").appendChild(ImageContainer);
}
var edform = document.getElementById("editform");
edform.action = edform.action + "&image=" + ImageString;
var content = document.getElementById("contentSub");
if (content) {
content.style.margin = "0px";
content.style.marginBottom = "10px";
}
if (!GetCookieOnWS("PrImageWidth")) Zoom(0);
}
}
function proofread_toolbar()
{
var tbar = document.createElement("div");
if (tbar)
{
var image2 = document.createElement("img");
image2.width = 23;
image2.height = 22;
image2.border = 0;
image2.className = "mw-toolbar-proofread";
image2.style.cursor = "pointer";
image2.alt = "+";
image2.title = "vergrößern";
image2.src = "//upload.wikimedia.org/wikipedia/commons/0/04/Button_zoom_in.png";
image2.onclick = function() { Zoom(50); };
tbar.appendChild(image2);
var image3 = document.createElement("img");
image3.width = 23;
image3.height = 22;
image3.border = 0;
image3.className = "mw-toolbar-proofread";
image3.style.cursor = "pointer";
image3.alt = "-";
image3.title = "verkleinern";
image3.src = "//upload.wikimedia.org/wikipedia/commons/0/03/Button_zoom_out.png";
image3.onclick = function() { Zoom(-50); };
tbar.appendChild(image3);
var image4 = document.createElement("img");
image4.width = 23;
image4.height = 22;
image4.border = 0;
image4.className = "mw-toolbar-proofread";
image4.style.cursor = "pointer";
image4.alt = "-";
image4.title = "Fensterbreite";
image4.src = "//upload.wikimedia.org/wikipedia/commons/2/2a/Button_examine.png";
image4.onclick = function() { Zoom(0); };
tbar.appendChild(image4);
return tbar
}
return;
}
function proofread_content(ImageString)
{
var ImageFrame = "";
if (DivHeight == 0)
{
if(document.selection && !is_gecko)
DivHeight=Math.ceil(document.body.clientHeight*0.5) + "px";
else
DivHeight=Math.ceil(window.innerHeight*0.4) + "px";
}
var ImageApp = /\.png$|\.jpeg$|\.jpg$|\.gif$|\.PNG$|\.JPEG$|\.JPG$|\.GIF$/;
if (ImageApp.test(ImageString) == true)
{
ImageFrame += "<div id=\"ImageFrame\" style=\"overflow: scroll; height: " + DivHeight + "; width: 100%;\">";
ImageFrame += "<img onerror=\"ImageError('"+ ImageString+"')\" id=\"ProofReadImage\"";
ImageFrame += "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;
}
function GetImageUrl(name)
{
if (name.indexOf("http:") == 0) return name;
return "index.php/Special:Filepath/" + name;
}
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;
}
}
function Zoom(value)
{
var PrImage = document.getElementById("ProofReadImage");
if (PrImage) {
if (value == 0)
PrImage.width = document.getElementById("ImageContainer").offsetWidth - 15;
else
PrImage.width = PrImage.width + value;
SetCookieOnWS("PrImageWidth", PrImage.width);
if (document.selection && !is_gecko) {
var Container = document.getElementById("ImageContainer");
if (Container) Container.innerHTML = proofread_content(PrImage.src);
}
}
}
hookEvent("load", ProofReading);
hookEvent("load", ProofReadLink);
/*******************************************************************************************/
/* </nowiki></pre><noinclude>[[Kategorie:Wikisource:Javascript]]</noinclude> */
/*******************************************************************************************/