MediaWiki:CodeQuickLinks/code.js

$(function {	//Cache mw variables	var mwVariables = mw.config.get([ 'wgServer', 'wgArticlePath', 'wgUserLanguage' ]);	var cc = "http://community.wikia.com/wiki/Special:MyPage/";	var lang = mwVariables.wgUserLanguage;	var i18n = {		en: { //English			title: 'Code Quick Links',			wwTitle: 'MediaWiki Files',			mpTitle: 'Personal Files',			hCSS: 'Chat.css',			hJS: 'Chat.js',			cCSS: 'Common.css',			cJS: 'Common.js',			mCSS: 'Monobook.css',			mJS: 'Monobook.js',			wCSS: 'Wikia.css',			wJS: 'Wikia.js',			gCSS: 'Global.css',			gJS: 'Global.js'		},		sv: { //Swedish			title: 'Källkod Snabba Hyperlänkar',			wwTitle: 'MediaWiki Filer',			mpTitle: 'Personliga Filer',			hCSS: 'Pratstund.css',			hJS: 'Pratstund.js',			cCSS: 'Gemensam.css',			cJS: 'Gemensam.js',			mCSS: 'Monobook.css',			mJS: 'Monobook.js',			wCSS: 'Wikia.css',			wJS: 'Wikia.js',			gCSS: 'Global.css',			gJS: 'Global.js'		}	}	var mwFiles = [		{			title: i18n[lang].mpTitle,			pages: [				{					url:'chat.css',					name:i18n[lang].hCSS				},				{					url:'chat.js', name:i18n[lang].hJS },				{					url:'common.css', name:i18n[lang].cCSS },				{					url:'common.js', name:i18n[lang].cJS },				{					url:'global.css', name:i18n[lang].gCSS },				{					url:'global.js', name:i18n[lang].gJS },				{					url:'monobook.css', name:i18n[lang].mCSS },				{					url:'monobook.js', name:i18n[lang].mJS },				{					url:'wikia.css', name:i18n[lang].wCSS },				{					url:'wikia.js', name:i18n[lang].wJS }			]		},		{			title: i18n[lang].wwTitle, pages: [ {					url:'MediaWiki:Chat.css', name:i18n[lang].hCSS },				{					url:'MediaWiki:Chat.js', name:i18n[lang].hJS },				{					url:'MediaWiki:Common.css', name:i18n[lang].cCSS },				{					url:'MediaWiki:Common.js', name:i18n[lang].cJS },				{					url:'MediaWiki:Monobook.css', name:i18n[lang].mCSS },				{					url:'MediaWiki:Monobook.js', name:i18n[lang].mJS },				{					url:'MediaWiki:Wikia.css', name:i18n[lang].wCSS },				{					url:'MediaWiki:Wikia.js', name:i18n[lang].wJS }			]		}	];

mw.util.addCSS(		'.WikiaRail .module h2 {' +			'margin-bottom:0;' +		'}' +		'#mwModuleContent {' +			'position: relative;' +		'}' +		'#mwModuleDiv-0 {' +			'float:left;' +		'}' +		'#mwModuleDiv-1 {' +			'float:right;' +		'}' +		'#mwModuleTitle {' +			'font-size: 16px;' +			'white-space: pre-line;' +		'}' +		'#mwModuleText {' +			'display: block;' +			'text-align: left;' +			'font-size: 12px;' +			'font-weight: bold;' +			'margin: 5px 0;' +			'padding: 0 20px;' +		'}'	);

var mwModule = document.createElement('section'); mwModule.setAttribute('class', 'module railModule'); mwModule.setAttribute('id', 'mwModule'); $(mwModule).prependTo('#WikiaRail');

var mwTitle = document.createElement('h2'); mwTitle.textContent = i18n[lang].title; $(mwTitle).appendTo('#mwModule');

var mwModuleContent = document.createElement('div'); mwModuleContent.setAttribute('id', 'mwModuleContent'); $(mwModuleContent).appendTo('#mwModule');

for (var i = 0; i < mwFiles.length; i++) { var mwModuleDiv = document.createElement('div'); var mw_id = 'mwModuleDiv-' + i;		mwModuleDiv.setAttribute('id', mw_id); $(mwModuleDiv).appendTo('#mwModuleContent');

var mwModuleTitle = document.createElement('h3'); mwModuleTitle.setAttribute('id', 'mwModuleTitle'); mwModuleTitle.textContent = mwFiles[i].title; $(mwModuleTitle).appendTo('#' + mw_id);

for (var j = 0; j < mwFiles[i].pages.length; j++) { var address = mwVariables.wgServer + mwVariables.wgArticlePath; var newAddress;

if (i===0) { newAddress = address.replace( "$1", 'Special:MyPage/' + mwFiles[i].pages[j].url); } else if (i==1) { newAddress = address.replace( "$1", mwFiles[i].pages[j].url); }

if (mwVariables.wgServer !== 'http://community.wikia.com') { if (i===0 && j==4 || i===0 && j==5) { newAddress = cc + mwFiles[i].pages[j].url; }			}

var mwModuleText = document.createElement('a'); mwModuleText.setAttribute('id', 'mwModuleText'); mwModuleText.setAttribute('href', newAddress); mwModuleText.textContent = mwFiles[i].pages[j].name; $(mwModuleText).appendTo('#' + mw_id); }	} });