move json data fetching to a standalone module

This commit is contained in:
Spedon
2023-03-14 01:19:01 +08:00
parent 1785e1e7ce
commit f3d3efb4ff
3 changed files with 22 additions and 21 deletions

View File

@@ -2,32 +2,13 @@ import { overlayEnable } from './overlay'
import { posCache, FIFO, layersPosSet, center } from './utils'
import { thresholdSensitivityArray, thresholdIndex } from './thresholdCtl'
import { imgIndexSpanUpdate } from './indexDisp'
interface ImageData {
index: string
url: string
imgH: string
imgW: string
}
import { imagesArrayLen, imagesArray } from './dataFetch'
export interface position {
x: number
y: number
}
// get images info from JSON
const imageArrayElement = document.getElementById('images_array') as HTMLElement
const rawImageArray = imageArrayElement.textContent as string
export const imagesArray: ImageData[] = JSON.parse(rawImageArray).sort(
(a: ImageData, b: ImageData) => {
if (a.index < b.index) {
return -1
}
return 1
}
)
export const imagesArrayLen: number = imagesArray.length
// get layer divs
const layer5 = document.getElementById('layer5') as HTMLDivElement
const layer4 = document.getElementById('layer4') as HTMLDivElement