MediaWiki:Common.js

var ArchiveToolConfig = { archiveListTemplate: 'ArchiveList', archivePageTemplate: 'Archive', archiveSubpage: 'Archive', userLang: true };

importArticles({   type: "script",    articles: [        'u:dev:ReferencePopups/code.js',        'u:dev:ReferencePopups/custom.js',        'u:dev:HeaderLinks/code.js',        'u:dev:UserTags/code.js',        'u:dev:Standard_Edit_Summary/code.js',        'u:dev:MiniComplete/code.js',        'u:dev:GalleryButtonCustomText/code.js',        'u:dev:View_Source/code.js',        'u:dev:CacheCheck/code.js',        'u:dev:AjaxRC/code.js',        'u:dev:SearchSuggest/code.js',        'u:dev:AutoEditDropdown/code.js',        'u:dev:DisableArchiveEdit/code.js', /* Discourage/disable the editing of talk page archives */        'u:dev:Countdown/code.js',        'u:dev:FloatingToc/code.js',        'u:dev:DupImageList/code.js',        'u:dev:SkinSwitchButton/code.js',        'MediaWiki:Common.js/addnavlinks.js', /* Add "about us" link to "On Wikizilla" menu */        'MediaWiki:Common.js/wallgreetingbutton.js', /* Add a button to edit Message Wall Greeting */ 'MediaWiki:Common.js/socialIcons.js', /* Social Icons */ 'u:dev:ArchiveTool/code.js', 'u:dev:DisableArchiveEdit/code.js', 'u:dev:InactiveUsers/code.js', 'u:dev:AutoEditDropdown/code.js', 'u:dev:FixWantedFiles/code.js', 'u:dev:RevealAnonIP/code.js' ] });

//

/**/

function hasGroup(group) { for (var i in wgUserGroups) { if (wgUserGroups[i] == group) return true; }   return false; }

/* Shows messages for Admins */ function showAdmMessage { if (hasGroup('sysop')) { $('.adminmessage').css({'display': 'block !important'}); } }

addOnloadHook(showAdmMessage);

/* ############################################# */ /* ##         CUSTOM EDIT BUTTONS            ## */ /* ############################################# */

if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT ",           "tagClose": "", "sampleText": "Insert text" };

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/godzilla/images/5/54/Wikia_Button_-_Category.png", "speedTip": "Category", "tagOpen": "Category:",           "tagClose": "", "sampleText": "Insert text" };

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/493titanollante/images/b/bf/Wikia_Button_-_Glow.png", "speedTip": "Glow", "tagOpen": " ", "sampleText": "Insert text" };

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/493titanollante/images/9/90/Wikia_Button_-_Reference.png", "speedTip": "Reference", "tagOpen": " ", "sampleText": "" };

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/493titanollante/images/c/cd/Wikia_Button_-_DVD.png", "speedTip": "DVD Info", "tagOpen": "COMPANY (YEAR) \r*Released: \r*Region: Region \r*Language: \r*Format: \r*Other Details: aspect ratio,  minutes run time,  disc,  version", "tagClose": "", "sampleText": "" };

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/493titanollante/images/0/05/Wikia_Button_-_Kaiju_Infobox.png", "speedTip": "Kaiju Infobox", "tagOpen": "", "tagClose": "", "sampleText": "" };

}

/* Replaces with the name of the user browsing the page. Requires copying Template:USERNAME. */

function UserNameReplace { if (typeof (disableUsernameReplace) != 'undefined' && disableUsernameReplace || wgUserName === null) return; $("span.insertusername").html(wgUserName); } addOnloadHook(UserNameReplace);

/* End of the replacement */

/* Any JavaScript here will be loaded for all users on every page load. */

// inserts user name into addOnloadHook(UserNameReplace);

function UserNameReplace { if (typeof (disableUsernameReplace) != 'undefined' && disableUsernameReplace) { return; }   for (var i = 0; UserName = document.getElementsByTagName("span")[i]; i++) { if ((document.getElementById('pt-userpage')) && (UserName.getAttribute('id') == "insertusername")) { var ViewerName = document.getElementById('pt-userpage').firstChild.innerHTML; UserName.innerHTML = ViewerName; }   } }

function rewriteHover { var gbl = document.getElementById("hover-global");

if (gbl === null) return;

var nodes = getElementsByClassName(gbl, '*', 'hoverable');

for (var i = 0; i < nodes.length; i++) { nodes[i].onmouseover = function { this.className += " over"; };

nodes[i].onmouseout = function { this.className = this.className.replace(new RegExp(" over\\b"), ""); };   } }

function ContentLoader { this.cache = true; }

ContentLoader.prototype.enableCache = function (caching) { this.cache = (caching === null) ? true : this.cache; };

ContentLoader.prototype.createRequest = function { if (typeof (XMLHttpRequest) != 'undefined') { return new XMLHttpRequest; } else if (typeof (ActiveXObject) != 'undefined') { return new ActiveXObject("Msxml2.XMLHTTP"); }

return null; };

ContentLoader.prototype.send = function (url, postdata, contentType) { var method = (postdata === null) ? 'GET' : 'POST'; this.request = this.createRequest; this.request.open(method, url);

if (!this.cache) this.request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");

var request = this.request; var loader = this;

if (postdata === null) { if (contentType === null) contentType = 'application/x-www-form-urlencoded';

request.setRequestHeader('Content-type', contentType); }

var f = function { if (request.readyState == 4) { loader.text = request.responseText; loader.document = request.responseXML; request = null; loader.request = null; loader.callback; }   };

this.request.onreadystatechange = f;   this.request.send(postdata); }; /*	end ContentLoader

function replaceSearchIcon { var innerDiv;

var searchbox = document.getElementById('searchBody');

if (searchbox) { innerDiv = searchbox.getElementsByTagName('div')[0]; var link = innerDiv.getElementsByTagName('a')[0];

if (link) innerDiv.removeChild(link); } else { searchbox = getElementsByClassName(document.getElementById('searchBox'), 'div', 'r_boxContent')[0]; innerDiv = searchbox.getElementsByTagName('div')[1]; }

var loader = new ContentLoader; loader.div = innerDiv; loader.callback = onSearchIconsArrival; loader.send('/index.php?title=Template:Searchicons&action=raw'); }

function rand(n) { return Math.round(Math.random * n); }

function onSearchIconsArrival { var lines = this.text.split('\n'); var line = lines[rand(lines.length - 1)]; var pos = line.indexOf(' ');

var link = document.createElement('div'); //	link.href = '/index.php?title=Special:Search&adv=1'; link.id = 'search-icon-wrapper'; var img = document.createElement('img'); img.alt = 'Search'; img.src = (pos == -1) ? line : line.substring(0, pos); link.appendChild(img);

this.div.insertBefore(link, this.div.firstChild);

var div = document.createElement('div'); div.id = 'search-popup'; div.style.display = 'none'; var ul = document.createElement('ul');

var li; var a;

li = document.createElement('li'); a = document.createElement('a'); a.href = '/index.php?title=Special:Search&adv=1'; a.appendChild(document.createTextNode('Advanced search')); li.appendChild(a); ul.appendChild(li);

li = document.createElement('li'); a = document.createElement('a'); a.href = (pos == -1) ? 'javascript:emptySearchDesc' : '/wiki/' + line.substring(pos + 1); a.appendChild(document.createTextNode("What's this? (" + ((pos == -1) ? 'NO DESCRIPTION' : line.substring(pos + 1)) + ')')); li.appendChild(a); ul.appendChild(li);

li = document.createElement('li'); a = document.createElement('a'); a.href = 'javascript:closeSearchPopup'; a.appendChild(document.createTextNode("Close")); li.appendChild(a); ul.appendChild(li);

div.appendChild(ul); document.getElementById('globalWrapper').appendChild(div);

link.onclick = openSearchPopup; }

function openSearchPopup(event) { var div = document.getElementById('search-popup'); var e = event || window.event;

div.style.display = (div.style.display == 'none') ? 'block' : 'none'; div.style.left = e.clientX + 'px'; div.style.top = (e.clientY + document.documentElement.scrollTop) + 'px'; }

function closeSearchPopup { document.getElementById('search-popup').style.display = 'none'; }

function emptySearchDesc { alert('No description exists for this search icon. Please contact the administrators to resolve this problem.'); }

function ContentLoader { this.cache = true; }

// ************************************************** // End (Sikon's?) searchicon code // **************************************************

// ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.3 // ************************************************** // // Usage example: // //  Only January 01 2007 00:00:00 PST until New years. // //  Javascript disabled.

function updatetimer(i) { var now = new Date; var then = timers[i].eventdate; var diff = count = Math.floor((then.getTime - now.getTime) / 1000);

// catch bad date strings if (isNaN(diff)) { timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **'; return; }

// determine plus/minus if (diff < 0) { diff = -diff; var tpm = ' '; } else { var tpm = ' '; }

// calcuate the diff var left = (diff % 60) + ' seconds'; diff = Math.floor(diff / 60); if (diff > 0) left = (diff % 60) + ' minutes ' + left; diff = Math.floor(diff / 60); if (diff > 0) left = (diff % 24) + ' hours ' + left; diff = Math.floor(diff / 24); if (diff > 0) left = diff + ' days ' + left timers[i].firstChild.nodeValue = tpm + left;

// a setInterval is more efficient, but calling setTimeout // makes errors break the script rather than infinitely recurse timeouts[i] = setTimeout('updatetimer(' + i + ')', 1000); }

function checktimers { //hide 'nocountdown' and show 'countdown' var nocountdowns = getElementsByClassName(document, 'span', 'nocountdown'); for (var i in nocountdowns) nocountdowns[i].style.display = 'none' var countdowns = getElementsByClassName(document, 'span', 'countdown'); for (var i in countdowns) countdowns[i].style.display = 'inline'

//set up global objects timers and timeouts. timers = getElementsByClassName(document, 'span', 'countdowndate'); //global timeouts = new Array; // generic holder for the timeouts, global if (timers.length == 0) return; for (var i in timers) { timers[i].eventdate = new Date(timers[i].firstChild.nodeValue); updatetimer(i); //start it up   } } addOnloadHook(checktimers);

// ************************************************** // - end -  Experimental javascript countdown timer // **************************************************

/* Code for "More Info Button" function showDiv { document.getElementById('welcomeDiv').style.display = "block"; } function hideDiv { document.getElementById('welcomeDiv').style.display = "none"; } /* End */

/* Code for Artworks */ $(document).ready(function {

var number = 0; var current;

// Set the first .view to display: block; $("td.views > div").each(function (index) {       number = number + 1;        if (index == 0) {            $(this).css("display", "block");            current = 0;        }    });

// Bind functions to the left/right keys $("body").keyup(function (event) {       if (event.keyCode == 37) {            backone;        }        if (event.keyCode == 39) {            forwardone;        }    });

// Bind functions to the buttons $(".backone").click(function {        backone;    }); $(".forwardone").click(function {        forwardone;    });

function backone { current--; if (current < 0) { current = number - 1; }       current2 = current + 1; $("td.views > div").css("display", "none"); $("td.views > div:nth-child(" + current2 + ")").css("display", "block"); console.log(current); }

function forwardone { current++; if (current > number - 1) { current = 0; }       current2 = current + 1; $("td.views > div").css("display", "none"); $("td.views > div:nth-child(" + current2 + ")").css("display", "block"); console.log(current); } }); /* End */