Wikia

Wikia Developers Wiki

SkinSwitchButton

Talk30
660pages on
this wiki
SkinSwitchButton
Skinswitch
TypeJavaScript
DescriptionScript for changing skins with one-click
ScopePersonal
Site-Wide (See below)
Author(s)UltimateSupreme
Updated14:26, October 6, 2013 (UTC)
Code/code.js
SkinsMonobook
Oasis
LanguagesCustomisable

SkinSwitchButton is script for changing skins with one-click.

Appearance

  • For Monobook (and for Pseudo-Vector), the button will show in the editing toolbar on the top,
  • for Oasis, the button will show in the toolbar below.

How to use

In order to use this, put it in your w:Special:MyPage/global.js or your local js on a specific wiki. A helpful guide can be found here. Follow the following instructions:

Installation

Add this JavaScript on your wiki:

Global
w:Special:Mypage/global.js
Personal
Special:Mypage/common.js
importScriptPage('SkinSwitchButton/code.js', 'dev');
importArticles — Best Practices for installing JavaScript on Wikia
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner.

If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow
One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Custom Wording

The ability to choose the wording of the Monobook text can be adjusted like this:

window.monoBookText = "Switch to Monobook";
importScriptPage('SkinSwitchButton/code.js', 'dev');

For the oasis one, you can change it like this:

window.oasisText = "Wikia skin's layout";
importScriptPage('SkinSwitchButton/code.js', 'dev');

For the mobile one, you can change it like this:

window.mobileText = "Mobile's view";
importScriptPage('SkinSwitchButton/code.js', 'dev');

Or you can change them all at a time, like this:

window.monoBookText = "Switch to Monobook";
window.oasisText = "Wikia skin's layout";
window.mobileText = "Mobile's view";
importScriptPage('SkinSwitchButton/code.js', 'dev');

Using Site-Wide

This script can't be used in Wikia skin site-wide. But since most people use this to switch from monobook to Oasis, incase you want to install it site-wide, you can install the script only for monobook skin by:

  • Import the code in Monobook.js
  • If you prefer keeping all code in Common.js, use a conditional check for skin and then import the script.

Around Wikia's network

Random Wiki