// <nowiki>
function textSelect(inp, s, e) {
e = e || s;
if (inp.createTextRange) {
var r = inp.createTextRange();
r.collapse(true);
r.moveEnd('character', e);
r.moveStart('character', s);
r.select();
} else if (inp.setSelectionRange) {
inp.focus();
inp.setSelectionRange(s, e);
}
}
function stoerfixBilderFix() {
var article = document.editform.wpTextbox1.value;
article = article.replace("In halt", "Inhalt");
article = article.replace("Li cenz", "Licenz");
article = article.replace("Licenz", "Lizenz");
article = article.replace(/==Inhalt==/, "== Inhalt ==");
article = article.replace(/==Lizenz==/, "== Lizenz ==");
article = article.replace(/== Inhalt ==/, "== {{int:filedesc}} ==");
article = article.replace(/== Lizenz ==/, "== {{int:license-header}} ==");
var regexp = /eschreibung *:(.+)/;
var res = regexp.exec(article);
var description = res[1].trim();
regexp = /Quelle *:(.+)/;
res = regexp.exec(article);
var source = res[1].trim();
regexp = /Fotograf *:(.+)/;
res = regexp.exec(article);
var author = res[1].trim();
regexp = /Datum *: *(\d+)\. +([\wä]+) +(\d\d\d\d)/;
res = regexp.exec(article);
var month = "??";
switch (res[2]) {
case "Januar":
month = "01";
break;
case "Februar":
month = "02";
break;
case "März":
month = "03";
break;
case "April":
month = "04";
break;
case "Mai":
month = "05";
break;
case "Juni":
month = "06";
break;
case "Juli":
month = "07";
break;
case "August":
month = "08";
break;
case "September":
month = "09";
break;
case "Oktober":
month = "10";
break;
case "November":
month = "11";
break;
case "Dezember":
month = "12";
break;
}
var day = res[1];
if (res[1]<10) {
day = "0"+ res[1];
}
var date = res[3] + "-" + month + "-" + day;
var information = "{{Information\n|Description={{de|1=" + description + "}}\n|Source=" + source + "\n|Date=" + date + "\n|Author=" + author + "\n|Permission=\n|other_versions=\n}}";
var startPos = article.indexOf("== {{int:filedesc}} ==") + 23;
var endPos = article.indexOf("== {{int:license-header}} ==")-2;
var str = article.substring(startPos, endPos);
article = article.replace(str, information);
document.getElementById("wpSummary").value = "cleanup";
document.editform.wpTextbox1.value = article;
document.getElementById("wpWatchthis").checked = true;
}
function cleanArticle() {
var article = document.editform.wpTextbox1.value;
article = article.replace(/== Summary ==/, "== {{int:filedesc}} ==");
article = article.replace(/== Licensing ==/, "== {{int:license-header}} ==");
article = article.replace(/== {{int:license}} ==/, "== {{int:license-header}} ==");
article = article.replace(/== Inhalt ==/, "== {{int:filedesc}} ==");
article = article.replace(/== Lizenz ==/, "== {{int:license-header}} ==");
//moving categories to the end
var startPos;
var firstTime = true;
do {
var licensePos = article.indexOf("{{int:license");
startPos = article.indexOf("[[Category:");
if ( (startPos==-1) || (licensePos==-1) || (startPos>licensePos) ) {
break;
}
var endPos = article.indexOf("]]", startPos + 11);
var categoryString = article.substring(startPos, endPos+3);
article = article.replace(categoryString, "");
if (firstTime) {
article += "\n\n";
firstTime = false;
}
article += categoryString;
} while (startPos>0);
if (!firstTime) {
article = article.replace(/\n\n/g, '\n');
}
//add "{{de|1=" to description if it is not available
var regexp = /Description *=(.+)/;
var res = regexp.exec(article);
var pos = res[1].indexOf("{{de|");
if (pos==-1) {
article = article.replace(res[1], "{{de|1=" + res[1].trim() + "}}");
}
article = article.replace("}}\n==", "}}\n\n==");
document.getElementById("wpSummary").value = "cleanup";
document.editform.wpTextbox1.value = article;
document.getElementById("wpWatchthis").checked = true;
}
/*function rename() {
var article = document.editform.wpTextbox1.value;
var oldName = mw.config.get('wgTitle');
var newName = oldName.replace(/pic/, "b").replace(/JPG/, "jpg");
var renamingRequest = "{{rename|1=" + newName + "|2=6|3=correcting naming according to https://de.wikisource.org/wiki/Die_Gartenlaube#Bilder|user=Aschroet}}";
document.editform.wpTextbox1.value = article.replace(/\[\[Category/, renamingRequest + "\n\n[[Category");
document.getElementById("wpWatchthis").checked = true;
var summary = "Requesting renaming this file to " + newName + "; Reason: correcting naming according to https://de.wikisource.org/wiki/Die_Gartenlaube#Bilder; Criterion 6)";
document.getElementById("wpSummary").value = summary;
}*/
/*function transcribe() {
var article = document.editform.wpTextbox1.value;
var pos1 = article.indexOf("{{Transcribe here}}");
var pos2 = article.indexOf("{{inscription");
if ( (pos1==-1) && (pos2==-1) ) {
document.editform.wpTextbox1.value = article + "[[Category:Needing transcription]]";
document.getElementById("wpSummary").value = "[[Category:Needing transcription]]";
}
document.getElementById("wpWatchthis").checked = true;
}*/
function transcribe() {
var article = document.editform.wpTextbox1.value;
var inscriptionRegex = /(^\s*\|description\s*=\s*{{[\s\S]+?}})\n(^\s*\|date\s*=\s*.+\n)/m;
var inscriptionCode = "\n|other_fields_1={{InFi|name={{i18n|inscription}}|"+
"value={{inscription|1=TRANSCRIBE-V1.2.0|language=de}}}}\n";
regexResult = inscriptionRegex.exec(article);
article = article.replace(regexResult[0], regexResult[1] + inscriptionCode + regexResult[2]);
article = article.replace(/{{Transcribe here}}\n/, "");
article = article.replace(/\[\[Category:Needing transcription\]\]\n/, "");
document.editform.wpTextbox1.value = article;
pos = document.editform.wpTextbox1.value.indexOf("TRANSCRIBE");
textSelect(document.editform.wpTextbox1, pos, pos+17);
document.getElementById("wpWatchthis").checked = true;
document.getElementById("wpSummary").value = "transcribe inscription";
}
function br() {
var article = document.editform.wpTextbox1.value;
var textarea = document.querySelector("textarea").value;
var startPos = document.editform.wpTextbox1.selectionStart;
var beforeStr = article.substring(0, startPos);
var afterStr = article.substring(startPos);
document.editform.wpTextbox1.value = beforeStr + "<br />" + afterStr;
textSelect(document.editform.wpTextbox1, startPos+6, startPos+6);
}
function ws() {
var article = document.editform.wpTextbox1.value;
var regexp1 = /other_versions *=(.+)/;
var res1 = regexp1.exec(article);
article = article.replace(res1[1], "");
var regexp2 = /Description *=(.+)/;
var res2 = regexp2.exec(article);
article = article.replace(res2[1], "{{de|1=" + res1[1] + "}}"+res2[1]);
var pos = res2[1].indexOf("{{en");
if (pos==-1) {
article = article.replace(res2[1], "{{en|1=" + res2[1] + "}}");
}
var regexp3 = /Date *=(.+)/;
var res3 = regexp3.exec(article);
var dateStrOld = res3[1];
var dateStr = dateStrOld.replace(/ /g, "-");
article = article.replace(dateStrOld, dateStr);
document.editform.wpTextbox1.value = article;
document.getElementById("wpWatchthis").checked = true;
document.getElementById("wpSummary").value = "move description to the right place";
}
function startUp() {
if (typeof $.fn.wikiEditor != 'undefined') {
// Execute on load
$( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'pretext': {
label: 'transcribe',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_broom.png',
action: {
type: 'callback',
execute: function() {
transcribe();
}
}
}
}
} );
} );
}
}
setTimeout(startUp(), 2000);
/* removed buttons
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'pretext': {
label: 'CL',
type: 'button',
icon: 'LINK.png',
action: {
type: 'callback',
execute: function() {
cleanArticle();
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'pretext': {
label: 'BR',
type: 'button',
icon: 'LINK.png',
action: {
type: 'callback',
execute: function() {
br();
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'pretext': {
label: 'RN',
type: 'button',
icon: 'LINK.png',
action: {
type: 'callback',
execute: function() {
rename();
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'pretext': {
label: 'WS',
type: 'button',
icon: 'LINK.png',
action: {
type: 'callback',
execute: function() {
ws();
}
}
}
}
} );
*/
// </nowiki>