FANDOM


This script creates customizable lists based on the RecentChanges API. It can be used for a variety of purposes.

Installation

Add the following to your wiki's Common.js (when used on Project pages) or your /wikia.js (when used on personal pages):


importArticles({
    type: 'script',
    articles: [
        'w:c:dev:MediaWiki/TopEditors/code.js'
    ]
});
importArticles — Best Practices for installing JavaScript on FANDOM
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. One other approach is by using the MediaWiki:ImportJS.
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.

Usage

The basic usage, which will list the top 25 contributors to all namespaces in the last week, looks like this:

<div class="topeditors"></div>

You can put anything inside the div; it will be replaced with the list. Please note that the list can take a while to load, especially for longer periods of time. You can use this multiple times on any page; results are loaded asynchronously.

Options

Various options can be set for the script; they are added to the div code. Here is a skeleton, using the default values (adding these attributes is not necessary to use the defaults):

<div class="topeditors" data-te-namespace="" data-te-type="edit|new" data-te-show="" data-te-user="" data-te-limit="25" data-te-offset="7" data-te-exclude=''>loading...</div>

Option descriptions:

  • namespace determines which namespace(s) are counted. Namespace numbers must be used. A list of built-in namespaces can be found here; you can find the namespace number for any page in its wgNamespaceNumber variable. Specify multiple namespaces like so: "0|6".
  • type determines which types of entry to count: page edits, creation of new pages, and/or log entries. Possible values are edit, new, and log; separate multiple parameters with a pipe (|).
  • show determines other properties for counted edits. Possible values are minor, bot, anon, redirect, and patrolled. Add an exclamation point (!) before a value for its opposite; separate multiple values with pipes (|). For example, to include only non-minor edits by anonymous users, this property should be set to "!minor|anon".
  • user specifies a single user for whom to count entries. Value is the username without User: prefix. The inserted code will not be wrapped in a list.
  • limit is the number of users to show in the list.
  • offset is the number of days (backward from the current time) to search through.
  • exclude is a list of users to exclude from the listing. The syntax must be valid JSON. Use spaces in usernames, not underscores. The value associated with the username does not matter and can be blank. Example: data-te-exclude='{"Aaron":"", "Bob":""}'

More details may be found here.

Comments

As always, I'd love to hear any feedback. I can look into adding support for date increments other than days if people need it. Default appearance customizations are also a possibility. Thanks! Please leave comments on my talk page or this page's talk page.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.