Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$.when( mw.loader.using( 'mediawiki.util' ), $.ready ).then( function () {

/******************************************************************/
/* Toujours avoir le titre de la page (pour le copier facilement) */
/******************************************************************/
$( function() {
	if( mw.config.get( 'wgAction' ) == 'view' || mw.config.get( 'wgNamespaceNumber' ) < 0 ) return;
	$('#firstHeading').text( mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ) );
});

/**
 * Add a link in a portlet, actionning a JavaScript action on click
 * 
 * Similar to mw.util.addPortletLink; the only difference is it can take
 *  a function on click event instead of a simple link
 */
function addPortletFunctionLink( portlet, functio, text, id, tooltip, accesskey, nextnode ) {
	
	var item = mw.util.addPortletLink( portlet, '#', text, id, tooltip, accesskey, nextnode );
	
	if( typeof functio == 'function' ) $(item).find('a').removeAttr('href').css('cursor','pointer').click(functio);
	
	return item;
}

/* Add the capacity of automatically adding < translate > tags in tab cells.
   Some false negatives will be missed, but no false positives should be added.
   This adds a link in the Tools portlet.
   Author: Seb35 - licence WTFPL 2.0
 */
$( function() {
	
	function addTranslateTagsInTabs() {
		
		const newTab = '\n{|', endTab = '\n|}', newTemplate = '{' + '{', endTemplate = '}}';
		
		// Internal function to create chunks by (possibly intricated) tags
		var chunkText = function( text, newTag, endTag ) {
			
			var chunks = [], lastTag = 0, thisTag;
			
			// Recursive function to close all opened tags
			function closeAllTags( text, pos ) {
				
				var secondOpen = text.indexOf( newTag, pos+newTag.length ),
				    firstClose = text.indexOf( endTag, pos );
				
				text = text.substring(0,secondOpen) + text.substring(secondOpen).replace( endTag, '\n##' );
				
				if( firstClose == -1 ) return text.length;
				if( secondOpen < firstClose && secondOpen != -1 ) return closeAllTags( text, secondOpen );
				
				return firstClose+endTag.length;
			}
			
			// Split by entry tags
			while( ( thisTag = text.indexOf( newTag, lastTag ) ) != -1 ) {
				
				// Add non-tab text
				chunks.push( text.substring( lastTag, thisTag ) );
				
				// Add tab text
				lastTag = closeAllTags( text, thisTag );
				chunks.push( text.substring( thisTag, lastTag ) );
			}
			if( lastTag != 0 ) chunks.push( text.substring( lastTag ) );
			
			return chunks;
		};
		
		// Helper function to effectively add < translate > tags in a tab cell
		var addTranslateTags = function(text,p1,p2) {
			
			if( p2.indexOf( newTemplate ) != -1 || p2.indexOf( '\'\'' ) != -1 || p2.indexOf( '<'+'translate>' ) != -1 || p2.indexOf( '</'+'translate>' ) != -1 || p2.trim() == '-' || p2.trim() == '}' ) return text;
			return '|' + p1 + ' <'+'translate>' + p2.trim() + '</'+'translate>';
		};
		
		// Get the text and split it between tabs and non-tabs
		var iTab,
		    text = $( '#wpTextbox1' ).val(),
		    tabs = chunkText( text, newTab, endTab );
		
		// Add translate tags in each tab cell
		for( iTab = 0; iTab < tabs.length; iTab++ ) {
			
			text = tabs[iTab];
			
			if( text.substr(0,newTab.length) != newTab ) continue;
			
			text = text.replace( /^\|()([^\|]*)$/mg, addTranslateTags );
			text = text.replace( /^\|([^\|]*\|)([^\|]*)$/mg, addTranslateTags );
			
			tabs[iTab] = text;
		}
		
		// Put back the result
		$( '#wpTextbox1' ).val( tabs.join('') );
	}
	
	addPortletFunctionLink( 'p-tb', addTranslateTagsInTabs, 'Translate tabs' );
} );

/*

Test

{|
|eife;%7*fjoewige
| gewige"wgj
|-
|}

{|
|#@egfeeee ee
| ggf-gggg
ghfi+=ho
{|
|-
|style="color:blue;"|f#ffffffff
eosf{ieoh
|}
|-
|}


*/

/* Calendrier - cf Events calendar/about */
importScript( 'User:0x010C/Events-calendar-editor.js' );
importScript( 'User:0x010C/Events-calendar-navigation.js' );


/**
 * Ajoute un lien NCO juste après le nom d’utilisateur en haut, ainsi que, le jeudi, un lien direct
 * vers le compte-rendu ou, le mercredi, un lien direct vers le compte-rendu du lendemain
 */

// Mois en français
var d = new Array( 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre' );
// Variables du jour
var ajd = new Date(), dem1 = new Date(ajd.getTime()+86400000);

// Ajout des liens « NCO » et le cas échéant « jeudi, c’est wiki » ou « demain, c’est wiki »
mw.util.addPortletLink( 'p-personal', '/wiki/Wikimédia_France/Groupes_de_travail/Groupes_locaux/Rennes', 'NCO', 'pt-nco', '', '', '#pt-mytalk' );

var page = null;

if( ajd.getDay() == 4 ) {

    page = 'Wikimédia_France/Groupes_de_travail/Groupes_locaux/Rennes/'+ajd.getDate()+(ajd.getDate()==1?'er':'')+'_'+d[ajd.getMonth()]+'_'+ajd.getFullYear();
    mw.util.addPortletLink( 'p-personal', '/wiki/' + page, 'jeudi, c’est wiki', 'pt-nco-jeudi', '', '', '#pt-mytalk' );
} else if( ajd.getDay() == 3 ) {

    page = 'Wikimédia_France/Groupes_de_travail/Groupes_locaux/Rennes/'+dem1.getDate()+(dem1.getDate()==1?'er':'')+'_'+d[dem1.getMonth()]+'_'+dem1.getFullYear();
    mw.util.addPortletLink( 'p-personal', '/wiki/' + page, 'demain, c’est wiki', 'pt-nco-jeudi', '', '', '#pt-mytalk' );
}

$.ajax( '/w/api.php?action=query&format=json&prop=info&titles=' + page, { 'complete': function( resp ) {

respglobal = resp;

    if( resp.readyState == 4 && resp.responseJSON.query.pages['-1'] ) {

        $( '#pt-nco-jeudi a' ).addClass( 'new' );
    }
} } );

});