User:Gary Queen/layout.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Gary Queen/layout. |
/*
GARY KING'S LAYOUT
FIXME When action=purge, icons are moved up higher.
TODO Change wikEd icon to text.
TODO Add a link to disable all (or also some) of the functions here.
TODO Separate page into functions.
TODO Consider templates (Template:) short pages? (In monobook.js)
TODO Automatically enlarge lead images to 300px when a size has not been set?
*/
/*
hook
*/
addOnloadHook(function()
{
pagesLayout();
});
/*
useful functions
*/
function $(element)
{
return document.getElementById(element);
}
Object.prototype.addClass = function(newClass)
{
element = this;
if (element.className)
{
classes = element.className.split(' ');
classes.push(newClass);
return element.className = classes.join(' ');
}
else return element.className = newClass;
}
Object.prototype.hasClass = function(classToCheck)
{
element = this;
if (!element.className) return false;
classes = element.className.split(' ');
for (var i = 0; i < classes.length; i++)
{
if (classes[i] == classToCheck)
return true;
}
return false;
}
Object.prototype.removeClass = function(oldClass)
{
element = this;
if (!element.className) return false;
classes = element.className.split(' ');
newClasses = [];
for (var i = 0; i < classes.length; i++)
{
if (classes[i] != oldClass)
newClasses.push(classes[i]);
}
return element.className = newClasses;
}
String.prototype.trim = function()
{
return this.replace(/^[\s|\n]+|[\s|\n]+$/g, '');
}
String.prototype.ltrim = function()
{
return this.replace(/^[\s|\n]+/, '');
}
String.prototype.rtrim = function()
{
return this.replace(/[\s|\n]+$/, '');
}
/*
do page layout
*/
function pagesLayout()
{
/*
variables
*/
var content = $('content');
var jumpToNav = $('jump-to-nav');
var pPersonal = $('p-personal');
var afterJumpToNav = jumpToNav.nextSibling.nextSibling.nextSibling.nextSibling;
var bodyContent = $('bodyContent');
var cactions = $('p-cactions');
var caEdit = $('ca-edit');
var caMain = $('ca-nstab-main');
var contentSub = $('contentSub');
var firstDiffElement = content.getElementsByClassName('diff')[0];
var globalWrapper = $('globalWrapper');
var h2 = content.getElementsByTagName('h2');
var paragraphs = content.getElementsByTagName('p');
var pBody = pPersonal.getElementsByClassName('pBody')[0];
var pendingChanges = $('mw-fr-revisiontag');
var relLinks = content.getElementsByClassName('rellink');
var section0 = $('section-0');
var siteSub = $('siteSub');
var toc = $('toc');
var tPrint = $('t-print');
var userMessages = content.getElementsByClassName('usermessage');
var wikiPreview = $('wikiPreview');
var wikitables = content.getElementsByClassName('wikitable');
}