MediaWiki:Gadgetprototype.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at MediaWiki:Gadgetprototype. |
/**
* This is a introductory comment.
* What will the following code do,
* where will it work (Commons only?),
* what do you have to know about?
* No worries:
* ResourceLoader will minify the code and remove these comments.
*
* @rev 1 (2012-01-10)
* @author YourName, 2012
* @author AnotherAuthor, 2013
*/
// List the global variables for jsHint-Validation. Please make sure that it passes http://jshint.com/
// Scheme: globalVariable:allowOverwriting[, globalVariable:allowOverwriting][, globalVariable:allowOverwriting]
/*global jQuery:false, mediaWiki:false*/
// Set jsHint-options. You should not set forin or undef to false if your script does not validate.
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, curly:true, browser:true*/
( function ( $, mw ) {
"use strict";
var variable1, literalObject1, moreVariables;
literalObject1 = {
/**
* Some short description of this function.
*
* @example
* literalObject1.fn1Name( params );
*
* @param param1 {Type} What is param1.
* @param param2 {string} Linktext, optional.
* @context {literalObject1}
* @return {Array} jQuery Array-Object containing a link to the top of the page.
*/
fn1Name: function( param1, param2 ) {
// do some stuff
return( $('<a>', { href: '#', text: (param2 || "Go to top.") }) );
},
fn2Name: function( params ) {
// do some stuff
},
aString: "Hello Word!",
anObject: {
objectProperty: "This is a string in an object in an object.",
objectProperty2: 2
}
};
// Expose globally
mw.libs.literalObject1 = literalObject1;
// Fire off the rest as soon as the dom is ready
$( /* pointer to a function - Note: Do not refer to "this" inside the function the pointer points to. */ );
}( jQuery, mediaWiki ));