User:KoshVorlon/common.js

/* Integrated watchlist. en.wikipedia.org/wiki/User:Yair rand/interwikiwatchlist.js */ importScript ("User:Yair rand/interwikiwatchlist.js"); /* Open search results in new tab */ /* commons.wikimedia.org/wiki/MediaWiki:Search-results-new-tab.js */ $(function {    $('#searchform, #search, #powersearch, .search-types, #search-types').attr({ target: '_blank' }); });

/* Open search results list and search suggestions in new browser tab */ /* commons.wikimedia.org/wiki/MediaWiki_talk:Search-results-new-tab.js */ mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Search-results-new-tab.js&action=raw&ctype=text/javascript');

/* Just a test  -   Force HTTP/HTTPS

/** * Gadget to let the users (possibly anonymous users) ask for a forceHTTPS cookie * * This cookie is specified in  * and is recognised by MediaWiki to redirect the user to HTTPS. The user * (or admins if written in MediaWiki:Common.js) can specify the messages * of the link and some explanation just after the click. * * @author Seb35 * @licence WTFPL 2.0 */ var forceHTTPSoptions = { gadget: true, // Activate this script (and let the users deactivate it) activate: 'Activate HTTPS', // 'Activer le HTTPS',    // Message of the enter link deactivate: 'Deactivate HTTPS', // 'Désactiver le HTTPS' // Message of the exit link messageIn: ' HTTPS will only be activated on this computer. Do you know HTTPS Everywhere? It activates HTTPS on a bunch of websites, including Wikipedia. As a tip, user accounts always use HTTPS, if you want to registrate. ', // ' HTTPS ne sera activé que sur cet ordinateur. Connaissez-vous HTTPS Everywhere ? Cela active le HTTPS sur de nombreux sites dont Wikipédia. Pour information, les comptes utilisateur utilisent toujours le HTTPS, si vous souhaitez créer un compte. ', // Give the user a message before setting the cookie (false or string) messageOut: ' HTTPS will only be deactivated only on this computer. Now you can also use the HTTP version (less secure than the HTTPS version). ', //' HTTPS sera désactivé uniquement sur cet ordinateur. Maintenant vous pouvez également utiliser la version HTTP (moins sécurisée que la version HTTPS). ', // Give the user a message before removing the cookie (false or string) widthIn: 400, // Hook to change the message window width, 0 to use the default widthOut: 400 // Hook to change the message window width, 0 to use the default }; $( function {   var opts = forceHTTPSoptions;    if( !opts.gadget || mw.config.get('wgUserName') !== null ) return;     // Add the link in the bottom of the pages    $('#footer-places').append(''+( !$.cookie(mw.config.get('wgCookiePrefix')+'forceHTTPS') ? opts.activate : opts.deactivate )+'');    $('#forceHTTPSlink').click( function { // This function displays the dialog function dialog(on) { if( !opts['message'+on] ) return; $('body').append(' '+opts['message'+on]+' ' ); var dialogOptions = { modal: true, buttons: { Ok: function { $( this ).dialog( 'destroy' ); $('#forceHTTPSmessage').remove; } }};           if( opts['width'+on] ) dialogOptions.width = opts['width'+on]; $( "#forceHTTPSmessage" ).dialog( dialogOptions ); }       // This is the logic to create or destroy the forceHTTPS cookie // NB: the attribute "secure: false" is really important else the system don’t work if( $.cookie( mw.config.get('wgCookiePrefix')+'forceHTTPS' ) === null ) { dialog('In'); $.cookie( mw.config.get('wgCookiePrefix')+'forceHTTPS', 'true', { path: '/', secure: false } ); $( this ).text( opts.deactivate ); }       else { dialog('Out'); $.cookie( mw.config.get('wgCookiePrefix')+'forceHTTPS', null, { path: '/', secure: false } ); $( this ).text( opts.activate ); }   }); });