User:Soulkeeper/statementSort.js

From Wikidata
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*
 * An updated and exhaustive version of this script can be found at [[MediaWiki:Gadget-statementSort.js]] 
 * CC BY-SA 3.0
*/

function sortMyStatements(so) {
	var ii, $sk = $('.wikibase-listview').filter(':first');
	if ($sk.length > 0) {
		$sk.css({'display':'none'});
		for (ii=0; ii<so[1].length; ii++) {
			$sk.children('#P'+so[1][ii]).appendTo($sk).addClass('sstobtm');
		}
		for (ii=so[0].length-1; ii>-1; ii--) {
			$sk.children('#P'+so[0][ii]).prependTo($sk).addClass('sstotop');
		}
		$sk.css({'display':'block'});
	}
	return;
}
function defaultOrderOfStatements() {
	// Move statements to top
	var toTop = [
		// Classification properties
		31, // instance of
		279, // subclass of
		1813, // short name
		289, // ship class 
		361, // part of
		360, // is a list of
		366, // main use of the subject
		// Terms/Biology
		225, // taxon name
		105, // taxon rank
		171, // parent taxon
		273, // domain
		75, // kingdom
		76, // phylum
		77, // class
		70, // order
		71, // family
		74, // genus
		89, // species
		405, // taxon author
		574, // date of scientific description
		183, // endemic to
		181, // range map
		// Geography - bottom-up
		30, // continent 
		17, // country 
		132, // type of administrative unit
		131, // is in the administrative unit 
		1001, // applies to jurisdiction 	
		442, // China administrative division code
		706, // located on terrain feature
		206, // located on body of water
		281, // postal code
		969, // located at street address
		// Geography - lateral
		37, // official language 
		47, // shares border with
		242, // locator map image
		1621, // detail map
		625, // coordinate location
		421, // time zone
		41, // flag image 
		163, // flag description 
		158, // seal image 
		418, // seal description 
		94, // coat of arms image 
		237, // coat of arms description 
		154, // logo image
		1451, // motto text
		1546, // motto description		
		// Geography - top-down
		36, // capital
		150, // contains administrative division
		// Navigation - lateral
		18, // image		
		155, // preceded by
		156, // succeeded by
		1365, // replaces
		1366, // replaced by
		460, // said to be the same as
		461, // opposite of
		301, // category's main topic
		910, // topic's main category
		1464, // category for Births here
		1465, // category for Deaths here
		1792, // category of associated people
		373, // Commons category
		935, // Commons gallery
		1151, // topic's main Wikimedia portal
		1204, // Wikimedia portal's main topic
		1424, // topic's main template
		1423, // template's main topic
		2354, // has list 
    
		// structure
		274, // chemical formula
		117, // chemical structure
		556, // crystal system
		589, // point group
		690, // space group
		233, // SMILES
		234, // InChI
		267, // ATC code
		728, // GHS hazard statement
		// general
		940, // GHS precautionary statements
		993, // NFPA Health
		994, // NFPA Fire
		995, // NFPA Reactivity
		877, // NFPA Other
		874, // UN class
		876, // UN packaging group
	 
		// Terms/Generic - bottom-up
		127, // owned by
		749, // parent company
		137, // operator	
		138, // named after
		790, // approved by 
		61, // discoverer/inventor
		176, // manufacturer
		1716, // brand
		// Terms/Generic - top-down
		527, // has part
		// Terms/Person
		1477, // birth name
		735, // given name
		734, // surname
		21, // sex
		91, // sexual orientation
		172, // ethnic group
		101, // field of work
		106, // occupation
		410, // military rank
		413, // position played on team
		793, // significant event
		428, // botanist author abbreviation
		835, // author citation (zoology)
		27, // country of citizenship
		103, // native language
		1412, // languages spoken or published
		569, // date of birth
		19, // place of birth
		513, // birth name
		570, // date of death
		20, // place of death
		1196, // manner of death
		509, // cause of death
		119, // place of burial
		// Terms/Person - bottom-up
		463, // member of
		108, // employer
		39, // office held
		102, // member of political party
		54, // member of sports team
		53, // noble family
		166, // awards
		69, // alma mater
		512, // academic degree
		22, // father
		25, // mother
		43, // stepfather
		44, // stepmother
		45, // grandparent
		// Terms/Person - lateral
		7, // brother
		9, // sister
		26, // spouse
		451, // coinhabitant
		// Terms/Person - top-down
		40, // child

		// Organization
		112, // founder
		169, // chief executive officer
		488, // chairperson 
		159, // headquarters location
		452, // industry
		571, // foundation
		576, // dissolution
		126, // maintained by
		355, // subsidiary
		121, // item operated	
		580, // start date
		582, // end date
		729, // service entry
		730, // service retirement

		// Works/Generic
		1476, // title of a work
		144, // based on
		136, // genre
		179, // series
		364, // original language
		371, // presenter
		407, // language
		449, // original network
		495, // country of origin
		750, // distributor
		825, // dedicated to
		577, // publication (date)
		// Works/Art&Architecture
		170, // creator
		64, // architect
		466, // occupant
		88, // commissioner
		149, // architectural style
		180, // depicts
		186, // material used
		189, // discovery place
		195, // collection
		276, // moveable object location
		// Works/Literature
		50, // author
		655, // translator
		98, // editor
		110, // illustrator
		123, // publisher
		// Works/Music
		175, // performer/musical artist
		86, // composer
		162, // producer
		264, // record label
		676, // lyrics by
		// Works/Film
		57, // director
		58, // screenwriter
		344, // director of photography
		272, // production company
 		// Event
 		585, // point in time
 		533, // target
 		710, // participant
 		1120, // number of deaths
 		1339, // number of injured
 		1446, // number of missing
 		1590, // number of casualties
 		1840, // investigated by		
		// Website account IDs
		553,  // Generic website account
		2013, // Facebook
		2002, // Twitter
		2003, // Instagram
		2035, // LinkedIn
		2037, // GitHub
		2038, // ResearchGate
		null // dummy without a comma
	];
	// Move statements to bottom
	var toBottom = [
		1687, // Wikidata property	
		// Authority control
		1017, // BAV
		508, // BNCF
		950, // BNE
		268, // BNF
		270, // CALIS
		271, // CiNii 
		227, // GND
		213, // ISNI
		244, // LCCN
		349, // NDL
		691, // NKC
		409, // NLA
		949, // NLI
		1006, // NTA PPN
		1005, // PTBNP
		947, // RSL
		906, // SELIBR
		269, // SUDOC
		245, // ULAN
		214, // VIAF
		231, // CAS registry number
		232, // EINECS number
		235, // InChIKey
		592, // ChEMBL
		662, // PubChem ID (CID) 
		683, // ChEBI ID
		695, // UN number
		700, // Kemler ID
		// External references
		854, // URL
		535, // Find a Grave
		640, // Léonore ID
		1045, // Sycomore ID
		1808, // senat.fr ID
		646, // Freebase
		345, // IMDb identifier
		434, // MusicBrainz artist ID
		1953, // Discogs artist ID
		948, // Wikivoyage banner
		300, // ISO 3166-2
		605, // NUTS code
		297, // ISO 3166-1 alpha-2
		298, // ISO 3166-1 alpha-3
		299, // ISO 3166-1 numeric
		815, // ITIS TSN
		846, // Global Biodiversity Information Facility ID
		685, // NCBI Taxonomy ID
		830, // Encyclopedia of Life ID
		1895, // Fauna Europaea ID
		null // dummy without a comma
	];
	// Clean up dummies
	if (toTop[toTop.length] === null) { toTop.pop(); }
	if (toBottom[toBottom.length] === null) { toBottom.pop(); }
	// Return arrays
	return [ toTop, toBottom ];
}
$(document).ready(function() {
	$('head').append('<style>.wikibase-listview .sstotop{border:1px solid limegreen;}.wikibase-listview .sstobtm{border:1px solid grey;}.wikibase-listview .rankpreferred{background-color:#dfe;}.wikibase-listview .rankdeprecated{background-color:#f5f1f1;}</style>');
	sortMyStatements(defaultOrderOfStatements());
});