User:Nux/yourGadgetName.js
Appearance
< User:Nux
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:Nux/yourGadgetName. This user script seems to have an accompanying .css page at User:Nux/yourGadgetName.css. |
// <nowiki>
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/**
* Wikiploy gadget example.
*
* History and docs:
* https://github.com/Eccenux/wikiploy-rollout-example
*
* Deployed using: [[Wikipedia:Wikiploy]]
*/
class MyGadget {
constructor() {
this.options = {
createTool: true,
};
}
/** Initialize things when DOM is ready. */
init() {
// Example link in the tools sidebar
if (this.options.createTool) {
var portletId = mw.config.get('skin') === 'timeless' ? 'p-pagemisc' : 'p-tb';
var linkLabel = '🧩 My gadget dialog';
var itemId = 'some-unique-gadget-tool';
var item = mw.util.addPortletLink(portletId, '#', linkLabel, itemId);
$(item).on('click', (evt) => {
evt.preventDefault();
this.openDialog();
});
}
}
/** Open some dialog. */
openDialog() {
// Open a dialog window here
alert("We are open for community!");
}
}
module.exports = { MyGadget };
},{}],2:[function(require,module,exports){
var { MyGadget } = require("./MyGadget");
// instance
var gadget = new MyGadget();
// hook when object is ready
mw.hook('userjs.yourGadgetNameExample.loaded').fire(gadget);
$(function(){
// load Mediwiki core dependency
// (in this case util is loaded to be able to use `mw.util.addPortletLink`)
mw.loader.using(["mediawiki.util"]).then( function() {
gadget.init();
// hook when initial elements are ready
mw.hook('userjs.yourGadgetNameExample.ready').fire(gadget);
});
});
},{"./MyGadget":1}]},{},[2]);
// </nowiki>