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.
(Please note: Due to bugs with the distribution system, this reward is temporarily unavailable.)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!

User:DDOstream/vector.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
/* UserCSSJS
** To make it easy to navigate to your own custom CSS and JS pages
** [[Special:MyPage/common.css]] [[Special:MyPage/common.js]]
** [[Special:MyPage/vector.css]] [[Special:MyPage/vector.js]]
**/

/* RC long dates */
if( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Recentchanges' ){
  var arrDaysOfWeek = [ 'Sunday', 'Monday',  'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ];
  $( 'div.mw-changeslist h4' ).each( function( n, h4date ) {
    var strDate = h4date.innerText;
    var thisDay = ( new Date( strDate ) ).getDay();
    if ( n === 0 ) {
      h4date.id = "today";
    } else {
      h4date.id = arrDaysOfWeek[ thisDay ] + ( Math.floor( n / 7 ) + 1 );
    }
    h4date.innerText = arrDaysOfWeek[ thisDay ] + ', ' + strDate;
  } );
  $( 'fieldset.rcoptions' ).html(
    $( 'fieldset.rcoptions' ).html()
      .replace( ' minor edits | ', ' minor | ' )
      .replace( ' anonymous users | ', ' IPs | ' )
      .replace( ' registered users | ', ' users | ' )
      .replace( ' patrolled edits | ', ' patrolled | ' )
      .replace( ' my edits', ' mine' )
  );
}

/* De-orpahaning script */
mw.loader.load( '/index.php?title=User:Technical_13/SandBox/DeOrphaner.js&action=raw&ctype=text/javascript' );//[[User:Technical_13/SandBox/DeOrphaner.js]]

/* NOW LIVE */
mw.loader.load( '/index.php?title=User:DDOstream/LiveStream.js&action=raw&ctype=text/javascript' );//[[User:DDOstream/LiveStream.js]]

//mw.loader.load( '/index.php?title=MediaWiki:Gadget-delete.js&action=raw&ctype=text/javascript' );//[[MediaWiki:Gadget-delete.js]]

/* BD */// Testing new code for "Better Diffs"
$( '.diff-otitle' ).append( '<br /><span style="color: #8B0000; font-weight: bold;">-' + $( '.diff-deletedline' ).text().length + '</span>' );
$( '.diff-ntitle' ).append( '<br /><span style="color: #006400; font-weight: bold;">+' + $( '.diff-addedline' ).text().length + '</span>' );
var intDiff = $( '.diff-addedline' ).text().length - $( '.diff-deletedline' ).text().length;
$( '.diff-otitle' ).parents( 'tr' ).after(
  '<tr style="vertical-align: top; text-align: center;"><td colspan="4">Change this edit: <span style="color: #' +
  ( intDiff === 0 ? '8A8A8A' : ( intDiff < 0 ? '8B0000' : '006400' ) ) +
  '; font-weight: ' + ( Math.abs( intDiff ) >= 500 ? 'bold' : 'inherit' ) + ';">' + intDiff + '</span></td></tr>'
  );

/* [[Category:Unique item enchantments]] fixes for [[T:Unique enchantment]] changes */
//</nowiki>
$( document ).ready( function() {
  var pageid = mw.config.get( 'wgArticleId' );
  var editSummary = 'Modifications for changes in  [[T:Unique enchantment]]';
  var pageContent = '';
  mw.util.addPortletLink(
    'p-tb-list',
    '#',
    'Fix Enchantments',
    'ca-fix-ue',
    'Update for modifications to T:Unique enchantment',
    null,
    null
  );
  $( '#ca-fix-ue' ).click( function ( e ) {
    e.preventDefault();
    new mw.Api().get( {
      action: 'query',
      prop: 'revisions|info',
      rvprop: 'content',
      pageids: pageid,
      indexpageids: 1
    } ).done( function ( pageResponse ) {
      pageContent = pageResponse.query.pages[ pageid ].revisions[ 0 ][ '*' ];
      pageContent = pageContent
        .replace( /[\s\r\n]*?\{\{Unique[ _]enchantment/gi, '{{Unique enchantment' )
        .replace( /[\s\r\n]*?\| *?name *?= *?/g,   '\n  | name   = ' )
        .replace( /[\s\r\n]*?\| *?effect *?= *?/g, '\n  | effect = ' )
        .replace( /[\s\r\n]*?\| *?found *?= *?/g,  '\n  | found  = ' )
        .replace( /[\s\r\n]*?\| *?note *?= *?/g,   '\n  | note   = ' )
        .replace( /\[http:\/\/forums\.ddo\.com\/showthread\.php\?t=([\d]*)(.*?)\]/, '{{Forums|$1}}' )
        .replace( /={1} */g,                                   '\= ' )
        .replace( /[\s\r\n]*?\}\}\{\{/g,                  '\n}}\n{{' );
      var nextTemplateStart = 0;
      var founds = 1;
      while ( pageContent.contains( '  | found  = ' ) ) {
        if ( confirm( '\t\t|found=\t\t\n\nRemove "found" line #' + founds + '?' ) ) {
          var indexFrom = pageContent.indexOf( '  | found  = ', nextTemplateStart );
          var indexTo =
            ( pageContent.indexOf( '  | effect = ', nextTemplateStart ) < pageContent.indexOf( '  | found  = ', nextTemplateStart ) ?
            pageContent.indexOf( '}}', nextTemplateStart ) : pageContent.indexOf( '  | effect = ', nextTemplateStart ) );
          pageContent = pageContent.replace( pageContent.substr( indexFrom, ( indexTo - indexFrom ) ), '');
          nextTemplateStart = pageContent.indexOf( '}}', nextTemplateStart + 2 );
          founds++;
        } else {
          if ( founds > 1 ) {
            alert( '\t\t|found=\t\t\n\nOkay, I won\'t remove any more "found" line(s)' );
          } else {
            alert( '\t\t|found=\t\t\n\nOkay, I won\'t remove any "found" line(s)' );
          }
          break;
        }
      }
      new mw.Api().postWithToken( 'edit', {
        action: 'edit',
        pageid: pageid,
        text: pageContent,
        summary: editSummary
      } ).done( function ( tagged ) { 
        if ( tagged.edit.result === 'Success' ) {
          alert( 'Page was updated!' );
          location.href = location.href.replace( location.hash, '' ) + ( location.search ? '&' : '?' ) + 'diff=last';
        } else {
          alert( 'Page was NOT updated!' );
        }
      } );
      // console.log( pageContent );
    } );
  } );
} );
//</nowiki>