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
- Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Strg+F5
// <nowiki>
// include the following line in your script file (without //):
// mw.loader.load('https://de.wikipedia.org/w/index.php?title=Benutzer:Hgzh/js/lintTableHelp.js&action=raw&ctype=text/javascript');
( function ( mw, $ ) {
'use strict';
let LINTPAGE = {
canonical: 'LintErrors',
selectorEntries: '.TablePager_col_title a:first-child',
selectorHeader: '#mw-content-text table.mw-datatable thead tr',
pages: []
};
let API = {
checkTemplates: [
'Vorlage:In Bearbeitung',
'Vorlage:Du darfst nicht'
],
msgError: 'API-Abfrage fehlgeschlagen.'
};
let ADDITION = {
classTimestamp: 'lintTableHelp-timestamp',
classRemarks: 'lintTableHelp-remarks',
textTimestamp: 'Bearbeitet',
textRemarks: 'Hinweise',
highlightPeriod: 48,
highlightCSS: {
'font-weight': 'bold',
'color': 'red'
},
list: []
};
LINTPAGE.getPage = ( $line ) => {
const text = $line.text();
if ( !LINTPAGE.pages.includes( text ) ) {
LINTPAGE.pages.push( text );
}
};
API.request = () => {
API.handle = new mw.Api();
API.handle.get({
action: 'query',
titles: LINTPAGE.pages.join( '|' ),
prop: 'revisions|templates',
rvprop: 'timestamp',
tlnamespace: 10,
tltemplates: API.checkTemplates.join( '|' ),
formatversion: 2
})
.then( API.processResult )
.fail( API.processError );
};
API.processResult = ( result ) => {
result.query.pages.forEach( ( page, i ) => {
let info = {
title: page.title,
timestamp: page.revisions[0].timestamp,
templates: []
};
if ( typeof page.templates === 'object' ) {
page.templates.forEach( ( template, i ) => {
info.templates.push( template.title.replace( 'Vorlage:', '' ) );
});
}
ADDITION.list.push( info );
});
ADDITION.apply();
};
API.processError = () => {
mw.notify( API.msgError );
};
ADDITION.formatTimestamp = ( timestamp ) => {
const ts = new Date( timestamp );
const now = new Date();
const $content = $( '<span>' );
const text = ts.toLocaleTimeString( 'de-DE', {
day: '2-digit',
month: '2-digit',
year: '2-digit',
hour: '2-digit',
minute: '2-digit'
} );
const diff = Math.abs( ts.getTime() - now.getTime() ) / 36e5;
if ( diff < ADDITION.highlightPeriod ) {
$content.css( ADDITION.highlightCSS );
}
$content.text( text );
return $content;
};
ADDITION.applySingle = ( $line ) => {
ADDITION.list.forEach( ( entry, i ) => {
if ( $line.text() === entry.title ) {
const $row = $line.parents( 'tr' );
$( '<td>' )
.addClass( ADDITION.classTimestamp )
.append( ADDITION.formatTimestamp( entry.timestamp ) )
.appendTo( $row );
$( '<td>' )
.addClass( ADDITION.classRemarks )
.text( entry.templates.join( ', ' ) )
.appendTo( $row );
return;
}
});
};
ADDITION.apply = () => {
LINTPAGE.$entries.each( function () {
ADDITION.applySingle( $( this ) );
} );
const $header = $( LINTPAGE.selectorHeader );
$( '<th>' ).text( ADDITION.textTimestamp ).appendTo( $header );
$( '<th>' ).text( ADDITION.textRemarks ).appendTo( $header );
};
const init = () => {
LINTPAGE.$entries = $( LINTPAGE.selectorEntries );
if ( !LINTPAGE.$entries.length ) {
return;
}
LINTPAGE.$entries.each( function () {
LINTPAGE.getPage( $( this ) );
} );
API.request();
};
if ( mw.config.get('wgCanonicalSpecialPageName') === LINTPAGE.canonical ) {
$( mw.loader.using( [ 'mediawiki.api' ], () => {
init();
} ) );
}
}( window.mediaWiki, window.jQuery ) );
// </nowiki>