MediaWiki:Gadget-Sonderzeichenauswahl.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
/// Deutschsprachige Wikisource: Sonderzeichenauswahl = Edittools
/// 2017-11-19
/// <nowiki>
/* global window: false, jQuery: false, mediaWiki: false */
/* jshint forin: false,
bitwise:true, curly:true, eqeqeq:true, latedef:true,
laxbreak:true,
nocomma:true, strict:true, undef:true, unused:true */
( function ( mw, $ ) {
// Konfiguration von menuSwitcher: Deutschsprachige Wikisource
"use strict";
var Switcher = "menuSwitcher",
Signature = "ext.gadget." + Switcher,
Shoot = Signature + ".config",
Options = { position: [ ] },
Proofread = { live: false,
max: 50,
msec: 100,
ns: 102,
scope: "proofread-page",
sel: ".prp-page-container" };
function fire() {
// menuSwitcher aktivieren.
mw.hook( Shoot ).fire( Options );
} // fire()
function former() {
// Historische individuelle Benutzer-Anpassungen:
// MyChar, MyCharEnd, MyCharText, MyCharDefault
// Kann und sollte wegfallen, wenn alle aktiven Benutzer migriert.
var chars = window.MyChar,
group = [ { show: "Eigene Zeichen:" } ],
options = { },
charsEnd, charsText, charsDefault, e, i, panel;
if ( typeof window.MyCharEnd === "object"
&& window.MyCharEnd &&
typeof window.MyCharEnd.length === "number" ) {
charsEnd = window.MyCharEnd;
} else {
charsEnd = [ ];
}
if ( typeof window.MyCharText === "object"
&& window.MyCharText &&
typeof window.MyCharText.length === "number" ) {
charsText = window.MyCharText;
} else {
charsText = [ ];
}
if ( typeof window.MyCharDefault === "object"
&& window.MyCharDefault &&
typeof window.MyCharDefault.length === "number" ) {
charsDefault = window.MyCharDefault;
} else {
charsDefault = [ ];
}
for ( i = 0; i < chars.length; i++ ) {
if ( typeof chars[ i ] === "string" ) {
e = { };
if ( chars[ i ] ) {
e.start = chars[ i ];
}
if ( typeof charsEnd[ i ] === "string"
&& charsEnd[ i ] ) {
e.suffix = charsEnd[ i ];
}
if ( typeof charsText[ i ] === "string"
&& charsText[ i ] ) {
e.show = charsText[ i ];
}
if ( typeof charsDefault[ i ] === "string"
&& charsDefault[ i ] ) {
if ( /^\+[1-9][0-9]*$/.test( charsDefault[ i ] ) ) {
e.jumper = parseInt( charsDefault[ i ].substr( 1 ) );
} else {
e.sample = charsDefault[ i ];
}
}
group.push( e );
}
} // for i
if ( group.length ) {
panel = { selector: "Eigene",
style: "font-family: Arial Unicode MS,"
+ "Lucida Sans Unicode,MS Mincho,"
+ "Arial,sans-serif",
support: "Eigene Zeichen",
def: group };
options.defs = { contentmodel: "wikitext",
system: "builtin",
last: false,
create: [ panel ] };
mw.hook( Shoot ).fire( options );
}
} // former()
function furnish() {
// Standard-Ausstattung deutsprachige Wikisource
var env = mw.config.get( [ "wgAction",
"wgNamespaceNumber",
"wgUserName" ] ),
pos;
if ( env.wgAction === "edit" || env.wgAction === "submit" ) {
// Nicht im VisualEditor.
// Bereitstellung aus [[MediaWiki:Edittools]]
Options.defs = { contentmodel: "wikitext",
system: "charinsert",
last: true,
create: { selector: "div#specialchars",
segments: "p.specialbasic," +
"p.speciallang" } };
if ( env.wgUserName ) {
pos = { lead: true };
if ( env.wgNamespaceNumber === Proofread.ns ) {
pos.selector = Proofread.sel;
Options.defs.contentmodel = Proofread.scope;
} else {
pos.selector = "textarea";
}
} else {
pos = { selector: ".mw-editTools",
lead: false };
}
pos.last = true;
Options.position.push( pos );
}
Options.tabKeys = true;
if ( Proofread.live ) {
$( Proofread.find );
} else {
fire();
}
if ( mw.loader.getState( Signature ) !== "ready" ) {
mw.loader.load( "https://en.wikipedia.org"
+ "/w/index.php?title="
+ "User:PerfektesChaos/js/"
+ Switcher + "/d.js"
+ "&bcache=1&maxage=604812"
+ "&action=raw"
+ "&ctype=text/javascript" );
}
} // furnish()
Proofread.find = function () {
// Proofread-Seite: Konfektionierung abwarten.
// Precondition: document.ready
// Ruft sich selbst .max mal auf, bis Element gefunden.
var s;
if ( $( Proofread.sel ).length ) {
fire();
s = "Proofread; noch " + Proofread.max + " * "
+ Proofread.msec + " ms";
mw.hook( "ext.gadget.Sonderzeichenauswahl.info" ).add( s );
} else if ( Proofread.max ) {
Proofread.max--;
window.setTimeout( Proofread.find, Proofread.msec );
}
}; // Proofread.find()
furnish();
// Historische Ausstattung (legacy):
if ( typeof window.MyChar === "object"
&& window.MyChar &&
typeof window.MyChar.length === "number" &&
typeof window.MyChar[ 0 ] === "string" ) {
former();
}
}( mediaWiki, jQuery ) );
//=======================================================================
/*
var SpecCharsAccesskeys = [ ];
// Ein Array von Accesskeys an ein Array von Elementen
function SetArrayAccessKeys(elements, keys) {
var i;
for ( i =0; i < elements.length;i++ ) {
if (i < keys.length) {
elements[i].setAttribute("accessKey",keys[i]);
elements[i].setAttribute("title","alt-"+keys[i]);
}
else {
elements[i].setAttribute("accessKey","");
elements[i].setAttribute("title","");
}
}
} // SetArrayAccessKeys()
function addCharSubsetMenu() {
var toolbar = document.getElementById('toolbar'),
charlinks, i;
// Gleicher Tabindex für alle Elemente der Toolbar
if ( toolbar ) {
charlinks = toolbar.getElementsByTagName('a');
for ( i=0; i < charlinks.length; i++ ) {
charlinks[i].setAttribute("tabindex", 8);
}
}
} // addCharSubsetMenu()
// CharSubset-Auswahl
function chooseCharSubset(evt) {
var index = evt.target.selectedIndex,
i, k, l;
if ( ! SpecCharsAccesskeys.length ) {
SpecCharsAccesskeys = ["1","2","3","4","5","6","7","8","9","0","!","\"","§","$","%","&","/","(",")","="];
}
if ( index >= 0 ) {
l = document.getElementById('specialchars').getElementsByTagName('p');
for ( i = 0; i < l.length; i++ ) {
if ( i === index ) {
l[i].style.display = 'inline';
SetArrayAccessKeys( l[i].getElementsByTagName('a'),
SpecCharsAccesskeys );
}
else {
l[i].style.display = 'none';
}
}
k = REMIND.fetch( "indexGroup" ) || 0;
if ( k !== index ) {
SetArrayAccessKeys(l[i].getElementsByTagName('a'),"");
}
REMIND.feed( "indexGroup", index );
}
} // chooseCharSubset()
// Eigene Sonderzeichenliste
function AddMyCharsDo(thechar, thecharend, thechartext, thechardefault) {
var specialcharslist = document.getElementById('specialchars'),
addtext = "", i, jsfunction;
for ( i = 0; i < thechar.length; i++ ) {
//Autoinkrement-Funktion einsetzen
if (thechardefault[i].charAt(0) === "+" &&
!isNaN(parseInt(thechardefault[i].substr(1)))) {
jsfunction = "insertTagsValue('" + thechar[i] + "','"
+ thecharend[i] + "','"
+ thechardefault[i] + "','"
+ i +"')";
}
if ( ! thechartext[i] ) {
thechartext[i] = thechar[i] + " " + thecharend[i];
}
}
specialcharslist.innerHTML = addtext+specialcharslist.innerHTML;
} // AddMyCharsDo()
// Autoinkrement-Tags
function insertTagsValue(uchar, ucharend, uchardefault, ucharnr) {
var txtarea = document.editform.wpTextbox1,
endPos, lastVal, replaced, scrollTop, startPos, theSelection;
if ( document.selection ) {
// IE
theSelection = document.selection.createRange().text;
}
else if ( txtarea.selectionStart ||
txtarea.selectionStart === '0' ) {
// Mozilla
replaced = false;
startPos = txtarea.selectionStart;
endPos = txtarea.selectionEnd;
if (endPos-startPos) {
replaced = true;
}
scrollTop = txtarea.scrollTop;
theSelection = (txtarea.value).substring(startPos, endPos);
}
if (theSelection === "") {
if (!(lastVal = GetCookieOnWS("CharDefaultValue-" + ucharnr))) {
lastVal ="0";
}
theSelection = parseInt(lastVal)
+ parseInt(uchardefault.substr(1));
theSelection = theSelection.toString();
}
SetCookie( "CharDefaultValue-"+ucharnr, theSelection );
insertTags(uchar,ucharend,theSelection);
////////////////////////////////////////////////////////////
} // insertTagsValue()
*/
/// </nowiki>