Year of the Dragon: Through April 23rd, claim the adventure pack Slice of Life for free! Speak to Xatheral in the Hall of Heroes.
Game mechanics • Newbie guide • In development • DDO Store • Social Media
Challenges • Classes • Collectables • Crafting • Enhancements • Epic Destinies • Favor • Feats
Glossary • Items • Maps • Monsters • Places • Quests • Races • Reincarnation • Skills • Spells
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:Common.js
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
//<nowiki>
/* --------------- Any JavaScript here will be loaded for all users on every page load. --------------- */
/* */
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* IMPORT SECTION *//*
*/
// mw.loader.load( '/index.php?title=MediaWiki:Gadget-Edittools.js&action=raw&ctype=text/javascript' );// Test
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* Make [[T:Button]] actually clickable! *//*
** BY: [[U:Technical 13]]
** 28 February 2017
*/
if ( $( 'span.fakeButton' ) !== undefined ) {
$( 'span.fakeButton' ).each( function() {
var realButton = '<input type="button" ';
var buttonID = $( this ).attr( 'id' );
realButton += 'id="' + buttonID + '" class="fakeButton" ';
var buttonTitle = $( this ).attr( 'title' );
realButton += 'title="' + buttonTitle + '" ';
if ( $( this ).attr( 'dir' ) !== undefined ) {
var buttonClick = $( this ).attr( 'dir' );
realButton += 'onClick="' + buttonClick + '"';
}
var buttonText = $( this ).text();
realButton += ' value="' + buttonText + '" />';console.log('replacing id: %s with: %s', buttonID, realButton);
$( 'span#' + buttonID ).replaceWith( realButton );
} );
}
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* Home page "What's new" section sizer works with [[MW:Common.css]] to achieve desired result *//*
** BY: [[User:Technical 13]]
** 29 July 2015
** Modified: 30 July 2015
*/
if (
mw.config.get( 'wgPageName' ) === 'Home' ||// [[Home]] itself
mw.config.get( 'wgPageName' ) === "Home/What's_new" ||// [[Home/What's_new]]
mw.config.get( 'wgPageName' ) === 'Talk:Home/ShoeMaker'//TESTCASES PAGE -- [[Talk:Home/ShoeMaker]]
) {
$( 'div#whatsNew, div.whatsNew' ).attr(
'style',
'width: ' + ( $( '#mw-content-text' ).width() - 14 ) + 'px !important;'
);
$( '.whatsNewSection' ).attr(
'style',
'width: ' + Math.floor( ( $( '#mw-content-text' ).width() - 73 ) / 3 ) + 'px !important;'
);
}
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* Namespace Stripping & Fixes *//*
** Written 2012-04-20 by [[User:Ague]]
** Modified 2016-08-15 by [[User:Technical 13]]
** Modified 2021-09-03 by [[User:Technical_13]]
**/
$( 'a[href^="/page/Item:"]' ).each( function() {
$( this ).addClass( 'item' );
$( this ).html( $( this ).html().replace( 'Item:', '' ) );
} );
$( '#firstHeading' ).each( function() {
$( this ).html( $( this ).html().replace( 'Item:', '' ) );
} );
$( 'title' ).each( function() {
$( this ).html( $( this ).html().replace( 'Item:', 'I:' ) );
} );
/*if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Editcount' ) {
$( 'td' ).filter( ( x, cell ) => { return $( cell ).text() === 'NS #274'; } ).text( 'Widget' );
$( 'td' ).filter( ( x, cell ) => { return $( cell ).text() === 'NS #275'; } ).text( 'Widget talk' );
}//*/
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* Collapsible tables *//*
* Description: Allows tables to be collapsed, showing only the header. See [[en:Wikipedia:NavFrame]]
* Maintainers: [[en:User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = 'hide';
var expandCaption = 'show';
window.collapseTable = function ( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
var i;
if ( Button.firstChild.data === collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
};
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( 'table' );
var i;
function handleButtonLink( index, e ) {
window.collapseTable( index );
e.preventDefault();
}
for ( i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
/* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
if ( !HeaderRow ) continue;
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
if ( !Header ) continue;
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
var Button = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
Button.className = 'collapseButton'; /* Styles are declared in Common.css */
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
Header.insertBefore( Button, Header.firstChild );
tableIndex++;
}
}
for ( i = 0; i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
window.collapseTable( i );
}
else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ((element = element.parentNode)) {
if ( $( element ).hasClass( 'outercollapse' ) ) {
window.collapseTable ( i );
break;
}
}
}
}
}
$( createCollapseButtons );
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* Dynamic Navigation Bars (experimental) *//*
* Description: See [[enWikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
// set up the words in your language
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
/**
* Shows and hides content and picture (if available) of navigation bars
* Parameters:
* indexNavigationBar: the index of navigation bar to be toggled
**/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var NavChild;
if ( !NavFrame || !NavToggle ) {
return false;
}
// if shown now
if ( NavToggle.firstChild.data === NavigationBarHide ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
// if hidden now
} else if ( NavToggle.firstChild.data === NavigationBarShow ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
event.preventDefault();
};
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
var NavFrame;
var NavChild;
/* iterate over all < div >-elements */
var divs = document.getElementsByTagName( 'div' );
for ( var i = 0; (NavFrame = divs[i]); i++ ) {
/* if found a navigation bar */
if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
indexNavigationBar++;
var NavToggle = document.createElement( 'a' );
NavToggle.className = 'NavToggle';
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute( 'href', '#' );
$( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
/**
* Check if any children are already hidden. This loop is here for backwards compatibility:
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
* the content visible without JavaScript support), the new recommended way is to add the class
* "collapsed" to the NavFrame itself, just like with collapsible tables.
*/
for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
if ( NavChild.style.display === 'none' ) {
isCollapsed = true;
}
}
}
if ( isCollapsed ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
NavChild.style.display = 'none';
}
}
}
var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
NavToggle.appendChild( NavToggleText );
// Find the NavHead and + the 1/0 link (Must be this complicated because Moz's 1stChild handling is borked)
for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild( NavToggle );
}
}
NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
}
}
}
$( createNavigationBarToggleButton );
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/* DDO Wiki UI Improvement - User Talk Archival Script - FINAL
* BY: [[User:Ague]]
* 31 January 2014
*/
$( 'p' ).click( function() {
var id = $( this ).attr( 'id' ) + '_div';
if ( $( '#' + id ).hasClass( 'show' ) ) {
$( '#' + id ).slideUp( 1000 ).removeClass( 'show' );
} else {
$( 'div.ArchiveContentBox > div' ).slideUp( 700 );
$( '#' + id ).slideDown( 1000 ).addClass( 'show' );
}
} );
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/**
* Redirect User:Name/skin.js and skin.css to the current skin's pages
* (unless the 'skin' page really exists).
*
* Dependencies: mediawiki.util
*
* @source https://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
* @revision 2016-04-13
*/
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
mw.loader.using( 'mediawiki.util', function () {
var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
// Make sure there was a part before and after the slash
// And that the latter is 'skin.js' or 'skin.css'
if ( titleParts.length == 2 ) {
var userSkinPage = titleParts[0] + '/' + mw.config.get( 'skin' );
if ( titleParts[1] === 'skin.js' ) {
location.href = mw.util.getUrl( userSkinPage + '.js' );
} else if ( titleParts[1] === 'skin.css' ) {
location.href = mw.util.getUrl( userSkinPage + '.css' );
}
}
} );
}
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/**
* @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @revision 2020-04-01
* @author [[User:Technical_13]]
*/
mw.loader.using( [ 'mediawiki.util', 'mediawiki.notify', 'mediawiki.api' ], function () {
var userPageCSS, isMWCSS;
var extraCSS = mw.util.getParamValue( 'withCSS' );
if ( extraCSS ) {
userPageCSS = ( extraCSS.split( ':' )[ 0 ] === 'User' ? extraCSS.split( ':' )[ 1 ].split( '/' )[ 0 ] : null );
isMWCSS = ( extraCSS.split( ':' )[ 0 ] === 'MediaWiki' ? true : false );
}
var userPageJS, isMWJS;
var extraJS = mw.util.getParamValue( 'withJS' );
if ( extraJS ) {
userPageJS = ( extraJS.split( ':' )[ 0 ] === 'User' ? extraJS.split( ':' )[ 1 ].split( '/' )[ 0 ] : null );
isMWJS = ( extraJS.split( ':' )[ 0 ] === 'MediaWiki' ? true : false );
}
var isUserSysop = ( mw.config.get( 'wgUserGroups' ).indexOf( 'sysop' ) !== -1 ? true : false );
var isOnSysopUser = false, doAnyway = false;
var strUsers = ( userPageCSS && userPageJS ? ( userPageCSS === userPageJS ? userPageCSS : userPageCSS + '|' + userPageJS ) : ( userPageCSS || userPageJS || mw.config.get( 'wgUserName' ) ) );
console.log( 'strUsers: %s', strUsers );
( new mw.Api ).get( {
action: 'query',
list: 'users',
usprop: 'rights',
ususers: strUsers
} ).done( function( userRights ) {
userRights = userRights.query.users[ 0 ].rights;
isOnSysopUser = ( userRights.indexOf( 'editinterface' ) !== -1 ? true : false );
if ( isUserSysop && ! isOnSysopUser && !isMWCSS && !isMWJS ) {
doAnyway = confirm( 'This code is NOT in the MediaWiki: namespace OR in the User: space of an administrator.\n\t\t\tHit [OK] ONLY if you trust the source of this code!' );
}
if ( extraCSS ) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
if ( isMWCSS || ( isOnSysopUser && userPageCSS ) || doAnyway ) {
mw.loader.load( '/index.php?title=' + encodeURIComponent( extraCSS ) + '&action=raw&ctype=text/css', 'text/css' );
} else {
mw.notify( 'Only pages on an administrators User: space or from the MediaWiki: namespace are allowed.', { title: 'Invalid withCSS value' } );
}
}
if ( extraJS ) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
if ( isMWJS || ( isOnSysopUser && userPageJS ) || doAnyway ) {
mw.loader.load( '/index.php?title=' + encodeURIComponent( extraJS ) + '&action=raw&ctype=text/javascript' );
} else {
mw.notify( 'Only pages on an administrators User: space or from the MediaWiki: namespace are allowed.', { title: 'Invalid withJS value' } );
}
}
} );
} );
//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//
/**
** /* Social Media iframe injector *//*
** BY: [[User:Technical 13]]
** 17 September 2021
*/
// $( 'head' ).append( '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>' );// Might not need this anymore.
$( '#footer-icons' ).prepend(
'<li id="footer-facebookLike"><iframe src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2Ffacebook.com%2FDDOwiki&width=90&layout=button_count&action=like&size=small&share=false&height=21&appId" width="90" height="21" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe></li>' +
'<li id="footer-twitterFollow"><iframe id="twitter-widget-0" scrolling="no" allowtransparency="true" allowfullscreen="true" class="twitter-follow-button twitter-follow-button-rendered" style="position: static; visibility: visible; width: 63px; height: 20px;" title="Twitter Follow Button" src="https://platform.twitter.com/widgets/follow_button.f88235f49a156f8b4cab34c7bc1a0acc.en.html#dnt=false&id=twitter-widget-0&lang=en&screen_name=DDOwiki&show_count=false&show_screen_name=false&size=m&time=1631909754820" data-screen-name="DDOwiki" frameborder="0"></iframe></li>'
);
if ( mw.config.get( 'wgPageName' ) === 'DDO_wiki:Social_media' ) {
$( '#fbFeedDDOwiki' ).replaceWith( '<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2FDDOwiki%2F&tabs=timeline%2C%20events%2C%20messages&width=500&height=500&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&hide_cta=true&appId" width="500" height="500" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>' );
$( '#twtrFeedDDOwiki' ).replaceWith( '<iframe id="twitter-widget-1" scrolling="no" allowtransparency="true" allowfullscreen="true" class="twitter-timeline twitter-timeline-rendered" style="position: static; visibility: visible; display: inline-block; width: 500px; height: 500px; padding: 0px; border: medium none; max-width: 100%; min-width: 180px; margin-top: 0px; margin-bottom: 0px; min-height: 200px;" data-widget-id="profile:DDOwiki" title="Twitter Timeline" frameborder="0"></iframe>' );
}
//</nowiki>