Autoformatter applied on all js files

This commit is contained in:
Luis Fernando Molina committed 2019-02-23 10:32:06 +01:00
1 parent 72c1017b20
commit c627aedcf6
59 files changed
+9087 -10892

No files matched your search

+78 -95
View File
@@ -1,130 +1,113 @@
function newChartAspectRatio() {
function newChartAspectRatio () {
let thisObject = {
aspectRatio: undefined,
draw: draw,
getContainer: getContainer,
initialize: initialize
}
let thisObject = {
aspectRatio: undefined,
draw: draw,
getContainer: getContainer,
initialize: initialize
};
let container = newContainer()
container.initialize()
thisObject.container = container
let container = newContainer();
container.initialize();
thisObject.container = container;
thisObject.container.frame.width = 50
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
thisObject.container.frame.width = 50;
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
resize()
resize();
container.isDraggeable = false
container.isClickeable = false
container.isWheeleable = true
container.isDraggeable = false;
container.isClickeable = false;
container.isWheeleable = true;
thisObject.aspectRatio = {}
thisObject.aspectRatio = {};
const INITIAL_Y_ASPECT_RATIO = 5 / 10
const MIN_Y_ASPECT_RATIO = 1 / 10
const MAX_Y_ASPECT_RATIO = 10 / 10
const INITIAL_Y_ASPECT_RATIO = 5 / 10;
const MIN_Y_ASPECT_RATIO = 1 / 10;
const MAX_Y_ASPECT_RATIO = 10 / 10;
thisObject.aspectRatio.x = 1
thisObject.aspectRatio.y = INITIAL_Y_ASPECT_RATIO
thisObject.aspectRatio.x = 1;
thisObject.aspectRatio.y = INITIAL_Y_ASPECT_RATIO;
canDrawIcon = false
canDrawIcon = false;
return thisObject
return thisObject;
function initialize () {
icon = new Image()
function initialize() {
icon.onload = onImageLoad
icon = new Image();
function onImageLoad () {
canDrawIcon = true
}
icon.onload = onImageLoad;
icon.src = window.canvasApp.urlPrefix + 'Images/Icons/chart-scale.png'
function onImageLoad() {
canDrawIcon = true;
}
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
icon.src = window.canvasApp.urlPrefix + "Images/Icons/chart-scale.png";
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
}
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel);
function resize () {
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
}
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
function onMouseWheel (pDelta) {
if (viewPort.isMinZoom() === false) { return } // We only make this button to work at the min zoom level.
}
if (pDelta < 0) {
pDelta = -0.1
} else {
pDelta = 0.1
}
function resize() {
thisObject.aspectRatio.y = thisObject.aspectRatio.y + pDelta
thisObject.aspectRatio.y = Math.round(thisObject.aspectRatio.y * 100) / 100
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width;
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
if (thisObject.aspectRatio.y < MIN_Y_ASPECT_RATIO) {
thisObject.aspectRatio.y = MIN_Y_ASPECT_RATIO
}
}
if (thisObject.aspectRatio.y > MAX_Y_ASPECT_RATIO) {
thisObject.aspectRatio.y = MAX_Y_ASPECT_RATIO
}
function onMouseWheel(pDelta) {
thisObject.container.eventHandler.raiseEvent('Chart Aspect Ratio Changed', thisObject.aspectRatio)
}
if (viewPort.isMinZoom() === false) { return; } // We only make this button to work at the min zoom level.
if (pDelta < 0) {
pDelta = -0.1;
} else {
pDelta = 0.1;
}
thisObject.aspectRatio.y = thisObject.aspectRatio.y + pDelta;
thisObject.aspectRatio.y = Math.round(thisObject.aspectRatio.y * 100) / 100;
if (thisObject.aspectRatio.y < MIN_Y_ASPECT_RATIO) {
thisObject.aspectRatio.y = MIN_Y_ASPECT_RATIO;
}
if (thisObject.aspectRatio.y > MAX_Y_ASPECT_RATIO) {
thisObject.aspectRatio.y = MAX_Y_ASPECT_RATIO;
}
thisObject.container.eventHandler.raiseEvent("Chart Aspect Ratio Changed", thisObject.aspectRatio);
}
function getContainer(point) {
let container;
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 {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return this.container
} else {
/* This point does not belong to this space. */
return undefined;
}
}
return undefined
}
}
function draw() {
function draw () {
thisObject.container.frame.draw(false, false)
thisObject.container.frame.draw(false, false);
if (canDrawIcon === false) { return }
if (viewPort.isMinZoom() === false) { return } // We only show this button at the min zoom level.
if (canDrawIcon === false) { return; }
if (viewPort.isMinZoom() === false) { return; } // We only show this button at the min zoom level.
let breakpointsHeight = 15
let breakpointsHeight = 15;
let imageHeight = 15
let imageWidth = 15
let imageHeight = 15;
let imageWidth = 15;
let imagePoint = {
x: 10,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
}
let imagePoint = {
x: 10,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
};
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint);
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
}
}
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
}
}
+177 -230
View File
@@ -1,86 +1,75 @@
function newDeleteTradingHistory() {

function newDeleteTradingHistory () {
const MODULE_NAME = 'Delete Trading History'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
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 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
var container = newContainer();
container.initialize();
thisObject.container = container;
thisObject.container.frame.width = 50
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
thisObject.container.frame.width = 50;
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
resize()
resize();
container.isDraggeable = false
container.isClickeable = true
container.isDraggeable = false;
container.isClickeable = true;
let icon
let canDrawIcon = false
let icon;
let canDrawIcon = false;
return thisObject
return thisObject;
function initialize (callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
function initialize(callBackFunction) {
icon = new Image()
try {
icon.onload = onImageLoad
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
function onImageLoad () {
canDrawIcon = true
}
icon = new Image();
icon.src = window.canvasApp.urlPrefix + 'Images/Icons/trash.png'
icon.onload = onImageLoad;
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
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); }
}
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() {
function resize () {
container.frame.position.x = viewPort.visibleArea.topRight.x
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
}
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')
function onClick() {
try {
if (INFO_LOG === true) { logger.write("[INFO] onClick -> Entering function."); }
let sessionToken = window.localStorage.getItem('sessionToken');
if (sessionToken === null || sessionToken === "") {
if (sessionToken === null || sessionToken === '') {
/* not logged in */
return;
}
return
}
/*
@@ -94,243 +83,201 @@ function newDeleteTradingHistory() {
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.
9. Save the Status Report without the records of this Start Mode.
*/
let storage = AzureStorage.Blob;
let storage = AzureStorage.Blob
let readOnlyBlobService;
let writeOnlyBlobService;
let deleteOnlyBlobService;
let readOnlyBlobService
let writeOnlyBlobService
let deleteOnlyBlobService
let readConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + "." + "READ");
let readConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'READ')
if (readConnectionString !== undefined) {
readOnlyBlobService = storage.createBlobService(readConnectionString);
}
if (readConnectionString !== undefined) {
readOnlyBlobService = storage.createBlobService(readConnectionString)
}
let writeConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + "." + "WRITE");
let writeConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'WRITE')
if (writeConnectionString !== undefined) {
writeOnlyBlobService = storage.createBlobService(writeConnectionString);
}
if (writeConnectionString !== undefined) {
writeOnlyBlobService = storage.createBlobService(writeConnectionString)
}
let deleteConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + "." + "DELETE");
let deleteConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'DELETE')
if (deleteConnectionString !== undefined) {
deleteOnlyBlobService = storage.createBlobService(deleteConnectionString);
}
if (deleteConnectionString !== undefined) {
deleteOnlyBlobService = storage.createBlobService(deleteConnectionString)
}
let containerName = window.DEV_TEAM.toLowerCase();
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";
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);
readOnlyBlobService.getBlobToText(containerName, statusReportFilePath + '/' + statusReportFileName, onStatusReport)
function onStatusReport(err, text, response) {
function onStatusReport (err, text, response) {
try {
if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> Entering function.') }
try {
if (err && err.code === 'BlobNotFound') {
console.log(statusReportFilePath + '/' + statusReportFileName + ' not found. No history detected for this start mode.')
return
}
if (INFO_LOG === true) { logger.write("[INFO] onClick -> onStatusReport -> Entering function."); }
let statusReport = JSON.parse(text)
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++) {
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";
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);
readOnlyBlobService.getBlobToText(containerName, filePath + '/' + fileName, onExecutionHistory)
function onExecutionHistory(err, text, response) {
function onExecutionHistory (err, text, response) {
let executionHistory = JSON.parse(text)
let executionHistory = JSON.parse(text);
for (let j = 0; j < executionHistory.length; j++) {
let dateTime = new Date(executionHistory[j][0])
for (let j = 0; j < executionHistory.length; j++) {
let datePath = dateTime.getUTCFullYear() + '/' + pad(dateTime.getUTCMonth() + 1, 2) + '/' + pad(dateTime.getUTCDate(), 2) + '/' + pad(dateTime.getUTCHours(), 2) + '/' + pad(dateTime.getUTCMinutes(), 2)
let dateTime = new Date(executionHistory[j][0]);
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'
let datePath = dateTime.getUTCFullYear() + "/" + pad(dateTime.getUTCMonth() + 1, 2) + "/" + pad(dateTime.getUTCDate(), 2) + "/" + pad(dateTime.getUTCHours(), 2) + "/" + pad(dateTime.getUTCMinutes(), 2);
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted)
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";
toBeDeleted++
deleteOnlyBlobService.deleteBlob(containerName, filePath + "/" + fileName, onDeleted);
function onDeleted (err, text, response) {
if (err) {
toBeDeleted++;
console.log(filePath + '/' + fileName + ' NOT deleted.')
console.log('err.message = ' + err.message)
} else {
function onDeleted(err, text, response) {
console.log(filePath + '/' + fileName + ' deleted.')
}
if (err) {
deleted++
console.log(filePath + "/" + fileName + " NOT deleted.");
console.log("err.message = " + err.message);
} else {
if (toBeDeleted === deleted) {
console.log(filePath + "/" + fileName + " deleted.");
}
deleted++;
if (toBeDeleted === deleted) {
updateStatusReport();
}
}
}
updateStatusReport()
}
}
}
/* Now we delete the execution history file. */
deleteOnlyBlobService.deleteBlob(containerName, filePath + "/" + fileName, onExecutionHistoryDeleted);
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onExecutionHistoryDeleted)
function onExecutionHistoryDeleted(err, text, response) {
function onExecutionHistoryDeleted (err, text, response) {
console.log(filePath + '/' + fileName + ' deleted.')
}
}
}
console.log(filePath + "/" + fileName + " deleted.");
function updateStatusReport () {
try {
if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> updateStatusReport -> Entering function.') }
}
}
}
function updateStatusReport() {
try {
if (INFO_LOG === true) { logger.write("[INFO] onClick -> onStatusReport -> updateStatusReport -> Entering function."); }
statusReport.runs = [];
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);
let fileContent = JSON.stringify(statusReport)
writeOnlyBlobService.createBlockBlobFromText(containerName, statusReportFilePath + "/" + statusReportFileName, fileContent, onStatusReportUpdated);
writeOnlyBlobService.createBlockBlobFromText(containerName, statusReportFilePath + '/' + statusReportFileName, fileContent, onStatusReportUpdated)
function onStatusReportUpdated(err, text, response) {
console.log(statusReportFilePath + "/" + statusReportFileName + " updated.");
}
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";
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);
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 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) }
}
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); }
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) {
function getContainer (point) {
try {
if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') }
try {
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
let container;
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 {
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); }
}
return undefined
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err.message = ' + err.message) }
}
}
function draw() {
function draw () {
try {
if (INFO_LOG === true) { logger.write('[INFO] draw -> Entering function.') }
try {
let sessionToken = window.localStorage.getItem('sessionToken')
if (INFO_LOG === true) { logger.write("[INFO] draw -> Entering function."); }
let sessionToken = window.localStorage.getItem('sessionToken');
if (sessionToken === null || sessionToken === "") {
if (sessionToken === null || sessionToken === '') {
/* not logged in */
return;
}
return
}
thisObject.container.frame.draw(false, false);
thisObject.container.frame.draw(false, false)
if (canDrawIcon === false) { return; }
if (canDrawIcon === false) { return }
let breakpointsHeight = 14;
let breakpointsHeight = 14
let imageHeight = 15;
let imageWidth = 15;
let imageHeight = 15
let imageWidth = 15
let imagePoint = {
x: 10,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
};
let imagePoint = {
x: 10,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
}
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint);
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); }
}
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err.message = ' + err.message) }
}
}
}
}
+110 -126
View File
@@ -1,164 +1,148 @@
function newPlayStopButton() {

function newPlayStopButton () {
var thisObject = {
container: undefined,
setDatetime: setDatetime,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
}
var thisObject = {
container: undefined,
setDatetime: setDatetime,
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
var container = newContainer();
container.initialize();
thisObject.container = container;
thisObject.container.frame.width = 50
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
thisObject.container.frame.width = 50;
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
resize()
resize();
container.isDraggeable = false
container.isClickeable = true
container.isDraggeable = false;
container.isClickeable = true;
let play
let stop
let canDraw = false
let showing = 'Play'
let image
let play;
let stop;
let canDraw = false;
let showing = "Play";
let image;
let datetime
let timePeriod
let datetime;
let timePeriod;
return thisObject
return thisObject;
function initialize () {
play = new Image()
function initialize() {
play = new Image();
play.onload = onImageLoad;
function onImageLoad() {
image = play;
canDraw = true;
}
play.src = window.canvasApp.urlPrefix + "Images/Icons/play.png";
stop = new Image();
stop.src = window.canvasApp.urlPrefix + "Images/Icons/pause.png";
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
timePeriod = INITIAL_TIME_PERIOD;
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
play.onload = onImageLoad
function onImageLoad () {
image = play
canDraw = true
}
function resize() {
play.src = window.canvasApp.urlPrefix + 'Images/Icons/play.png'
container.frame.position.x = viewPort.visibleArea.topLeft.x + 150 * 4;
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
stop = new Image()
}
stop.src = window.canvasApp.urlPrefix + 'Images/Icons/pause.png'
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
function onClick() {
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
timePeriod = INITIAL_TIME_PERIOD
let sessionToken = window.localStorage.getItem('sessionToken');
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
}
if (sessionToken === null || sessionToken === "") {
function resize () {
container.frame.position.x = viewPort.visibleArea.topLeft.x + 150 * 4
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
}
function onClick () {
let sessionToken = window.localStorage.getItem('sessionToken')
if (sessionToken === null || sessionToken === '') {
/* not logged in */
return;
return
}
switch (showing) {
case 'Play': {
image = stop
showing = 'Stop'
let UI_COMMANDS = {
beginDatetime: datetime,
endDatetime: undefined,
timePeriod: timePeriod,
startMode: window.CURRENT_START_MODE,
eventHandler: thisObject.container.eventHandler
}
switch (showing) {
cloudVM.onBotPlayPressed(UI_COMMANDS)
case "Play": {
image = stop;
showing = "Stop";
break
}
case 'Stop': {
image = play
showing = 'Play'
let UI_COMMANDS = {
beginDatetime: datetime,
endDatetime: undefined,
timePeriod: timePeriod,
startMode: window.CURRENT_START_MODE,
eventHandler: thisObject.container.eventHandler
};
cloudVM.onBotStopPressed()
cloudVM.onBotPlayPressed(UI_COMMANDS);
break;
}
case "Stop": {
image = play;
showing = "Play";
cloudVM.onBotStopPressed();
break;
}
}
break
}
}
}
function onZoomChanged(event) {
function onZoomChanged (event) {
timePeriod = recalculatePeriod(event.newLevel)
}
timePeriod = recalculatePeriod(event.newLevel);
function setDatetime (pDatetime) {
datetime = new Date(pDatetime)
}
}
function setDatetime(pDatetime) {
datetime = new Date(pDatetime);
}
function getContainer(point) {
let container;
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 {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return this.container
} else {
/* This point does not belong to this space. */
return undefined;
}
return undefined
}
}
function draw() {
function draw () {
let sessionToken = window.localStorage.getItem('sessionToken')
let sessionToken = window.localStorage.getItem('sessionToken');
if (sessionToken === null || sessionToken === "") {
if (sessionToken === null || sessionToken === '') {
/* not logged in */
return;
}
thisObject.container.frame.draw(false, false);
let breakpointsHeight = 14;
if (canDraw === false) { return; }
let imageHeight = 20;
let imageWidth = 20;
let imagePoint = {
x: thisObject.container.frame.width / 2 - imageWidth / 2,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
};
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint);
browserCanvasContext.drawImage(image, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
return
}
}
thisObject.container.frame.draw(false, false)
let breakpointsHeight = 14
if (canDraw === false) { return }
let imageHeight = 20
let imageWidth = 20
let imagePoint = {
x: thisObject.container.frame.width / 2 - imageWidth / 2,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
}
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
browserCanvasContext.drawImage(image, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
}
}