MediaWiki:UserFunctions/code.js

/** * User Functions * Provides functions similar to Mw:Extension:UserFunctions * Author: 机智的小鱼君 **/ $('.UserFunctions').html(function{ // Create variables  var ifture,      type = this.dataset.type,      dataif = this.dataset.if;

// Functions switch (type) {

case 'iflogin': ifture = mw.config.get('wgUserName') != null ; if ( ifture ) { $(this).children('#true').show;$(this).children('#false').hide; } else { $(this).children('#false').show;$(this).children('#true').hide; }     break;

case 'username': return mw.config.get('wgUserName'); break;

case 'usergroup': return mw.config.get('wgUserGroups'); break;

case 'ifingroup': ifture = $.inArray(mw.config.get('wgUserGroups'), dataif) < -1 ; if ( ifture ) { $(this).children('#true').show;$(this).children('#false').hide; } else { $(this).children('#false').show;$(this).children('#true').hide; }     break;

default: return ' User Functions type error! '; }

});