From dfe3752087a538d11d034e7294171d1d96a8cd78 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 8 Oct 2018 13:09:50 +0200 Subject: [PATCH] Team Image comes from Teams Module Storage, when exists --- ProductCard.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ProductCard.js b/ProductCard.js index af3ac3a05..c6d2d9404 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -66,6 +66,9 @@ let timePeriod = INITIAL_TIME_PERIOD; let datetime = INITIAL_DATE; + let teamAvatar; // stores the avatar image of the team the bot portrayed at this card belongs to. + let teamAvatarLoaded = false; + return thisObject; function initialize() { @@ -143,6 +146,24 @@ thisObject.container.eventHandler.listenToEvent('onMouseClick', buttonPressed); + /* + Here we will download the images of teams uploaded at the Teams Module. + There might be Product Cards of bots beloging to teams not present currently at the Teams Module, in those cases + nothing should happen. + */ + + teamAvatar = new Image(); + + teamAvatar.onload = onImageLoad; + + function onImageLoad() { + teamAvatarLoaded = true; + } + + const STORAGE_URL = "https://algobotcommstorage.blob.core.windows.net"; + const TEAM = thisObject.devTeam.codeName.toLowerCase(); + teamAvatar.src = STORAGE_URL + "/" + TEAM + "/" + TEAM + "-" + "avatar.jpg"; + } function getContainer(point) { @@ -363,7 +384,13 @@ teamImagePoint = thisObject.container.frame.frameThisPoint(teamImagePoint); - let teamImage = document.getElementById(thisObject.bot.devTeam + ".png"); + let teamImage; + + if (teamAvatarLoaded === false) { + teamImage = document.getElementById(thisObject.bot.devTeam + ".png"); + } else { + teamImage = teamAvatar; + } if (teamImage.naturalHeight !== 0) {