@ca-plant-list/ca-plant-list 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jekyll/assets/css/main.css +5 -0
- package/jekyll/assets/js/name_search.js +7 -3
- package/lib/csv.js +3 -0
- package/lib/externalsites.js +43 -0
- package/lib/pagetaxon.js +18 -2
- package/package.json +1 -1
@@ -50,7 +50,7 @@ class Search {
|
|
50
50
|
|
51
51
|
Search.#debounceTimer = undefined;
|
52
52
|
|
53
|
-
const value = document.getElementById( "name" ).value
|
53
|
+
const value = Search.#normalizeName( document.getElementById( "name" ).value );
|
54
54
|
|
55
55
|
const matches = [];
|
56
56
|
const shouldSearch = ( value.length >= MIN_LEN );
|
@@ -124,14 +124,14 @@ class Search {
|
|
124
124
|
// eslint-disable-next-line no-undef
|
125
125
|
for ( const taxon of NAMES ) {
|
126
126
|
const taxonData = [ taxon ];
|
127
|
-
taxonData.push( taxon[ 0 ]
|
127
|
+
taxonData.push( this.#normalizeName( taxon[ 0 ] ) );
|
128
128
|
if ( taxon[ 1 ] ) {
|
129
129
|
taxonData.push( taxon[ 1 ].toLowerCase() );
|
130
130
|
}
|
131
131
|
if ( taxon[ 2 ] ) {
|
132
132
|
const syns = [];
|
133
133
|
for ( const syn of taxon[ 2 ] ) {
|
134
|
-
syns.push(
|
134
|
+
syns.push( this.#normalizeName( syn ) );
|
135
135
|
}
|
136
136
|
taxonData[ 3 ] = syns;
|
137
137
|
}
|
@@ -156,6 +156,10 @@ class Search {
|
|
156
156
|
document.getElementById( "search_form" ).onsubmit = () => { this.#handleSubmit(); return false; };
|
157
157
|
}
|
158
158
|
|
159
|
+
static #normalizeName( name ) {
|
160
|
+
return name.toLowerCase().replace( / (subsp|var)\./, "" );
|
161
|
+
}
|
162
|
+
|
159
163
|
}
|
160
164
|
|
161
165
|
Search.init();
|
package/lib/csv.js
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
class ExternalSites {
|
2
|
+
|
3
|
+
static getCalscapeLink( taxonName ) {
|
4
|
+
const url = new URL( "https://calscape.org/loc-California/" + taxonName.replace( "subsp.", "ssp." ) + " ()" );
|
5
|
+
return url.toString();
|
6
|
+
}
|
7
|
+
|
8
|
+
static getInatObsLink( options ) {
|
9
|
+
|
10
|
+
const url = new URL( "https://www.inaturalist.org/observations?subview=map" );
|
11
|
+
|
12
|
+
for ( const [ k, v ] of Object.entries( options ) ) {
|
13
|
+
switch ( k ) {
|
14
|
+
case "coords": {
|
15
|
+
const delta = .1;
|
16
|
+
const params = url.searchParams;
|
17
|
+
params.set( "nelat", v[ 1 ] + delta );
|
18
|
+
params.set( "swlat", v[ 1 ] - delta );
|
19
|
+
params.set( "nelng", v[ 0 ] + delta );
|
20
|
+
params.set( "swlng", v[ 0 ] - delta );
|
21
|
+
break;
|
22
|
+
}
|
23
|
+
case "created_d1":
|
24
|
+
case "list_id":
|
25
|
+
case "place_id":
|
26
|
+
case "project_id":
|
27
|
+
case "subview":
|
28
|
+
case "taxon_id":
|
29
|
+
case "taxon_name":
|
30
|
+
if ( v ) {
|
31
|
+
url.searchParams.set( k, v );
|
32
|
+
}
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
return url.toString();
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
export { ExternalSites };
|
package/lib/pagetaxon.js
CHANGED
@@ -3,6 +3,7 @@ import { Jepson } from "./jepson.js";
|
|
3
3
|
import { Config } from "./config.js";
|
4
4
|
import { RarePlants } from "./rareplants.js";
|
5
5
|
import { GenericPage } from "./genericpage.js";
|
6
|
+
import { ExternalSites } from "./externalsites.js";
|
6
7
|
|
7
8
|
class PageTaxon extends GenericPage {
|
8
9
|
|
@@ -31,6 +32,16 @@ class PageTaxon extends GenericPage {
|
|
31
32
|
if ( rpiLink ) {
|
32
33
|
links.push( rpiLink );
|
33
34
|
}
|
35
|
+
if ( this.#taxon.isNative() ) {
|
36
|
+
links.push(
|
37
|
+
HTML.getLink(
|
38
|
+
ExternalSites.getCalscapeLink( this.#taxon.getName() ),
|
39
|
+
"Calscape",
|
40
|
+
undefined,
|
41
|
+
true
|
42
|
+
)
|
43
|
+
);
|
44
|
+
}
|
34
45
|
return links;
|
35
46
|
}
|
36
47
|
|
@@ -50,8 +61,13 @@ class PageTaxon extends GenericPage {
|
|
50
61
|
if ( iNatID ) {
|
51
62
|
links.push(
|
52
63
|
HTML.getLink(
|
53
|
-
|
54
|
-
|
64
|
+
ExternalSites.getInatObsLink(
|
65
|
+
{
|
66
|
+
project_id: Config.getConfigValue( "inat", "project_id" ),
|
67
|
+
subview: "map",
|
68
|
+
taxon_id: iNatID
|
69
|
+
}
|
70
|
+
),
|
55
71
|
"iNaturalist",
|
56
72
|
{},
|
57
73
|
true
|