-
Notifications
You must be signed in to change notification settings - Fork 6
/
iNat_Ungrafted_taxa.html
193 lines (177 loc) · 7.35 KB
/
iNat_Ungrafted_taxa.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="iNaturalist API Ungrafted Taxa" />
<title>iNaturalist API Ungrafted Taxa</title>
</head>
<body>
<script src="https://www.tablefilter.com/tablefilter/tablefilter.js"></script>
<script>
const RANK_LEVELS = {
root: 100,
kingdom: 70,
subkingdom: 67,
phylum: 60,
subphylum: 57,
superclass: 53,
class: 50,
subclass: 47,
infraclass: 45,
subterclass: 44,
superorder: 43,
order: 40,
suborder: 37,
infraorder: 35,
parvorder: 34.5,
zoosection: 34,
zoosubsection: 33.5,
superfamily: 33,
epifamily: 32,
family: 30,
subfamily: 27,
supertribe: 26,
tribe: 25,
subtribe: 24,
genus: 20,
genushybrid: 20,
subgenus: 15,
section: 13,
subsection: 12,
complex: 11,
species: 10,
hybrid: 10,
subspecies: 5,
variety: 5,
form: 5,
infrahybrid: 5
};
var tfConfig = {
base_path: 'https://www.tablefilter.com/tablefilter/',
alternate_rows: true, // highlight alternate rows
rows_counter: {
text: 'Taxa: '
},
btn_reset: true, // clear button
no_results_message: true,
col_widths: ['310px', '130px', '90px', '70px', '80px', '70px', '380px', '70px', '120px', '90px'],
// columns data types
col_types: [
'string',
'string',
'number',
'number',
'boolean',
'number',
'none',
'none',
'none',
'none'
],
col_1: 'checklist',
col_4: 'select',
col_6: 'none',
col_7: 'none',
col_8: 'none',
col_9: 'none',
auto_filter: true,
// We use a custom comparer for the "Rank" column.
filter_options_sorter: {
col: [1],
comparer: [
function(a, b) {
return (RANK_LEVELS[b] - RANK_LEVELS[a]);
}
]
},
sticky_headers: true,
extensions: [{ name: 'sort', sort_col_at_start: [2, true] }]
};
function furl(url,txt=url) { return '<a href="'+url+'">'+txt+'</a>'; };
function faddelem(etype,eparent,eclass=null,eid=null,ehtml=null) {
var eobj = document.createElement(etype);
if (eclass!==null) { eobj.classList = eclass };
if (eid!==null) { eobj.id = eid };
if (ehtml!==null) { eobj.innerHTML = ehtml };
eparent.appendChild(eobj);
return eobj;
};
function fgather(url,perpage=500,results=[],sofar=0,page=1) {
fetch(url+'&page='+page+'&per_page='+perpage)
.then((response) => {
if (!response.ok) { throw new Error(response.status+' ('+response.statusText+') returned from '+response.url); };
return response.json();
})
.then((data) => {
var newResults = results.concat(data.results);
if (sofar + perpage > data.total_results) {
var table = fresults(newResults);
var tf = new TableFilter(table, tfConfig);
tf.init();
} else {
return fgather(url,perpage,newResults,sofar+perpage,page+1);
};
})
.catch((err) => {
console.error(err.message);
faddelem('p',document.body,null,null,'There was a problem retrieving data. Error '+err.message+'.')
});
}
function fresults(results) {
var table = faddelem('table',document.body,null,'main');
var thead = faddelem('thead',table);
var hrow = faddelem('tr',thead);
faddelem('th',hrow,null,null,'Taxon');
faddelem('th',hrow,null,null,'Rank');
faddelem('th',hrow,null,null,'ID');
faddelem('th',hrow,null,null,'# Obs');
faddelem('th',hrow,null,null,'Extinct?');
faddelem('th',hrow,null,null,'Open Flags');
faddelem('th',hrow,null,null,'Search');
faddelem('th',hrow,null,null,'Edit Taxon');
faddelem('th',hrow,null,null,'New Taxon Change');
faddelem('th',hrow,null,null,'Check IDs');
var tbody = faddelem('tbody',table);
for (var i=0; i<results.length; i++) {
var brow = faddelem('tr',tbody);
faddelem('td',brow,null,null,furl('https://www.inaturalist.org/taxa/'+results[i].id,results[i].name));
faddelem('td',brow,null,null,results[i].rank);
faddelem('td',brow,null,null,results[i].id);
faddelem('td',brow,null,null,furl('https://www.inaturalist.org/observations?verifiable=any&taxon_id='+results[i].id,results[i].observations_count));
faddelem('td',brow,null,null,results[i].extinct);
faddelem('td',brow,null,null,furl('https://www.inaturalist.org/taxa/'+results[i].id+'/flags', results[i].flag_counts.unresolved));
faddelem('td',brow,null,null,
furl('https://www.google.com/search?q='+results[i].name, 'Google')
+' | '+furl('https://scholar.google.com/scholar?q='+results[i].name, 'Scholar')
+' | '+furl('https://www.inaturalist.org/search?q='+results[i].name, 'iNat')
+' | '+furl('https://www.inaturalist.org/taxa/search?is_active=any&q='+results[i].name, 'old iNat')
+' | '+furl('https://eol.org/search?utf8=%E2%9C%93&q='+results[i].name, 'EOL')
+' | '+furl('https://www.catalogueoflife.org/annual-checklist/2012/search/all/key/'+results[i].name, 'COL')
+' | '+furl('http://powo.science.kew.org/?q='+results[i].name, 'POWO')
);
faddelem('td',brow,null,null,furl('https://www.inaturalist.org/taxa/'+results[i].id+'/edit', 'Edit'));
faddelem('td',brow,null,null,furl('https://www.inaturalist.org/taxon_changes/new?input_taxon_ids%5B%5D='+results[i].id+'&type=TaxonSwap','Add Change'));
faddelem('td',brow,null,null,furl('https://www.inaturalist.org/identifications?current=any&taxon_id='+results[i].id, 'Check'));
};
return table
};
var apiurl = 'https://api.inaturalist.org/v1/taxa?is_active=true&id_above=0&parent_id=0&rank=phylum,subphylum,superclass,class,subclass,infraclass,subterclass,superorder,order,suborder,infraorder,parvorder,zoosection,zoosubsection,superfamily,epifamily,family,subfamily,supertribe,tribe,subtribe,genus,genushybrid,subgenus,section,subsection,complex,species,hybrid,subspecies,variety,form,infrahybrid';
faddelem('h1',document.body,null,null,'iNaturalist Ungrafted Taxa');
faddelem('h3',document.body,null,null,'Note: this page does NOT take query parameters in the URL.');
faddelem('h2',document.body,null,null, 'External taxonomic authorities and taxon curators can be found ' + furl('https://www.inaturalist.org/pages/curator+guide#authorities', 'here')+'.');
faddelem('h2',document.body,null,null, 'Other taxonomic resources -- NOT iNat authorities: ' + ' ' +
furl('https://www.gbif.org/', 'GBIF')
+', ' + furl('https://www.itis.gov/', 'ITIS')
+', ' + furl('https://www.iucnredlist.org/', 'IUCN')
+', ' + furl('https://species.wikimedia.org/wiki/Main_Page', 'Wikispecies')
+', ' + furl('https://www.ala.org.au/', 'Atlas of Living Australia')
+', ' + furl('https://www.calacademy.org/scientists/projects/eschmeyers-catalog-of-fishes', 'Catalog of Fishes')
+', ' + furl('https://forum.inaturalist.org/t/taxonomic-resources-for-insects-wiki/11584', 'List of insect resources'));
faddelem('h2',document.body,null,null, furl('https://www.inaturalist.org/taxa/new', 'Add new taxon'));
faddelem('h2',document.body,null,null, furl('https://www.inaturalist.org/taxon_changes/new', 'Add new taxon change'));
faddelem('h2',document.body,null,null, furl('https://www.inaturalist.org/taxa/curation', 'Official taxon curation page'));
faddelem('h3',document.body,null,null, 'Click column headers to sort.');
fgather(apiurl)
</script>
</body>
</html>