From 6ff26ab72ec507698f43e86fd59188a3a3fbee54 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Thu, 5 May 2022 12:27:45 +1000 Subject: Make image copyright/link info retrieved upon info-modal open --- src/components/Tile.vue | 4 ++-- src/components/TileInfoModal.vue | 22 +++++++++++++--------- src/tol.ts | 12 ++---------- 3 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/components/Tile.vue b/src/components/Tile.vue index a4083bc..744adc3 100644 --- a/src/components/Tile.vue +++ b/src/components/Tile.vue @@ -88,9 +88,9 @@ export default defineComponent({ leafStyles(): Record { return { // Image (and scrims) - backgroundImage: this.tolNode.img?.filename != null ? + backgroundImage: this.tolNode.imgName != null ? 'linear-gradient(to bottom, rgba(0,0,0,0.4), #0000 40%, #0000 60%, rgba(0,0,0,0.4) 100%),' + - 'url(\'/img/' + this.tolNode.img.filename.replaceAll('\'', '\\\'') + '\')' : + 'url(\'/img/' + this.tolNode.imgName.replaceAll('\'', '\\\'') + '\')' : 'none', backgroundColor: '#1c1917', backgroundSize: 'cover', diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index b59a5c9..7cd75b7 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -11,6 +11,7 @@ export default defineComponent({ return { desc: null as null | string, fromRedirect: false, + imgInfo: null as null | {eolId: string, sourceUrl: string, license: string, copyrightOwner: string}, }; }, props: { @@ -24,9 +25,9 @@ export default defineComponent({ }, imgStyles(): Record { return { - backgroundImage: this.tolNode.img?.filename != null ? + backgroundImage: this.tolNode.imgName != null ? 'linear-gradient(to bottom, rgba(0,0,0,0.4), #0000 40%, #0000 60%, rgba(0,0,0,0.4) 100%),' + - 'url(\'/img/' + this.tolNode.img.filename.replaceAll('\'', '\\\'') + '\')' : + 'url(\'/img/' + this.tolNode.imgName.replaceAll('\'', '\\\'') + '\')' : 'none', backgroundColor: '#1c1917', width: this.uiOpts.infoModalImgSz + 'px', @@ -45,14 +46,17 @@ export default defineComponent({ }, created(){ let url = new URL(window.location.href); - url.pathname = '/data/desc'; + url.pathname = '/data/info'; url.search = '?name=' + encodeURIComponent(this.node.name); fetch(url.toString()) .then(response => response.json()) .then(obj => { if (obj != null){ - this.desc = obj[0]; - this.fromRedirect = obj[1]; + if (obj.desc != null){ + this.desc = obj.desc.text; + this.fromRedirect = obj.desc.fromRedirect; + } + this.imgInfo = obj.imgInfo; } }); }, @@ -72,11 +76,11 @@ export default defineComponent({
-
+
    -
  • License: {{tolNode.img.license}}
  • -
  • Source URL
  • -
  • Copyright Owner: {{tolNode.img.copyrightOwner}}
  • +
  • License: {{imgInfo.license}}
  • +
  • Source URL
  • +
  • Copyright Owner: {{imgInfo.copyrightOwner}}
diff --git a/src/tol.ts b/src/tol.ts index 77c401e..073f848 100644 --- a/src/tol.ts +++ b/src/tol.ts @@ -10,20 +10,12 @@ export class TolNode { parent: string | null; tips: number; pSupport: boolean; - img: null | { - filename: string, - eolId: string, - sourceUrl: string, - license: string, - copyrightOwner: string - }; - desc: null | [string, boolean]; + imgName: null | string; constructor(children: string[] = [], parent = null, tips = 0, pSupport = false){ this.children = children; this.parent = parent; this.tips = tips; this.pSupport = pSupport; - this.img = null; - this.desc = null; + this.imgName = null; } } -- cgit v1.2.3