MediaWiki:Gadget-CatGenRepairForm.js
Version vom 4. Mai 2011, 11:31 Uhr von WWWIG (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „→------------------------------------------------: →Script zum Erstellen von Vorlagen und Kategorien: /* ------------------------------------------------…“)
Hinweis: Leere nach dem Speichern 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: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Gehe zu Menü → Einstellungen (Opera → Einstellungen auf dem Mac) und dann auf Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
/* ------------------------------------------------ */
/* Script zum Erstellen von Vorlagen und Kategorien */
/* ------------------------------------------------ */
addOnloadHook( function () {
if ( window.wgUserGroups ) {
for ( var i = 0; i < wgUserGroups.length; i++ ) {
if ( wgUserGroups[i] === 'sysop' || wgUserGroups[i] === 'bot' ) {
InsertNode("javascript:CatGenRepairForm.LoadCatGenRepairForm()", "Ergänzungen", TW_WERKZEUGE, "ul");
break;
}
}
}
});
var CatGenRepairForm = {
t_Sprachen : new Array('it'),
t_Typen : new Array('Uhrenmodelle','Uhrwerke','Archiv','Porträt','Gebäude','Marken und Warenzeichen','Werkzeuge'),
InitLanguageVars : function () {
CatGenRepairForm.t_VorlagenTexte['de'] = 'Kategorie Bildgalerie ';
CatGenRepairForm.t_VorlagenTexte['it'] = 'Categoria galleria fotografica ';
CatGenRepairForm.t_KategorienTexte['de'] = 'Bildgalerie ';
CatGenRepairForm.t_KategorienTexte['it'] = 'Galleria fotografica ';
CatGenRepairForm.t_TypTexte['Uhrenmodelle_de'] = 'Uhrenmodelle ';
CatGenRepairForm.t_TypTexte['Uhrenmodelle_it'] = 'di modelli orologi ';
CatGenRepairForm.t_TypTexte['Uhrwerke_de'] = 'Uhrwerke ';
CatGenRepairForm.t_TypTexte['Uhrwerke_it'] = 'di movimento degli orologi ';
CatGenRepairForm.t_TypTexte['Archiv_de'] = 'Archiv ';
CatGenRepairForm.t_TypTexte['Archiv_it'] = 'di Archivio ';
},
PreCheckRepairPreviewVFiles : function () {
if ( document.getElementById('TypSel').value + '' == '' ) {
t_msg2 = 'Es ist kein Typ gewählt!';
document.getElementById( 'PreviewForm' ).innerHTML = t_msg2;
return;
}
CatGenRepairForm.InitLanguageVars();
document.getElementById( 'PreviewForm' ).innerHTML = '<hr style="margin-top:1em;">' + '<b>Hole Kategorienliste:</b><p id="PreviewSubForm"></p>';
t_FilesToCheckString = CatGenRepairForm.t_VorlagenTexte['de'] + document.getElementById('TypSel').value;
var t_parameters = '?action=query&generator=search&format=json&gsrnamespace=10&gsrlimit=500&gsrsearch=' + encodeURIComponent( t_FilesToCheckString );
var t_http_req = null;
if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
t_http_req.open("POST", CatGenRepairForm.t_wikiurl + t_parameters, true);
t_http_req.onreadystatechange = function() {
if(t_http_req.readyState != 4) {
if ( t_FilesToCheckString != '' ) {
document.getElementById( 'PreviewSubForm' ).style.height = '75px';
document.getElementById( 'PreviewSubForm' ).style.overflow = 'auto';
document.getElementById( 'PreviewSubForm' ).scrollTop = 1000;
document.getElementById( 'PreviewSubForm' ).innerHTML += String(t_FilesToCheckString).replace(/\|/g, "<br>") + '<br>';
t_FilesToCheckString = '';
}
}
if(t_http_req.readyState == 4 && t_http_req.status == 200) {
alert(t_http_req.responseText);
if ( CatGenRepairForm.t_vkdebug ) {
document.getElementById( 'StatusPrev' ).style.display = 'block';
document.getElementById( 'StatusPrev' ).innerHTML += '<hr>' + t_http_req.responseText;
}
CatGenRepairForm.CheckRepairPreviewVFiles( eval("(" + t_http_req.responseText + ")") );
}
}
t_http_req.send(null);
},
CheckRepairPreviewVFiles : function ( queryData, rawData ) {
},
StartCreatingVKFiles : function () {
},
t_VorlagenTexte : new Array(),
t_KategorienTexte : new Array(),
t_TypTexte : new Array(),
t_vkdebug : true,
t_Content : '',
t_Sic_GenContent : '',
t_Sic_selectedTyp : 0,
t_wikiurl2 : 'http://watch-wiki.org/api.php',
t_wikiurl : wgServer + wgScriptPath + '/api.php',
UnloadCatGenRepairForm : function () {
CatGenRepairForm.t_stopp = true;
setcursor( 'auto' );
CatGenRepairForm.t_Sic_GenContent = document.getElementById( 'content' ).innerHTML;
CatGenRepairForm.t_selectedTyp = document.getElementById( 'Typ' ).selectedIndex;
if ( CatGenRepairForm.t_Content != '' ) {
document.getElementById( 'content' ).innerHTML = CatGenRepairForm.t_Content;
CatGenRepairForm.t_Content = '';
}
},
LoadCatGenRepairForm : function ( t_status ) {
// if ( typeof my_vkdebug != "undefined" && my_vkdebug != '' ) CatGenRepairForm.t_vkdebug = my_vkdebug;
if ( document.getElementById( 'content' ) ) {
if ( CatGenRepairForm.t_Content != '' && t_status != 'n' ) {
return;
}
if ( CatGenRepairForm.t_Content == '' ) {
CatGenRepairForm.t_Content = document.getElementById( 'content' ).innerHTML;
}
if ( CatGenRepairForm.t_Sic_GenContent != '' ) {
document.getElementById( 'content' ).innerHTML = CatGenRepairForm.t_Sic_GenContent;
document.getElementById( 'Typ' ).selectedIndex = CatGenRepairForm.t_selectedTyp;
CatGenRepairForm.t_Sic_GenContent = '';
return;
}
out = '<form method="get" style="width:100%" name="CatGenRepairForm">' +
'<fieldset><legend>Vorlagen- und Kategoriegenerator - Ergänzungen</legend>' +
'<div style="margin-top:.5em; margin-left:1em; margin-right:1em;">' +
'<h3>Parameter</h3>' +
'<p><input type="button" value="Vorschau" ' +
'title="Erzeugt eine Vorschau der Vorlagen und Kategorien mit Inhalten" onClick="PreCheckRepairPreviewVFiles()"> ' +
'<input type="button" style="float:right;" value="Schließen" title="Beendet den Vorlagen und Kategorien-Generator" onClick="UnloadCatGenRepairForm()">' +
'<select id="Typ" size="8" type="hidden" ' +
'onchange="this.form.TypSel.value = this.form.Typ.options[this.form.Typ.selectedIndex].value">';
for ( t_Typ = 0; t_Typ < CatGenRepairForm.t_Typen.length; t_Typ++ ) {
out += '<option value="' + CatGenRepairForm.t_Typen[t_Typ] + '">' + CatGenRepairForm.t_Typen[t_Typ] + '</option>';
}
out += '</select><input id="TypSel" name="TypSel" type="hidden" value=""><br><br><br>' +
'<label for="Summary">Zusammenfassung:</label>' +
'<input id="Summary" type="text" size="75" value="Mit neuer Vorlage automatisch erstellt"><br>' +
'<p id="StatusPrev" style="border: 1px solid #aaa; padding:.5em;display:none;">Debuginfo</p></p>' +
'<div id="PreviewForm"></div>' +
'<div id="TemplateForm"></div>' +
'<div id="InsertCreateForm"></div>' +
'</div></fieldset></form><div id="tippinfo"></div>';
document.getElementById( 'content' ).innerHTML = out;
t_tippinfo = document.getElementById('tippinfo');
}
}
};
function PreCheckRepairPreviewVFiles( ) {
CatGenRepairForm.PreCheckRepairPreviewVFiles();
}
function UnloadCatGenRepairForm( ) {
CatGenRepairForm.UnloadCatGenRepairForm();
}
var TW_PERSONAL = "p-personal";
var TW_WERKZEUGE = "p-tb";
var TW_REITER = "column-one";
function InsertNode(p_href, p_text, p_id, p_tag, p_before_id)
{
var new_a = document.createElement('a');
new_a.href = p_href;
new_a.appendChild(document.createTextNode(p_text));
var new_li = document.createElement('li');
new_li.appendChild(new_a);
var tmp_nodes = document.getElementById(p_id).getElementsByTagName(p_tag);
tmp_Node = tmp_nodes[0];
if (p_before_id)
{
tmp_Node.insertBefore(new_li.cloneNode(true), document.getElementById(p_before_id));
}
else
{
tmp_Node.appendChild(new_li.cloneNode(true));
}
}
function setcursor( cursortype ) {
document.getElementById( 'content' ).style.cursor = cursortype;
for ( i = 0; i < document.getElementById( 'content' ).getElementsByTagName( 'input' ).length; i++ ) {
document.getElementById( 'content' ).getElementsByTagName( 'input' )[i].style.cursor = cursortype;
}
}
function trim( t_string ) {
return t_string.replace (/^\s+/, '').replace (/\s+$/, '');
}