Merge pull request #40 from AAMasters/develop
BUG corrected: scaling failed after turning off and on an indicator
This commit is contained in:
21 files changed
+52
-574
No files matched your search
@@ -1,283 +0,0 @@
|
||||
|
||||
function newDeleteTradingHistory () {
|
||||
const MODULE_NAME = 'Delete Trading History'
|
||||
const INFO_LOG = false
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
var thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
var container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
thisObject.container.frame.width = 50
|
||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||
|
||||
resize()
|
||||
|
||||
container.isDraggeable = false
|
||||
container.isClickeable = true
|
||||
|
||||
let icon
|
||||
let canDrawIcon = false
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
icon = new Image()
|
||||
|
||||
icon.onload = onImageLoad
|
||||
|
||||
function onImageLoad () {
|
||||
canDrawIcon = true
|
||||
}
|
||||
|
||||
icon.src = window.canvasApp.urlPrefix + 'Images/Icons/trash.png'
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err.message = ' + err.message) }
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) }
|
||||
}
|
||||
}
|
||||
|
||||
function resize () {
|
||||
container.frame.position.x = viewPort.visibleArea.topRight.x
|
||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||
}
|
||||
|
||||
function onClick () {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] onClick -> Entering function.') }
|
||||
|
||||
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||
|
||||
if (sessionToken === null || sessionToken === '') {
|
||||
/* not logged in */
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
To delete the trading history we will follow these steps:
|
||||
|
||||
1. Get the status report of that bot.
|
||||
2. Iterate through all the entries for the startMode received by parameters.
|
||||
3. For each entry, get the execution history file belonging to that entry.
|
||||
4. Iterate on each entry of each execution history file to get the date of each execution that we will use to locate the
|
||||
execution context file.
|
||||
6. Delete every execution context file found.
|
||||
7. Delete the execution history file after finishing the interation.
|
||||
8. Delete the Sequence file belonging to the received Start Mode.
|
||||
9. Save the Status Report without the records of this Start Mode.
|
||||
|
||||
*/
|
||||
|
||||
let storage = AzureStorage.Blob
|
||||
|
||||
let readOnlyBlobService
|
||||
let writeOnlyBlobService
|
||||
let deleteOnlyBlobService
|
||||
|
||||
let readConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'READ')
|
||||
|
||||
if (readConnectionString !== undefined) {
|
||||
readOnlyBlobService = storage.createBlobService(readConnectionString)
|
||||
}
|
||||
|
||||
let writeConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'WRITE')
|
||||
|
||||
if (writeConnectionString !== undefined) {
|
||||
writeOnlyBlobService = storage.createBlobService(writeConnectionString)
|
||||
}
|
||||
|
||||
let deleteConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'DELETE')
|
||||
|
||||
if (deleteConnectionString !== undefined) {
|
||||
deleteOnlyBlobService = storage.createBlobService(deleteConnectionString)
|
||||
}
|
||||
|
||||
let containerName = window.DEV_TEAM.toLowerCase()
|
||||
|
||||
let statusReportFilePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Reports' + '/' + 'Trading-Process'
|
||||
let statusReportFileName = window.CURRENT_START_MODE + '.' + 'Status.Report.USDT_BTC.json'
|
||||
|
||||
readOnlyBlobService.getBlobToText(containerName, statusReportFilePath + '/' + statusReportFileName, onStatusReport)
|
||||
|
||||
function onStatusReport (err, text, response) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> Entering function.') }
|
||||
|
||||
if (err && err.code === 'BlobNotFound') {
|
||||
console.log(statusReportFilePath + '/' + statusReportFileName + ' not found. No history detected for this start mode.')
|
||||
return
|
||||
}
|
||||
|
||||
let statusReport = JSON.parse(text)
|
||||
|
||||
let toBeDeleted = 0
|
||||
let deleted = 0
|
||||
|
||||
for (let i = 0; i < statusReport.runs.length; i++) {
|
||||
/* For each record, we will get the execution history file. */
|
||||
|
||||
let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process'
|
||||
let fileName = 'Execution.History.' + window.CURRENT_START_MODE + '.' + i + '.json'
|
||||
|
||||
readOnlyBlobService.getBlobToText(containerName, filePath + '/' + fileName, onExecutionHistory)
|
||||
|
||||
function onExecutionHistory (err, text, response) {
|
||||
let executionHistory = JSON.parse(text)
|
||||
|
||||
for (let j = 0; j < executionHistory.length; j++) {
|
||||
let dateTime = new Date(executionHistory[j][0])
|
||||
|
||||
let datePath = dateTime.getUTCFullYear() + '/' + pad(dateTime.getUTCMonth() + 1, 2) + '/' + pad(dateTime.getUTCDate(), 2) + '/' + pad(dateTime.getUTCHours(), 2) + '/' + pad(dateTime.getUTCMinutes(), 2)
|
||||
|
||||
let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process' + '/' + datePath
|
||||
let fileName = 'Execution.Context.' + window.CURRENT_START_MODE + '.' + i + '.json'
|
||||
|
||||
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted)
|
||||
|
||||
toBeDeleted++
|
||||
|
||||
function onDeleted (err, text, response) {
|
||||
if (err) {
|
||||
|
||||
console.log(filePath + '/' + fileName + ' NOT deleted.')
|
||||
console.log('err.message = ' + err.message)
|
||||
} else {
|
||||
|
||||
console.log(filePath + '/' + fileName + ' deleted.')
|
||||
}
|
||||
|
||||
deleted++
|
||||
|
||||
if (toBeDeleted === deleted) {
|
||||
|
||||
updateStatusReport()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now we delete the execution history file. */
|
||||
|
||||
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onExecutionHistoryDeleted)
|
||||
|
||||
function onExecutionHistoryDeleted (err, text, response) {
|
||||
console.log(filePath + '/' + fileName + ' deleted.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatusReport () {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> updateStatusReport -> Entering function.') }
|
||||
|
||||
statusReport.runs = []
|
||||
|
||||
/* Here is where we update the current Status Report file with the new version without records for the current Start Mode. */
|
||||
|
||||
let fileContent = JSON.stringify(statusReport)
|
||||
|
||||
writeOnlyBlobService.createBlockBlobFromText(containerName, statusReportFilePath + '/' + statusReportFileName, fileContent, onStatusReportUpdated)
|
||||
|
||||
function onStatusReportUpdated (err, text, response) {
|
||||
console.log(statusReportFilePath + '/' + statusReportFileName + ' updated.')
|
||||
}
|
||||
|
||||
/* Finally we delete the sequence file. */
|
||||
|
||||
let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process'
|
||||
let fileName = 'Execution.History.' + window.CURRENT_START_MODE + '.' + 'Sequence' + '.json'
|
||||
|
||||
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted)
|
||||
|
||||
function onDeleted (err, text, response) {
|
||||
console.log(filePath + '/' + fileName + ' deleted.')
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> updateStatusReport -> err.message = ' + err.message) }
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> err.message = ' + err.message) }
|
||||
}
|
||||
}
|
||||
|
||||
function pad (str, max) {
|
||||
str = str.toString()
|
||||
return str.length < max ? pad('0' + str, max) : str
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> err.message = ' + err.message) }
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') }
|
||||
|
||||
let container
|
||||
|
||||
/* First we check if this point is inside this object UI. */
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return this.container
|
||||
} else {
|
||||
/* This point does not belong to this space. */
|
||||
|
||||
return undefined
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err.message = ' + err.message) }
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] draw -> Entering function.') }
|
||||
|
||||
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||
|
||||
if (sessionToken === null || sessionToken === '') {
|
||||
/* not logged in */
|
||||
return
|
||||
}
|
||||
|
||||
thisObject.container.frame.draw(false, false)
|
||||
|
||||
if (canDrawIcon === false) { return }
|
||||
|
||||
let breakpointsHeight = 0
|
||||
|
||||
let imageHeight = 15
|
||||
let imageWidth = 15
|
||||
|
||||
let imagePoint = {
|
||||
x: 10,
|
||||
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
|
||||
}
|
||||
|
||||
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
|
||||
|
||||
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err.message = ' + err.message) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
|
||||
function newBreakpointsBar () {
|
||||
var thisObject = {
|
||||
setDatetime: setDatetime,
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
var container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
thisObject.container.frame.width = browserCanvasContext.width
|
||||
thisObject.container.frame.height = 15
|
||||
|
||||
container.frame.position.x = 0
|
||||
container.frame.position.y = viewPort.visibleArea.bottomRight.y
|
||||
|
||||
container.isDraggeable = false
|
||||
container.isClickeable = true
|
||||
|
||||
let logo
|
||||
let canDrawLogo = false
|
||||
|
||||
let datetime
|
||||
let timePeriod
|
||||
let timeLineCoordinateSystem
|
||||
let chartContainer
|
||||
|
||||
let breakpointsByTimePeriod = new Map()
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize (pChartContainer, pTimeLineCoordinateSystem) {
|
||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem
|
||||
chartContainer = pChartContainer
|
||||
|
||||
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
|
||||
timePeriod = INITIAL_TIME_PERIOD
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||
|
||||
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
||||
let breakpointsMap = new Map()
|
||||
breakpointsByTimePeriod.set(marketFilesPeriods[i][0], breakpointsMap)
|
||||
}
|
||||
|
||||
for (let i = 0; i < dailyFilePeriods.length; i++) {
|
||||
let breakpointsMap = new Map()
|
||||
breakpointsByTimePeriod.set(dailyFilePeriods[i][0], breakpointsMap)
|
||||
}
|
||||
}
|
||||
|
||||
function onClick (pPoint) {
|
||||
let point = {
|
||||
x: pPoint.x,
|
||||
y: pPoint.y
|
||||
}
|
||||
|
||||
let miliSeconds = getMilisecondsFromPoint(point, chartContainer, timeLineCoordinateSystem)
|
||||
|
||||
miliSeconds = normalizeX(miliSeconds) // We are now exactly at the middle of the "candle" correspondind to the point clicked.
|
||||
|
||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod)
|
||||
let breakpoint = breakpointsMap.get(miliSeconds)
|
||||
|
||||
if (breakpoint === undefined) {
|
||||
/* The breakpoint didnt exist, then we create one. */
|
||||
breakpointsMap.set(miliSeconds, 1)
|
||||
} else {
|
||||
/* The breakpoint existed, so we remove it. */
|
||||
breakpointsMap.set(miliSeconds, undefined)
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeX (pX) {
|
||||
return Math.trunc(pX / timePeriod) * timePeriod + timePeriod / 2
|
||||
}
|
||||
|
||||
function onZoomChanged (event) {
|
||||
timePeriod = recalculatePeriod(event.newLevel)
|
||||
}
|
||||
|
||||
function setDatetime (pDatetime) {
|
||||
datetime = new Date(pDatetime)
|
||||
}
|
||||
|
||||
function getContainer (point) {
|
||||
let container
|
||||
|
||||
/* First we check if this point is inside this object UI. */
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return this.container
|
||||
} else {
|
||||
/* This point does not belong to this space. */
|
||||
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function draw () {
|
||||
/*
|
||||
To draw the breakpoints, we will calculate the miliseconds for the first x pixel of the breakpoint bar, and for the last x pixel. Once we have that
|
||||
we can create an array with all the possible points for breack points. Finally we can see if brealpoints exists at those points. We plot only the ones
|
||||
that exists.
|
||||
*/
|
||||
|
||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod)
|
||||
|
||||
let beginX = {
|
||||
x: viewPort.visibleArea.bottomLeft.x,
|
||||
y: 0
|
||||
}
|
||||
|
||||
let endX = {
|
||||
x: viewPort.visibleArea.bottomRight.x,
|
||||
y: 0
|
||||
}
|
||||
|
||||
let beginMiliseconds = getMilisecondsFromPoint(beginX, chartContainer, timeLineCoordinateSystem)
|
||||
let endMiliseconds = getMilisecondsFromPoint(endX, chartContainer, timeLineCoordinateSystem)
|
||||
|
||||
beginMiliseconds = normalizeX(beginMiliseconds)
|
||||
endMiliseconds = normalizeX(endMiliseconds)
|
||||
|
||||
window.AT_BREAKPOINT = false
|
||||
|
||||
for (let miliSeconds = beginMiliseconds; miliSeconds < endMiliseconds; miliSeconds = miliSeconds + timePeriod) {
|
||||
let breakpoint = breakpointsMap.get(miliSeconds)
|
||||
|
||||
if (breakpoint !== undefined) {
|
||||
let point1 = {
|
||||
x: miliSeconds,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point1 = timeLineCoordinateSystem.transformThisPoint(point1)
|
||||
point1 = transformThisPoint(point1, chartContainer)
|
||||
|
||||
let point2 = {
|
||||
x: miliSeconds,
|
||||
y: thisObject.container.frame.height / 2 + 1
|
||||
}
|
||||
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
|
||||
let point = {
|
||||
x: point1.x,
|
||||
y: point2.y
|
||||
}
|
||||
|
||||
let isCurrentRecord = false
|
||||
|
||||
if (datetime !== undefined) {
|
||||
let dateValue = datetime.valueOf()
|
||||
if (dateValue >= miliSeconds - timePeriod / 2 && dateValue <= miliSeconds + timePeriod / 2 - 1) {
|
||||
isCurrentRecord = true
|
||||
}
|
||||
}
|
||||
|
||||
let radius = 5
|
||||
|
||||
let opacity = '0.5'
|
||||
|
||||
browserCanvasContext.lineWidth = 1
|
||||
|
||||
/* Outer Circle */
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(123, 50, 40, ' + opacity + ')'
|
||||
|
||||
if (isCurrentRecord === false) {
|
||||
browserCanvasContext.fillStyle = 'rgba(223, 70, 60, ' + opacity + ')'
|
||||
} else {
|
||||
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, ' + opacity + ')' /* highlight the current record */
|
||||
|
||||
window.AT_BREAKPOINT = true // We are hitting a breakpoint!
|
||||
}
|
||||
|
||||
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
if (point.x < viewPort.visibleArea.topLeft.x + 50 || point.x > viewPort.visibleArea.bottomRight.x - 50) { /* we leave this history without fill. */ } else {
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
function newCandle () {
|
||||
var candle = {
|
||||
let candle = {
|
||||
open: undefined,
|
||||
close: undefined,
|
||||
min: 10000000000000,
|
||||
|
||||
+19
-4
@@ -10,15 +10,29 @@ function newContainer () {
|
||||
isWheelable: false,
|
||||
name: undefined,
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
connectToParent: connectToParent,
|
||||
isForThisPurpose: isForThisPurpose
|
||||
}
|
||||
|
||||
let connectedToParentWidth = false
|
||||
let connectedToParentHeight = false
|
||||
let isConnectedToParent = false
|
||||
|
||||
let dimensionsChangedEventSubscriptionId
|
||||
let onMouseOverEventSubscriptionId
|
||||
let onMouseNotOverEventSubscriptionId
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
if (isConnectedToParent === true) {
|
||||
thisObject.parentContainer.eventHandler.stopListening(dimensionsChangedEventSubscriptionId)
|
||||
thisObject.parentContainer.eventHandler.stopListening(onMouseOverEventSubscriptionId)
|
||||
thisObject.parentContainer.eventHandler.stopListening(onMouseNotOverEventSubscriptionId)
|
||||
}
|
||||
}
|
||||
|
||||
function initialize (pName) {
|
||||
thisObject.name = pName
|
||||
|
||||
@@ -28,7 +42,6 @@ function newContainer () {
|
||||
thisObject.frame.container = thisObject
|
||||
|
||||
thisObject.eventHandler = newEventHandler()
|
||||
thisObject.eventHandler.initialize()
|
||||
thisObject.eventHandler.name = pName
|
||||
|
||||
thisObject.displacement = newDisplacement()
|
||||
@@ -39,13 +52,15 @@ function newContainer () {
|
||||
function connectToParent (parentContainer, onWidth, onHeight) {
|
||||
connectedToParentWidth = onWidth
|
||||
connectedToParentHeight = onHeight
|
||||
isConnectedToParent = true
|
||||
|
||||
thisObject.displacement.parentDisplacement = parentContainer.displacement
|
||||
thisObject.frame.parentFrame = parentContainer.frame
|
||||
thisObject.parentContainer = parentContainer
|
||||
thisObject.parentContainer.eventHandler.listenToEvent('Dimmensions Changed', onParentDimmensionsChanged)
|
||||
thisObject.parentContainer.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
thisObject.parentContainer.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
|
||||
dimensionsChangedEventSubscriptionId = thisObject.parentContainer.eventHandler.listenToEvent('Dimmensions Changed', onParentDimmensionsChanged)
|
||||
onMouseOverEventSubscriptionId = thisObject.parentContainer.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSubscriptionId = thisObject.parentContainer.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
|
||||
if (connectedToParentWidth) {
|
||||
thisObject.frame.width = thisObject.parentContainer.frame.width
|
||||
|
||||
+5
-2
@@ -18,6 +18,9 @@ function newDashboard () {
|
||||
|
||||
const DEBUG_START_UP_DELAY = 0 // 3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time.
|
||||
|
||||
let userProfileChangedEventSubscriptionId
|
||||
let browserResizedEventSubscriptionId
|
||||
|
||||
return thisObject
|
||||
|
||||
function start () {
|
||||
@@ -31,8 +34,8 @@ function newDashboard () {
|
||||
/* Here we will setup the global eventHandler that will enable the Canvas App to react to events happening outside its execution scope. */
|
||||
|
||||
window.canvasApp.eventHandler = newEventHandler()
|
||||
window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged)
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized)
|
||||
userProfileChangedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged)
|
||||
browserResizedEventSubscriptionId = window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized)
|
||||
|
||||
loadImages(onImagesLoaded)
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ The displacement is a vector that displaces everything static drawn on on the co
|
||||
*/
|
||||
|
||||
function newDisplacement () {
|
||||
var displacement = {
|
||||
let displacement = {
|
||||
containerName: '', // This is for debugging purposes only.
|
||||
parentDisplacement: undefined, // Here we store the displacement object of the parent cointainer, if exists.
|
||||
container: undefined,
|
||||
|
||||
+11
-56
@@ -1,83 +1,38 @@
|
||||
|
||||
function newEventHandler () {
|
||||
const CONSOLE_LOG = false
|
||||
|
||||
let thisObject = {
|
||||
name: undefined, // This is for debugging purposes only.
|
||||
parentEventHandler: undefined, // Here we store the parent cointainer zoom object.
|
||||
listenToEvent: listenToEvent,
|
||||
stopListening: stopListening,
|
||||
raiseEvent: raiseEvent,
|
||||
initialize: initialize
|
||||
raiseEvent: raiseEvent
|
||||
}
|
||||
|
||||
var eventHandlers = [] // Here we store all the functions we will call when an event is comming.
|
||||
var eventHandlers = [] // Here we store all the functions we will call when an event is raiseed.
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
|
||||
}
|
||||
|
||||
function listenToEvent (eventType, handler, extraData) {
|
||||
eventHandlers.push([eventType, handler, extraData])
|
||||
|
||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||
console.log('Event Handler named ' + thisObject.name + ' received a request to listenToEvent ' + eventType + ' and call ' + (handler.toString()).substring(0, 50))
|
||||
}
|
||||
let eventSubscriptionId = Math.trunc(Math.random() * 1000000)
|
||||
eventHandlers.push([eventType, handler, extraData, eventSubscriptionId])
|
||||
return eventSubscriptionId
|
||||
}
|
||||
|
||||
function stopListening (pEventType, pHandler) {
|
||||
if (pHandler === undefined) {
|
||||
pHandler = 'Anonymous Function'
|
||||
}
|
||||
|
||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||
console.log('Event Handler named ' + thisObject.name + ' received a request to stop listening to an the event ' + pEventType + ' with this handler: ' + pHandler)
|
||||
}
|
||||
|
||||
function stopListening (pEventSubscriptionId) {
|
||||
for (let i = 0; i < eventHandlers.length; i++) {
|
||||
let record = eventHandlers[i]
|
||||
let eventType = record[0]
|
||||
let handler = record[1]
|
||||
|
||||
if (pHandler === 'Anonymous Function') {
|
||||
if (pEventType === eventType) {
|
||||
eventHandlers.splice(i, 1)
|
||||
|
||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||
console.log('Evethandler found and deleted.')
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (pEventType === eventType && pHandler.toString() === handler.toString()) {
|
||||
eventHandlers.splice(i, 1)
|
||||
|
||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||
console.log('Evethandler found and deleted.')
|
||||
}
|
||||
return
|
||||
}
|
||||
if (pEventSubscriptionId === eventHandlers[i][3]) {
|
||||
eventHandlers.splice(i, 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function raiseEvent (eventType, event) {
|
||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||
console.log('Event Handler named ' + thisObject.name + ' received a request to raiseEvent ' + eventType + ' with this data ' + (event.toString()).substring(0, 50))
|
||||
}
|
||||
|
||||
for (var i = 0; i < eventHandlers.length; i++) {
|
||||
/* We will execute all the functions listening to this event type. */
|
||||
|
||||
if (eventHandlers[i][0] === eventType) {
|
||||
var handler = eventHandlers[i][1]
|
||||
var extraData = eventHandlers[i][2]
|
||||
|
||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||
console.log('Event Handler named ' + thisObject.name + ' received a request to raiseEvent ' + eventType + ' and will call this handler: ' + (handler.toString()).substring(0, 50))
|
||||
}
|
||||
let handler = eventHandlers[i][1]
|
||||
let extraData = eventHandlers[i][2]
|
||||
|
||||
handler(event, extraData)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ function newFloatingObject () {
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
|
||||
physicsLoop: physicsLoop,
|
||||
eventHandler: undefined,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
function newNote () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
|
||||
physicsLoop: physicsLoop,
|
||||
onMouseOver: onMouseOver,
|
||||
|
||||
@@ -3,7 +3,7 @@ function newFrame () {
|
||||
const PANEL_CORNERS_RADIOUS = 5
|
||||
const TITLE_BAR_HEIGHT = 14 // this must be grater than radius
|
||||
|
||||
var frame = {
|
||||
let frame = {
|
||||
containerName: '', // This is for debugging purposes only.
|
||||
parentFrame: undefined, // Here we store the parent cointainer zoom object.
|
||||
width: browserCanvas.width,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function newPanelTabButton () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
parentContainer: undefined,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function newProductsPanel () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
getLoadingProductCards: getLoadingProductCards,
|
||||
draw: draw,
|
||||
@@ -64,6 +64,7 @@
|
||||
userTeams = JSON.parse(storedTeams)
|
||||
userTeam = userTeams[0] // Currently we assume a user can be at only one team.
|
||||
}
|
||||
if (userTeam === undefined) { userTeam = {slug: ''} }
|
||||
|
||||
/* First thing is to build the productCards array */
|
||||
|
||||
|
||||
@@ -619,6 +619,7 @@ function newPlottersManager () {
|
||||
productPlotters[i].storage.finalize()
|
||||
|
||||
if (productPlotters[i].plotter.finalize !== undefined) {
|
||||
productPlotters[i].plotter.container.finalize()
|
||||
productPlotters[i].plotter.finalize()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ function newProductCard () {
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
status: 'off',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
function newBottomSpace () {
|
||||
var thisObject = {
|
||||
deleteTradingHistory: undefined,
|
||||
let thisObject = {
|
||||
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
@@ -19,9 +19,6 @@ function newBottomSpace () {
|
||||
return thisObject
|
||||
|
||||
function initialize () {
|
||||
thisObject.deleteTradingHistory = newDeleteTradingHistory()
|
||||
thisObject.deleteTradingHistory.initialize()
|
||||
|
||||
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
}
|
||||
|
||||
@@ -36,9 +33,6 @@ function newBottomSpace () {
|
||||
function getContainer (point) {
|
||||
let container
|
||||
|
||||
container = thisObject.deleteTradingHistory.getContainer(point)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
return thisObject.container
|
||||
}
|
||||
|
||||
@@ -46,7 +40,6 @@ function newBottomSpace () {
|
||||
thisObject.container.frame.draw(false, false)
|
||||
|
||||
drawBackground()
|
||||
thisObject.deleteTradingHistory.draw()
|
||||
}
|
||||
|
||||
function drawBackground () {
|
||||
|
||||
@@ -13,7 +13,7 @@ function newChartSpace () {
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
drawBackground: drawBackground,
|
||||
draw: draw,
|
||||
|
||||
@@ -5,7 +5,7 @@ The Panel Space y the place wehre all panels live, no matter who create them.
|
||||
*/
|
||||
|
||||
function newPanelsSpace () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
createNewPanel: createNewPanel,
|
||||
destroyPanel: destroyPanel,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
function newTopSpace () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ The Splash Screen is to show some 'loading...' controls while the app is being l
|
||||
*/
|
||||
|
||||
function newSplashScreen () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
timeMachines: [],
|
||||
|
||||
@@ -8,7 +8,7 @@ The scale on the Y axis depends on the data that wants to be plotted. Usually we
|
||||
*/
|
||||
|
||||
function newTimeLineCoordinateSystem () {
|
||||
var thisObject = {
|
||||
let thisObject = {
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
scale: undefined,
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
thisObject.container.detectMouseOver = true
|
||||
|
||||
// let chartGrid
|
||||
let breakpointsBar
|
||||
|
||||
let initializationReady = false
|
||||
|
||||
let productsPanel
|
||||
@@ -113,9 +110,6 @@
|
||||
logoExchange.src = window.canvasApp.urlPrefix + 'Images/' + exchange + '-logo-background.png'
|
||||
logoAA.src = window.canvasApp.urlPrefix + 'Images/sa-logo-background.png'
|
||||
|
||||
breakpointsBar = newBreakpointsBar()
|
||||
breakpointsBar.initialize(thisObject.container, timeLineCoordinateSystem)
|
||||
|
||||
// moveToUserPosition(thisObject.container, timeLineCoordinateSystem, undefined, undefined, undefined, true)
|
||||
timePeriod = INITIAL_TIME_PERIOD
|
||||
datetime = NEW_SESSION_INITIAL_DATE
|
||||
@@ -188,7 +182,6 @@
|
||||
if (thisObject.container.frame.isInViewPort()) {
|
||||
plotterManager.setDatetime(pDatetime)
|
||||
plotterManager.positionAtDatetime(pDatetime)
|
||||
breakpointsBar.setDatetime(pDatetime)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,8 +221,6 @@
|
||||
|
||||
plotterManager.setDatetime(datetime)
|
||||
|
||||
breakpointsBar.setDatetime(datetime)
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent('Datetime Changed', datetime)
|
||||
}
|
||||
|
||||
@@ -242,8 +233,6 @@
|
||||
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
container = breakpointsBar.getContainer(point)
|
||||
|
||||
return container
|
||||
}
|
||||
|
||||
@@ -289,7 +278,6 @@
|
||||
|
||||
timePeriodScale.draw()
|
||||
plotterManager.draw()
|
||||
breakpointsBar.draw()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user