[MediaWiki-l] Custom JavaScript

Daniel Friesen daniel at nadir-seen-fire.com
Tue Nov 11 02:37:21 UTC 2014

On 2014-11-10 5:53 PM, John wrote:
> OK, Ive spent the better part of two hours trying to figure out mediawiki
> JavaScript. In the last two hours all I have accomplished is giving myself
> a headache.
> My goal is a basic JavaScript tool for moving pages. On a private wiki I
> run it is often needed to archive material that is no longer needed, We
> dont like to delete because often this material is still useful. Instead we
> move it to a custom namespace.
> What I am trying to do in JavaScript and failing spectacularly at is a tool
> that will take Title, and move it to Archive:Title without a redirect with
> a single click.
> Yes I know it sounds simple but Im having a devil of a time figuring out
> how to use the mediawiki js api
> Any help would be welcome

Here's a few hints of what you'll need.

Get an APi instance with:
  var api = new mw.Api();

Get an edit token with:

Move a page with:
      from: ...,
      to: ...,
      reason: "...",
      noredirect: true,
      token: edittoken

Note that api methods are async and return a jQuery "promise".

~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://danielfriesen.name/]

More information about the MediaWiki-l mailing list