CatNav

CatNav is a tool for performing an advanced category member listing. It is very similar to the "Category Exhibition" wiki feature, however, it allows you to list pages from multiple categories, as well as specifying categories from which you would not like to list pages.
== ==
== ==
When installed, a "CatNav" link will appear in the bottom wiki bar. Clicking it would lead you to Special:CatNav, where the feature is found.
CatNav's main component consists of 2 textareas, each is a whitespace-separated list of category names:
* An "Include" textarea: list here categories from which you'd like to collect pages for the navigation. A page will only be listed if it contains each one of the specified categories. You must specify at least 1 category
* An "Exclude" textarea: if you prefer not to list pages from certain categories, you can list them here. This textarea is optional, and you can leave it blank
When you're done, click the "generate" button. If results are found, they will be listed below CatNav's form, with each page represented by a square thumbnail with a title. If there are too many results, they would be divided into subpages.
In addition, there are some extra options:
* A "favorites" menu above the textareas lets you add frequently-used categories to your favorites. Whenever you enter CatNav in that specific wiki, you favorite categories would be loaded. Left-clicking a category adds it to the Include textarea, and right-clicking it adds it to the Exclude textarea. You can add new favorites and delete items from your favorites.
* Selecting the number of rows each navigation subpage has (the width is determined by your screen size)
* The option to list only mainspace pages, or pages from all namespaces (default is articles)
* Sorting options
== Settings ==
The script always defines a window.CatNav object, with an init method for re-initializing its interface at any given time. You can use it as a function callback, or call CatNav.init at any given moment.
=== Debug mode ===
General console events are logged in a local array. If you're interested in them being displayed in the browser's console, add the following line above the import:
window.CatNav = {debug: true};
=== Events ===
You can use custom DOM events to know whenever something happens in CatNav's page. Each event is meant to be triggered by a specific element (using addEventListener or jQuery's .on(), for example). The available events are the following:
Event 	Target 	When fired
catnavready 	document.body	When CatNav's interface fully loads
catnavgenerated	#catnav 	Whenever CatNav finishes generating content
catnavpageload 	#catnav 	Whenever the user goes to a certain navigation page. If triggered at the same time as catnavgenerated, it will have an additional property of uponGeneration set to true. This can be used if you want catnavpageload to have a different behavior when the script auto-opens the first page after generating content
=== Global favorites ===
You can also set a list of favorite categories through the Community Central, through Special:MyPage/catnav.css. Pressing the "import" button would import all favorite categories associated with the current wiki to the local storage in your device (but for changing the global settings, you'd have to edit the global page).
Note that if you already have favorite categories in a given wiki and then press the "import" button, it would not delete favorite categories that do not appear in your global settings for the given wiki, but will just add categories that weren't favorite beforehand.
The syntax is the following:
== Notes ==
* You can declare the same wiki twice, but it's advisable to save all the categories for each wiki together, for an easier category managing.
* Make sure not to list categories without declaring their associated wikis first.
* Make sure that the declared wiki's subdomain is valid. Invalid URL characters will result in an error, but merely invalid wiki subdomains may silently get through.
* Comments can be written by starting the line with any character other than "@" or "#", but please only use spaces as comment line starters, to reserve other characters for possible future updates. Using other characters for comments could create an unexpected behavior in the future.
In case the wiki on which you store your favorite categories imports/exports (more info on the global favorites section) is not the Community Central, you can define that in the following manner:
window.CatNav = window.CatNav || {};
window.CatNav.storage = [wikiUrl, scriptPath];
* wikiUrl is the full wiki URL (e.g. "https://community.fandom.com")
* scriptPath is the URL path to scripts on that wiki (empty string in the case of Fandom). You can check it with wgScriptPath
Note that CatNav's functionality relies on Fandom's API, so it will currently not work with non-Fandom wikis (e.g. Wikimedia wikis, such as Wikipedia and Commons).
== Credits and special thanks ==
*Chiến Thần Vương - suggested adding sorting options and favorite categories, as well as submitting a few small script tweaks
*Dai ca superman - for sending multiple crucial bug reports
*RianL110 - for sending bug reports
*Aspallar - notifying and providing an API syntax fix for the when UCP is implemented
*CrescentHusky12 - sending bug report related to non-alphabetic sorting methods
*Magiczocker - implementing i18n & major cleanup
== Changelog ==
Date 	Description
March 17, 2015 	Prototype release in the Club Penguin Wiki.
September 9, 2015 	Script improvements and official release in the Dev wiki.
September 3, 2016 	Adding favorite categories and sorting options. Also, now adding empty lines no longer returns an error. Minor changes in the interface and some other code tweaks.
September 18, 2016	Providing global favorites importing to the current wiki in the current device. Some small CSS changes.
October 7, 2016 	Added sorting by popularity (uses standard Category Exhibition order, due to limitations of the current popular pages API available in Fandom and MediaWiki) and the ability to get the exported syntax for your current wiki. Added monobook selectors and added support for wikis with a different "Special:" prefix.
October 8, 2016 	syntax fixes, fixing sorting issues with sorting by popularity, and extra updates for the export interface.
October 10, 2016 	Providing global CatNav object. Making script path wiki-specific.
October 15, 2016 	Solving issue with global imports.
October 28, 2016 	Adding sorting by article comments.
November 19, 2016 	Adding results counter and the catnavpageload event.
November 19, 2016 	Giving a contrast to the results counter, and adding the catnavready and catnavgenerated events.
May 26, 2017 	Fixed crash that occurs if any of the pages in the currently-viewed CatNav page contains commas in its title.
April 1, 2018 	Fixed contrast of results counter.
June 9, 2020 	Fixed script compatibility for non-English wikis after an update in their URL path syntax across Fandom.
June 22, 2020 	Fixed text contrast issues for wikis with a non-hexadecimal page background value.
June 23, 2020 	Adapting the API requests to the MediaWiki version of the Unified Community Platform.
October 31, 2020 	Updating lines that relied on UFC-deprecated wg parameters.
June 26, 2021 	Adding FandomDesktop compatibility (special thanks to Original Authority), as well as making it compatible with non-FandomDesktop Gamepedia wikis. Making the script compatible with UCP wikis that have numerous language versions. Removing sorting options that relied on the now-defunct article comment and category exhibition features. Adding title filtering options. Most console logs/errors will now only be visible on debug mode. Some UI and other small, miscellaneous changes.
July 1, 2021 	Fixing bug related to updating the browser's tab title.
August 2, 2021 	Fixing issue with large results when selecting non-alphabetic sorting modes (special thanks to CrescentHusky12).
August 14, 2022 	Implementing i18n and major cleanup (special thanks to Magiczocker)
August 20, 2022 	Updating variables, fixing minor issues with the number of results
September 26, 2022	Fixing issue with large requests sorted by non-alphabetical order, small i18n change