User:Dantman/Tricks

=Article= =CSS= These apply to pages such as:
 * MediaWiki:Common.css
 * MediaWiki:Monobook.css
 * Special:Mypage/Monobook.css (assuming you use the default 'monobook' theme).

Include other CSS files
This one is quite a simple thing to do. But it's overlooked by people. If you want another CSS file included into the current one then just use: @import "/index.php?title=PAGENAME&action=raw&ctype=text/css"; or @import "/index.php?title=PAGENAME&action=raw&ctype=text/css&templates=expand"; Where PAGENAME is the name of the page you want to include. Note that this will include a page from the local wikia you are on. If you want to include from another wikia place http:// and it's domain before the /index.php. See for information on the second one.

This is very handy when you are doing a project which spans multiple Wikia such as the Wikia Anime Project or you just want to include your own user .css to work across multiple wikia (though do note that there will be a global system in the future.)

Note that some browsers don't like it when you have a @import inside of another @import. So if you're doing this on an actual project then it's good to use this method and the one at at the same time to support more browsers.

=JS= These apply to pages such as:
 * MediaWiki:Common.js
 * MediaWiki:Monobook.js
 * Special:Mypage/Monobook.js (assuming you use the default 'monobook' theme).

Include other JS files
I didn't exactly come up with this one but I didn't know about this before other people showed me it. So to stop anyone else from beating themselves up for not knowing how this works here's how to include another JS page. document.write(' '); or document.write(' '); Where PAGENAME is the name of the page you want to include. Note that this will include a page from the local wikia you are on. If you want to include from another wikia place http:// and it's domain before the /index.php. See for information on the second one.

Include other CSS files using JS
This one is more of a modification on the one before. Some browsers don't like it when you have a @import inside of another @import so it's also good to use JS to include the CSS at the same time. document.write('/*<![CDATA[*/@import "' 		+ '/index.php?title=PAGENAME' 		+ '&action=raw&ctype=text/css";/*]]>*/ '); or document.write('/*<![CDATA[*/@import "' 		+ '/index.php?title=PAGENAME' 		+ '&action=raw&ctype=text/css&templates=expand";/*]]>*/ '); Where PAGENAME is the name of the page you want to include. Note that this will include a page from the local wikia you are on. If you want to include from another wikia place http:// and it's domain before the /index.php. See for information on the second one.

Namespace and Group information
Sometimes it's handy to know what namespaces and groups are on a Wikia. Unfortunately there is no built in system which lists these. So in these cases it's good to have an admin build a Namespaces.js and Groups.js file so that you can use this information inside of other scripts. Note that these files are in a format which is good for using a for loop to create switch statements which match that of those on Special:Prefixindex and Special:Listusers.

Information on how to generate the arrays and code examples can be found at Anime:MediaWiki:Namespaces.js and Anime:MediaWiki:Groups.js. (Hopefully this trend will catch on and you'll have these on most wikia you come by.)

Searchswitch
The searchswitch is a special addition to the Search portlet. When used it adds a extra box above the search box in the sidebar. This box modifies the search box to whatever you pick. There's still the normal Search listed there. But there are a number of other options to:
 * Article: This works a little like a creationbox. You can type in an article name and then hit view to go to that page, or you can hit edit to go strait to the editpage for that article. (The code for this was borrowed from User:Splarka/tricks)
 * Editcount: Plain and simply this is like going to Special:Editcount just enter a username in the box and hit go, you'll then be sent to the editcount for the person.
 * Prefixindex: This works just like Special:Prefixindex. The nice thing about it is you can use the dropdown box to select a namespace such as the main namespace and then hitting submit gives you a list of all the articles in that namespace.
 * Listusers: Listusers works just like going to Special:Listusers. You can just submit for a list of all users (A new feature is also in place so that now only active users are listed there.) You can enter in a username to get information on a user such as what status tags such as Jonin they may have. Or you can use the dropdown box to find a list of all the Jonin(sysop), Kage(bureaucrat), or Tokubetsu Jonin(rollback) there are on the wiki.
 * Contribs: Simply enter a username here and you will be sent to the contribs page of a user. Works similar to Editcount.

Please note that to use these features you must be on a Wikia which is using the trick at. Though if you are not, you can optionally create those two pages at Special:Mypage/namespaces.js and Special:Mypage/groups.js and use overrideNamespaces and overrideGroups to direct the system to use your personal files instead of using the default ones for the trick.

If you are already using the trick then you can simply include this system by using the code: includeJS( 'MediaWiki:Searchswitch.js', 'en.anime' ); includeCSS( 'MediaWiki:Searchswitch.css', 'en.anime' ); or you could replace the includeCSS in your JS file with this inside of your CSS page (or you can use both): @import "http://en.anime.wikia.com/index.php?title=MediaWiki:Searchswitch.css&action=raw&ctype=text/css"; Though do note that if you are on a wikia which styles the sidebar you'll half to apply the same style to #p-switch.

Borrow things from the Wikia Anime Project
I experiment with new things to make it easier to use a Wiki on the Wikia Anime Project. It's actually possible to include these things when you travel outside of the project using a little code in your own CSS and JS.

Note: There are 2 important things which including things from the WAP does. Firstly it includes the functions used at so after you include code from the project, any other code you include from other places will be able to use the includeJS and includeCSS functions. Another system that is included is the so if you are not on a project which uses the  trick you must either have the project admins create this page or you could create those two pages at Special:Mypage/namespaces.js and Special:Mypage/groups.js and then uncomment the 2 lines which override the location and change MYUSERNAME to whatever your username actually is. If you're wondering what cancelAnime is. It's a variable that tells the WAP's javascript and such to not include other files and systems which are specially made for things such as styling things in the WAP. This also stops the global Anime:MediaWiki:Anime-Monobook-Accesstips.js from being included to.

Inside of your monobook.js: //Stuff to include WAP Stuff into here.// var cancelAnime = true; //var overrideNamespaces = 'User:MYUSERNAME/namespaces.js'; //var overrideGroups = 'User:MYUSERNAME/groups.js'; document.write(' '); Inside of your monobook.css: @import "http://en.anime.wikia.com/index.php?title=MediaWiki:Searchswitch.css&action=raw&ctype=text/css";

For an example of this in use you can see my User:Dantman/monobook.js and User:Dantman/monobook.css.

=CSS or JS=

Include other CSS and JS files by function
This is quite simply an addition to and  this is basically code which takes those methods and changes them into simple to use functions. function includeJS( page, onWikia, expand ) { document.write(' '); } function includeCSS( page, onWikia, expand ) { document.write('/*<![CDATA[*/@import "'			+ ( onWikia ? 'http://'+onWikia+'.wikia.com' :  )			+ '/index.php?title=' + page			+ '&action=raw&ctype=text/css'+( expand == false ?  : '&templates=expand' )			+ '";/*]]>*/ '); } If you include this into the MediaWiki:Common.js file on a wikia then you can easily include other things elsewhere.

If you want to include MediaWiki:Example.css in a local wiki you would use: includeCSS( 'MediaWiki:Example.css' ); To include MediaWiki:Example.js which we could say is only on central then you'd use: includeJS( 'MediaWiki:Example.js', 'www' );

See for information on the expand parameter, by default these functions expand the templates, but you can set the 3rd parameter to false to stop this from happening (use null on the 2nd parameter if you're doing this for a local wiki).

Reduce your includes while splitting the code
At times when you're on a project you may notice that you're accumulating a lot of .js or .css inside of your project and it can become hard to organize. It is possible to use the tricks I've shown to split all that stuff up into other files and just include them into the main stuff. But then that means the reader's browsers need to load more files. But there is one way to split up all your .css and/or .js into different article pages and yet still make the browser load only a few pages. We can do this using MediaWiki's template system. Though this technique actually only reduces the number of files you half to include with the above techniques, it doesn't replace them. In fact this technique doesn't work without including a file using the above methods first. This technique also only works locally. You can't include files from other wikia using this tecnique. Though you can use this to make it so that you only need to include one file from a remote wikia.

It's a simple case of splitting up what you have at say MediaWiki:Common.css into other files such as MediaWiki:Forum.css and MediaWiki:Misc.css.

Then back at your MediaWiki:Common.css instead of using the techniques I listed above you use the old template tricks of and. For a good organized formatting you could use: /* MediaWiki:Forum.css */

/* MediaWiki:Misc.css */

But here's the big question now. Since when we include another CSS we use the &action=raw parameter which stops wikitext from doing anything. The trick applies in using &templates=expand with that. When you do that you still get a code output, but at the same time templates are expanded with their code so suddenly a number of .css files can be combined into one. This is already shown in the above examples. Just use the second example which has &templates=expand already inside of it. Or you can use the .js functions which by default tell the system to expand the templates.

For an example of this system see Anime:MediaWiki:Anime-Common.css which is included by all the Wikia in the Wikia Anime Project. You can see Anime:MediaWiki:Common.css, Anime:MediaWiki:Common.js, and Anime:MediaWiki:Anime-Common.js to understand how the files are included.