diff --git a/Canvas.js b/Canvas.js index fceef9090..8a6f1eab3 100644 --- a/Canvas.js +++ b/Canvas.js @@ -170,12 +170,12 @@ function newCanvas () { animation.addCallBackFunction('ViewPort Draw', viewPort.draw, onFunctionAdded) animation.addCallBackFunction('Chart Space Background', thisObject.chartSpace.drawBackground, onFunctionAdded) animation.addCallBackFunction('Chart Space', thisObject.chartSpace.draw, onFunctionAdded) - animation.addCallBackFunction('Floating Space', thisObject.floatingSpace.floatingLayer.physicsLoop, onFunctionAdded) animation.addCallBackFunction('Panels Space', thisObject.panelsSpace.draw, onFunctionAdded) animation.addCallBackFunction('ViewPort Animate', viewPort.animate, onFunctionAdded) animation.addCallBackFunction('Bottom Space', thisObject.bottomSpace.draw, onFunctionAdded) animation.addCallBackFunction('Top Space', thisObject.topSpace.draw, onFunctionAdded) animation.addCallBackFunction('Strategy Space', thisObject.strategySpace.draw, onFunctionAdded) + animation.addCallBackFunction('Floating Space', thisObject.floatingSpace.floatingLayer.physicsLoop, onFunctionAdded) animation.addCallBackFunction('Splash Screen', splashScreen.draw, onFunctionAdded) animation.start(onStart) @@ -540,58 +540,69 @@ function newCanvas () { /* We check if the mouse is over an element of the Strategy Space / */ - container = thisObject.strategySpace.getContainer(point) + if (thisObject.strategySpace !== undefined) { + container = thisObject.strategySpace.getContainer(point) - if (container !== undefined && container.detectMouseOver === true) { - container.eventHandler.raiseEvent('onMouseOver', point) - return + if (container !== undefined && container.detectMouseOver === true) { + container.eventHandler.raiseEvent('onMouseOver', point) + return + } } /* We check if the mouse is over an element of the Top Space / */ - container = thisObject.topSpace.getContainer(point) + if (thisObject.topSpace !== undefined) { + container = thisObject.topSpace.getContainer(point) - if (container !== undefined && container.detectMouseOver === true) { - container.eventHandler.raiseEvent('onMouseOver', point) - return + if (container !== undefined && container.detectMouseOver === true) { + container.eventHandler.raiseEvent('onMouseOver', point) + return + } } /* We check if the mouse is over an element of the Bottom Space / */ - container = thisObject.bottomSpace.getContainer(point) + if (thisObject.bottomSpace !== undefined) { + container = thisObject.bottomSpace.getContainer(point) - if (container !== undefined && container.detectMouseOver === true) { - container.eventHandler.raiseEvent('onMouseOver', point) - return + if (container !== undefined && container.detectMouseOver === true) { + container.eventHandler.raiseEvent('onMouseOver', point) + return + } } /* We check if the mouse is over a panel/ */ - container = thisObject.panelsSpace.getContainer(point) + if (thisObject.panelsSpace !== undefined) { + container = thisObject.panelsSpace.getContainer(point) - if (container !== undefined && container.detectMouseOver === true) { - container.eventHandler.raiseEvent('onMouseOver', point) - return + if (container !== undefined && container.detectMouseOver === true) { + container.eventHandler.raiseEvent('onMouseOver', point) + return + } } /* We check if the mouse is over a floatingObject/ */ + if (thisObject.floatingSpace !== undefined) { + let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(point.x, point.y) - let floatingObjectBeingClicked = thisObject.floatingSpace.floatingLayer.isInside(point.x, point.y) + if (floatingObjectBeingClicked >= 0) { + let floatingObject = thisObject.floatingSpace.floatingLayer.getFloatingObject(undefined, floatingObjectBeingClicked) + floatingObject.eventHandler.raiseEvent('onMouseOver', point) - if (floatingObjectBeingClicked >= 0) { - let floatingObject = thisObject.floatingSpace.floatingLayer.getFloatingObject(undefined, floatingObjectBeingClicked) - floatingObject.eventHandler.raiseEvent('onMouseOver', point) - - return + return + } } /* If it is not, then we check if it is over any of the existing containers at the Chart Space. */ - container = thisObject.chartSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) + if (thisObject.chartSpace !== undefined) { + container = thisObject.chartSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) - if (container !== undefined && container.detectMouseOver === true) { - container.eventHandler.raiseEvent('onMouseOver', point) - return + if (container !== undefined && container.detectMouseOver === true) { + container.eventHandler.raiseEvent('onMouseOver', point) + return + } } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseOver -> err = ' + err.stack) } diff --git a/StrategySpace/StrategyCollectionItem.js b/StrategySpace/StrategyCollectionItem.js index 9abf2644c..1ac83be78 100644 --- a/StrategySpace/StrategyCollectionItem.js +++ b/StrategySpace/StrategyCollectionItem.js @@ -37,21 +37,29 @@ function newStrategyCollectionItem () { } function onMouseClick (event) { - if (productPlotter.plotter.payload !== undefined) { - let imageId = pProductCard.bot.devTeam + '.' + pProductCard.bot.profilePicture + let handle + let payload = { + profile: { + position: { + x: 500, + y: 500 + }, + visible: true + }, + notes: [] + } - productPlotter.plotter.payload.profile.upLabel = pProductCard.product.shortDisplayName - productPlotter.plotter.payload.profile.downLabel = pProductCard.bot.displayName - productPlotter.plotter.payload.profile.imageId = imageId - productPlotter.plotter.payload.profile.botAvatar = pProductCard.bot.avatar + let imageId = 'My Image.png' - canvas.floatingSpace.profileBalls.createNewProfileBall(productPlotter.plotter.payload, onProfileBallCreated) + payload.profile.upLabel = thisObject.strategy.name + payload.profile.downLabel = thisObject.strategy.name + payload.profile.imageId = imageId + payload.profile.botAvatar = 'dont know what this is' - function onProfileBallCreated (err, pProfileHandle) { - productPlotter.profile = pProfileHandle + canvas.floatingSpace.profileBalls.createNewProfileBall(payload, onProfileBallCreated) - /* There is no policy yet of what to do if this fails. */ - } + function onProfileBallCreated (err, pProfileHandle) { + handle = pProfileHandle } }