Benutzer:D/Edittools.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 3: Zeile 3:


/** bastelt die Edittools-Box */
/** bastelt die Edittools-Box */
function add_cats_init() {
aOnloadFunctions[aOnloadFunctions.length] = function() {
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// konfiguration
// konfiguration
var sonderzeichen = [
[ 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü' ],
[ 'ß', ['„','“'], '’', [ '‚','‘'], '–' ],
[ ['«','»'], '°', '′', '″' ],
[ '…', '€', '†', '§', '™', '•' ],
[ '·', '×', '÷', '±', '−', '‰' ],
[ '²', '³', '½', '¼', '¾', '‣' ],
[ '≈', '≠', '≙', '≤', '≥', '∑' ],
[ '→', '←', '↔', '⇝', '⇒', '⇔' ],
[ '☛', '†', '☠', '☢', '☣', '☭' ],
[ 'ſ', 'Œ', 'œ', 'Ç', 'ç' ],
[ 'İ', 'ı', 'Ğ', 'ğ', 'Ş', 'ş' ],
[ ['[[',']]'], '|', ' ' ],
[ ['{{','}}'], '~~~~' ],
];
var kategorieNamen = [
var kategorieNamen = [
Zeile 202: Zeile 218:
"Zeitgeschehen",
"Zeitgeschehen",
"Zusammenrottung"
"Zusammenrottung"
];
var sonderzeichen = [
[ 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü' ],
[ 'ß', ['„','“'], '’', [ '‚','‘'], '–' ],
[ ['«','»'], '°', '′', '″' ],
[ '…', '€', '†', '§', '™', '•' ],
[ '·', '×', '÷', '±', '−', '‰' ],
[ '²', '³', '½', '¼', '¾', '‣' ],
[ '≈', '≠', '≙', '≤', '≥', '∑' ],
[ '→', '←', '↔', '⇝', '⇒', '⇔' ],
[ '☛', '†', '☠', '☢', '☣', '☭' ],
[ 'ſ', 'Œ', 'œ', 'Ç', 'ç' ],
[ 'İ', 'ı', 'Ğ', 'ğ', 'Ş', 'ş' ],
[ ['[[',']]'], '|', ' ' ],
[ ['{{','}}'], '~~~~' ],
];
];
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// GUI
function editTool() {
function editTool() {
Zeile 344: Zeile 345:
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// init
var editform = document.getElementById('editform');
var editform = document.getElementById('editform');
Zeile 354: Zeile 356:
wpTextbox1.value = wpTextbox1.value.replace(/\s+$/, "");
wpTextbox1.value = wpTextbox1.value.replace(/\s+$/, "");
}
}
aOnloadFunctions[aOnloadFunctions.length] = add_cats_init;
 


//</pre></nowiki></pre>
//</pre></nowiki></pre>

Version vom 21. September 2007, 17:42 Uhr

//<pre><nowiki>
//Diese Seite wird von [[MediaWiki:Monobook.js]] aus geladen, sobald eine Seite bearbeitet wird

/** bastelt die Edittools-Box */
aOnloadFunctions[aOnloadFunctions.length] = function() {
	//--------------------------------------------------------------------------------
	// konfiguration
	
	var sonderzeichen = [
		[	'Ä',		'ä',		'Ö',		'ö',		'Ü',		'ü'	],
		[	'ß',		['„','“'],	'’',		[ '‚','‘'],	'–'				],
		[	['«','»'],	'°',		'′',		'″'							],
		[	'…',		'€',		'†',		'§',		'™',		'•'	],
		[	'·',		'×',		'÷',		'±',		'−',		'‰'	],
		[	'²',		'³',		'½',		'¼',		'¾',		'‣'	],
		[	'≈',		'≠',		'≙',		'≤',		'≥',		'∑'	],
		[	'→',		'←',		'↔',		'⇝',		'⇒',		'⇔'	],
		[	'☛',		'†',		'☠',		'☢',		'☣',		'☭'	],
		[	'ſ',		'Œ',		'œ',		'Ç',		'ç'				],
		[	'İ',		'ı',		'Ğ',		'ğ',		'Ş',		'ş'	],
		[	['[[',']]'],	'|',	'&amp;nbsp;'							],
		[	['{{','}}'],	'~~~~'											],
	];
	
	var kategorieNamen = [
		"Abkürzung",
		"Ägypten",
		"Aliens",
		"Alkohol",
		"Amphibien",
		"Anatomie",
		"Architektur",
		"Artikel, die wo so aussehen, wie die Dinge, die sie beschreiben tun",
		"Artikel und Kamele mit eigenem Skin",
		"Astronomie",
		"Ausgestorben",
		"Auto",
		"Bahn",
		"Bären",
		"Baum",
		"Beruf",
		"Bildung",
		"Biographie",
		"Biologie",
		"Böses Kamel",
		"Botanik",
		"Brauchtum",
		"Chamäleons",
		"Chemie",
		"China",
		"Computer",
		"Denkmal",
		"Deutschland",
		"Dienstleistung",
		"Drogen",
		"Eier",
		"Elektrotechnik",
		"Enten",
		"Eulen",
		"Fabelwesen",
		"Fäkalien",
		"Farben",
		"Feminismus",
		"Film",
		"Fische",
		"Fleisch",
		"Fluss",
		"Freizeit",
		"Frisuren",
		"Gastronomie",
		"Gebäck",
		"Gebirge",
		"Geheim",
		"Geistlicher",
		"Genie & Wahnsinn",
		"Geographie",
		"Geologie",
		"Geschichte",
		"Gesellschaft",
		"Getränk",
		"Gewässer",
		"Gilden",
		"Götter",
		"Grammatik",
		"Häh?",
		"Helden",
		"Hunde",
		"Hygiene",
		"Indianisch",
		"Industrie",
		"Insekten",
		"Inseln",
		"Jahrestag",
		"Japan",
		"Kalender",
		"Kamele",
		"Kamelkunde",
		"Kamelopedia",
		"Kasusativ",
		"Katzen",
		"Kleidung",
		"Komische Kamele",
		"Komische Typen",
		"Kommunikation",
		"Kosmetik",
		"Krabbeltiere",
		"Krankheiten",
		"Krieg",
		"Kulinarik",
		"Kulturgut",
		"Kunst",
		"Land & Leute",
		"Landschaften",
		"Landwirtschaft",
		"Listen",
		"Literatur",
		"Löcher",
		"Logik",
		"Luft & Raumfahrt",
		"Lyrik",
		"Märchen",
		"Maschinen",
		"Maßeinheit",
		"Mathematik",
		"Medien",
		"Medizin",
		"Microsoft",
		"Mikroben",
		"Milch & Käse",
		"Mischwesen",
		"Möbel",
		"Mode",
		"Musik",
		"Musikrichtungen",
		"Mythologie",
		"Nachrichten",
		"Nah dran",
		"Name",
		"Natur",
		"Nichtkamele",
		"Oberflächliches",
		"Obst & Gemüse",
		"Optik & Lichttechnik",
		"Organisationen",
		"Ort",
		"Pferde & Esel",
		"Philosophie",
		"Physik",
		"Pilze",
		"Planeten",
		"Plem-Plem",
		"Politik",
		"Projekt",
		"Psychologie",
		"Pyramiden",
		"Raubtier",
		"Re(h)kursion",
		"Recht",
		"Religion",
		"Religionen",
		"Rezepte",
		"Rindviecher",
		"Sammelartikel",
		"Saurier",
		"Schach",
		"Schafe",
		"ScheibchenWelt",
		"Schifffahrt",
		"Schlangen",
		"Schnecken",
		"Schöner Wohnen",
		"Schule",
		"Schweine",
		"Schweiz",
		"Sexualität",
		"Soziologie",
		"Spezies",
		"Spiel",
		"Sport",
		"Sprache",
		"Sprachwissenschaft",
		"Staat",
		"Stadt",
		"Stuchbabe",
		"Süßigkeiten",
		"Suppe",
		"Technik",
		"Theorie",
		"Tiger",
		"Tisch",
		"Touristik",
		"Umfrage",
		"Unterwasser",
		"Verkehr",
		"Verkehrsmittel",
		"Verpackung",
		"Verschwörungstheorien",
		"Verwechslungen",
		"Vögel",
		"Waffen",
		"Wale",
		"Weiß der Kuckuck",
		"Werbung",
		"Werkzeuge & Geräte",
		"Wetter",
		"Wikipedia",
		"Wirtschaft",
		"Wissenschaft",
		"Wortsinn & Tiefsinn",
		"WTF-8",
		"Würmer",
		"Wüste",
		"Wurst",
		"Zahl",
		"Zauberei",
		"Zeit",
		"Zeitanzeigegeräte",
		"Zeitgeschehen",
		"Zusammenrottung"
	];
	
	//--------------------------------------------------------------------------------
	// GUI
	
	function editTool() {
		var	sonderzeichenEditor	= contentFrame(
				"Sonderzeichen",
				helpLink("/index.php/Hilfe:Edittools", "Hilfe (in neuem Fenster)"),	
				sonderzeichenContent());
		var	kategorienEditor	= contentFrame(
				"Klick-Kategorien",
				null,
				categoriesContent());
		
		var	editor	= document.createElement("div");
		editor.id = 'cat_editor';	// TODO id und CSS benutzen
		editor.style.background	= "none";
		editor.style.border		= "none";
		editor.style.height		= "400px";
		editor.style.width		= "13%";
		editor.style.fontSize	= "8pt";
		editor.style.padding	= "3px";
		editor.style.lineHeight	= "1.3em";
		editor.style.overflow	= "auto";
		editor.style.cssFloat	= "right";
		
		editor.appendChild(sonderzeichenEditor);
		editor.appendChild(kategorienEditor);
		return editor;
	}
	
	function categoriesContent() {
		var	content	= document.createElement("ul");
		for (var i=0; i<kategorieNamen.length; i++ ) {
			var name	= kategorieNamen[i];
			var	link	= categoryAddLink(name);
			var	item	= document.createElement("li");
			item.appendChild(link);
			content.appendChild(item);
		}
		return content;
	}
	
	function categoryAddLink(categoryName) {
		var	a	= document.createElement("a");
		a.textContent	= categoryName;
		a.onclick	= function() {
			document.editform.wpTextbox1.value += '\n[[Kategorie:' + categoryName + ']]';
		};
	}

	function sonderzeichenContent() {
		var	table	= document.createElement("table");
		for (var i=0; i<sonderzeichen.length; i++) {
			var	line	= sonderzeichen[i];
			var	tr		= document.createElement("tr");
			for (var j=0; j<line.length; j++) {
				var	cell	= line[j];
				var	td		= document.createElement("td");
				bar	knob	= cell.constructor == Array
							? klammerLink(cell[0], cell[1])
							: zeichenLink(cell);
				td.appendChild(knob);
				tr.appendChild(td);
			}
			table.appendChild(tr);
		}
		return table;
	}
	
	function zeichenLink(text) {
		var	a	= document.createElement("a");
		a.textContent	= text;
		a.onclick		= function() {
			insertTags(text, "", "");
		};
	}
	
	function klammerLink(open, close) {
		var	a	= document.createElement("a");
		a.textContent	= open + close;
		a.onclick		= function() {
			insertTags(open, close, "");
		};
	}
	
	function switchLink(targetElement) {
		var	visible	= true;
		var	a	= document.createElement("a");
		a.onclick	= function() {
			visible	= !visible;
			update();
		};
		function update() {
			a.textContent				= visible ? "[verbergen]" : "[anzeigen"];
			targetElement.style.display	= visible ? null : "none"; 
		}
		update();
		return a;
	}
	
	function helpLink(target, title) {
		var	a	= document.createElement("a");
		a.href			= target;
		a.title			= title;
		a.innerHTML		= "<sup>?</sup>";
		return a;
	}
	
	function contentFrame(headerText, helpLink, contentElement) {
		var	header	= document.createElement("b");
		head.textContent	= headerText;
		
		var switch	= switchLink(contentElement);
		
		var	frame	= document.createElement("div");
		frame.appendChild(header);
		if (helpLink)
		frame.appendChild(helpLink);
		frame.appendChild(switch);
		frame.appendChild(contentElement);
		
		return frame;
	}
	
	//--------------------------------------------------------------------------------
	// init
	
	var	editform	= document.getElementById('editform');
	
	var	wpScrolltop	= document.getElementById('wpScrolltop');
	wpScrolltop.parentNode.insertBefore(div, editTool());
	
	// Leerzeilen am Ende des Artikeltextes entfernen
	var	wpTextbox1	= editform.wpTextbox1;
	wpTextbox1.value = wpTextbox1.value.replace(/\s+$/, "");
}


//</pre></nowiki></pre>