Saltar para o conteúdo

Usuário:Juan90264/StatusChangerAPI.js

Origem: Wikipédia, a enciclopédia livre.

Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.

  • Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
//////////STATUS CHANGER
// Creator: Misza13
// Credits: Voyagerfan5761 for some minor improvements
//     Modified by Xenocidic to simply use /Status as a one word indicator,
//     Modified by Kraftlos to include Sleep status
//     Modified by APerson for compatibility with {{UserStatus}}
//     compatible with {{Statustop}} for display
//     Modified by Juan90264 for an adjustment leaving the possibility to return the page


$(function (){
  
var pageName = uc.pageName;

mw.messages.set( {
	// General
	'uc-edit-success': '<p>A página foi editada com sucesso.',
	'uc-error-requestFail': 'Houve um erro ao requisitar a edição da página.'

} );

var params = {
		action: 'edit',
		format: 'json',
		title: 'User:Juan90264/Status',
		text: stat,
		summary: 'Juan90264 está agora online',
		minor: true,
                done: {
			success: function ( data ) {
				mw.notify(
					$( uc.message(
						'uc-edit-success',
						page.replace( /_/g, ' ' ),
						mw.util.getUrl( page, {
							diff: data.newrevid
						} ),
						mw.util.getUrl( page )
					) )
				);
			},
			apiError: function () {
				mw.notify( uc.message( 'uc-error-requestFail' ) );
			}
		}
	},
	api = new mw.Api();
	
  //Check if the config is defined
  if (typeof(statusChangerConfig) == 'undefined') {
    statusChangerConfig = {}
  }
 
  if (typeof(statusChangerConfig.statusList) == 'undefined') {
      statusChangerConfig.statusList = [ 'online', 'offline', 'dormindo' ];
  }
 
  if (typeof(statusChangerConfig.statusPage) == 'undefined') {
      statusChangerConfig.statusPage = 'User:' + mw.config.get('wgUserName') + '/Status';
  }
 
  //Add the links
  for (var i=0; i<statusChangerConfig.statusList.length; i++) {
    var stat = statusChangerConfig.statusList[i];
    var message = (stat === "dormindo") ?  link = "dormindo" : link = stat;
    mw.util.addPortletLink(
      "p-personal", //target tab - personal links
      params,
      stat, //link URL
      "pt-status-" + stat, //id of new button
      "Estou" + message + "!", //hover text
      "", //???
      document.getElementById("pt-logout")); //add before logout button
  }
});