aboutsummaryrefslogtreecommitdiff
path: root/src/lib.ts
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2023-01-29 12:21:55 +1100
committerTerry Truong <terry06890@gmail.com>2023-01-29 12:23:13 +1100
commit629b9208503369c3f20ceb59685ef49766344093 (patch)
tree87071d862358c56ee38756ab94eb04f9c55fd0dc /src/lib.ts
parent8781fdb2b8c530a6c1531ae9e82221eb062e34fb (diff)
Adjust frontend coding style
Add line spacing and section comments Fix 'Last updated' line in help modal being shown despite overflow
Diffstat (limited to 'src/lib.ts')
-rw-r--r--src/lib.ts24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/lib.ts b/src/lib.ts
index e262e05..c284de4 100644
--- a/src/lib.ts
+++ b/src/lib.ts
@@ -4,9 +4,11 @@
import {TolNode} from './tol';
-// For server requests
+// ========== For server requests ==========
+
const SERVER_DATA_URL = (new URL(window.location.href)).origin + '/data/'
const SERVER_IMG_PATH = '/tol_data/img/'
+
export async function queryServer(params: URLSearchParams){
// Construct URL
const url = new URL(SERVER_DATA_URL);
@@ -22,26 +24,33 @@ export async function queryServer(params: URLSearchParams){
}
return responseObj;
}
+
export function getImagePath(imgName: string): string {
return SERVER_IMG_PATH + imgName.replaceAll('\'', '\\\'');
}
-// For server search responses
-export type SearchSugg = { // Represents a search-string suggestion
+
+// ========== For server responses (matches backend/tilo.py) ==========
+
+// Represents a search-string suggestion
+export type SearchSugg = {
name: string,
canonicalName: string | null,
pop: number,
};
-export type SearchSuggResponse = { // Holds search suggestions and an indication of if there was more
+
+// Holds search suggestions and an indication of if there was more
+export type SearchSuggResponse = {
suggs: SearchSugg[],
hasMore: boolean,
};
-// For server tile-info responses
+
export type DescInfo = {
text: string,
wikiId: number,
fromRedirect: boolean,
fromDbp: boolean,
};
+
export type ImgInfo = {
id: number,
src: string,
@@ -50,17 +59,20 @@ export type ImgInfo = {
artist: string,
credit: string,
};
+
export type NodeInfo = {
tolNode: TolNode,
descInfo: null | DescInfo,
imgInfo: null | ImgInfo,
};
+
export type InfoResponse = {
nodeInfo: NodeInfo,
subNodesInfo: [] | [NodeInfo | null, NodeInfo | null],
};
-// Used by auto-mode and tutorial-pane
+// ========== Used by auto-mode and tutorial-pane ==========
+
export type Action =
'expand' | 'collapse' | 'expandToView' | 'unhideAncestor' |
'tileInfo' | 'search' | 'autoMode' | 'settings' | 'help';