(Import du code concernant les traductions) |
(Bas) |
||
Ligne 99 : | Ligne 99 : | ||
$( 'body.action-edit #mw-translation-editnotice' ) |
$( 'body.action-edit #mw-translation-editnotice' ) |
||
.css( 'background', 'darkred' ) |
.css( 'background', 'darkred' ) |
||
− | .html( '<b>Cette page n’est pas à jour.</b><br>Vous pouvez aider en <a target="_blank" rel="noopener noreferrer" href="https://bindingofisaacrebirth.gamepedia.com/index.php?type=revision&diff=' + lastRevision + '&oldid=' + revision + '">la mettant à jour</a>, puis en remplaçant <code>{{révision | ' + revision + ' | ' + origine + ' }}</code> par <code>{{révision | ' + lastRevision + ' | ' + origine + ' }}</code> en |
+ | .html( '<b>Cette page n’est pas à jour.</b><br>Vous pouvez aider en <a target="_blank" rel="noopener noreferrer" href="https://bindingofisaacrebirth.gamepedia.com/index.php?type=revision&diff=' + lastRevision + '&oldid=' + revision + '">la mettant à jour</a>, puis en remplaçant <code>{{révision | ' + revision + ' | ' + origine + ' }}</code> par <code>{{révision | ' + lastRevision + ' | ' + origine + ' }}</code> en bas de la page.' ); |
} |
} |
||
} ); |
} ); |
Version du 10 septembre 2019 à 06:23
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
$( function () {
var purge_href = $( '#ca-cargo-purge > a' ).attr( 'href' );
$( '#ca-cargo-purge' ).remove();
$( '#p-views > ul' ).append( '<li></li>' );
$( '#p-views > ul > li:not([id])' ).attr( 'id', 'ca-cargo-purge' );
$( '#ca-cargo-purge' ).append( '<span><a>⟳</a></span>' );
$( '#ca-cargo-purge > span > a' )
.attr( { 'title': 'Purge the cache [alt-shift-g]', 'href': purge_href, 'accesskey': 'g' } )
.css( { 'line-height': 0, 'font-size': 'large' } );
} );
// Tooltips
$( document ).on( 'mousemove', function ( event ) {
$( '.tooltip:hover > .tooltip-block' ).css( { 'left': event.clientX + 10 + 'px', 'top': event.clientY + 20 + 'px' } );
} );
$( function () {
// Links titles
$( '.notitle, .tooltip' )
.find( 'a' )
.attr( 'title', '' );
// Nav
$( '.nav-master-button-visible' ).hide();
$( '.nav-master-button-collapsed' ).show();
$( '.nav-master' ).hide();
$( '.nav-master-button-visible' ).click( function () {
$( '.nav-master-button-visible' ).hide();
$( '.nav-master-button-collapsed' ).show();
$( '.nav-master' ).hide();
} );
$( '.nav-master-button-collapsed' ).click( function () {
$( '.nav-master-button-visible' ).show();
$( '.nav-master-button-collapsed' ).hide();
$( '.nav-master' ).show();
} );
// Slideshows initialization
var $slideshows = $( '.infobox-slideshow' ),
anim = new Array( $slideshows.size() ).fill( 0 );
$slideshows.each( function () {
var maxHeight = 0,
maxWidth = 0;
$( this )
.find( '.slide' )
.each( function () {
maxHeight = Math.max( maxHeight, $( this ).height() );
maxWidth = Math.max( maxWidth , $( this ).width() );
} );
$( this )
.height( maxHeight )
.width ( maxWidth );
} );
// Slideshows loop
setInterval( function () {
$slideshows.each( function ( i, slideshow ) {
var $slides = $( slideshow ).find( '.slide' );
if ( $slides.length > 1 )
if ( $( slideshow ).hasClass( 'infobox-slideshow-smooth' ) ) {
$( $slides.get( anim[ i ] ) ).fadeOut( 'slow' );
anim[ i ] = $slides.get( anim[ i ] + 1 ) ? anim[ i ] + 1 : 0;
$( $slides.get( anim[ i ] ) ).fadeIn( 'slow' );
} else {
$( $slides.get( anim[ i ] ) ).fadeOut( 'slow' );
anim[ i ] = $slides.get( anim[ i ] + 1 ) ? anim[ i ] + 1 : 0;
$( $slides.get( anim[ i ] ) ).fadeIn( 'slow' );
}
} );
}, 3000 );
} )
// Translation progress
var pageName = mw.config.get( 'wgPageName' );
fetch( "https://bindingofisaacrebirth-fr.gamepedia.com/api.php?format=json&action=cargoquery&tables=maintenance&fields=origine,revision&where=_pageName='" + pageName + "'&limit=1" )
.then( function( r ) { return r.json(); } )
.then( function( r ) {
if ( r.cargoquery.length ) {
var fr = r.cargoquery[0].title;
var revision = fr.revision;
var origine = fr.origine;
fetch( "https://cors-anywhere.herokuapp.com/https://bindingofisaacrebirth.gamepedia.com/api.php?format=json&action=query&prop=revisions&pageids=" + origine )
.then( function( r2 ) { return r2.json(); } )
.then( function( r2 ) {
var lastRevision = r2.query.pages[origine].revisions[0].revid;
if ( lastRevision == revision ) {
$( 'body.action-view #firstHeading' )
.prepend( '<div style="width: 15px; height: 15px; float: right; background: green"></div>' );
$( 'body.action-edit #mw-translation-editnotice' )
.css( 'background', 'green' )
.html( '<b>Cette page est à jour.</b><br>Elle est une traduction de la révision <code>' + lastRevision + '</code> de la page <a href="https://bindingofisaacrebirth.gamepedia.com/index.php?curid=' + origine + '">' + r2.query.pages[origine].title + '</a>.' );
} else {
$( 'body.action-view #firstHeading' )
.prepend( '<a target="_blank" rel="noopener noreferrer" href="https://bindingofisaacrebirth.gamepedia.com/index.php?type=revision&diff=' + lastRevision + '&oldid=' + revision + '"><div style="width: 15px; height: 15px; float: right; background: darkred"></div></a>' );
$( 'body.action-edit #mw-translation-editnotice' )
.css( 'background', 'darkred' )
.html( '<b>Cette page n’est pas à jour.</b><br>Vous pouvez aider en <a target="_blank" rel="noopener noreferrer" href="https://bindingofisaacrebirth.gamepedia.com/index.php?type=revision&diff=' + lastRevision + '&oldid=' + revision + '">la mettant à jour</a>, puis en remplaçant <code>{{révision | ' + revision + ' | ' + origine + ' }}</code> par <code>{{révision | ' + lastRevision + ' | ' + origine + ' }}</code> en bas de la page.' );
}
} );
} else
$( 'body.action-edit #mw-translation-editnotice' )
.append( '<br><br>Entrer le nom d’une page pour obtenir le texte correspondant à la dernière révision.<br><div class="oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-textInputWidget oo-ui-textInputWidget-type-text oo-ui-labelElement" style="width: 40%; display: inline-block"><input type="text" id="mw-translation-editnotice-search" class="oo-ui-inputWidget-input"></div><a class="mw-ui-button button" style="min-width: 30px; margin-right: 0.5em" onclick="translationSearch()"><b>></b></a><br><code>{{révision | <span id="mw-translation-editnotice-revision"></span> | <span id="mw-translation-editnotice-origine"></span> }}</code>' );
} );
function translationSearch() {
var pageName = $( '#mw-translation-editnotice-search' ).val();
fetch( "https://cors-anywhere.herokuapp.com/https://bindingofisaacrebirth.gamepedia.com/api.php?format=json&action=query&prop=revisions&titles=" + pageName )
.then( function( r ) { return r.json(); } )
.then( function( r ) {
var pages = r.query.pages;
var p;
for ( p in pages )
break;
if ( p === "-1" )
$( '#mw-translation-editnotice-revision, #mw-translation-editnotice-origine' ).html( '' );
else {
var page = pages[p];
$( '#mw-translation-editnotice-revision' ).html( page.revisions[0].revid );
$( '#mw-translation-editnotice-origine' ).html( page.pageid );
}
} );
}
// Outdated pages list
var $list = $( '#mw-translation-list' );
if ( $list.length )
fetch( "https://bindingofisaacrebirth-fr.gamepedia.com/api.php?format=json&action=cargoquery&tables=maintenance&fields=_pageName=page,origine,revision&limit=500" )
.then( function( r ) { return r.json(); } )
.then( function( r ) {
var pages = r.cargoquery;
for ( var p in pages )
li( pages[p].title );
} );
function li( page ) {
var title = page.page;
var revision = page.revision;
var origine = page.origine;
if ( origine !== "0" )
fetch( "https://cors-anywhere.herokuapp.com/https://bindingofisaacrebirth.gamepedia.com/api.php?format=json&action=query&prop=revisions&pageids=" + origine )
.then( function( r ) { return r.json(); } )
.then( function( r ) {
var lastRevision = r.query.pages[origine].revisions[0].revid;
$list.append( '<li><a href="https://bindingofisaacrebirth-fr.gamepedia.com/index.php?title=' + title + '">' + title + '</a> : <a href="https://bindingofisaacrebirth.gamepedia.com/index.php?type=revision&diff=' + lastRevision + '&oldid=' + revision + '"><code>' + revision + '</code> -> <code>' + lastRevision + '</code></a>' );
} );
}