MediaWiki:Common.js: Unterschied zwischen den Versionen

MediaWiki-Schnittstellenseite
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 2: Zeile 2:


mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Faq.js&action=raw&ctype=text/javascript' );
mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Faq.js&action=raw&ctype=text/javascript' );
mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Datatables.js&action=raw&ctype=text/javascript' );


// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Querystring.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Querystring.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Datatables.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Labelauty.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Labelauty.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Highlight.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Highlight.js&action=raw&ctype=text/javascript' );
Zeile 10: Zeile 10:
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Ready.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Ready.js&action=raw&ctype=text/javascript' );


// $( window ).on( 'load', function( ) {
// Interaktive Tabellen
// } );
$( function() {
// Menüfeld füllen
function fillSelectFilter( arrColumnData ) {
var strAll = '';
var expSeparator = / *,{1} */;
var arrSelectList = new Array();
for ( i = 0; i < arrColumnData.length; i++ ) {
arrFieldData = arrColumnData[i].split(expSeparator);
for ( j = 0; j < arrFieldData.length; j++ ) {
if (jQuery.inArray(arrFieldData[j], arrSelectList) > -1) {
continue;
} else {
arrSelectList.push(arrFieldData[j]);
}
}
}
var strHtml = '<select><option value="">' + strAll + '</option>', i;
for ( k = 0; k < arrSelectList.length; k++ ) {
strHtml += '<option value="' + arrSelectList[k] + '">' + arrSelectList[k] + '</option>';
}
return strHtml + '</select>';
}
 
// Eigenschaften festlegen
var objFilterTable = $(".datatable #tools").dataTable( {
"bAutoWidth": true,
"bFilter": true,
"bInfo": false,
"bLengthChange": false,
"bPaginate": false,
"bProcessing": false,
"bSort": false,
"bSortClasses": false,
"oLanguage": {
"sEmptyTable": "Die Tabelle ist leer.",
"sSearch": "Alle Spalten filtern",
"sZeroRecords": "Die Filter führen zu keinem Ergebnis.",
},
} );
 
// Filter erstellen
$(".datatable thead td").each( function ( i ) {
if ($(this).hasClass("selectFilter")){
this.innerHTML = fillSelectFilter( objFilterTable.fnGetColumnData(i) );
$('select', this).change( function () {
objFilterTable.fnFilter( $(this).val(), i );
} );
} else if ($(this).hasClass("inputFilter")) {
this.innerHTML = '<input>';
$("thead input").keyup( function () {
objFilterTable.fnFilter( $(this).val(), i );
} );
};
} );
 
// Alle Filter zurücksetzen
$( ".datatable .aktionen a#resetFilter" ).click( function( ) {
objFilterTable.fnFilterClear();
$(".datatable thead td").each( function ( ) {
$("input").val( '' );
$("select").val( '' );
} );
} );
 
// Kategorie vorauswählen
var strKategorie = querystring.kategorie;
if (typeof(strKategorie) !== 'undefined') {
$(".datatable thead td").each( function ( i ) {
if ( $(this).attr('id') == 'kategorie' ) {
objFilterTable.fnFilter( strKategorie, i );
$("select").val( strKategorie );
}
} );
}
});

Version vom 10. Juli 2017, 11:19 Uhr

// Das Script Common.js wird immer eingebunden und eignet sich deshalb zur Verknüpfung weiterer Scripte.

mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Faq.js&action=raw&ctype=text/javascript' );
mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Datatables.js&action=raw&ctype=text/javascript' );

// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Querystring.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Labelauty.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Highlight.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Webfont.js&action=raw&ctype=text/javascript' );
// mw.loader.load( 'http://wiki.llz.uni-halle.de/index.php?title=MediaWiki:Common.js/Ready.js&action=raw&ctype=text/javascript' );

// Interaktive Tabellen
$( function() {
	// Menüfeld füllen
	function fillSelectFilter( arrColumnData ) {
		var strAll = '';
		var expSeparator = / *,{1} */;
		var arrSelectList = new Array();
		for ( i = 0; i < arrColumnData.length; i++ ) {
			arrFieldData = arrColumnData[i].split(expSeparator);
			for ( j = 0; j < arrFieldData.length; j++ ) {
				if (jQuery.inArray(arrFieldData[j], arrSelectList) > -1) {
					continue;
				} else {
					arrSelectList.push(arrFieldData[j]);
				}
			}
		}
		var strHtml = '<select><option value="">' + strAll + '</option>', i;
		for ( k = 0; k < arrSelectList.length; k++ ) {
			strHtml += '<option value="' + arrSelectList[k] + '">' + arrSelectList[k] + '</option>';
		}
		return strHtml + '</select>';
	}

	// Eigenschaften festlegen
	var objFilterTable = $(".datatable #tools").dataTable( {
		"bAutoWidth": true,
		"bFilter": true,
		"bInfo": false,
		"bLengthChange": false,
		"bPaginate": false,
		"bProcessing": false,
		"bSort": false,
		"bSortClasses": false,
		"oLanguage": {
			"sEmptyTable": "Die Tabelle ist leer.",
			"sSearch": "Alle Spalten filtern",
			"sZeroRecords": "Die Filter führen zu keinem Ergebnis.",
		},
	} );

	// Filter erstellen
	$(".datatable thead td").each( function ( i ) {
		if ($(this).hasClass("selectFilter")){
			this.innerHTML = fillSelectFilter( objFilterTable.fnGetColumnData(i) );
			$('select', this).change( function () {
				objFilterTable.fnFilter( $(this).val(), i );
			} );
		} else if ($(this).hasClass("inputFilter")) {
			this.innerHTML = '<input>';
			$("thead input").keyup( function () {
				objFilterTable.fnFilter( $(this).val(), i );
			} );			
		};
	} );

	// Alle Filter zurücksetzen
	$( ".datatable .aktionen a#resetFilter" ).click( function( ) {
		objFilterTable.fnFilterClear();
		$(".datatable thead td").each( function ( ) {
			$("input").val( '' );
			$("select").val( '' );
		} );
	} );

	// Kategorie vorauswählen
	var strKategorie = querystring.kategorie;
	if (typeof(strKategorie) !== 'undefined') {
		$(".datatable thead td").each( function ( i ) {
			if ( $(this).attr('id') == 'kategorie' ) {
				objFilterTable.fnFilter( strKategorie, i );
				$("select").val( strKategorie );
			}
		} );
	}
});