Year of the Dragon: Through May 28th, claim free Expansion Pack (excluding Vecna Unleashed) or a Greater Elixir of Discovery! Speak to Xatheral in the Hall of Heroes.
Known Issue: Xatheral has been temporarily disabled while we investigate a bug with Year of the Dragon gift delivery.DDO Forums edit

Game mechanicsNewbie guideIn developmentDDO StoreSocial Media


ChallengesClassesCollectablesCraftingEnhancementsEpic DestiniesFavorFeats

GlossaryItemsMapsMonstersPlacesQuestsRacesReincarnationSkillsSpells


Please create an account or log in to build a reputation and unlock more editing privileges, and then visit DDO wiki's IRC Chat/Discord if you need any help!

MediaWiki:Gadget-ppIndicators.js

From DDO wiki
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes, you can click here or try one of the methods below..

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+r ( Command+r on a Mac)
  • Google Chrome: Press Ctrl+ Shift+R ( Command+ Shift+R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl+F5
  • Konqueror: Click Reload or press F5
  • Opera: Clear the cache in Tools ‣ Preferences
// Testcases can be found on [[User:Technical 13/Protection tests]]
//<nowiki>
  var protectionLevel;
  var isMW = ( mw.config.get( 'wgCanonicalNamespace' ) === 'MediaWiki' ? true : false );
  var isSpecial = ( mw.config.get( 'wgCanonicalNamespace' ) === 'Special' ? true : false );
  var isUserCssJs = false;
  var editUserCssJs = false;
  if ( mw.config.get( 'wgCanonicalNamespace' ) === 'User' &&// IF it is User: space
    ( mw.config.get( 'wgPageContentModel' ) === 'javascript' ||// AND is .js
    mw.config.get( 'wgPageContentModel' ) === 'css' ) ) {// OR .css
    isUserCssJs = true;
  }
  if ( mw.config.get( 'wgRelevantUserName' ) === mw.config.get( 'wgUserName' ) ||// IF it is current user's space
    $.inArray( 'sysop', mw.config.get( 'wgUserGroups' ) ) !== -1 ) {// OR is an administrator
    editUserCssJs = true;
  }
  
  function createDie( edit, move, title ) {
    var piClass = edit.toLowerCase() + '-' + move.toLowerCase();
    if ( edit.toLowerCase() === move.toLowerCase() ) {
      ppSection = ( edit.toUpperCase() === 'PURPLE' ? 'PP' : edit.toUpperCase() + 'DIE' );
      ppIcon = edit;
    } else {
      ppSection = edit.toUpperCase() + move.toUpperCase() + 'DIE';
      ppIcon = edit + move;
    }
    var imgSource = 'https://ddowiki.com/images/' + ppIcon + '_d20.png';
    var imgStyle = 'style="width: 16px; height: 16px;"';
    var imgIcon = '<img src="' + imgSource + '" ' + imgStyle + ' title="' + title + '" />';
    var anchorLink = '<a href="https://ddowiki.com/page/DDO:' + ppSection + '">' + imgIcon + '</a>';
    return lineItem = '<li id="pt-ppicon" class="pi-' + piClass + '">' + anchorLink + '</li>';
  }
  
  if ( !isMW && !isSpecial && ( !isUserCssJs || editUserCssJs ) ) {// No need to do all this processing if it's not editable
    var editLevel = mw.config.get( 'wgRestrictionEdit' );// Get the edit protection flag for page
    if ( editLevel == '' || editLevel == 'undefined' || editLevel == null ) {
      editLevel = 'none';// page isn't protected at all
    } else {
      if ( $.inArray( 'sysop', editLevel ) >= 0 ) {
        editLevel = 'full';// sysop is full
      }
      else if ( $.inArray( 'autoconfirmed', editLevel ) >= 0 ) {
        editLevel = 'semi';// autoconfirmed is semi
      } else {
        editLevel = 'none';// otherwise there's none
      }
    }
    var moveLevel = mw.config.get( 'wgRestrictionMove' );// Get the move protection flag for page
    if ( moveLevel == '' || moveLevel == 'undefined' || moveLevel == null ) {
      moveLevel = 'none';// page isn't protected at all
    } else {
      if ( $.inArray( 'sysop', moveLevel ) >= 0 ) {
        moveLevel = 'full';// sysop is full
      }
      else if ( $.inArray( 'autoconfirmed', moveLevel ) >= 0 ) {
        moveLevel = 'semi';// autoconfirmed is semi
      } else {
        moveLevel = 'none';// otherwise there's none
      }
    }
    protectionLevel = editLevel + '/' + moveLevel;
  }
   
  if ( isSpecial ) {
    $( 'li#pt-userpage' ).before( createDie( 'Black', 'Black', 'Special page' ) );
  } else if ( isMW ) {
    $( 'li#pt-userpage' ).before( createDie( 'Black', 'Black', 'User Interface page' ) );
  } else if ( isUserCssJs && !editUserCssJs ) {
    $( 'li#pt-userpage' ).before( createDie( 'Black', 'Black', 'User CSS or JavaScript page' ) );
  } else if ( protectionLevel === 'full/full' ) {
    $( 'li#pt-userpage' ).before( createDie( 'Red', 'Red', 'Full protection enabled' ) );
  } else if ( protectionLevel === 'full/semi' ){
    $( 'li#pt-userpage' ).before( createDie( 'Red', 'Blue', 'Full/Semi protection enabled' ) );
  } else if ( protectionLevel === 'full/none' ){
    $( 'li#pt-userpage' ).before( createDie( 'Red', 'Purple', 'Full edit protection enabled' ) );
  } else if ( protectionLevel === 'semi/full' ){
    $( 'li#pt-userpage' ).before( createDie( 'Blue', 'Red', 'Semi/Full protection enabled' ) );
  } else if ( protectionLevel === 'semi/semi' ){
    $( 'li#pt-userpage' ).before( createDie( 'Blue', 'Blue', 'Semi protection enabled' ) );
  } else if ( protectionLevel === 'semi/none' ){
    $( 'li#pt-userpage' ).before( createDie( 'Blue', 'Purple', 'Semi edit protection enabled' ) );
  } else if ( protectionLevel === 'none/full' ){
    $( 'li#pt-userpage' ).before( createDie( 'Purple', 'Red', 'Full move protection enabled' ) );
  } else if ( protectionLevel === 'none/semi' ){
    $( 'li#pt-userpage' ).before( createDie( 'Purple', 'Blue', 'Semi move protection enabled' ) );
  } else {
    $( 'li#pt-userpage' ).before( createDie( 'Purple', 'Purple', 'Not protected' ) );
  }
//</nowiki>[[Category:Gadgets]]