User:Bility/biographyListasGenerator


 * Code for this script resides at User:Bility/biographyListasGenerator.js

This script populates the listas parameter of with a suggested sort name based on the article's title. The script only executes when editing a mainspace (article) talk page. The scripts adds a button above the edit tool box that attempts to insert the sort name when you click it.

You must be in edit mode on a mainspace talk page and the WikiProject Biography or WPBiography templates must be in the page's wikitext. Additionally, the template must already contain the listas parameter.
 * Requirements

The script goes through a series if instructions to return a sort name:
 * Suggestion rules
 * 1) If no spaces are in the title, nothing is done
 * 2) If the article starts with "List of", whatever comes after "List of" is returned, with the first letter capitalized.
 * 3) * Ex: "List of brown-haired poodle trainers" would become "Brown-haired poodle trainers".
 * 4) Anything in parentheses is removed.
 * 5) * Ex: "Tim Jones (baseball player)" would become "Tim Jones".
 * 6) If a comma exists, only text to the left of the comma is considered.
 * 7) * Ex: "Tim Jones, player of the millenium" would become "Tim Jones".
 * 8) Article names in the form of "[text] of [text]" only consider the "[text]" to the left of the word "of".
 * 9) * Ex: "Tim Jones of Madagascar" would become "Tim Jones".
 * 10) If a Nobiliary particle is detected, it and whatever follows it becomes the last name and whatever precedes it becomes the first name.
 * 11) * Ex: "Tim von Jones" would become "von Jones, Tim".
 * 12) * Current list of particles: de, von, du, del, zu, di, van, na
 * 13) If there is no nobiliary particle, the word following the last space becomes the last name and whatever precedes it becomes the first name.
 * 14) * Ex: "Tim Jones" would become "Jones, Tim" and "Tim Zacharias Jones" would become "Jones, Tim Zacharias".

Installation
To install this script, edit your skin javascript or common.js and add the following code: