aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/App.vue6
-rw-r--r--src/components/AncestryBar.vue2
-rw-r--r--src/components/SearchModal.vue9
-rw-r--r--src/components/Tile.vue4
-rw-r--r--src/components/TileInfoModal.vue40
-rw-r--r--src/layout.ts2
-rw-r--r--src/lib.ts38
-rw-r--r--src/tol.ts25
8 files changed, 62 insertions, 64 deletions
diff --git a/src/App.vue b/src/App.vue
index cddb027..99f4018 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -14,8 +14,8 @@ import SearchIcon from './components/icon/SearchIcon.vue';
import PlayIcon from './components/icon/PlayIcon.vue';
import SettingsIcon from './components/icon/SettingsIcon.vue';
// Other
-import type {TolMap} from './tol';
-import {TolNode} from './tol';
+import type {TolMap} from './lib';
+import {TolNode} from './lib';
import {LayoutNode, initLayoutTree, initLayoutMap, tryLayout} from './layout';
import type {LayoutOptions, LayoutTreeChg} from './layout';
import {arraySum, randWeightedChoice, getScrollBarWidth} from './lib';
@@ -302,7 +302,7 @@ export default defineComponent({
},
onDetachedAncestorClick(layoutNode: LayoutNode, alsoCollapse = false){
if (!this.handleActionForTutorial('unhideAncestor')){
- return;
+ return Promise.resolve(false);
}
this.setLastFocused(null);
this.activeRoot = layoutNode;
diff --git a/src/components/AncestryBar.vue b/src/components/AncestryBar.vue
index 8f31900..a56568c 100644
--- a/src/components/AncestryBar.vue
+++ b/src/components/AncestryBar.vue
@@ -3,7 +3,7 @@ import {defineComponent, PropType} from 'vue';
import Tile from './Tile.vue'
import {LayoutNode} from '../layout';
import type {LayoutOptions} from '../layout';
-import type {TolMap} from '../tol';
+import type {TolMap} from '../lib';
// Displays a sequence of nodes, representing ancestors from a tree-of-life root to a currently-active root
export default defineComponent({
diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue
index 9ea10c8..4ea5cea 100644
--- a/src/components/SearchModal.vue
+++ b/src/components/SearchModal.vue
@@ -3,10 +3,7 @@ import {defineComponent, PropType} from 'vue';
import SearchIcon from './icon/SearchIcon.vue';
import InfoIcon from './icon/InfoIcon.vue';
import {LayoutNode} from '../layout';
-import type {TolMap} from '../tol';
-
-type SearchSugg = {name: string, canonicalName: string | null}; // Represents a search string suggestion
-type SearchSuggResponse = [SearchSugg[], boolean]; // Holds search suggestions and an indication of if there was more
+import type {TolMap, SearchSugg, SearchSuggResponse} from '../lib';
// Displays a search box, and sends search requests
export default defineComponent({
@@ -107,8 +104,8 @@ export default defineComponent({
return response.json()
})
.then((results: SearchSuggResponse) => {
- this.searchSuggs = results[0];
- this.searchHasMoreSuggs = results[1];
+ this.searchSuggs = results.suggs;
+ this.searchHasMoreSuggs = results.hasMore;
this.focusedSuggIdx = null;
})
.catch(error => {
diff --git a/src/components/Tile.vue b/src/components/Tile.vue
index 9bbff51..29b4856 100644
--- a/src/components/Tile.vue
+++ b/src/components/Tile.vue
@@ -3,8 +3,8 @@ import {defineComponent, PropType} from 'vue';
import InfoIcon from './icon/InfoIcon.vue';
import {LayoutNode} from '../layout';
import type {LayoutOptions} from '../layout';
-import type {TolMap} from '../tol';
-import {TolNode} from '../tol';
+import type {TolMap} from '../lib';
+import {TolNode} from '../lib';
import {capitalizeWords} from '../lib';
// Displays one, or a hierarchy of, tree-of-life nodes, as a 'tile'
diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue
index 45b3192..bd6cc5d 100644
--- a/src/components/TileInfoModal.vue
+++ b/src/components/TileInfoModal.vue
@@ -4,18 +4,10 @@ import CloseIcon from './icon/CloseIcon.vue';
import Tile from './Tile.vue'
import {LayoutNode} from '../layout';
import type {LayoutOptions} from '../layout';
-import type {TolMap} from '../tol';
-import {TolNode} from '../tol';
+import type {TolMap} from '../lib';
+import {TolNode, DescInfo, ImgInfo, TileInfoResponse} from '../lib';
import {capitalizeWords} from '../lib';
-type DescInfo = {text: string, fromRedirect: boolean, wikiId: number, fromDbp: boolean};
-type ImgInfo = {imgId: number, imgSrc: 'eol' | 'enwiki', url: string, license: string, artist: string, credit: string}
-type TileInfoResponse = {
- tolNode: null | TolNode,
- descData: null | DescInfo | [DescInfo, DescInfo],
- imgData: null | ImgInfo | [ImgInfo, ImgInfo],
-};
-
// Displays information about a tree-of-life node
export default defineComponent({
data(){
@@ -123,18 +115,16 @@ export default defineComponent({
fetch(url.toString())
.then(response => response.json())
.then(obj => {
- if (obj != null){
- this.tolNode = obj.nodeObj;
- if (!Array.isArray(obj.descData)){
- this.descInfo = obj.descData;
- } else {
- [this.descInfo1, this.descInfo2] = obj.descData;
- }
- if (!Array.isArray(obj.imgData)){
- this.imgInfo = obj.imgData;
- } else {
- [this.imgInfo1, this.imgInfo2] = obj.imgData;
- }
+ this.tolNode = obj.tolNode;
+ if (!Array.isArray(obj.descData)){
+ this.descInfo = obj.descData;
+ } else {
+ [this.descInfo1, this.descInfo2] = obj.descData;
+ }
+ if (!Array.isArray(obj.imgData)){
+ this.imgInfo = obj.imgData;
+ } else {
+ [this.imgInfo1, this.imgInfo2] = obj.imgData;
}
});
},
@@ -164,7 +154,7 @@ export default defineComponent({
<div v-else-if="!Array.isArray(tolNode.imgName)">
<div :style="imgStyles"/>
<ul v-if="imgInfo != null">
- <li>Obtained via: {{imgInfo.imgSrc}}</li>
+ <li>Obtained via: {{imgInfo.src}}</li>
<li>License: <a :href="licenseToUrl(imgInfo.license)">{{imgInfo.license}}</a></li>
<li><a :href="imgInfo.url" class="underline">Source URL</a></li>
<li>Artist: {{imgInfo.artist}}</li>
@@ -174,7 +164,7 @@ export default defineComponent({
<div v-else>
<div v-if="tolNode.imgName[0] != null" :style="firstImgStyles"/>
<ul v-if="imgInfo1 != null">
- <li>Obtained via: {{imgInfo1.imgSrc}}</li>
+ <li>Obtained via: {{imgInfo1.src}}</li>
<li>License: <a :href="licenseToUrl(imgInfo1.license)">{{imgInfo1.license}}</a></li>
<li><a :href="imgInfo1.url" class="underline">Source URL</a></li>
<li>Artist: {{imgInfo1.artist}}</li>
@@ -182,7 +172,7 @@ export default defineComponent({
</ul>
<div v-if="tolNode.imgName[1] != null" :style="secondImgStyles"/>
<ul v-if="imgInfo2 != null">
- <li>Obtained via: {{imgInfo2.imgSrc}}</li>
+ <li>Obtained via: {{imgInfo2.src}}</li>
<li>License: <a :href="licenseToUrl(imgInfo2.license)">{{imgInfo2.license}}</a></li>
<li><a :href="imgInfo2.url" class="underline">Source URL</a></li>
<li>Artist: {{imgInfo2.artist}}</li>
diff --git a/src/layout.ts b/src/layout.ts
index 0dd598d..416ec73 100644
--- a/src/layout.ts
+++ b/src/layout.ts
@@ -6,7 +6,7 @@
* find a tile-based layout, filling in node fields to represent placement.
*/
-import type {TolMap} from './tol';
+import type {TolMap} from './lib';
import {range, arraySum, linspace, limitVals, updateAscSeq} from './lib';
// Represents a node/tree that holds layout data for a TolNode node/tree
diff --git a/src/lib.ts b/src/lib.ts
index 67ac4c3..a6c8df1 100644
--- a/src/lib.ts
+++ b/src/lib.ts
@@ -1,7 +1,43 @@
/*
- * Types
+ * Types/classes
*/
+// Used for tree-of-life representation
+// Maps tree-of-life node names to node objects
+export type TolMap = Map<string, TolNode>;
+// Represents a tree-of-life node
+export class TolNode {
+ otolId: string | null;
+ children: string[];
+ parent: string | null;
+ tips: number;
+ pSupport: boolean;
+ commonName: null | string;
+ imgName: null | string | [string, string] | [null, string] | [string, null];
+ constructor(children: string[] = [], parent = null, tips = 0, pSupport = false){
+ this.otolId = null;
+ this.children = children;
+ this.parent = parent;
+ this.tips = tips;
+ this.pSupport = pSupport;
+ this.commonName = null;
+ this.imgName = null;
+ }
+}
+// Used for server search-responses
+export type SearchSugg = {name: string, canonicalName: string | null};
+ // Represents a search-string suggestion
+export type SearchSuggResponse = {suggs: SearchSugg[], hasMore: boolean};
+ // Holds search suggestions and an indication of if there was more
+// Used for server info-responses
+export type DescInfo = {text: string, wikiId: number, fromRedirect: boolean, fromDbp: boolean};
+export type ImgInfo = {id: number, src: string, url: string, license: string, artist: string, credit: string}
+export type TileInfoResponse = {
+ tolNode: null | TolNode,
+ descData: null | DescInfo | [DescInfo, DescInfo],
+ imgData: null | ImgInfo | [ImgInfo, ImgInfo],
+};
+
// Used by auto-mode and tutorial
export type Action =
'expand' | 'collapse' | 'expandToView' | 'unhideAncestor' |
diff --git a/src/tol.ts b/src/tol.ts
deleted file mode 100644
index 59ecadc..0000000
--- a/src/tol.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Provides classes for representing and working with tree-of-life data.
- */
-
-// Maps tree-of-life node names to node objects
-export type TolMap = Map<string, TolNode>;
-// Represents a tree-of-life node
-export class TolNode {
- otolId: string | null;
- children: string[];
- parent: string | null;
- tips: number;
- pSupport: boolean;
- commonName: null | string;
- imgName: null | string | [string, string] | [null, string] | [string, null];
- constructor(children: string[] = [], parent = null, tips = 0, pSupport = false){
- this.otolId = null;
- this.children = children;
- this.parent = parent;
- this.tips = tips;
- this.pSupport = pSupport;
- this.imgName = null;
- this.commonName = null;
- }
-}