User:FreightXPress/wikibaseStatementSort.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
function wikibase_statement_prepend_by_property_list(property_array,class_name){
	var property_string =property_array.join(',#P');
	property_string = '#P' + property_string;
	$('.wikibase-statementgrouplistview > .wikibase-listview').prepend($(property_string).addClass(class_name));
}
/**** properties in statements grouped by datatype, 
 * order of datatypes as in Special:ListDatatypes
 * datatype-string: don't mention all of them here, will be at bottom automatically, most of the items are external identifiers
 * mention those that are not identifiers
****/
var datatype_property = {
	"commonsmedia":[10,14,15,18,41,51,94,109,117,154,158,181,207,242,367,368,443,491,692,948,989,990,996,1442,1543,1621,1766,1801,1846],
	"globe-coordinate":[625,626,1259,1332,1333,1334,1335],
	"quantity":[1081,1082,1083,1086,1087,1088,1090,1092,1093,1096,1097,1098,1099,1100,1101,1102,1103,1104,1106,1107,1108,1109,1110,1111,1112,1113,1114,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1139,1141,1148,1164,1174,1181,1193,1198,1215,1247,1279,1295,1301,1314,1339,1342,1345,1350,1351,1352,1355,1356,1357,1358,1359,1373,1390,1410,1418,1436,1446,1457,1458,1470,1538,1539,1540,1548,1561,1569,1570,1590,1603,1641,1658,1661,1674,1675,1676,1689,1697,1725,1752,1831,1833],
	"string":[373,935],
	"time":[569,570,571,574,575,576,577,578,580,582,585,606,619,620,621,622,729,730,746,813,1191,1249,1317,1319,1326,1619,1636,1734],
	"url":[854,855,856,857,953,963,968,973,1019,1065,1244,1324,1325,1348,1401,1421,1482,1581,1613,1628,1709,1713],
	"wikibase-item":[6,7,9,16,17,19,20,21,22,25,26,27,30,31,35,36,37,38,39,40,43,44,47,50,53,54,57,58,59,61,65,66,69,78,81,84,85,86,87,88,91,92,97,98,101,102,103,105,106,108,110,111,112,113,114,115,118,119,121,122,123,126,127,128,129,131,134,135,136,137,138,140,141,143,144,149,150,155,156,157,159,161,162,163,166,167,169,170,171,172,175,176,177,178,179,180,183,184,185,186,189,190,193,194,195,196,197,199,200,201,205,206,208,209,210,237,241,248,263,264,272,275,276,277,279,282,286,287,289,291,301,306,344,355,358,360,361,364,366,369,371,375,376,397,398,399,400,403,404,405,406,407,408,410,411,412,413,414,415,417,418,421,423,425,427,437,447,448,449,450,451,452,453,457,459,460,461,462,463,466,467,468,469,470,479,483,485,488,489,495,500,501,504,505,509,511,512,514,515,516,517,518,520,521,522,523,524,527,530,531,532,533,534,537,538,541,542,543,545,546,547,548,550,551,552,553,556,559,560,562,565,566,567,568,579,588,589,598,607,608,609,610,611,612,618,624,629,631,634,636,641,642,647,654,655,658,659,660,664,669,674,676,678,680,681,682,684,688,689,690,693,694,697,702,703,706,707,708,710,720,725,726,734,735,736,737,738,739,740,741,744,747,748,749,750,751,756,765,767,768,769,770,780,783,784,785,786,787,788,789,790,793,794,795,796,797,800,802,803,805,807,811,812,814,816,817,822,823,825,826,828,831,832,833,834,837,840,841,852,853,859,868,870,872,873,878,880,881,885,887,908,910,912,913,914,915,916,921,922,923,924,925,926,927,928,929,930,931,937,941,942,943,944,945,967,970,971,972,974,991,1000,1001,1002,1011,1012,1013,1016,1018,1026,1027,1028,1029,1032,1033,1034,1035,1037,1038,1039,1040,1041,1046,1049,1050,1056,1057,1060,1064,1066,1068,1071,1072,1073,1074,1075,1078,1079,1080,1135,1136,1137,1142,1145,1151,1152,1158,1165,1170,1171,1192,1194,1196,1199,1200,1201,1202,1204,1210,1211,1221,1227,1264,1268,1269,1283,1290,1299,1302,1303,1304,1308,1310,1312,1313,1318,1321,1322,1327,1336,1340,1343,1344,1346,1347,1349,1354,1363,1365,1366,1372,1376,1382,1383,1387,1389,1393,1398,1399,1403,1406,1408,1411,1412,1414,1416,1419,1420,1423,1424,1425,1427,1429,1431,1432,1433,1434,1435,1437,1441,1443,1444,1445,1454,1455,1456,1462,1464,1465,1478,1479,1480,1531,1532,1533,1534,1535,1536,1537,1542,1546,1547,1552,1557,1558,1560,1568,1571,1574,1576,1582,1589,1591,1592,1593,1594,1595,1596,1597,1598,1604,1605,1606,1611,1620,1622,1625,1629,1637,1639,1640,1642,1643,1652,1654,1656,1657,1660,1672,1677,1678,1686,1703,1704,1706,1716,1731,1740,1750,1753,1754,1773,1774,1775,1776,1777,1778,1779,1780,1789,1791,1792,1809,1811,1817,1830,1840,1851,1853,1855,1859],
	"wikibase-property":[1646,1647,1659,1687,1696],
	"monolingualtext":[1448,1449,1450,1451,1476,1477,1549,1559,1635,1638,1680,1683,1684,1705,1813,1843]
}

/* desired order of display */
var wikibase_datatype_property_order = ['monolingualtext','globe-coordinate','time','quantity','url','commonsmedia','wikibase-property','wikibase-item','string'];

wikibase_datatype_property_order.reverse();
for (var i in wikibase_datatype_property_order) {
	datatype_name = wikibase_datatype_property_order[i];
	wikibase_statement_prepend_by_property_list(datatype_property[datatype_name],'datatype-'+datatype_name);
}

/**** properties in statements that provide human readable identification of the item ****/
/* instance of, subclass of, part of, has part */ 
var p_top = [31,279,361,527];

wikibase_statement_prepend_by_property_list(p_top,"x_p_top");

$('.wikibase-sitelinkgrouplistview > .wikibase-listview').prepend($("div[data-wb-sitelinks-group='special']"));