mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-14 10:09:31 -07:00
move json data fetching to a standalone module
This commit is contained in:
19
assets/ts/dataFetch.ts
Normal file
19
assets/ts/dataFetch.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
interface ImageData {
|
||||
index: string
|
||||
url: string
|
||||
imgH: string
|
||||
imgW: string
|
||||
}
|
||||
|
||||
// fetch images info from JSON
|
||||
const imageArrayElement = document.getElementById('images_array') as HTMLScriptElement
|
||||
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
|
||||
@@ -1,7 +1,8 @@
|
||||
import { footerHeightUpdateInit } from './utils'
|
||||
import { imgIndexSpanUpdate } from './indexDisp'
|
||||
import { imagesArrayLen, trackMouseInit } from './trackMouse'
|
||||
import { trackMouseInit } from './trackMouse'
|
||||
import { thresholdCtlInit } from './thresholdCtl'
|
||||
import { imagesArrayLen } from './dataFetch'
|
||||
|
||||
function init(): void {
|
||||
footerHeightUpdateInit()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user