MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ GetSpecialVideo = function{ if (document.getElementById('video_dragonage')) {   if (typeof ord=='undefined') {ord=Math.random*10000000000000000;} var daiframe = document.createElement('iframe'); var dasrc = "http://ad.doubleclick.net/adi/wka.gaming/_dragonage/home;sz=400x266;ord=" + ord + "?"; daiframe.setAttribute("src",dasrc); daiframe.style.width = 400+"px"; daiframe.style.height = 266+"px"; daiframe.setAttribute("marginwidth",0); daiframe.setAttribute("marginheight",0); daiframe.setAttribute("frameborder",0); daiframe.setAttribute("scrolling","no"); var video_dragonage = document.getElementById('video_dragonage'); video_dragonage.appendChild(daiframe); if (navigator.userAgent.indexOf("Gecko")==-1) {     var dascript = document.createElement('script'); var dascriptsrc = 'http://ad.doubleclick.net/adj/wka.gaming/_dragonage/home;sz=400x266;abr=!ie;ord=' + ord + '?' dascript.setAttribute("language","JavaScript"); dascript.setAttribute("src",dascriptsrc); dascript.setAttribute("type","text/javascript"); daiframe.appendChild(dascript); } } } jQuery(document).ready(GetSpecialVideo);

// prototype functions function $A(a) { var r = []; for (var i = 0, len = a.length; i < len; ++i) r.push(a[i]); return r; }

Function.prototype.bind = function { var __method = this, args = $A(arguments), object = args.shift; return function { return __method.apply(object, args.concat($A(arguments))) }; }

/* Test if an element has a certain class ************************************** * Description: Uses regular expressions and caching for better performance. * Maintainers: User:Mike Dillon, User:R. Koot, User:SG */ var hasClass = (function {    var reCache = {};    return function (element, className) {        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);   }; }); /** Collapsible tables ********************************************************* * Description: Allows tables to be collapsed, showing only the header. See *              NavFrame. * Maintainers: User:R. Koot */ var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show"; function collapseTable( tableIndex ) {   var Button = document.getElementById( "collapseButton" + tableIndex ); var Table = document.getElementById( "collapsibleTable" + tableIndex ); if ( !Table || !Button ) { return false; }   var Rows = Table.rows; if ( Button.firstChild.data == collapseCaption ) { for ( var i = 1; i < Rows.length; i++ ) { Rows[i].style.display = "none"; }       Button.firstChild.data = expandCaption; } else { for ( var 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 = new Object; var Tables = document.getElementsByTagName( "table" ); for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "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", "javascript:collapseTable(" + tableIndex + ");" ); ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button, Header.childNodes[0] ); tableIndex++; }   }    for ( var i = 0;  i < tableIndex; i++ ) { if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { collapseTable( i ); }        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) { var element = NavigationBoxes[i]; while (element = element.parentNode) { if ( hasClass( element, "outercollapse" ) ) { collapseTable ( i ); break; }           }        }    } } addOnloadHook( createCollapseButtons );

/** Magic editintros **************************************************** * * Description: Adds editintros on disambiguation pages. */ function addEditIntro(name) { var el = document.getElementById('control_edit'); if (!el) return; el = el.getElementsByTagName('a')[0]; if (el) el.href += '&editintro=' + name; } if (wgNamespaceNumber == 0) { addOnloadHook(function{   if (document.getElementById('disambigbox'))      addEditIntro('Template:Disambig_editintro');  }); }

/****************************************/ /* sliders using jquery by User:Tierrie */ /****************************************/ //wsl.loadScript("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"); //wsl.loadScript("http://dragonage.wikia.com/index.php?title=MediaWiki:Jquery-ui.min.js&action=raw&ctype=text/javascript");

mw.loader.using( ['jquery.ui.tabs'], function { $(document).ready(function { var $tabs = $("#portal_slider").tabs({ fx: {opacity:'toggle', duration:100} } ); $("[class^=portal_sliderlink]").click(function { // bind click event to link   $tabs.tabs('select', this.className.replace("portal_sliderlink_", ""));    return false;  }); $('#portal_next').click(function {   $tabs.tabs('select', ($tabs.tabs('option', 'selected') == ($tabs.tabs('length'))-1) ? 0 : $tabs.tabs('option', 'selected') + 1 ); // switch to next tab   return false;  }); $('#portal_prev').click(function { // bind click event to link   $tabs.tabs('select', ($tabs.tabs('option', 'selected') == 0) ? ($tabs.tabs('length')-1) : $tabs.tabs('option', 'selected') - 1 ); // switch to previous tab   return false;  }); }); } );

/****************************/ /* spoilers by User:Tierrie */ /****************************/ var showSpoiler = new Array; function showSpoilers(splrType) { var Divs= document.getElementsByTagName("div"); for (i=0;i<Divs.length;i++) { // allows the child to be something besides a div (a table for example) if (hasClass(Divs[i], 'splr') && hasClass(Divs[i].childNodes[0], 'splr_'+splrType)) { var warning = Divs[i].childNodes[0].childNodes[1]; warning.className = warning.className.replace('show_warning','hide_warning'); var spoiler = Divs[i].childNodes[1]; spoiler.className = spoiler.className.replace('hide_spoiler','show_spoiler'); } }  document.cookie='showspoiler_'+splrType+'=1; path=/'; }

function hideSpoilers(splrType) { var Divs= document.getElementsByTagName("div"); for (i=0;i<Divs.length;i++) {

// allows the child to be something besides a div (a table for example) if (hasClass(Divs[i], 'splr') && hasClass(Divs[i].childNodes[0], 'splr_'+splrType)) { var warning = Divs[i].childNodes[0].childNodes[1]; warning.className = warning.className.replace('hide_warning','show_warning'); var spoiler = Divs[i].childNodes[1]; spoiler.className = spoiler.className.replace('show_spoiler','hide_spoiler'); } }  document.cookie='showspoiler_'+splrType+'=0; path=/'; } function toggleSpoilers(ev) { var splrType=this.className.split('_')[1]; showSpoiler[splrType] = showSpoiler[splrType]?0:1; if(showSpoiler[splrType]) showSpoilers(splrType); else hideSpoilers(splrType); //ev.target.focus; /* focus back on the element because large spoilers tend to move the page around */ } function initSpoilers { var Divs= document.getElementsByTagName("div"); for (i=0;i<Divs.length;i++) { if (hasClass(Divs[i], 'splr')) { Divs[i].childNodes[0].onclick = toggleSpoilers;

var warning = Divs[i].childNodes[0].childNodes[1]; warning.className = warning.className.replace('hide_warning','show_warning'); var spoiler = Divs[i].childNodes[1]; spoiler.className = spoiler.className.replace('show_spoiler','hide_spoiler'); } }  var cookies = document.cookie.split("; "); for (var i=0; i < cookies.length; i++) { // a name/value pair (a crumb) is separated by an equal sign if(cookies[i].indexOf('showspoiler')!=-1) { var crumbs = cookies[i].split("="); var splrType = crumbs[0].split('_')[1]; /* cookie="showspoiler_dao=1", crumbs[0] = "showspoiler_dao", splrType="dao" */ var splrValue = parseInt(crumbs[1]); showSpoiler[splrType]=splrValue; if(splrValue) showSpoilers(splrType); else hideSpoilers(splrType); } } } var spoilers = true; function loadSpoilers { if(spoilers) initSpoilers; } addOnloadHook(loadSpoilers);

/************************/ /* tooltip: by Kirkburn */ /************************/ //ttBgStyle = "background: transparent url(picture.png);"; var ttBgStyle = "background-color:transparent;"; var ttHTMLStart = '';

// Empty variables to hold the mouse position and the window size var mousePos = null; var winSize = null;

function mouseMove(ev) { if (ev) { if (ev.clientX) var mouseX = ev.clientX; if (ev.clientY) var mouseY = ev.clientY; } else if (typeof(window.event) != "undefined") { var mouseX = window.event.clientX; var mouseY = window.event.clientY; } mousePos = {x:mouseX, y:mouseY}; }

function getDBC { dbc = new Array; docBase = document.documentElement || document.body; dbc[0] = docBase.clientWidth || 0; dbc[1] = docBase.clientHeight || 0; return dbc; }

function getDBS { dbs = new Array; docBase = document.documentElement || document.body; dbs[0] = docBase.scrollLeft || 0; dbs[1] = docBase.scrollTop || 0; return dbs; }

// The windowResize function keeps track of the window size for us function windowResize { dbC = getDBC; winSize = {x:(dbC[0])? dbC[0]:window.innerWidth, y:(dbC[1])? dbC[1]:window.innerHeight} } windowResize;

// Set events to catch mouse position and window size document.onmousemove = mouseMove; window.onresize = windowResize;

// displays the tooltip function displayTip { var tip = document.getElementById("simpletfb"); tip.style.position = "absolute"; tip.style.visibility = "hidden"; tip.style.display = "block"; tip.style.zIndex = "999"; moveTip; tip.style.visibility = "visible"; }

// This function moves the tooltips when our mouse moves function moveTip { skinAdjust = new Array; dbS = getDBS; tip = document.getElementById("simpletfb"); var showTTAtTop  = mousePos.y > (winSize.y / 2); var showTTAtLeft = mousePos.x > (winSize.x / 2); var newTop = mousePos.y + (showTTAtTop  ? - (tip.clientHeight + 20) : 20); var newLeft = mousePos.x + (showTTAtLeft ? - (tip.clientWidth + 20) : 20); tip.style.position = 'fixed'; tip.style.top = newTop + "px"; tip.style.left = newLeft + "px"; }

// hides the tip function hideTip { var tip = document.getElementById("simpletfb"); if (typeof(tip.style) == "undefined") return false; $(tip).html(""); tip.style.display = "none"; }

// quick tooltips function showTemplateTip(i) { var Tip = document.getElementById("tttc" + i); tooltip = ttHTMLStart + Tip.innerHTML + ' '; document.getElementById("simpletfb").innerHTML = tooltip; displayTip; }

function performTooltips { var contentstart = document.getElementById("bodyContent") ? document.getElementById("bodyContent") : document.getElementById("WikiaArticle"); qttfdiv = document.createElement("div"); qttfdiv.setAttribute("id", "simpletfb"); contentstart.insertBefore(qttfdiv, contentstart.childNodes[0]); var Spans = document.getElementsByTagName("span"); for (i=0;i<Spans.length;i++) { if (hasClass(Spans[i], "ttlink")) { Spans[i].nextSibling.setAttribute("id", "tttc" + i); Spans[i].firstChild.setAttribute("title", ""); Spans[i].onmouseover = showTemplateTip.bind(Spans[i],i); Spans[i].onmouseout = hideTip; Spans[i].onmousemove = moveTip; } } }

var tooltips = true; function loadTooltips { if (tooltips) performTooltips; } addOnloadHook(loadTooltips);

/** Archive edit tab disabling ************************************* * Disables the edit tab on old forum topic pages to stop new people bumping old topics. * Page can still be edited by going via the edit tab on the history etc, or by * typing the edit address manually. * By Spang * Monaco support by Uberfuzzy * Oasis support by Uberfuzzy and Monchoman45 ********************************************************************/ if(wgNamespaceNumber == 110) { function disableOldForumEdit { if( typeof( enableOldForumEdit ) != 'undefined' && enableOldForumEdit ) { return; }	if( !document.getElementById('old-forum-warning') ) { return; }	if( skin == 'oasis' ) {		$("#WikiaPageHeader .wikia-menu-button li a:first").html('Archived').removeAttr('href' ); $('#WikiaPageHeader .wikia-button').html('Archived').removeAttr('href'); return; }	if( !document.getElementById('ca-edit') ) { return; }	var editLink = null; if( skin == 'monaco' ) {		editLink = document.getElementById('ca-edit'); }	else if( skin == 'monobook' ) {		editLink = document.getElementById('ca-edit').firstChild; }	else {		return; }	editLink.removeAttribute('href', 0); editLink.removeAttribute('title', 0); editLink.style.color = 'gray'; editLink.innerHTML = 'Archived'; $('span.editsection-upper').remove; } addOnloadHook( disableOldForumEdit ); }

/* ######################################################################## */ /* ### AJAX RC                                                         ### */ /* ### ### */ /* ### Description: Automatically refresh "Recent changes" via AJAX     ### */ /* ### Credit:     User:pcj (http://www.wowpedia.org)                  ### */ /* ###             User:Porter21 (fallout.wikia.com)                   ### */ /* ######################################################################## */ var indicator = 'https://images.wikia.nocookie.net/dragonage/images/c/c5/AJAX_icon.gif'; var ajaxPages = new Array("Special:RecentChanges", "Special:WikiActivity", "Dragon Age Wiki:WikiActivity"); var ajaxTimer; var ajaxRefresh = 60000; var refreshText = 'Auto-refresh'; if( typeof AjaxRCRefreshText == "string" ) { refreshText = AjaxRCRefreshText; } var refreshHover = 'Enable auto-refreshing page loads'; if( typeof AjaxRCRefreshHoverText == "string" ) { refreshHover = AjaxRCRefreshHoverText; } var doRefresh = true; function setCookie(c_name,value,expiredays) { var exdate=new Date exdate.setDate(exdate.getDate+expiredays) document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString) } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) }   }   return "" } function preloadAJAXRL { ajaxRLCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; appTo = ($("#WikiaPageHeader").length)?$("#WikiaPageHeader > h1"):$(".firstHeading"); appTo.append('&#160; ' + refreshText + ':   '); $("#ajaxLoadProgress").ajaxSend(function (event, xhr, settings){     if (location.href == settings.url) $(this).show;   }).ajaxComplete (function (event, xhr, settings){      if (location.href == settings.url) $(this).hide;   }); $("#ajaxToggle").click(toggleAjaxReload); $("#ajaxToggle").attr("checked", ajaxRLCookie); if (getCookie("ajaxload-"+wgPageName)=="on") loadPageData; } function toggleAjaxReload { if ($("#ajaxToggle").attr("checked") == true) { setCookie("ajaxload-"+wgPageName, "on", 30); doRefresh = true; loadPageData; } else { setCookie("ajaxload-"+wgPageName, "off", 30); doRefresh = false; clearTimeout(ajaxTimer); } } function loadPageData { cC = ($("#WikiaArticle").length)?"#WikiaArticle":"#bodyContent"; $(cC).load(location.href + " " + cC + " > *", function (data) {      if (doRefresh) ajaxTimer = setTimeout("loadPageData;", ajaxRefresh);   }); } addOnloadHook(function{ for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) preloadAJAXRL } } );

/******************************/ /* changes the redirect image */ /******************************/ function ChangeRedirectImage { $('.redirectMsg img').attr('src', 'https://images.wikia.nocookie.net/__cb20100902033555/dragonage/images/b/b5/Redirectltr.png'); } addOnloadHook(ChangeRedirectImage); /////////////////////////////////////////////////////////////////////////////////////////////////////////// // END OF CODE ///////////////////////////////////////////////////////////////////////////////////////////////////////////