mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-14 10:09:31 -07:00
27 lines
533 B
TypeScript
27 lines
533 B
TypeScript
// data structure for images info
|
|
export interface ImageJSON {
|
|
index: number
|
|
alt: string
|
|
loUrl: string
|
|
loImgH: number
|
|
loImgW: number
|
|
hiUrl: string
|
|
hiImgH: number
|
|
hiImgW: number
|
|
}
|
|
|
|
export function initResources(): ImageJSON[] {
|
|
const imagesJson = document.getElementById('imagesSource')
|
|
if (imagesJson === null) {
|
|
return []
|
|
}
|
|
return JSON.parse(imagesJson.textContent as string).sort(
|
|
(a: ImageJSON, b: ImageJSON) => {
|
|
if (a.index < b.index) {
|
|
return -1
|
|
}
|
|
return 1
|
|
}
|
|
)
|
|
}
|