MediaWiki:Common.js
Aller à la navigation
Aller à la recherche
Note : après avoir enregistré vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
- Opera : appuyez sur Ctrl + F5.
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
$( function() {
if( $( '.page-MediaWikiFarm_static_analysis' ).length == 0 ) return;
var families = {},
listfamilies = [],
all = false,
changeLink = function(family, value) {
if( all ) return;
var result = '';
families[family].forEach( function(v) {
if( v != value ) {
$('#link-' + family + '-' + v).removeClass('link-selected').css('font-weight', 'normal');
} else {
$('#link-' + family + '-' + value).addClass('link-selected').css('font-weight', 'bold');
}
} );
$('#css-'+family).text(
'.' + family + '-default-hide { display: none; } ' +
'.' + family + '-default-show { display: inline; } ' +
'.hide-when-' + family + '-' + value + ' { display: none; } ' +
'.show-when-' + family + '-' + value + ' { display: inline; } ' +
'.' + family + '-' + value + ' { display: inline; }'
);
};
$( '#mw-content-text table th span#link-all').wrapInner( '<a id="thelink-all"></a>' );
$( '#thelink-all').click( function() {
if( !all ) {
listfamilies.forEach( function(family) {
families[family].forEach( function(v) {
$('#link-' + family + '-' + v).css('font-weight', 'bold');
$('#css-'+family).text(
'.' + family + '-default-hide, ' +
'.' + family + '-default-show, ' +
'.hide-when-' + family + '-' + v + ', ' +
'.show-when-' + family + '-' + v + ', ' +
'.' + family + '-' + v + ' { display: inline; }' +
'.void { display: none; }'
);
} );
} );
$(this).text('(Reset)');
all = true;
} else {
window.location.reload();
all = false;
}
} );
$( '#mw-content-text table th span' ).each( function() {
if( $(this).attr('id') && $(this).attr('id').match( /^link-/ ) ) {
var result = $(this).attr('id').match( /^link-([a-z]+)-([a-z]+)$/ );
if( !families[result[1]] ) families[result[1]] = [];
listfamilies.push( result[1] );
families[result[1]].push( result[2] );
if( $('#css-' + result[1]).length == 0 ) {
$('head').append( '<style id="css-' + result[1] + '" type="text/css"></style>' );
}
$(this).wrapInner( '<a id="thelink-' + result[1] + '-' + result[2] + '"></a>' );
$('#thelink-' + result[1] + '-' + result[2]).click( function() {
changeLink( result[1], result[2] );
return false;
} );
if( $(this).hasClass('link-selected') ) {
changeLink( result[1], result[2] );
}
}
} );
} );