Autoformatter applied on all js files
This commit is contained in:
1 parent
72c1017b20
commit
c627aedcf6
59 files changed
+9087
-10892
No files matched your search
+82
-123
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
function newAnimation() {
|
|
||||||
|
|
||||||
const MODULE_NAME = "Animation";
|
function newAnimation () {
|
||||||
const INFO_LOG = false;
|
const MODULE_NAME = 'Animation'
|
||||||
const ERROR_LOG = true;
|
const INFO_LOG = false
|
||||||
const logger = newWebDebugLog();
|
const ERROR_LOG = true
|
||||||
logger.fileName = MODULE_NAME;
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -15,157 +14,117 @@ function newAnimation() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let animationLoopHandle; // This is the handle to the animation loop. With this handle we can cancel the loop, for instance.
|
let animationLoopHandle // This is the handle to the animation loop. With this handle we can cancel the loop, for instance.
|
||||||
let callBackFunctions = new Map();
|
let callBackFunctions = new Map()
|
||||||
|
|
||||||
let thisObject = {
|
let thisObject = {
|
||||||
start: start,
|
start: start,
|
||||||
stop: stop,
|
stop: stop,
|
||||||
addCallBackFunction: addCallBackFunction,
|
addCallBackFunction: addCallBackFunction,
|
||||||
removeCallBackFunction: removeCallBackFunction,
|
removeCallBackFunction: removeCallBackFunction,
|
||||||
initialize: initialize
|
initialize: initialize
|
||||||
};
|
}
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(callBackFunction) {
|
function initialize (callBackFunction) {
|
||||||
|
try {
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
|
|
||||||
/* Nothing to do here yet. */
|
/* Nothing to do here yet. */
|
||||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE);
|
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE)
|
||||||
|
} catch (err) {
|
||||||
} catch (err) {
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function start (callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] start -> Entering function.') }
|
||||||
|
|
||||||
function start(callBackFunction) {
|
animationLoop() // Inside this function the animation process is started, and at the same time it creates a loop.
|
||||||
|
} catch (err) {
|
||||||
try {
|
if (ERROR_LOG === true) { logger.write('[ERROR] start -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] start -> Entering function."); }
|
|
||||||
|
|
||||||
animationLoop(); // Inside this function the animation process is started, and at the same time it creates a loop.
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] start -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function stop(callBackFunction) {
|
function stop (callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] stop -> Entering function.') }
|
||||||
|
|
||||||
try {
|
window.cancelAnimationFrame(animationLoopHandle)
|
||||||
|
} catch (err) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] stop -> Entering function."); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] stop -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
window.cancelAnimationFrame(animationLoopHandle);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] stop -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addCallBackFunction(key, callBack, callBackFunction) {
|
function addCallBackFunction (key, callBack, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] addCallBackFunction -> Entering function.') }
|
||||||
|
|
||||||
try {
|
callBackFunctions.set(key, callBack)
|
||||||
|
} catch (err) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] addCallBackFunction -> Entering function."); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] addCallBackFunction -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunctions.set(key, callBack);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] addCallBackFunction -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeCallBackFunction(key, callBackFunction) {
|
function removeCallBackFunction (key, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] removeCallBackFunction -> Entering function.') }
|
||||||
|
|
||||||
try {
|
callBackFunctions.delete(key)
|
||||||
|
} catch (err) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] removeCallBackFunction -> Entering function."); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] removeCallBackFunction -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunctions.delete(key);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] removeCallBackFunction -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function animationLoop() {
|
function animationLoop () {
|
||||||
|
try {
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] animationLoop -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] animationLoop -> Entering function."); }
|
|
||||||
|
|
||||||
if (window.canvasApp.visible === true) {
|
|
||||||
|
|
||||||
|
if (window.canvasApp.visible === true) {
|
||||||
/* We set the canvas to its normal width and height */
|
/* We set the canvas to its normal width and height */
|
||||||
|
|
||||||
browserCanvas.width = window.innerWidth;
|
browserCanvas.width = window.innerWidth
|
||||||
browserCanvas.height = window.innerHeight - window.canvasApp.topMargin;
|
browserCanvas.height = window.innerHeight - window.canvasApp.topMargin
|
||||||
|
|
||||||
/* First thing is to clear the actual canvas */
|
/* First thing is to clear the actual canvas */
|
||||||
|
|
||||||
clearBrowserCanvas();
|
clearBrowserCanvas()
|
||||||
|
|
||||||
/* We loop through the callback functions collections and execute them all. */
|
/* We loop through the callback functions collections and execute them all. */
|
||||||
|
|
||||||
callBackFunctions.forEach(function (callBackFunction) {
|
callBackFunctions.forEach(function (callBackFunction) {
|
||||||
|
callBackFunction()
|
||||||
callBackFunction();
|
})
|
||||||
|
} else {
|
||||||
});
|
browserCanvas.width = 1
|
||||||
|
browserCanvas.height = 1
|
||||||
} else {
|
}
|
||||||
|
|
||||||
browserCanvas.width = 1;
|
|
||||||
browserCanvas.height = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We request the next frame to be drawn, and stablishing a loop */
|
/* We request the next frame to be drawn, and stablishing a loop */
|
||||||
|
|
||||||
animationLoopHandle = window.requestAnimationFrame(animationLoop);
|
animationLoopHandle = window.requestAnimationFrame(animationLoop)
|
||||||
|
} catch (err) {
|
||||||
} catch (err) {
|
if (ERROR_LOG === true) { logger.write('[ERROR] animationLoop -> err = ' + err) }
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] animationLoop -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clearBrowserCanvas() {
|
function clearBrowserCanvas () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] clearBrowserCanvas -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] clearBrowserCanvas -> Entering function."); }
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.rect(0, 0, browserCanvas.width, browserCanvas.height)
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
|
|
||||||
browserCanvasContext.rect(0, 0, browserCanvas.width, browserCanvas.height);
|
browserCanvasContext.closePath()
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
browserCanvasContext.fill()
|
||||||
|
}
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.fill();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,130 +1,113 @@
|
|||||||
function newChartAspectRatio() {
|
function newChartAspectRatio () {
|
||||||
|
let thisObject = {
|
||||||
|
aspectRatio: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
aspectRatio: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = 50
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 50;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = false
|
||||||
|
container.isWheeleable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
thisObject.aspectRatio = {}
|
||||||
container.isClickeable = false;
|
|
||||||
container.isWheeleable = true;
|
|
||||||
|
|
||||||
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;
|
thisObject.aspectRatio.x = 1
|
||||||
const MIN_Y_ASPECT_RATIO = 1 / 10;
|
thisObject.aspectRatio.y = INITIAL_Y_ASPECT_RATIO
|
||||||
const MAX_Y_ASPECT_RATIO = 10 / 10;
|
|
||||||
|
|
||||||
thisObject.aspectRatio.x = 1;
|
canDrawIcon = false
|
||||||
thisObject.aspectRatio.y = INITIAL_Y_ASPECT_RATIO;
|
|
||||||
|
|
||||||
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() {
|
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
|
||||||
canDrawIcon = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
if (thisObject.aspectRatio.y < MIN_Y_ASPECT_RATIO) {
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
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.
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
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;
|
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* 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; }
|
let breakpointsHeight = 15
|
||||||
if (viewPort.isMinZoom() === false) { return; } // We only show this button at the min zoom level.
|
|
||||||
|
|
||||||
let breakpointsHeight = 15;
|
let imageHeight = 15
|
||||||
|
let imageWidth = 15
|
||||||
|
|
||||||
let imageHeight = 15;
|
let imagePoint = {
|
||||||
let imageWidth = 15;
|
x: 10,
|
||||||
|
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
|
||||||
|
}
|
||||||
|
|
||||||
let imagePoint = {
|
imagePoint = thisObject.container.frame.frameThisPoint(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)
|
||||||
|
}
|
||||||
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+177
-230
@@ -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";
|
var thisObject = {
|
||||||
const INFO_LOG = false;
|
container: undefined,
|
||||||
const ERROR_LOG = true;
|
draw: draw,
|
||||||
const logger = newWebDebugLog();
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
logger.fileName = MODULE_NAME;
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
thisObject.container.frame.width = 50
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 50;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
let icon
|
||||||
container.isClickeable = true;
|
let canDrawIcon = false
|
||||||
|
|
||||||
let icon;
|
return thisObject
|
||||||
let canDrawIcon = false;
|
|
||||||
|
|
||||||
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() {
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
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); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
function onClick () {
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onClick -> Entering function.') }
|
||||||
|
|
||||||
}
|
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||||
|
|
||||||
|
if (sessionToken === null || sessionToken === '') {
|
||||||
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 */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -94,243 +83,201 @@ function newDeleteTradingHistory() {
|
|||||||
6. Delete every execution context file found.
|
6. Delete every execution context file found.
|
||||||
7. Delete the execution history file after finishing the interation.
|
7. Delete the execution history file after finishing the interation.
|
||||||
8. Delete the Sequence file belonging to the received Start Mode.
|
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 readOnlyBlobService
|
||||||
let writeOnlyBlobService;
|
let writeOnlyBlobService
|
||||||
let deleteOnlyBlobService;
|
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) {
|
if (readConnectionString !== undefined) {
|
||||||
readOnlyBlobService = storage.createBlobService(readConnectionString);
|
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) {
|
if (writeConnectionString !== undefined) {
|
||||||
writeOnlyBlobService = storage.createBlobService(writeConnectionString);
|
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) {
|
if (deleteConnectionString !== undefined) {
|
||||||
deleteOnlyBlobService = storage.createBlobService(deleteConnectionString);
|
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 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 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') {
|
let toBeDeleted = 0
|
||||||
|
let deleted = 0
|
||||||
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 (let i = 0; i < statusReport.runs.length; i++) {
|
||||||
/* For each record, we will get the execution history file. */
|
/* 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 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 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;
|
toBeDeleted++
|
||||||
let fileName = "Execution.Context." + window.CURRENT_START_MODE + "." + i + ".json";
|
|
||||||
|
|
||||||
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.");
|
if (toBeDeleted === deleted) {
|
||||||
console.log("err.message = " + err.message);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
console.log(filePath + "/" + fileName + " deleted.");
|
updateStatusReport()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
deleted++;
|
|
||||||
|
|
||||||
if (toBeDeleted === deleted) {
|
|
||||||
|
|
||||||
updateStatusReport();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now we delete the execution history file. */
|
/* 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.') }
|
||||||
|
|
||||||
}
|
statusReport.runs = []
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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. */
|
/* 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) {
|
function onStatusReportUpdated (err, text, response) {
|
||||||
|
console.log(statusReportFilePath + '/' + statusReportFileName + ' updated.')
|
||||||
console.log(statusReportFilePath + "/" + statusReportFileName + " updated.");
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Finally we delete the sequence file. */
|
/* 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 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 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) {
|
function onDeleted (err, text, response) {
|
||||||
|
console.log(filePath + '/' + fileName + ' deleted.')
|
||||||
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 -> 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) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> err.message = ' + err.message) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] onClick -> 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 {
|
let container
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
} catch (err) {
|
if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err.message = ' + err.message) }
|
||||||
|
|
||||||
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."); }
|
if (sessionToken === null || sessionToken === '') {
|
||||||
|
|
||||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
|
||||||
|
|
||||||
if (sessionToken === null || sessionToken === "") {
|
|
||||||
/* not logged in */
|
/* 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 imageHeight = 15
|
||||||
let imageWidth = 15;
|
let imageWidth = 15
|
||||||
|
|
||||||
let imagePoint = {
|
let imagePoint = {
|
||||||
x: 10,
|
x: 10,
|
||||||
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
|
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)
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err.message = ' + err.message) }
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] draw -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
+110
-126
@@ -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 = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
setDatetime: setDatetime,
|
thisObject.container = container
|
||||||
draw: draw,
|
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
thisObject.container.frame.width = 50
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 50;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
let play
|
||||||
container.isClickeable = true;
|
let stop
|
||||||
|
let canDraw = false
|
||||||
|
let showing = 'Play'
|
||||||
|
let image
|
||||||
|
|
||||||
let play;
|
let datetime
|
||||||
let stop;
|
let timePeriod
|
||||||
let canDraw = false;
|
|
||||||
let showing = "Play";
|
|
||||||
let image;
|
|
||||||
|
|
||||||
let datetime;
|
return thisObject
|
||||||
let timePeriod;
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
play = new Image()
|
||||||
|
|
||||||
function initialize() {
|
play.onload = onImageLoad
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
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;
|
stop = new Image()
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
|
||||||
|
|
||||||
}
|
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 */
|
/* 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": {
|
break
|
||||||
image = stop;
|
}
|
||||||
showing = "Stop";
|
case 'Stop': {
|
||||||
|
image = play
|
||||||
|
showing = 'Play'
|
||||||
|
|
||||||
let UI_COMMANDS = {
|
cloudVM.onBotStopPressed()
|
||||||
beginDatetime: datetime,
|
|
||||||
endDatetime: undefined,
|
|
||||||
timePeriod: timePeriod,
|
|
||||||
startMode: window.CURRENT_START_MODE,
|
|
||||||
eventHandler: thisObject.container.eventHandler
|
|
||||||
};
|
|
||||||
|
|
||||||
cloudVM.onBotPlayPressed(UI_COMMANDS);
|
break
|
||||||
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Stop": {
|
|
||||||
image = play;
|
|
||||||
showing = "Play";
|
|
||||||
|
|
||||||
cloudVM.onBotStopPressed();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onZoomChanged(event) {
|
function onZoomChanged (event) {
|
||||||
|
timePeriod = recalculatePeriod(event.newLevel)
|
||||||
|
}
|
||||||
|
|
||||||
timePeriod = recalculatePeriod(event.newLevel);
|
function setDatetime (pDatetime) {
|
||||||
|
datetime = new Date(pDatetime)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
function setDatetime(pDatetime) {
|
|
||||||
|
|
||||||
datetime = new Date(pDatetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* 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 */
|
/* not logged in */
|
||||||
return;
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
+131
-155
@@ -1,219 +1,195 @@
|
|||||||
|
|
||||||
function newBreakpointsBar() {
|
|
||||||
|
|
||||||
var thisObject = {
|
function newBreakpointsBar () {
|
||||||
setDatetime: setDatetime,
|
var thisObject = {
|
||||||
container: undefined,
|
setDatetime: setDatetime,
|
||||||
draw: draw,
|
container: undefined,
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
draw: draw,
|
||||||
initialize: initialize
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
};
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var container = newContainer();
|
var container = newContainer()
|
||||||
container.initialize();
|
container.initialize()
|
||||||
thisObject.container = container;
|
thisObject.container = container
|
||||||
|
|
||||||
thisObject.container.frame.width = browserCanvasContext.width;
|
thisObject.container.frame.width = browserCanvasContext.width
|
||||||
thisObject.container.frame.height = 15;
|
thisObject.container.frame.height = 15
|
||||||
|
|
||||||
container.frame.position.x = 0;
|
container.frame.position.x = 0
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomRight.y;
|
container.frame.position.y = viewPort.visibleArea.bottomRight.y
|
||||||
|
|
||||||
container.isDraggeable = false;
|
container.isDraggeable = false
|
||||||
container.isClickeable = true;
|
container.isClickeable = true
|
||||||
|
|
||||||
let logo;
|
let logo
|
||||||
let canDrawLogo = false;
|
let canDrawLogo = false
|
||||||
|
|
||||||
let datetime;
|
let datetime
|
||||||
let timePeriod;
|
let timePeriod
|
||||||
let timeLineCoordinateSystem;
|
let timeLineCoordinateSystem
|
||||||
let chartContainer;
|
let chartContainer
|
||||||
|
|
||||||
let breakpointsByTimePeriod = new Map();
|
let breakpointsByTimePeriod = new Map()
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(pChartContainer, pTimeLineCoordinateSystem) {
|
function initialize (pChartContainer, pTimeLineCoordinateSystem) {
|
||||||
|
timeLineCoordinateSystem = pTimeLineCoordinateSystem
|
||||||
|
chartContainer = pChartContainer
|
||||||
|
|
||||||
timeLineCoordinateSystem = pTimeLineCoordinateSystem;
|
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
|
||||||
chartContainer = pChartContainer;
|
timePeriod = INITIAL_TIME_PERIOD
|
||||||
|
|
||||||
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
|
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||||
timePeriod = INITIAL_TIME_PERIOD;
|
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
||||||
|
let breakpointsMap = new Map()
|
||||||
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
breakpointsByTimePeriod.set(marketFilesPeriods[i][0], breakpointsMap)
|
||||||
|
|
||||||
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) {
|
for (let i = 0; i < dailyFilePeriods.length; i++) {
|
||||||
|
let breakpointsMap = new Map()
|
||||||
|
breakpointsByTimePeriod.set(dailyFilePeriods[i][0], breakpointsMap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let point = {
|
function onClick (pPoint) {
|
||||||
x: pPoint.x,
|
let point = {
|
||||||
y: pPoint.y
|
x: pPoint.x,
|
||||||
};
|
y: pPoint.y
|
||||||
|
}
|
||||||
|
|
||||||
let miliSeconds = getMilisecondsFromPoint(point, chartContainer, timeLineCoordinateSystem);
|
let miliSeconds = getMilisecondsFromPoint(point, chartContainer, timeLineCoordinateSystem)
|
||||||
|
|
||||||
miliSeconds = normalizeX(miliSeconds); // We are now exactly at the middle of the "candle" correspondind to the point clicked.
|
miliSeconds = normalizeX(miliSeconds) // We are now exactly at the middle of the "candle" correspondind to the point clicked.
|
||||||
|
|
||||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod);
|
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod)
|
||||||
let breakpoint = breakpointsMap.get(miliSeconds);
|
let breakpoint = breakpointsMap.get(miliSeconds)
|
||||||
|
|
||||||
if (breakpoint === undefined) {
|
|
||||||
|
|
||||||
|
if (breakpoint === undefined) {
|
||||||
/* The breakpoint didnt exist, then we create one. */
|
/* The breakpoint didnt exist, then we create one. */
|
||||||
breakpointsMap.set(miliSeconds, 1);
|
breakpointsMap.set(miliSeconds, 1)
|
||||||
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
/* The breakpoint existed, so we remove it. */
|
/* The breakpoint existed, so we remove it. */
|
||||||
breakpointsMap.set(miliSeconds, undefined);
|
breakpointsMap.set(miliSeconds, undefined)
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeX(pX) {
|
function normalizeX (pX) {
|
||||||
|
return Math.trunc(pX / timePeriod) * timePeriod + timePeriod / 2
|
||||||
|
}
|
||||||
|
|
||||||
return Math.trunc(pX / timePeriod) * timePeriod + timePeriod / 2;
|
function onZoomChanged (event) {
|
||||||
|
timePeriod = recalculatePeriod(event.newLevel)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function setDatetime (pDatetime) {
|
||||||
|
datetime = new Date(pDatetime)
|
||||||
|
}
|
||||||
|
|
||||||
function onZoomChanged(event) {
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
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. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function draw() {
|
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
|
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
|
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.
|
that exists.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod);
|
let breakpointsMap = breakpointsByTimePeriod.get(timePeriod)
|
||||||
|
|
||||||
let beginX = {
|
let beginX = {
|
||||||
x: viewPort.visibleArea.bottomLeft.x,
|
x: viewPort.visibleArea.bottomLeft.x,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
let endX = {
|
let endX = {
|
||||||
x: viewPort.visibleArea.bottomRight.x,
|
x: viewPort.visibleArea.bottomRight.x,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
let beginMiliseconds = getMilisecondsFromPoint(beginX, chartContainer, timeLineCoordinateSystem);
|
let beginMiliseconds = getMilisecondsFromPoint(beginX, chartContainer, timeLineCoordinateSystem)
|
||||||
let endMiliseconds = getMilisecondsFromPoint(endX, chartContainer, timeLineCoordinateSystem);
|
let endMiliseconds = getMilisecondsFromPoint(endX, chartContainer, timeLineCoordinateSystem)
|
||||||
|
|
||||||
beginMiliseconds = normalizeX(beginMiliseconds);
|
beginMiliseconds = normalizeX(beginMiliseconds)
|
||||||
endMiliseconds = normalizeX(endMiliseconds);
|
endMiliseconds = normalizeX(endMiliseconds)
|
||||||
|
|
||||||
window.AT_BREAKPOINT = false;
|
window.AT_BREAKPOINT = false
|
||||||
|
|
||||||
for (let miliSeconds = beginMiliseconds; miliSeconds < endMiliseconds; miliSeconds = miliSeconds + timePeriod) {
|
for (let miliSeconds = beginMiliseconds; miliSeconds < endMiliseconds; miliSeconds = miliSeconds + timePeriod) {
|
||||||
|
let breakpoint = breakpointsMap.get(miliSeconds)
|
||||||
|
|
||||||
let breakpoint = breakpointsMap.get(miliSeconds);
|
if (breakpoint !== undefined) {
|
||||||
|
let point1 = {
|
||||||
|
x: miliSeconds,
|
||||||
|
y: 0
|
||||||
|
}
|
||||||
|
|
||||||
if (breakpoint !== undefined) {
|
point1 = timeLineCoordinateSystem.transformThisPoint(point1)
|
||||||
|
point1 = transformThisPoint(point1, chartContainer)
|
||||||
|
|
||||||
let point1 = {
|
let point2 = {
|
||||||
x: miliSeconds,
|
x: miliSeconds,
|
||||||
y: 0
|
y: thisObject.container.frame.height / 2 + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
point1 = timeLineCoordinateSystem.transformThisPoint(point1);
|
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||||
point1 = transformThisPoint(point1, chartContainer);
|
|
||||||
|
|
||||||
let point2 = {
|
let point = {
|
||||||
x: miliSeconds,
|
x: point1.x,
|
||||||
y: thisObject.container.frame.height / 2 + 1
|
y: point2.y
|
||||||
}
|
}
|
||||||
|
|
||||||
point2 = thisObject.container.frame.frameThisPoint(point2);
|
let isCurrentRecord = false
|
||||||
|
|
||||||
let point = {
|
if (datetime !== undefined) {
|
||||||
x: point1.x,
|
let dateValue = datetime.valueOf()
|
||||||
y: point2.y
|
if (dateValue >= miliSeconds - timePeriod / 2 && dateValue <= miliSeconds + timePeriod / 2 - 1) {
|
||||||
}
|
isCurrentRecord = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let isCurrentRecord = false;
|
let radius = 5
|
||||||
|
|
||||||
if (datetime !== undefined) {
|
let opacity = '0.5'
|
||||||
let dateValue = datetime.valueOf();
|
|
||||||
if (dateValue >= miliSeconds - timePeriod / 2 && dateValue <= miliSeconds + timePeriod / 2 - 1) {
|
|
||||||
isCurrentRecord = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let radius = 5;
|
browserCanvasContext.lineWidth = 1
|
||||||
|
|
||||||
let opacity = '0.5';
|
|
||||||
|
|
||||||
browserCanvasContext.lineWidth = 1;
|
|
||||||
|
|
||||||
/* Outer Circle */
|
/* Outer Circle */
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.strokeStyle = 'rgba(123, 50, 40, ' + opacity + ')';
|
browserCanvasContext.strokeStyle = 'rgba(123, 50, 40, ' + opacity + ')'
|
||||||
|
|
||||||
if (isCurrentRecord === false) {
|
if (isCurrentRecord === false) {
|
||||||
browserCanvasContext.fillStyle = 'rgba(223, 70, 60, ' + opacity + ')';
|
browserCanvasContext.fillStyle = 'rgba(223, 70, 60, ' + opacity + ')'
|
||||||
} else {
|
} else {
|
||||||
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, ' + opacity + ')'; /* highlight the current record */
|
browserCanvasContext.fillStyle = 'rgba(255, 233, 31, ' + opacity + ')' /* highlight the current record */
|
||||||
|
|
||||||
window.AT_BREAKPOINT = true; // We are hitting a breakpoint!
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,17 +1,15 @@
|
|||||||
function newCandle() {
|
function newCandle () {
|
||||||
|
var candle = {
|
||||||
|
open: undefined,
|
||||||
|
close: undefined,
|
||||||
|
min: 10000000000000,
|
||||||
|
max: 0,
|
||||||
|
begin: undefined,
|
||||||
|
end: undefined,
|
||||||
|
direction: undefined,
|
||||||
|
beginId: undefined,
|
||||||
|
endId: undefined
|
||||||
|
}
|
||||||
|
|
||||||
var candle = {
|
return candle
|
||||||
open: undefined,
|
}
|
||||||
close: undefined,
|
|
||||||
min: 10000000000000,
|
|
||||||
max: 0,
|
|
||||||
begin: undefined,
|
|
||||||
end: undefined,
|
|
||||||
direction: undefined,
|
|
||||||
beginId: undefined,
|
|
||||||
endId: undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
return candle;
|
|
||||||
|
|
||||||
}
|
|
||||||
+105
-113
@@ -1,150 +1,142 @@
|
|||||||
|
|
||||||
|
|
||||||
function getSideDays(timePeriod) {
|
function getSideDays (timePeriod) {
|
||||||
|
let daysOnSides
|
||||||
|
|
||||||
let daysOnSides;
|
if (timePeriod < _1_HOUR_IN_MILISECONDS) {
|
||||||
|
daysOnSides = 1
|
||||||
|
}
|
||||||
|
|
||||||
if (timePeriod < _1_HOUR_IN_MILISECONDS) {
|
if (timePeriod === _1_HOUR_IN_MILISECONDS) {
|
||||||
daysOnSides = 1;
|
daysOnSides = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _1_HOUR_IN_MILISECONDS) {
|
if (timePeriod === _2_HOURS_IN_MILISECONDS) {
|
||||||
daysOnSides = 9;
|
daysOnSides = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _2_HOURS_IN_MILISECONDS) {
|
if (timePeriod === _3_HOURS_IN_MILISECONDS) {
|
||||||
daysOnSides = 10;
|
daysOnSides = 12
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _3_HOURS_IN_MILISECONDS) {
|
if (timePeriod === _4_HOURS_IN_MILISECONDS) {
|
||||||
daysOnSides = 12;
|
daysOnSides = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _4_HOURS_IN_MILISECONDS) {
|
if (timePeriod === _6_HOURS_IN_MILISECONDS) {
|
||||||
daysOnSides = 20;
|
daysOnSides = 35
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _6_HOURS_IN_MILISECONDS) {
|
if (timePeriod === _8_HOURS_IN_MILISECONDS) {
|
||||||
daysOnSides = 35;
|
daysOnSides = 44
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _8_HOURS_IN_MILISECONDS) {
|
if (timePeriod === _12_HOURS_IN_MILISECONDS) {
|
||||||
daysOnSides = 44;
|
daysOnSides = 56
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === _12_HOURS_IN_MILISECONDS) {
|
if (timePeriod === ONE_DAY_IN_MILISECONDS) {
|
||||||
daysOnSides = 56;
|
daysOnSides = 154
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePeriod === ONE_DAY_IN_MILISECONDS) {
|
return daysOnSides
|
||||||
daysOnSides = 154;
|
|
||||||
}
|
|
||||||
|
|
||||||
return daysOnSides;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCondenseFactor (timePeriod) {
|
||||||
function getCondenseFactor(timePeriod) {
|
switch (timePeriod) {
|
||||||
|
case _1_MINUTE_IN_MILISECONDS: return 1
|
||||||
switch (timePeriod) {
|
case _5_MINUTES_IN_MILISECONDS: return 5
|
||||||
case _1_MINUTE_IN_MILISECONDS: return 1;
|
case _10_MINUTES_IN_MILISECONDS: return 10
|
||||||
case _5_MINUTES_IN_MILISECONDS: return 5;
|
case _30_MINUTES_IN_MILISECONDS: return 50
|
||||||
case _10_MINUTES_IN_MILISECONDS: return 10;
|
case _1_HOUR_IN_MILISECONDS: return 100
|
||||||
case _30_MINUTES_IN_MILISECONDS: return 50;
|
}
|
||||||
case _1_HOUR_IN_MILISECONDS: return 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTransparenceFactor (timePeriod) {
|
||||||
function getTransparenceFactor(timePeriod) {
|
switch (timePeriod) {
|
||||||
|
case _1_MINUTE_IN_MILISECONDS: return '0.12'
|
||||||
switch (timePeriod) {
|
case _5_MINUTES_IN_MILISECONDS: return '0.10'
|
||||||
case _1_MINUTE_IN_MILISECONDS: return "0.12";
|
case _10_MINUTES_IN_MILISECONDS: return '0.08'
|
||||||
case _5_MINUTES_IN_MILISECONDS: return "0.10";
|
case _30_MINUTES_IN_MILISECONDS: return '0.06'
|
||||||
case _10_MINUTES_IN_MILISECONDS: return "0.08";
|
case _1_HOUR_IN_MILISECONDS: return '0.04'
|
||||||
case _30_MINUTES_IN_MILISECONDS: return "0.06";
|
}
|
||||||
case _1_HOUR_IN_MILISECONDS: return "0.04";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function recalculatePeriod (zoomLevel) {
|
||||||
|
// console.log(" recalculatePeriod > " + zoomLevel);
|
||||||
|
|
||||||
function recalculatePeriod(zoomLevel) {
|
if (zoomLevel > 200) {
|
||||||
|
return _1_MINUTE_IN_MILISECONDS
|
||||||
|
}
|
||||||
|
|
||||||
//console.log(" recalculatePeriod > " + zoomLevel);
|
if (zoomLevel > 120) {
|
||||||
|
return _2_MINUTES_IN_MILISECONDS
|
||||||
|
}
|
||||||
|
|
||||||
if (zoomLevel > 200) {
|
if (zoomLevel > 80) {
|
||||||
return _1_MINUTE_IN_MILISECONDS;
|
return _3_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > 120) {
|
if (zoomLevel > 60) {
|
||||||
return _2_MINUTES_IN_MILISECONDS;
|
return _4_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > 80) {
|
if (zoomLevel > 15) {
|
||||||
return _3_MINUTES_IN_MILISECONDS;
|
return _5_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > 60) {
|
if (zoomLevel > -7) {
|
||||||
return _4_MINUTES_IN_MILISECONDS;
|
return _10_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > 15) {
|
if (zoomLevel > -10) {
|
||||||
return _5_MINUTES_IN_MILISECONDS;
|
return _15_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 7) {
|
if (zoomLevel > -13) {
|
||||||
return _10_MINUTES_IN_MILISECONDS;
|
return _20_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 10) {
|
if (zoomLevel > -15) {
|
||||||
return _15_MINUTES_IN_MILISECONDS;
|
return _30_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 13) {
|
if (zoomLevel > -16) {
|
||||||
return _20_MINUTES_IN_MILISECONDS;
|
return _40_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 15) {
|
if (zoomLevel > -17) {
|
||||||
return _30_MINUTES_IN_MILISECONDS;
|
return _45_MINUTES_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 16) {
|
if (zoomLevel > -18) {
|
||||||
return _40_MINUTES_IN_MILISECONDS;
|
return _1_HOUR_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 17) {
|
if (zoomLevel > -24) {
|
||||||
return _45_MINUTES_IN_MILISECONDS;
|
return _2_HOURS_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 18) {
|
if (zoomLevel > -25) {
|
||||||
return _1_HOUR_IN_MILISECONDS;
|
return _3_HOURS_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 24) {
|
if (zoomLevel > -27) {
|
||||||
return _2_HOURS_IN_MILISECONDS;
|
return _4_HOURS_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 25) {
|
if (zoomLevel > -27.5) {
|
||||||
return _3_HOURS_IN_MILISECONDS;
|
return _6_HOURS_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 27) {
|
if (zoomLevel > -27.75) {
|
||||||
return _4_HOURS_IN_MILISECONDS;
|
return _8_HOURS_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 27.5) {
|
if (zoomLevel > -28) {
|
||||||
return _6_HOURS_IN_MILISECONDS;
|
return _12_HOURS_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 27.75) {
|
if (zoomLevel <= -28) {
|
||||||
return _8_HOURS_IN_MILISECONDS;
|
return ONE_DAY_IN_MILISECONDS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoomLevel > - 28) {
|
|
||||||
return _12_HOURS_IN_MILISECONDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zoomLevel <= - 28) {
|
|
||||||
return ONE_DAY_IN_MILISECONDS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+38
-50
@@ -1,61 +1,49 @@
|
|||||||
function newCloudRequire(bot, logger) {
|
function newCloudRequire (bot, logger) {
|
||||||
|
const INFO_LOG = true
|
||||||
|
const LOG_FILE_CONTENT = false
|
||||||
|
|
||||||
const INFO_LOG = true;
|
const MODULE_NAME = 'Cloud Require'
|
||||||
const LOG_FILE_CONTENT = false;
|
|
||||||
|
|
||||||
const MODULE_NAME = "Cloud Require";
|
let thisObject = {
|
||||||
|
downloadBot: downloadBot,
|
||||||
|
downloadCommons: downloadCommons
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
return thisObject
|
||||||
downloadBot: downloadBot,
|
|
||||||
downloadCommons: downloadCommons
|
|
||||||
};
|
|
||||||
|
|
||||||
return thisObject;
|
function downloadBot (pCloudStorage, pFilePath, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write(MODULE_NAME, '[INFO] downloadBot -> Entering function.') }
|
||||||
|
|
||||||
function downloadBot(pCloudStorage, pFilePath, callBackFunction) {
|
let filePath = window.canvasApp.urlPrefix + 'Bots' + '/' + pFilePath + '/' + 'User.Bot.js'
|
||||||
|
|
||||||
try {
|
downloadModule(filePath, onDownloaded)
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write(MODULE_NAME, "[INFO] downloadBot -> Entering function."); }
|
function onDownloaded (pModule) {
|
||||||
|
callBackFunction(window.DEFAULT_OK_RESPONSE, pModule)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.write(MODULE_NAME, '[ERROR] downloadBot -> err = ' + err.message)
|
||||||
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let filePath = window.canvasApp.urlPrefix + "Bots" + "/" + pFilePath + "/" + "User.Bot.js";
|
function downloadCommons (pCloudStorage, pFilePath, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write(MODULE_NAME, '[INFO] downloadCommons -> Entering function.') }
|
||||||
|
|
||||||
downloadModule(filePath, onDownloaded)
|
let filePath = window.canvasApp.urlPrefix + 'Bots' + '/' + pFilePath + '/' + 'Commons.js'
|
||||||
|
|
||||||
function onDownloaded(pModule) {
|
downloadModule(filePath, onDownloaded)
|
||||||
|
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, pModule);
|
function onDownloaded (pModule) {
|
||||||
return;
|
callBackFunction(window.DEFAULT_OK_RESPONSE, pModule)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
} catch (err) {
|
logger.write(MODULE_NAME, '[ERROR] downloadCommons -> err = ' + err.message)
|
||||||
logger.write(MODULE_NAME, "[ERROR] downloadBot -> err = " + err.message);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function downloadCommons(pCloudStorage, pFilePath, callBackFunction) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write(MODULE_NAME, "[INFO] downloadCommons -> Entering function."); }
|
|
||||||
|
|
||||||
let filePath = window.canvasApp.urlPrefix + "Bots" + "/" + pFilePath + "/" + "Commons.js";
|
|
||||||
|
|
||||||
downloadModule(filePath, onDownloaded)
|
|
||||||
|
|
||||||
function onDownloaded(pModule) {
|
|
||||||
|
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, pModule);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
logger.write(MODULE_NAME, "[ERROR] downloadCommons -> err = " + err.message);
|
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
+102
-124
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This module is for enabling the AACloud to run at the browser.
|
This module is for enabling the AACloud to run at the browser.
|
||||||
@@ -7,137 +7,115 @@ When running at the clode on NodeJS some things work diffently that at the brows
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function webRequire(pModulePath) {
|
function webRequire (pModulePath) {
|
||||||
|
switch (pModulePath) {
|
||||||
|
|
||||||
switch (pModulePath) {
|
case './AzureStorage': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newAzureStorage = newAzureStorage
|
||||||
|
return MODULE
|
||||||
|
|
||||||
case './AzureStorage': {
|
function newAzureStorage () {
|
||||||
|
return AzureStorage.Blob
|
||||||
let MODULE = {};
|
}
|
||||||
MODULE.newAzureStorage = newAzureStorage;
|
|
||||||
return MODULE;
|
|
||||||
|
|
||||||
function newAzureStorage() {
|
|
||||||
|
|
||||||
return AzureStorage.Blob;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case './EventHandler': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newEventHandler = newEventHandler;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './BlobStorage': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newBlobStorage = newBlobStorage;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './DebugLog': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newDebugLog = newDebugLog;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './TradingBotProcessMainLoop': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newTradingBotProcessMainLoop = newTradingBotProcessMainLoop;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './ExtractionBotProcessMainLoop': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newExtractionBotProcessMainLoop = newExtractionBotProcessMainLoop;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './IndicatorBotProcessMainLoop': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newIndicatorBotProcessMainLoop = newIndicatorBotProcessMainLoop;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './CloudUtilities': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newCloudUtilities = newCloudUtilities;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './PoloniexAPIClient': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newPoloniexAPIClient = newPoloniexAPIClient;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './Exchange/ExchangeAPI': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newExchangeAPI = newExchangeAPI;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './Context': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newContext = newContext;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './Assistant': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newAssistant = newAssistant;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './StatusReport': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newStatusReport = newStatusReport;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './DataSet': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newDataSet = newDataSet;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './StatusDependencies': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newStatusDependencies = newStatusDependencies;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './DataDependencies': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newDataDependencies = newDataDependencies;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
case './CloudRequire': {
|
|
||||||
|
|
||||||
let MODULE = {};
|
|
||||||
MODULE.newCloudRequire = newCloudRequire;
|
|
||||||
return MODULE;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
console.log(pModulePath + " not found. ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case './EventHandler': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newEventHandler = newEventHandler
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './BlobStorage': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newBlobStorage = newBlobStorage
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './DebugLog': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newDebugLog = newDebugLog
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './TradingBotProcessMainLoop': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newTradingBotProcessMainLoop = newTradingBotProcessMainLoop
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './ExtractionBotProcessMainLoop': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newExtractionBotProcessMainLoop = newExtractionBotProcessMainLoop
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './IndicatorBotProcessMainLoop': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newIndicatorBotProcessMainLoop = newIndicatorBotProcessMainLoop
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './CloudUtilities': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newCloudUtilities = newCloudUtilities
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './PoloniexAPIClient': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newPoloniexAPIClient = newPoloniexAPIClient
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './Exchange/ExchangeAPI': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newExchangeAPI = newExchangeAPI
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './Context': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newContext = newContext
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './Assistant': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newAssistant = newAssistant
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './StatusReport': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newStatusReport = newStatusReport
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './DataSet': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newDataSet = newDataSet
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './StatusDependencies': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newStatusDependencies = newStatusDependencies
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './DataDependencies': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newDataDependencies = newDataDependencies
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
case './CloudRequire': {
|
||||||
|
let MODULE = {}
|
||||||
|
MODULE.newCloudRequire = newCloudRequire
|
||||||
|
return MODULE
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
console.log(pModulePath + ' not found. ')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadModule(pPath, callBackFunction) {
|
function downloadModule (pPath, callBackFunction) {
|
||||||
|
|
||||||
/* We will need this to load individual bots modules. */
|
/* We will need this to load individual bots modules. */
|
||||||
|
|
||||||
REQUIREJS([pPath], onRequired);
|
REQUIREJS([pPath], onRequired)
|
||||||
|
|
||||||
function onRequired(pModule) {
|
function onRequired (pModule) {
|
||||||
|
console.log('CloudVM ' + pPath + ' downloaded.')
|
||||||
|
|
||||||
console.log("CloudVM " + pPath + " downloaded.");
|
let MODULE = {}
|
||||||
|
MODULE.newUserBot = newUserBot
|
||||||
let MODULE = {};
|
callBackFunction(MODULE)
|
||||||
MODULE.newUserBot = newUserBot;
|
}
|
||||||
callBackFunction(MODULE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+107
-130
@@ -1,152 +1,129 @@
|
|||||||
|
|
||||||
function newCloudVM() {
|
function newCloudVM () {
|
||||||
|
const MODULE_NAME = 'CloudVM'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "CloudVM";
|
var thisObject = {
|
||||||
const INFO_LOG = false;
|
onBotPlayPressed: onBotPlayPressed,
|
||||||
const ERROR_LOG = true;
|
onBotStopPressed: onBotStopPressed
|
||||||
const logger = newWebDebugLog();
|
}
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
var thisObject = {
|
let root = newRoot()
|
||||||
onBotPlayPressed: onBotPlayPressed,
|
let intervalHandler
|
||||||
onBotStopPressed: onBotStopPressed
|
let previousBotCode = ''
|
||||||
};
|
let errorsCheckingForBotCodeChanges = 0
|
||||||
|
|
||||||
let root = newRoot();
|
return thisObject
|
||||||
let intervalHandler;
|
|
||||||
let previousBotCode = "";
|
|
||||||
let errorsCheckingForBotCodeChanges = 0;
|
|
||||||
|
|
||||||
return thisObject;
|
function onBotPlayPressed (pUI_COMMANDS) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onBotPlayPressed -> Entering function.') }
|
||||||
|
|
||||||
function onBotPlayPressed(pUI_COMMANDS) {
|
window.SHALL_BOT_STOP = false
|
||||||
|
errorsCheckingForBotCodeChanges = 0
|
||||||
|
|
||||||
try {
|
window.CURRENT_ENVIRONMENT = 'Develop'
|
||||||
|
window.CURRENT_EXECUTION_AT = 'Browser'
|
||||||
|
window.STORAGE_PERMISSIONS = ecosystem.getStoragePermissions()
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onBotPlayPressed -> Entering function."); }
|
window.EXCHANGE_NAME = 'Poloniex'
|
||||||
|
window.MARKET = {
|
||||||
window.SHALL_BOT_STOP = false;
|
assetA: 'USDT',
|
||||||
errorsCheckingForBotCodeChanges = 0;
|
assetB: 'BTC'
|
||||||
|
}
|
||||||
window.CURRENT_ENVIRONMENT = "Develop";
|
|
||||||
window.CURRENT_EXECUTION_AT = "Browser";
|
|
||||||
window.STORAGE_PERMISSIONS = ecosystem.getStoragePermissions();
|
|
||||||
|
|
||||||
window.EXCHANGE_NAME = "Poloniex";
|
|
||||||
window.MARKET = {
|
|
||||||
assetA: "USDT",
|
|
||||||
assetB: "BTC"
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
When running at the browser, the AACloud VM will look for this data, in this case it does not contain any key or secret, since the browser only know the
|
When running at the browser, the AACloud VM will look for this data, in this case it does not contain any key or secret, since the browser only know the
|
||||||
session token the user received when he logged in.
|
session token the user received when he logged in.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.EXCHANGE_KEYS = {
|
window.EXCHANGE_KEYS = {
|
||||||
Poloniex: {
|
Poloniex: {
|
||||||
Key: "",
|
Key: '',
|
||||||
Secret: ""
|
Secret: ''
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
root.initialize(pUI_COMMANDS, onInitialized);
|
|
||||||
|
|
||||||
function onInitialized() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onBotPlayPressed -> Entering function."); }
|
|
||||||
|
|
||||||
root.start();
|
|
||||||
|
|
||||||
intervalHandler = setInterval(checkForChangesInBotCode, 10000);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] onBotPlayPressed -> onInitialized -> err.message = " + err.message); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] onBotPlayPressed -> err.message = " + err.message); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBotStopPressed() {
|
root.initialize(pUI_COMMANDS, onInitialized)
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onBotStopPressed -> Entering function."); }
|
|
||||||
|
|
||||||
window.SHALL_BOT_STOP = true;
|
|
||||||
errorsCheckingForBotCodeChanges = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForChangesInBotCode() {
|
|
||||||
|
|
||||||
|
function onInitialized () {
|
||||||
try {
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onBotPlayPressed -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> Entering function."); }
|
root.start()
|
||||||
|
|
||||||
let botFunction = newUserBot;
|
|
||||||
|
|
||||||
if (botFunction !== undefined) {
|
|
||||||
|
|
||||||
let currentBotCode = botFunction.toString();
|
|
||||||
|
|
||||||
if (previousBotCode !== "") {
|
|
||||||
|
|
||||||
if (currentBotCode !== previousBotCode) {
|
|
||||||
|
|
||||||
console.log("CloudVM -> Bot code changes detected.");
|
|
||||||
|
|
||||||
let path = window.canvasApp.urlPrefix
|
|
||||||
+ "AABrowserAPI" + "/"
|
|
||||||
+ "saveBotCode" + "/"
|
|
||||||
+ window.DEV_TEAM + "/"
|
|
||||||
+ "members" + "/"
|
|
||||||
+ window.USER_LOGGED_IN + "/"
|
|
||||||
+ window.CURRENT_BOT_REPO + "/"
|
|
||||||
+ window.CURRENT_PROCESS + "/"
|
|
||||||
+ "User.Bot.js"
|
|
||||||
;
|
|
||||||
|
|
||||||
callServer(currentBotCode, path, onServerResponse);
|
|
||||||
|
|
||||||
function onServerResponse(err) {
|
|
||||||
|
|
||||||
err = JSON.parse(err);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> onServerResponse -> Entering function."); }
|
|
||||||
|
|
||||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] checkForChangesInBotCode -> onServerResponse -> err.message = " + err.message); }
|
|
||||||
console.log("CloudVM -> Changes in code NOT saved. Plase check the error log and try again.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("CloudVM -> Changes in code saved.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
previousBotCode = currentBotCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
intervalHandler = setInterval(checkForChangesInBotCode, 10000)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] onBotPlayPressed -> onInitialized -> err.message = ' + err.message) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] checkForChangesInBotCode -> err.message = " + err.message); }
|
|
||||||
errorsCheckingForBotCodeChanges++;
|
|
||||||
|
|
||||||
if (errorsCheckingForBotCodeChanges > 2) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] checkForChangesInBotCode -> Giving up."); }
|
|
||||||
|
|
||||||
clearInterval(intervalHandler);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] onBotPlayPressed -> err.message = ' + err.message) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onBotStopPressed () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onBotStopPressed -> Entering function.') }
|
||||||
|
|
||||||
|
window.SHALL_BOT_STOP = true
|
||||||
|
errorsCheckingForBotCodeChanges = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkForChangesInBotCode () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] checkForChangesInBotCode -> Entering function.') }
|
||||||
|
|
||||||
|
let botFunction = newUserBot
|
||||||
|
|
||||||
|
if (botFunction !== undefined) {
|
||||||
|
let currentBotCode = botFunction.toString()
|
||||||
|
|
||||||
|
if (previousBotCode !== '') {
|
||||||
|
if (currentBotCode !== previousBotCode) {
|
||||||
|
console.log('CloudVM -> Bot code changes detected.')
|
||||||
|
|
||||||
|
let path = window.canvasApp.urlPrefix
|
||||||
|
+ 'AABrowserAPI' + '/'
|
||||||
|
+ 'saveBotCode' + '/'
|
||||||
|
+ window.DEV_TEAM + '/'
|
||||||
|
+ 'members' + '/'
|
||||||
|
+ window.USER_LOGGED_IN + '/'
|
||||||
|
+ window.CURRENT_BOT_REPO + '/'
|
||||||
|
+ window.CURRENT_PROCESS + '/'
|
||||||
|
+ 'User.Bot.js'
|
||||||
|
|
||||||
|
callServer(currentBotCode, path, onServerResponse)
|
||||||
|
|
||||||
|
function onServerResponse (err) {
|
||||||
|
err = JSON.parse(err)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] checkForChangesInBotCode -> onServerResponse -> Entering function.') }
|
||||||
|
|
||||||
|
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] checkForChangesInBotCode -> onServerResponse -> err.message = ' + err.message) }
|
||||||
|
console.log('CloudVM -> Changes in code NOT saved. Plase check the error log and try again.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('CloudVM -> Changes in code saved.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
previousBotCode = currentBotCode
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] checkForChangesInBotCode -> err.message = ' + err.message) }
|
||||||
|
errorsCheckingForBotCodeChanges++
|
||||||
|
|
||||||
|
if (errorsCheckingForBotCodeChanges > 2) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] checkForChangesInBotCode -> Giving up.') }
|
||||||
|
|
||||||
|
clearInterval(intervalHandler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
-48
@@ -1,71 +1,64 @@
|
|||||||
function newWebFS() {
|
function newWebFS () {
|
||||||
|
const MODULE_NAME = 'Web FS'
|
||||||
const MODULE_NAME = "Web FS";
|
const INFO_LOG = false
|
||||||
const INFO_LOG = false;
|
const ERROR_LOG = true
|
||||||
const ERROR_LOG = true;
|
const logger = newWebDebugLog()
|
||||||
const logger = newWebDebugLog();
|
logger.fileName = MODULE_NAME
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This is the module emulates the NodeJS 'fs'.
|
This is the module emulates the NodeJS 'fs'.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var thisObject = {
|
var thisObject = {
|
||||||
readFileSync: readFileSync,
|
readFileSync: readFileSync,
|
||||||
appendFileSync: appendFileSync,
|
appendFileSync: appendFileSync,
|
||||||
mkdirSync: mkdirSync,
|
mkdirSync: mkdirSync,
|
||||||
statSync: statSync,
|
statSync: statSync,
|
||||||
readdir: readdir,
|
readdir: readdir,
|
||||||
readdirSync: readdirSync,
|
readdirSync: readdirSync,
|
||||||
readFile: readFile
|
readFile: readFile
|
||||||
};
|
}
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function readFileSync (pPath, pEncoding) {
|
||||||
|
switch (pPath) {
|
||||||
|
|
||||||
function readFileSync(pPath, pEncoding) {
|
case '': {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (pPath) {
|
function appendFileSync (pPath, pText) {
|
||||||
|
|
||||||
case '': {
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendFileSync(pPath, pText) {
|
|
||||||
|
|
||||||
/* We will ignore this since we can not and dont want to really write something on disk while we are at the browser. */
|
/* We will ignore this since we can not and dont want to really write something on disk while we are at the browser. */
|
||||||
}
|
}
|
||||||
|
|
||||||
function readdir(pPath, callBackFunction) {
|
|
||||||
|
|
||||||
|
function readdir (pPath, callBackFunction) {
|
||||||
/* We will return an empty array of files. */
|
/* We will return an empty array of files. */
|
||||||
callBackFunction([]);
|
callBackFunction([])
|
||||||
}
|
}
|
||||||
|
|
||||||
function readdirSync(pPath, callBackFunction) {
|
function readdirSync (pPath, callBackFunction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function mkdirSync (pPath) {
|
||||||
|
|
||||||
function mkdirSync(pPath) {
|
|
||||||
|
|
||||||
/* Again we do nothing. */
|
/* Again we do nothing. */
|
||||||
}
|
}
|
||||||
|
|
||||||
function readFile(pPath) {
|
function readFile (pPath) {
|
||||||
|
|
||||||
/* Again we do nothing. */
|
/* Again we do nothing. */
|
||||||
}
|
}
|
||||||
|
|
||||||
function statSync(pPath) {
|
function statSync (pPath) {
|
||||||
|
let stats
|
||||||
let stats
|
stats.size = 0
|
||||||
stats.size = 0;
|
return stats
|
||||||
return stats
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+108
-132
@@ -1,160 +1,136 @@
|
|||||||
|
|
||||||
function newCompetitionStorage(pName) {
|
function newCompetitionStorage (pName) {
|
||||||
|
const MODULE_NAME = 'Competition Storage'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Competition Storage";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
|
||||||
const ERROR_LOG = true;
|
|
||||||
const logger = newWebDebugLog();
|
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
let thisObject = {
|
competitorsSequences: [],
|
||||||
|
eventHandler: undefined,
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
competitorsSequences: [],
|
}
|
||||||
eventHandler: undefined,
|
|
||||||
initialize: initialize
|
|
||||||
|
|
||||||
}
|
thisObject.eventHandler = newEventHandler()
|
||||||
|
|
||||||
thisObject.eventHandler = newEventHandler();
|
|
||||||
|
|
||||||
/* We name the event Handler to easy debugging. */
|
/* We name the event Handler to easy debugging. */
|
||||||
|
|
||||||
thisObject.eventHandler.name = "Storage-" + pName;
|
thisObject.eventHandler.name = 'Storage-' + pName
|
||||||
|
|
||||||
let fileSequences = [];
|
let fileSequences = []
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(pHost, pCompetition, pExchange, pMarket, callBackFunction) {
|
function initialize (pHost, pCompetition, pExchange, pMarket, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pHost.codeName + '-' + pCompetition.codeName) }
|
||||||
|
|
||||||
try {
|
let dataSetsToLoad = 0
|
||||||
|
let dataSetsLoaded = 0
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
fileSequences = []
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + pHost.codeName + "-" + pCompetition.codeName); }
|
|
||||||
|
|
||||||
let dataSetsToLoad = 0;
|
for (let j = 0; j < pCompetition.participants.length; j++) {
|
||||||
let dataSetsLoaded = 0;
|
let devTeam = ecosystem.getTeam(pCompetition.participants[j].devTeam)
|
||||||
|
let bot = ecosystem.getBot(devTeam, pCompetition.participants[j].bot)
|
||||||
|
let product = ecosystem.getProduct(bot, 'Competition Trading History')
|
||||||
|
|
||||||
fileSequences = [];
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
|
||||||
|
|
||||||
for (let j = 0; j < pCompetition.participants.length; j++) {
|
for (let i = 0; i < product.dataSets.length; i++) {
|
||||||
|
let thisSet = product.dataSets[i]
|
||||||
|
|
||||||
let devTeam = ecosystem.getTeam(pCompetition.participants[j].devTeam);
|
switch (thisSet.type) {
|
||||||
let bot = ecosystem.getBot(devTeam, pCompetition.participants[j].bot)
|
case 'File Sequence': {
|
||||||
let product = ecosystem.getProduct(bot, "Competition Trading History");
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> File Sequence -> key = ' + pHost.codeName + '-' + pCompetition.codeName + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName); }
|
let fileSequence = newFileSequence()
|
||||||
|
fileSequence.initialize(devTeam, bot, product, thisSet, pExchange, pMarket, onFileSequenceReady)
|
||||||
|
fileSequences.push(fileSequence)
|
||||||
|
dataSetsToLoad++
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < product.dataSets.length; i++) {
|
function onFileSequenceReady (err, pCaller) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> key = ' + pHost.codeName + '-' + pCompetition.codeName + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
|
||||||
|
|
||||||
let thisSet = product.dataSets[i];
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
switch (thisSet.type) {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received OK Response.') }
|
||||||
case 'File Sequence': {
|
break
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> File Sequence -> key = " + pHost.codeName + "-" + pCompetition.codeName + "-" + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName); }
|
|
||||||
|
|
||||||
let fileSequence = newFileSequence();
|
|
||||||
fileSequence.initialize(devTeam, bot, product, thisSet, pExchange, pMarket, onFileSequenceReady);
|
|
||||||
fileSequences.push(fileSequence);
|
|
||||||
dataSetsToLoad++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onFileSequenceReady(err, pCaller) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> key = " + pHost.codeName + "-" + pCompetition.codeName + "-" + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> err.message = " + err.message); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> This bot has not starting competing yet."); }
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
totalValue: pCaller.getExpectedFiles(),
|
|
||||||
currentValue: pCaller.getFilesLoaded()
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent('File Sequence Loaded', event);
|
|
||||||
|
|
||||||
if (event.currentValue === event.totalValue) {
|
|
||||||
|
|
||||||
dataSetsLoaded++;
|
|
||||||
|
|
||||||
checkInitializeComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileSequenceReady -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkInitializeComplete() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] checkInitializeComplete -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] checkInitializeComplete -> key = " + pHost.codeName + "-" + pCompetition.codeName + "-" + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName); }
|
|
||||||
|
|
||||||
if (dataSetsLoaded === dataSetsToLoad) {
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> checkInitializeComplete -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> err.message = ' + err.message) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> This bot has not starting competing yet.') }
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let event = {
|
||||||
|
totalValue: pCaller.getExpectedFiles(),
|
||||||
|
currentValue: pCaller.getFilesLoaded()
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('File Sequence Loaded', event)
|
||||||
|
|
||||||
|
if (event.currentValue === event.totalValue) {
|
||||||
|
dataSetsLoaded++
|
||||||
|
|
||||||
|
checkInitializeComplete()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileSequenceReady -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.competitorsSequences.push(fileSequences);
|
function checkInitializeComplete () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] checkInitializeComplete -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] checkInitializeComplete -> key = ' + pHost.codeName + '-' + pCompetition.codeName + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
|
||||||
|
|
||||||
if (pCompetition.participants.length === 0) { //If there are no competitions, respond OK
|
if (dataSetsLoaded === dataSetsToLoad) {
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> checkInitializeComplete -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thisObject.competitorsSequences.push(fileSequences)
|
||||||
|
|
||||||
|
if (pCompetition.participants.length === 0) { // If there are no competitions, respond OK
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+27
-31
@@ -1,36 +1,32 @@
|
|||||||
|
|
||||||
|
|
||||||
function newContainer() {
|
function newContainer () {
|
||||||
|
var container = {
|
||||||
|
frame: undefined,
|
||||||
|
displacement: undefined,
|
||||||
|
eventHandler: undefined,
|
||||||
|
parentContainer: undefined,
|
||||||
|
isDraggeable: true,
|
||||||
|
isClickeable: false,
|
||||||
|
isWheelable: false,
|
||||||
|
name: undefined,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var container = {
|
return container
|
||||||
frame: undefined,
|
|
||||||
displacement: undefined,
|
|
||||||
eventHandler: undefined,
|
|
||||||
parentContainer: undefined,
|
|
||||||
isDraggeable: true,
|
|
||||||
isClickeable: false,
|
|
||||||
isWheelable: false,
|
|
||||||
name: undefined,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
return container;
|
function initialize () {
|
||||||
|
var frame = newFrame()
|
||||||
|
frame.initialize()
|
||||||
|
this.frame = frame
|
||||||
|
frame.container = container
|
||||||
|
|
||||||
function initialize() {
|
var eventHandler = newEventHandler()
|
||||||
|
eventHandler.initialize()
|
||||||
|
eventHandler.name = container.name
|
||||||
|
this.eventHandler = eventHandler
|
||||||
|
|
||||||
var frame = newFrame();
|
var displacement = newDisplacement()
|
||||||
frame.initialize();
|
this.displacement = displacement
|
||||||
this.frame = frame;
|
displacement.container = container
|
||||||
frame.container = container;
|
}
|
||||||
|
}
|
||||||
var eventHandler = newEventHandler();
|
|
||||||
eventHandler.initialize();
|
|
||||||
eventHandler.name = container.name;
|
|
||||||
this.eventHandler = eventHandler;
|
|
||||||
|
|
||||||
var displacement = newDisplacement();
|
|
||||||
this.displacement = displacement;
|
|
||||||
displacement.container = container;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+126
-165
@@ -1,133 +1,105 @@
|
|||||||
|
|
||||||
let canvas;
|
let canvas
|
||||||
let markets;
|
let markets
|
||||||
let ecosystem = newEcosystem();
|
let ecosystem = newEcosystem()
|
||||||
let cloudVM = newCloudVM();
|
let cloudVM = newCloudVM()
|
||||||
let INITIAL_ZOOM_LEVEL = -26; // This is the zoom level at the view port in which the APP starts.
|
let INITIAL_ZOOM_LEVEL = -26 // This is the zoom level at the view port in which the APP starts.
|
||||||
let INITIAL_TIME_PERIOD = recalculatePeriod(INITIAL_ZOOM_LEVEL); // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser.
|
let INITIAL_TIME_PERIOD = recalculatePeriod(INITIAL_ZOOM_LEVEL) // This value will be overwritten at the viewPort.initialize if the user had a prevous session with this same browser.
|
||||||
let viewPort = newViewPort();
|
let viewPort = newViewPort()
|
||||||
|
|
||||||
function newDashboard() {
|
function newDashboard () {
|
||||||
|
const MODULE_NAME = 'Dashboard'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const INTENSIVE_LOG = false
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Dashboard";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
start: start
|
||||||
const ERROR_LOG = true;
|
}
|
||||||
const INTENSIVE_LOG = false;
|
|
||||||
const logger = newWebDebugLog();
|
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
let thisObject = {
|
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.
|
||||||
start: start
|
|
||||||
};
|
|
||||||
|
|
||||||
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.
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function start () {
|
||||||
|
try {
|
||||||
function start() {
|
if (INFO_LOG === true) { logger.write('[INFO] start -> Entering function.') }
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] start -> Entering function."); }
|
|
||||||
|
|
||||||
/* Here we will setup the global eventHandler that will enable the Canvas App to react to events happening outside its execution scope. */
|
/* 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 = newEventHandler()
|
||||||
window.canvasApp.eventHandler.listenToEvent("User Profile Changed", userProfileChanged);
|
window.canvasApp.eventHandler.listenToEvent('User Profile Changed', userProfileChanged)
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", browserResized);
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', browserResized)
|
||||||
|
|
||||||
loadImages(onImagesLoaded);
|
loadImages(onImagesLoaded)
|
||||||
|
|
||||||
function onImagesLoaded() {
|
function onImagesLoaded () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] start -> onImagesLoaded -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] start -> onImagesLoaded -> Entering function."); }
|
/* Next we start the App */
|
||||||
|
|
||||||
/* Next we start the App*/
|
setTimeout(delayedStart, DEBUG_START_UP_DELAY)
|
||||||
|
}
|
||||||
setTimeout(delayedStart, DEBUG_START_UP_DELAY);
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] start -> err = ' + err) }
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] start -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delayedStart () {
|
||||||
function delayedStart() {
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] delayedStart -> Entering function.') }
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] delayedStart -> Entering function."); }
|
|
||||||
|
|
||||||
/* For now, we are supporting only one market. */
|
/* For now, we are supporting only one market. */
|
||||||
|
|
||||||
let market = {
|
let market = {
|
||||||
id: 2,
|
id: 2,
|
||||||
assetA: "USDT",
|
assetA: 'USDT',
|
||||||
assetB: "BTC"
|
assetB: 'BTC'
|
||||||
};
|
}
|
||||||
|
|
||||||
markets = new Map();
|
markets = new Map()
|
||||||
|
|
||||||
markets.set(market.id, market);
|
markets.set(market.id, market)
|
||||||
|
|
||||||
canvas = newCanvas();
|
canvas = newCanvas()
|
||||||
canvas.initialize();
|
canvas.initialize()
|
||||||
|
} catch (err) {
|
||||||
} catch (err) {
|
if (ERROR_LOG === true) { logger.write('[ERROR] delayedStart -> err = ' + err) }
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] delayedStart -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function userProfileChanged() {
|
function userProfileChanged () {
|
||||||
|
try {
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] userProfileChanged -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] userProfileChanged -> Entering function."); }
|
|
||||||
|
|
||||||
canvas.topSpace.initialize();
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] userProfileChanged -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
canvas.topSpace.initialize()
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] userProfileChanged -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function browserResized() {
|
function browserResized () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] browserResized -> Entering function.') }
|
||||||
|
|
||||||
try {
|
browserCanvas = document.getElementById('canvas')
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] browserResized -> Entering function."); }
|
browserCanvas.width = window.innerWidth
|
||||||
|
browserCanvas.height = window.innerHeight - window.canvasApp.topMargin
|
||||||
browserCanvas = document.getElementById('canvas');
|
|
||||||
|
|
||||||
browserCanvas.width = window.innerWidth;
|
|
||||||
browserCanvas.height = window.innerHeight - window.canvasApp.topMargin;
|
|
||||||
|
|
||||||
viewPort.initialize();
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] browserResized -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
viewPort.initialize()
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] browserResized -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadImages(callBack) {
|
function loadImages (callBack) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] loadImages -> Entering function.') }
|
||||||
|
|
||||||
try {
|
const accessToken = ''
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] loadImages -> Entering function."); }
|
|
||||||
|
|
||||||
const accessToken = "";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Soon, we will need to get images from the Financial Beings Module. I live this core here as a sample for that:
|
Soon, we will need to get images from the Financial Beings Module. I live this core here as a sample for that:
|
||||||
@@ -187,25 +159,25 @@ function newDashboard() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const networkInterfaceTeams = Apollo.lib.createNetworkInterface({
|
const networkInterfaceTeams = Apollo.lib.createNetworkInterface({
|
||||||
uri: window.canvasApp.graphQL.masterAppApiUrl
|
uri: window.canvasApp.graphQL.masterAppApiUrl
|
||||||
});
|
})
|
||||||
|
|
||||||
networkInterfaceTeams.use([{
|
networkInterfaceTeams.use([{
|
||||||
applyMiddleware(req, next) {
|
applyMiddleware (req, next) {
|
||||||
req.options.headers = {
|
req.options.headers = {
|
||||||
authorization: `Bearer ${accessToken}`
|
authorization: `Bearer ${accessToken}`
|
||||||
};
|
}
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
}]);
|
}])
|
||||||
|
|
||||||
const apolloClientTeams = new Apollo.lib.ApolloClient({
|
|
||||||
networkInterface: networkInterfaceTeams,
|
|
||||||
connectToDevTools: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ALL_TEAMS_QUERY = Apollo.gql`
|
const apolloClientTeams = new Apollo.lib.ApolloClient({
|
||||||
|
networkInterface: networkInterfaceTeams,
|
||||||
|
connectToDevTools: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const ALL_TEAMS_QUERY = Apollo.gql`
|
||||||
{
|
{
|
||||||
teams_Teams{
|
teams_Teams{
|
||||||
edges{
|
edges{
|
||||||
@@ -238,70 +210,59 @@ function newDashboard() {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
let teams;
|
let teams
|
||||||
|
|
||||||
const getTeams = () => {
|
const getTeams = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
apolloClientTeams.query({
|
apolloClientTeams.query({
|
||||||
query: ALL_TEAMS_QUERY
|
query: ALL_TEAMS_QUERY
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
teams = response.data.teams_Teams;
|
teams = response.data.teams_Teams
|
||||||
window.localStorage.setItem('Teams', JSON.stringify(response.data.teams_Teams));
|
window.localStorage.setItem('Teams', JSON.stringify(response.data.teams_Teams))
|
||||||
resolve({ teams: response.data.teams_Teams })
|
resolve({ teams: response.data.teams_Teams })
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] loadImages -> getTeams -> Error fetching data from Teams Module."); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] loadImages -> getTeams -> Error fetching data from Teams Module.') }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] loadImages -> getTeams -> err = " + err); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] loadImages -> getTeams -> err = ' + err) }
|
||||||
reject(err)
|
reject(err)
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// To avoid race conditions, add asynchronous fetches to array
|
// To avoid race conditions, add asynchronous fetches to array
|
||||||
let fetchDataPromises = [];
|
let fetchDataPromises = []
|
||||||
|
|
||||||
fetchDataPromises.push(/*getUser(),*/ getTeams()); // <-- Here we must add the function calll to the Financial Beings module.
|
fetchDataPromises.push(/* getUser(), */ getTeams()) // <-- Here we must add the function calll to the Financial Beings module.
|
||||||
|
|
||||||
// When all asynchronous fetches resolve, authenticate user or throw error.
|
// When all asynchronous fetches resolve, authenticate user or throw error.
|
||||||
Promise.all(fetchDataPromises).then(result => {
|
Promise.all(fetchDataPromises).then(result => {
|
||||||
|
|
||||||
/* All good, we will go through the results creating a map with all the Images URLs */
|
/* All good, we will go through the results creating a map with all the Images URLs */
|
||||||
|
|
||||||
let teamProfileImages = new Map();
|
let teamProfileImages = new Map()
|
||||||
let fbProfileImages = new Map();
|
let fbProfileImages = new Map()
|
||||||
|
|
||||||
for (let i = 0; i < teams.edges.length; i++) {
|
for (let i = 0; i < teams.edges.length; i++) {
|
||||||
|
let team = teams.edges[i].node
|
||||||
|
|
||||||
let team = teams.edges[i].node;
|
teamProfileImages.set(team.slug, team.profile.avatar)
|
||||||
|
|
||||||
teamProfileImages.set(team.slug, team.profile.avatar);
|
|
||||||
|
|
||||||
if (team.fb.length > 0) {
|
|
||||||
|
|
||||||
fbProfileImages.set(team.slug + "-" + team.fb[0].slug, team.fb[0].avatar);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.canvasApp.context.teamProfileImages = teamProfileImages;
|
|
||||||
window.canvasApp.context.fbProfileImages = fbProfileImages;
|
|
||||||
|
|
||||||
callBack();
|
|
||||||
|
|
||||||
}, err => {
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] loadImages -> Error fetching data from Teams Module."); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] loadImages -> err = " + err); }
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] loadImages -> err = " + err); }
|
|
||||||
|
|
||||||
|
if (team.fb.length > 0) {
|
||||||
|
fbProfileImages.set(team.slug + '-' + team.fb[0].slug, team.fb[0].avatar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.canvasApp.context.teamProfileImages = teamProfileImages
|
||||||
|
window.canvasApp.context.fbProfileImages = fbProfileImages
|
||||||
|
|
||||||
|
callBack()
|
||||||
|
}, err => {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] loadImages -> Error fetching data from Teams Module.') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] loadImages -> err = ' + err) }
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] loadImages -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+42
-59
@@ -1,81 +1,64 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
We call displacement to the offset we can produce to the object which the displcement object is is a child from.
|
||||||
|
The displacement is a vector that displaces everything static drawn on on the context of the parent object.
|
||||||
|
|
||||||
We call displacement to the offset we can produce to the object which the displcement object is is a child from.
|
|
||||||
The displacement is a vector that displaces everything static drawn on on the context of the parent object.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function newDisplacement() {
|
function newDisplacement () {
|
||||||
|
var displacement = {
|
||||||
|
containerName: '', // This is for debugging purposes only.
|
||||||
|
parentDisplacement: undefined, // Here we store the displacement object of the parent cointainer, if exists.
|
||||||
|
container: undefined,
|
||||||
|
x: 0, // This is the actual x displacement.
|
||||||
|
y: 0, // This is the actual y displacement.
|
||||||
|
displace: displace,
|
||||||
|
undisplaceThisPoint: undisplaceThisPoint,
|
||||||
|
displaceThisPoint: displaceThisPoint
|
||||||
|
}
|
||||||
|
|
||||||
var displacement = {
|
return displacement
|
||||||
containerName: "", // This is for debugging purposes only.
|
|
||||||
parentDisplacement: undefined, // Here we store the displacement object of the parent cointainer, if exists.
|
|
||||||
container: undefined,
|
|
||||||
x: 0, // This is the actual x displacement.
|
|
||||||
y: 0, // This is the actual y displacement.
|
|
||||||
displace: displace,
|
|
||||||
undisplaceThisPoint: undisplaceThisPoint,
|
|
||||||
displaceThisPoint: displaceThisPoint
|
|
||||||
};
|
|
||||||
|
|
||||||
return displacement;
|
|
||||||
|
|
||||||
|
|
||||||
function displace(amountX, amountY) {
|
|
||||||
|
|
||||||
|
function displace (amountX, amountY) {
|
||||||
/* First we check if by allowing this displacement we would produce the current frame to be beyond its limit. */
|
/* First we check if by allowing this displacement we would produce the current frame to be beyond its limit. */
|
||||||
|
|
||||||
tempDisplacement = newDisplacement();
|
tempDisplacement = newDisplacement()
|
||||||
tempDisplacement.x = amountX;
|
tempDisplacement.x = amountX
|
||||||
tempDisplacement.y = amountY;
|
tempDisplacement.y = amountY
|
||||||
|
|
||||||
if (this.container.frame.canYouMoveHere(tempDisplacement)) {
|
|
||||||
|
|
||||||
|
if (this.container.frame.canYouMoveHere(tempDisplacement)) {
|
||||||
/* Now we displace */
|
/* Now we displace */
|
||||||
|
|
||||||
displacement.x = displacement.x + amountX;
|
displacement.x = displacement.x + amountX
|
||||||
displacement.y = displacement.y + amountY;
|
displacement.y = displacement.y + amountY
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function displaceThisPoint(point) {
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if (this.parentDisplacement !== undefined) {
|
function displaceThisPoint (point) {
|
||||||
|
if (this.parentDisplacement !== undefined) {
|
||||||
point = this.parentDisplacement.displaceThisPoint(point);
|
point = this.parentDisplacement.displaceThisPoint(point)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
point.x = point.x + displacement.x;
|
|
||||||
point.y = point.y + displacement.y;
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function undisplaceThisPoint(point) {
|
point.x = point.x + displacement.x
|
||||||
|
point.y = point.y + displacement.y
|
||||||
|
|
||||||
if (this.parentDisplacement !== undefined) {
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
point = this.parentDisplacement.undisplaceThisPoint(point);
|
function undisplaceThisPoint (point) {
|
||||||
|
if (this.parentDisplacement !== undefined) {
|
||||||
}
|
point = this.parentDisplacement.undisplaceThisPoint(point)
|
||||||
|
|
||||||
point.x = point.x - displacement.x;
|
|
||||||
point.y = point.y - displacement.y;
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
point.x = point.x - displacement.x
|
||||||
|
point.y = point.y - displacement.y
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+51
-72
@@ -1,93 +1,72 @@
|
|||||||
|
|
||||||
function newEventHandler() {
|
function newEventHandler () {
|
||||||
|
const CONSOLE_LOG = false
|
||||||
|
|
||||||
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
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
var eventHandlers = [] // Here we store all the functions we will call when an event is comming.
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
var eventHandlers = []; // Here we store all the functions we will call when an event is comming.
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
|
||||||
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopListening (pEventType, pHandler) {
|
||||||
|
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 listenToEvent(eventType, handler, extraData) {
|
for (let i = 0; i < eventHandlers.length; i++) {
|
||||||
|
let record = eventHandlers[i]
|
||||||
|
let eventType = record[0]
|
||||||
|
let handler = record[1]
|
||||||
|
|
||||||
eventHandlers.push([eventType, handler, extraData]);
|
if (pEventType === eventType && pHandler.toString() === handler.toString()) {
|
||||||
|
eventHandlers.splice(i, 1)
|
||||||
|
|
||||||
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||||
|
console.log('Evethandler found and deleted.')
|
||||||
console.log("Event Handler named " + thisObject.name + " received a request to listenToEvent " + eventType + " and call " + (handler.toString()).substring(0, 50));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopListening(pEventType, pHandler) {
|
for (var i = 0; i < eventHandlers.length; i++) {
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < eventHandlers.length; i++) {
|
|
||||||
|
|
||||||
let record = eventHandlers[i];
|
|
||||||
let eventType = record[0];
|
|
||||||
let handler = record[1];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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. */
|
/* We will execute all the functions listening to this event type. */
|
||||||
|
|
||||||
if (eventHandlers[i][0] === eventType) {
|
if (eventHandlers[i][0] === eventType) {
|
||||||
|
var handler = eventHandlers[i][1]
|
||||||
|
var extraData = eventHandlers[i][2]
|
||||||
|
|
||||||
var handler = eventHandlers[i][1];
|
if (thisObject.name !== undefined && CONSOLE_LOG === true) {
|
||||||
var extraData = eventHandlers[i][2];
|
console.log('Event Handler named ' + thisObject.name + ' received a request to raiseEvent ' + eventType + ' and will call this handler: ' + (handler.toString()).substring(0, 50))
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
handler(event, extraData);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handler(event, extraData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+117
-128
@@ -1,166 +1,155 @@
|
|||||||
function newExchangeAPI() {
|
function newExchangeAPI () {
|
||||||
|
const INFO_LOG = true
|
||||||
|
const LOG_FILE_CONTENT = true
|
||||||
|
|
||||||
const INFO_LOG = true;
|
const MODULE_NAME = 'CloudVM -> Exchange API'
|
||||||
const LOG_FILE_CONTENT = true;
|
|
||||||
|
|
||||||
const MODULE_NAME = "CloudVM -> Exchange API";
|
const SERVER_URL = window.canvasApp.urlPrefix + 'ExchangeAPI/'
|
||||||
|
|
||||||
const SERVER_URL = window.canvasApp.urlPrefix + "ExchangeAPI/";
|
let thisObject = {
|
||||||
|
initialize: initialize,
|
||||||
let thisObject = {
|
getTicker: getTicker,
|
||||||
initialize: initialize,
|
getOpenPositions: getOpenPositions,
|
||||||
getTicker: getTicker,
|
getExecutedTrades: getExecutedTrades,
|
||||||
getOpenPositions: getOpenPositions,
|
putPosition: putPosition,
|
||||||
getExecutedTrades: getExecutedTrades,
|
movePosition: movePosition,
|
||||||
putPosition: putPosition,
|
getPublicTradeHistory: getPublicTradeHistory
|
||||||
movePosition: movePosition,
|
}
|
||||||
getPublicTradeHistory: getPublicTradeHistory
|
|
||||||
};
|
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(callBackFunction) {
|
|
||||||
|
|
||||||
|
function initialize (callBackFunction) {
|
||||||
/* When this initialized is called from the Browser, there is no need to send it to the server since the server will
|
/* When this initialized is called from the Browser, there is no need to send it to the server since the server will
|
||||||
anyways initialize this library at each method call. */
|
anyways initialize this library at each method call. */
|
||||||
|
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE);
|
callBackFunction(window.DEFAULT_OK_RESPONSE)
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function getTicker(pMarket, callBackFunction) {
|
function getTicker (pMarket, callBackFunction) {
|
||||||
|
let authToken = window.localStorage.getItem('access_token')
|
||||||
|
|
||||||
let authToken = window.localStorage.getItem('access_token');
|
let path = SERVER_URL
|
||||||
|
+ CURRENT_BOT_CODE_NAME + '/'
|
||||||
let path = SERVER_URL
|
+ 'getTicker' + '/'
|
||||||
+ CURRENT_BOT_CODE_NAME + "/"
|
|
||||||
+ "getTicker" + "/"
|
|
||||||
+ authToken
|
+ authToken
|
||||||
;
|
|
||||||
|
|
||||||
callServer(undefined, path + "/NO-LOG", onServerResponse);
|
callServer(undefined, path + '/NO-LOG', onServerResponse)
|
||||||
|
|
||||||
function onServerResponse(pServerResponse) {
|
function onServerResponse (pServerResponse) {
|
||||||
let response = JSON.parse(pServerResponse);
|
let response = JSON.parse(pServerResponse)
|
||||||
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
|
if (response.result === window.DEFAULT_FAIL_RESPONSE.result) {
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
else
|
} else {
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
|
callBackFunction(window.DEFAULT_OK_RESPONSE, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getOpenPositions(pMarket, callBackFunction) {
|
function getOpenPositions (pMarket, callBackFunction) {
|
||||||
|
let authToken = window.localStorage.getItem('access_token')
|
||||||
|
|
||||||
let authToken = window.localStorage.getItem('access_token');
|
let path = SERVER_URL
|
||||||
|
+ CURRENT_BOT_CODE_NAME + '/'
|
||||||
let path = SERVER_URL
|
+ 'getOpenPositions' + '/'
|
||||||
+ CURRENT_BOT_CODE_NAME + "/"
|
|
||||||
+ "getOpenPositions" + "/"
|
|
||||||
+ authToken
|
+ authToken
|
||||||
;
|
|
||||||
|
|
||||||
callServer(undefined, path + "/NO-LOG", onServerResponse);
|
callServer(undefined, path + '/NO-LOG', onServerResponse)
|
||||||
|
|
||||||
function onServerResponse(pServerResponse) {
|
function onServerResponse (pServerResponse) {
|
||||||
let response = JSON.parse(pServerResponse);
|
let response = JSON.parse(pServerResponse)
|
||||||
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
|
if (response.result === window.DEFAULT_FAIL_RESPONSE.result) {
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
else
|
} else {
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
|
callBackFunction(window.DEFAULT_OK_RESPONSE, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getExecutedTrades(pPositionId, callBackFunction) {
|
function getExecutedTrades (pPositionId, callBackFunction) {
|
||||||
|
let authToken = window.localStorage.getItem('access_token')
|
||||||
|
|
||||||
let authToken = window.localStorage.getItem('access_token');
|
let path = SERVER_URL
|
||||||
|
+ CURRENT_BOT_CODE_NAME + '/'
|
||||||
let path = SERVER_URL
|
+ 'getExecutedTrades' + '/'
|
||||||
+ CURRENT_BOT_CODE_NAME + "/"
|
+ authToken + '/'
|
||||||
+ "getExecutedTrades" + "/"
|
|
||||||
+ authToken + "/"
|
|
||||||
+ pPositionId
|
+ pPositionId
|
||||||
;
|
|
||||||
|
|
||||||
callServer(undefined, path + "/NO-LOG", onServerResponse);
|
callServer(undefined, path + '/NO-LOG', onServerResponse)
|
||||||
|
|
||||||
function onServerResponse(pServerResponse) {
|
function onServerResponse (pServerResponse) {
|
||||||
let response = JSON.parse(pServerResponse);
|
let response = JSON.parse(pServerResponse)
|
||||||
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
|
if (response.result === window.DEFAULT_FAIL_RESPONSE.result) {
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
else
|
} else {
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
|
callBackFunction(window.DEFAULT_OK_RESPONSE, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function putPosition(pMarket, pType, pRate, pAmountA, pAmountB, callBackFunction) {
|
|
||||||
|
|
||||||
let authToken = window.localStorage.getItem('access_token');
|
function putPosition (pMarket, pType, pRate, pAmountA, pAmountB, callBackFunction) {
|
||||||
|
let authToken = window.localStorage.getItem('access_token')
|
||||||
|
|
||||||
let path = SERVER_URL
|
let path = SERVER_URL
|
||||||
+ CURRENT_BOT_CODE_NAME + "/"
|
+ CURRENT_BOT_CODE_NAME + '/'
|
||||||
+ "putPosition" + "/"
|
+ 'putPosition' + '/'
|
||||||
+ authToken + "/"
|
+ authToken + '/'
|
||||||
+ pType + "/"
|
+ pType + '/'
|
||||||
+ pRate + "/"
|
+ pRate + '/'
|
||||||
+ pAmountA + "/"
|
+ pAmountA + '/'
|
||||||
+ pAmountB
|
+ pAmountB
|
||||||
;
|
|
||||||
|
|
||||||
callServer(undefined, path + "/NO-LOG", onServerResponse);
|
callServer(undefined, path + '/NO-LOG', onServerResponse)
|
||||||
|
|
||||||
function onServerResponse(pServerResponse) {
|
function onServerResponse (pServerResponse) {
|
||||||
let response = JSON.parse(pServerResponse);
|
let response = JSON.parse(pServerResponse)
|
||||||
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
|
if (response.result === window.DEFAULT_FAIL_RESPONSE.result) {
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
else
|
} else {
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
|
callBackFunction(window.DEFAULT_OK_RESPONSE, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function movePosition(pPositionId, pNewRate, pPositionAmountB, callBackFunction) {
|
function movePosition (pPositionId, pNewRate, pPositionAmountB, callBackFunction) {
|
||||||
|
let authToken = window.localStorage.getItem('access_token')
|
||||||
|
|
||||||
let authToken = window.localStorage.getItem('access_token');
|
let path = SERVER_URL
|
||||||
|
+ CURRENT_BOT_CODE_NAME + '/'
|
||||||
let path = SERVER_URL
|
+ 'movePosition' + '/'
|
||||||
+ CURRENT_BOT_CODE_NAME + "/"
|
+ authToken + '/'
|
||||||
+ "movePosition" + "/"
|
+ pPositionId + '/'
|
||||||
+ authToken + "/"
|
+ pNewRate + '/'
|
||||||
+ pPositionId + "/"
|
|
||||||
+ pNewRate + "/"
|
|
||||||
+ pPositionAmountB
|
+ pPositionAmountB
|
||||||
;
|
|
||||||
|
|
||||||
callServer(undefined, path + "/NO-LOG", onServerResponse);
|
callServer(undefined, path + '/NO-LOG', onServerResponse)
|
||||||
|
|
||||||
function onServerResponse(pServerResponse) {
|
function onServerResponse (pServerResponse) {
|
||||||
let response = JSON.parse(pServerResponse);
|
let response = JSON.parse(pServerResponse)
|
||||||
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
|
if (response.result === window.DEFAULT_FAIL_RESPONSE.result) {
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
else
|
} else {
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
|
callBackFunction(window.DEFAULT_OK_RESPONSE, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getPublicTradeHistory(pMarket, startTime, endTime, callBackFunction) {
|
function getPublicTradeHistory (pMarket, startTime, endTime, callBackFunction) {
|
||||||
|
let authToken = window.localStorage.getItem('access_token')
|
||||||
|
|
||||||
let authToken = window.localStorage.getItem('access_token');
|
let path = SERVER_URL
|
||||||
|
+ CURRENT_BOT_CODE_NAME + '/'
|
||||||
let path = SERVER_URL
|
+ 'getPublicTradeHistory' + '/'
|
||||||
+ CURRENT_BOT_CODE_NAME + "/"
|
+ authToken + '/'
|
||||||
+ "getPublicTradeHistory" + "/"
|
+ startTime + '/'
|
||||||
+ authToken + "/"
|
|
||||||
+ startTime + "/"
|
|
||||||
+ endTime
|
+ endTime
|
||||||
;
|
|
||||||
|
|
||||||
callServer(undefined, path + "/NO-LOG", onServerResponse);
|
callServer(undefined, path + '/NO-LOG', onServerResponse)
|
||||||
|
|
||||||
function onServerResponse(pServerResponse) {
|
function onServerResponse (pServerResponse) {
|
||||||
let response = JSON.parse(pServerResponse);
|
let response = JSON.parse(pServerResponse)
|
||||||
if (response.result === window.DEFAULT_FAIL_RESPONSE.result)
|
if (response.result === window.DEFAULT_FAIL_RESPONSE.result) {
|
||||||
callBackFunction(window.DEFAULT_FAIL_RESPONSE);
|
callBackFunction(window.DEFAULT_FAIL_RESPONSE)
|
||||||
else
|
} else { callBackFunction(window.DEFAULT_OK_RESPONSE, response) }
|
||||||
callBackFunction(window.DEFAULT_OK_RESPONSE, response);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+256
-321
@@ -1,392 +1,327 @@
|
|||||||
|
|
||||||
function newDailyFiles() {
|
function newDailyFiles () {
|
||||||
|
const MODULE_NAME = 'Daily Files'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Daily Files";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
getFileCursor: getFileCursor,
|
||||||
const ERROR_LOG = true;
|
setDatetime: setDatetime,
|
||||||
const logger = newWebDebugLog();
|
setTimePeriod: setTimePeriod,
|
||||||
logger.fileName = MODULE_NAME;
|
getExpectedFiles: getExpectedFiles,
|
||||||
|
getFilesLoaded: getFilesLoaded,
|
||||||
|
initialize: initialize,
|
||||||
|
finalize: finalize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let filesLoaded = 0
|
||||||
getFileCursor: getFileCursor,
|
let expectedFiles = 0
|
||||||
setDatetime: setDatetime,
|
|
||||||
setTimePeriod: setTimePeriod,
|
let fileCloud
|
||||||
getExpectedFiles: getExpectedFiles,
|
|
||||||
getFilesLoaded: getFilesLoaded,
|
let fileCursors = new Map()
|
||||||
initialize: initialize,
|
|
||||||
finalize: finalize
|
let callBackWhenFileReceived
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
|
function finalize () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') }
|
||||||
|
|
||||||
|
filesLoaded = undefined
|
||||||
|
expectedFiles = undefined
|
||||||
|
fileCloud = undefined
|
||||||
|
|
||||||
|
fileCursors.forEach(finalizeEach)
|
||||||
|
|
||||||
|
function finalizeEach (item, key, mapObj) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> finalizeEach -> Entering function.') }
|
||||||
|
|
||||||
|
item.finalize()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let filesLoaded = 0;
|
function initialize (pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
|
||||||
let expectedFiles = 0;
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
let fileCloud;
|
callBackWhenFileReceived = callBackFunction
|
||||||
|
|
||||||
let fileCursors = new Map;
|
let exchange = ecosystem.getExchange(pProduct, pExchange)
|
||||||
|
|
||||||
let callBackWhenFileReceived;
|
if (exchange === undefined) {
|
||||||
|
throw 'Exchange not supoorted by this product of the ecosystem! - pDevTeam.codeName = ' + pDevTeam.codeName + ', pBot.codeName = ' + pBot.codeName + ', pProduct.codeName = ' + pProduct.codeName + ', pExchange = ' + pExchange
|
||||||
|
}
|
||||||
|
|
||||||
return thisObject;
|
fileCloud = newFileCloud()
|
||||||
|
fileCloud.initialize(pBot)
|
||||||
function finalize() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); }
|
|
||||||
|
|
||||||
filesLoaded = undefined;
|
|
||||||
expectedFiles = undefined;
|
|
||||||
fileCloud = undefined;
|
|
||||||
|
|
||||||
fileCursors.forEach(finalizeEach);
|
|
||||||
|
|
||||||
function finalizeEach(item, key, mapObj) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> finalizeEach -> Entering function."); }
|
|
||||||
|
|
||||||
item.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
callBackWhenFileReceived = callBackFunction;
|
|
||||||
|
|
||||||
let exchange = ecosystem.getExchange(pProduct, pExchange);
|
|
||||||
|
|
||||||
if (exchange === undefined) {
|
|
||||||
|
|
||||||
throw "Exchange not supoorted by this product of the ecosystem! - pDevTeam.codeName = " + pDevTeam.codeName + ", pBot.codeName = " + pBot.codeName + ", pProduct.codeName = " + pProduct.codeName + ", pExchange = " + pExchange;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fileCloud = newFileCloud();
|
|
||||||
fileCloud.initialize(pBot);
|
|
||||||
|
|
||||||
/* First we will get the Data Range */
|
/* First we will get the Data Range */
|
||||||
|
|
||||||
fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, true, onDataRangeReceived);
|
fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, true, onDataRangeReceived)
|
||||||
|
|
||||||
function onDataRangeReceived(err, pFile) {
|
function onDataRangeReceived (err, pFile) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Entering function.') }
|
||||||
|
|
||||||
try {
|
let beginDateRange
|
||||||
|
let endDateRange
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Entering function."); }
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received OK Response.') }
|
||||||
|
|
||||||
let beginDateRange;
|
beginDateRange = new Date(pFile.begin)
|
||||||
let endDateRange;
|
endDateRange = new Date(pFile.end)
|
||||||
|
|
||||||
switch (err.result) {
|
break
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received OK Response."); }
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
beginDateRange = new Date(pFile.begin);
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
endDateRange = new Date(pFile.end);
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
break;
|
if (err.message === 'File does not exist.') {
|
||||||
}
|
if (INFO_LOG === true) { logger.write('[WARN] initialize -> onFileReceived -> No Date Range file found. maxDate will be set to current datetime. ') }
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
endDateRange = new Date()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received FAIL Response."); }
|
if (err.message === 'Missing Configuration.') {
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
if (ERROR_LOG === true) { logger.write('[WARN] initialize -> onFileReceived -> The needed configuration for the dateRange at the dataSet of the product was not found.') }
|
||||||
return;
|
if (ERROR_LOG === true) { logger.write('[WARN] initialize -> onFileReceived -> maxDate will be set to current datetime.') }
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
endDateRange = new Date()
|
||||||
|
break
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response."); }
|
}
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
if (err.message === "File does not exist.") {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[WARN] initialize -> onFileReceived -> No Date Range file found. maxDate will be set to current datetime. "); }
|
|
||||||
|
|
||||||
endDateRange = new Date();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err.message === "Missing Configuration.") {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[WARN] initialize -> onFileReceived -> The needed configuration for the dateRange at the dataSet of the product was not found."); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[WARN] initialize -> onFileReceived -> maxDate will be set to current datetime."); }
|
|
||||||
|
|
||||||
endDateRange = new Date();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If none of the previous conditions are met, the we return the err to the caller. */
|
/* If none of the previous conditions are met, the we return the err to the caller. */
|
||||||
|
|
||||||
callBackFunction(err);
|
callBackFunction(err)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received Unexpected Response.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received Unexpected Response."); }
|
callBackFunction(err)
|
||||||
callBackFunction(err);
|
return
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Now we will get the daily files */
|
/* Now we will get the daily files */
|
||||||
|
|
||||||
for (i = 0; i < dailyFilePeriods.length; i++) {
|
for (i = 0; i < dailyFilePeriods.length; i++) {
|
||||||
|
let periodTime = dailyFilePeriods[i][0]
|
||||||
|
let periodName = dailyFilePeriods[i][1]
|
||||||
|
|
||||||
let periodTime = dailyFilePeriods[i][0];
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> periodTime = ' + periodTime) }
|
||||||
let periodName = dailyFilePeriods[i][1];
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> periodName = ' + periodName) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> periodTime = " + periodTime); }
|
if (pSet.validPeriods.includes(periodName) === true) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> periodName = " + periodName); }
|
let fileCursor = newFileCursor()
|
||||||
|
fileCursor.initialize(fileCloud, pDevTeam, pBot, pSet, exchange, pMarket, periodName, periodTime, pDatetime, pTimePeriod, beginDateRange, endDateRange, onInitialized)
|
||||||
|
|
||||||
if (pSet.validPeriods.includes(periodName) === true) {
|
function onInitialized (err) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Entering function.') }
|
||||||
|
|
||||||
let fileCursor = newFileCursor();
|
switch (err.result) {
|
||||||
fileCursor.initialize(fileCloud, pDevTeam, pBot, pSet, exchange, pMarket, periodName, periodTime, pDatetime, pTimePeriod, beginDateRange, endDateRange, onInitialized);
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
|
||||||
function onInitialized(err) {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> onInitialized -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received FAIL Response.') }
|
||||||
|
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
|
||||||
switch (err.result) {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received Unexpected Response.') }
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
callBackWhenFileReceived(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> onInitialized -> Received OK Response."); }
|
fileCursors.set(periodTime, fileCursor)
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> expectedFiles = ' + expectedFiles) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> onInitialized -> Received FAIL Response."); }
|
expectedFiles = expectedFiles + fileCursor.getExpectedFiles()
|
||||||
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> onInitialized -> Received Unexpected Response."); }
|
|
||||||
callBackWhenFileReceived(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fileCursors.set(periodTime, fileCursor);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> onInitialized -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
expectedFiles = expectedFiles + fileCursor.getExpectedFiles();
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> onInitialized -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> onInitialized -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadThemAll();
|
|
||||||
|
|
||||||
function loadThemAll() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> loadThemAll -> Entering function."); }
|
|
||||||
|
|
||||||
for (i = 0; i < dailyFilePeriods.length; i++) {
|
|
||||||
|
|
||||||
let periodTime = dailyFilePeriods[i][0];
|
|
||||||
let periodName = dailyFilePeriods[i][1];
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> loadThemAll -> periodTime = " + periodTime); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> loadThemAll -> periodName = " + periodName); }
|
|
||||||
|
|
||||||
if (pSet.validPeriods.includes(periodName) === true) {
|
|
||||||
|
|
||||||
let fileCursor = fileCursors.get(periodTime);
|
|
||||||
fileCursor.reload(onFileReceived);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> loadThemAll -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> expectedFiles = ' + expectedFiles) }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> onInitialized -> err = ' + err) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> err = " + err); }
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (err) {
|
loadThemAll()
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
function loadThemAll () {
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
try {
|
||||||
}
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> loadThemAll -> Entering function.') }
|
||||||
}
|
|
||||||
|
|
||||||
function onFileReceived(err) {
|
for (i = 0; i < dailyFilePeriods.length; i++) {
|
||||||
|
let periodTime = dailyFilePeriods[i][0]
|
||||||
|
let periodName = dailyFilePeriods[i][1]
|
||||||
|
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> loadThemAll -> periodTime = ' + periodTime) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> loadThemAll -> periodName = ' + periodName) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> Entering function."); }
|
if (pSet.validPeriods.includes(periodName) === true) {
|
||||||
|
let fileCursor = fileCursors.get(periodTime)
|
||||||
switch (err.result) {
|
fileCursor.reload(onFileReceived)
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> Received FAIL Response."); }
|
|
||||||
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackWhenFileReceived(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> Received Unexpected Response."); }
|
|
||||||
callBackWhenFileReceived(err);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> loadThemAll -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
filesLoaded++;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onFileReceived -> filesLoaded = " + filesLoaded); }
|
|
||||||
|
|
||||||
callBackWhenFileReceived(GLOBAL.DEFAULT_OK_RESPONSE, thisObject); // Note that the call back is called for every file loaded at each cursor.
|
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> err = ' + err) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] onFileReceived -> err = " + err); }
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFileCursor(pPeriod) {
|
function onFileReceived (err) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> Entering function.') }
|
||||||
|
|
||||||
try {
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFileCursor -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
return fileCursors.get(pPeriod);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFileCursor -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function setDatetime(pDatetime) {
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> Received FAIL Response.') }
|
||||||
try {
|
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
|
|
||||||
|
|
||||||
filesLoaded = 0;
|
|
||||||
expectedFiles = 0;
|
|
||||||
|
|
||||||
fileCursors.forEach(setDatetimeToEach)
|
|
||||||
|
|
||||||
function setDatetimeToEach(fileCursor, key, map) {
|
|
||||||
|
|
||||||
fileCursor.setDatetime(pDatetime);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
expectedFiles = expectedFiles + fileCursor.getExpectedFiles();
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
fileCursor.reload(onFileReceived);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] setDatetime -> err = " + err); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function setTimePeriod(pTimePeriod, pDatetime) {
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> Entering function."); }
|
|
||||||
|
|
||||||
filesLoaded = 0;
|
|
||||||
expectedFiles = 0;
|
|
||||||
|
|
||||||
fileCursors.forEach(setTimePeriodToEach)
|
|
||||||
|
|
||||||
function setTimePeriodToEach(fileCursor, key, map) {
|
|
||||||
|
|
||||||
fileCursor.setTimePeriod(pTimePeriod, pDatetime);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
expectedFiles = expectedFiles + fileCursor.getExpectedFiles();
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
fileCursor.reload(onFileReceived);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> err = " + err); }
|
|
||||||
|
|
||||||
|
callBackWhenFileReceived(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> Received Unexpected Response.') }
|
||||||
|
callBackWhenFileReceived(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filesLoaded++
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onFileReceived -> filesLoaded = ' + filesLoaded) }
|
||||||
|
|
||||||
|
callBackWhenFileReceived(GLOBAL.DEFAULT_OK_RESPONSE, thisObject) // Note that the call back is called for every file loaded at each cursor.
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] onFileReceived -> err = ' + err) }
|
||||||
|
callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getExpectedFiles() {
|
function getFileCursor (pPeriod) {
|
||||||
|
try {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getExpectedFiles -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] getFileCursor -> Entering function.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getExpectedFiles -> expectedFiles = " + expectedFiles); }
|
|
||||||
|
|
||||||
return expectedFiles;
|
|
||||||
|
|
||||||
|
return fileCursors.get(pPeriod)
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFileCursor -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFilesLoaded() {
|
function setDatetime (pDatetime) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setDatetime -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFilesLoaded -> Entering function."); }
|
filesLoaded = 0
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFilesLoaded -> filesLoaded = " + filesLoaded); }
|
expectedFiles = 0
|
||||||
|
|
||||||
return filesLoaded;
|
fileCursors.forEach(setDatetimeToEach)
|
||||||
|
|
||||||
|
function setDatetimeToEach (fileCursor, key, map) {
|
||||||
|
fileCursor.setDatetime(pDatetime)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setDatetime -> expectedFiles = ' + expectedFiles) }
|
||||||
|
|
||||||
|
expectedFiles = expectedFiles + fileCursor.getExpectedFiles()
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setDatetime -> expectedFiles = ' + expectedFiles) }
|
||||||
|
|
||||||
|
fileCursor.reload(onFileReceived)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] setDatetime -> err = ' + err) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTimePeriod (pTimePeriod, pDatetime) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setTimePeriod -> Entering function.') }
|
||||||
|
|
||||||
|
filesLoaded = 0
|
||||||
|
expectedFiles = 0
|
||||||
|
|
||||||
|
fileCursors.forEach(setTimePeriodToEach)
|
||||||
|
|
||||||
|
function setTimePeriodToEach (fileCursor, key, map) {
|
||||||
|
fileCursor.setTimePeriod(pTimePeriod, pDatetime)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setTimePeriod -> expectedFiles = ' + expectedFiles) }
|
||||||
|
|
||||||
|
expectedFiles = expectedFiles + fileCursor.getExpectedFiles()
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setTimePeriod -> expectedFiles = ' + expectedFiles) }
|
||||||
|
|
||||||
|
fileCursor.reload(onFileReceived)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] setTimePeriod -> err = ' + err) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getExpectedFiles () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getExpectedFiles -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getExpectedFiles -> expectedFiles = ' + expectedFiles) }
|
||||||
|
|
||||||
|
return expectedFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFilesLoaded () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFilesLoaded -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFilesLoaded -> filesLoaded = ' + filesLoaded) }
|
||||||
|
|
||||||
|
return filesLoaded
|
||||||
|
}
|
||||||
|
}
|
||||||
+190
-232
@@ -1,252 +1,210 @@
|
|||||||
|
|
||||||
function newFileCloud() {
|
function newFileCloud () {
|
||||||
|
const MODULE_NAME = 'File Cloud'
|
||||||
const MODULE_NAME = "File Cloud";
|
const INFO_LOG = false
|
||||||
const INFO_LOG = false;
|
const ERROR_LOG = true
|
||||||
const ERROR_LOG = true;
|
const logger = newWebDebugLog()
|
||||||
const logger = newWebDebugLog();
|
logger.fileName = MODULE_NAME
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This is the module in the system that actually connects to the cloud storage and grabs from there the needed files.
|
This is the module in the system that actually connects to the cloud storage and grabs from there the needed files.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var thisObject = {
|
var thisObject = {
|
||||||
getFile: getFile,
|
getFile: getFile,
|
||||||
initialize: initialize
|
initialize: initialize
|
||||||
};
|
}
|
||||||
|
|
||||||
let blobService;
|
let blobService
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(pBot) {
|
function initialize (pBot) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> pBot = ' + pBot.codeName) }
|
||||||
|
|
||||||
try {
|
blobService = AzureStorage.Blob.createBlobServiceWithSas(pBot.storage.fileUri, pBot.storage.sas)
|
||||||
|
} catch (err) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> pBot = " + pBot.codeName); }
|
// callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); TODO> Handle this callback.
|
||||||
|
|
||||||
blobService = AzureStorage.Blob.createBlobServiceWithSas(pBot.storage.fileUri, pBot.storage.sas);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
//callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); TODO> Handle this callback.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFile(pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) {
|
function getFile (pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> Entering function.') }
|
||||||
|
|
||||||
|
const MAX_RETRIES = 3
|
||||||
|
|
||||||
|
getFileRecursively(0, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction)
|
||||||
|
|
||||||
|
function getFileRecursively (pRetryCounter, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) {
|
||||||
try {
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> Entering function.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pSet.filePath + '-' + pSet.fileName) }
|
||||||
|
|
||||||
const MAX_RETRIES = 3;
|
let fileName
|
||||||
|
let filePath
|
||||||
getFileRecursively(0, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction)
|
|
||||||
|
if (pDataRange === undefined) {
|
||||||
function getFileRecursively(pRetryCounter, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction) {
|
fileName = pSet.fileName
|
||||||
|
filePath = pSet.filePath
|
||||||
try {
|
} else {
|
||||||
|
if (pSet.dataRange !== undefined) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> Entering function."); }
|
fileName = pSet.dataRange.fileName
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pSet.filePath + "-" + pSet.fileName); }
|
filePath = pSet.dataRange.filePath
|
||||||
|
} else {
|
||||||
let fileName;
|
let customErr = {
|
||||||
let filePath;
|
result: GLOBAL.CUSTOM_FAIL_RESPONSE.result,
|
||||||
|
message: 'Missing Configuration.'
|
||||||
if (pDataRange === undefined) {
|
}
|
||||||
|
|
||||||
fileName = pSet.fileName;
|
if (ERROR_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = ' + customErr.message) }
|
||||||
filePath = pSet.filePath;
|
if (ERROR_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> Data Range configuration could not be found. ') }
|
||||||
|
|
||||||
} else {
|
callBackFunction(customErr)
|
||||||
|
return
|
||||||
if (pSet.dataRange !== undefined) {
|
|
||||||
|
|
||||||
fileName = pSet.dataRange.fileName;
|
|
||||||
filePath = pSet.dataRange.filePath;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
let customErr = {
|
|
||||||
result: GLOBAL.CUSTOM_FAIL_RESPONSE.result,
|
|
||||||
message: "Missing Configuration."
|
|
||||||
};
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = " + customErr.message); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[WARN] getFile -> getFileRecursively -> onFileReceived -> Data Range configuration could not be found. "); }
|
|
||||||
|
|
||||||
callBackFunction(customErr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileName === undefined) {
|
|
||||||
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> Inconsistant data. Check the following: ");
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> pDevTeam = " + JSON.stringify(pDevTeam));
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> pBot = " + JSON.stringify(pBot));
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> pSet = " + JSON.stringify(pSet));
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> pExchange = " + JSON.stringify(pExchange));
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> pMarket = " + JSON.stringify(pMarket));
|
|
||||||
logger.write("[ERROR] getFile -> getFileRecursively -> pPeriodName = " + JSON.stringify(pPeriodName));
|
|
||||||
|
|
||||||
throw ("Inconsistant data received.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pMarket !== undefined) {
|
|
||||||
|
|
||||||
fileName = fileName.replace("@AssetA", pMarket.assetA);
|
|
||||||
fileName = fileName.replace("@AssetB", pMarket.assetB);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pDevTeam !== undefined) {
|
|
||||||
|
|
||||||
filePath = filePath.replace("@DevTeam", pDevTeam.codeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pBot !== undefined) {
|
|
||||||
|
|
||||||
filePath = filePath.replace("@Bot", pBot.codeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pExchange !== undefined) {
|
|
||||||
|
|
||||||
filePath = filePath.replace("@Exchange", pExchange.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
filePath = filePath.replace("@Period", pPeriodName);
|
|
||||||
|
|
||||||
if (pDatetime !== undefined) {
|
|
||||||
|
|
||||||
filePath = filePath.replace("@Year", pDatetime.getUTCFullYear());
|
|
||||||
filePath = filePath.replace("@Month", pad(pDatetime.getUTCMonth() + 1, 2));
|
|
||||||
filePath = filePath.replace("@Day", pad(pDatetime.getUTCDate(), 2));
|
|
||||||
filePath = filePath.replace("@Hour", pad(pDatetime.getUTCHours(), 2));
|
|
||||||
filePath = filePath.replace("@Minute", pad(pDatetime.getUTCMinutes(), 2));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSequence !== undefined) {
|
|
||||||
|
|
||||||
fileName = fileName.replace("@Sequence", pSequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> filePath = " + filePath); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> fileName = " + fileName); }
|
|
||||||
|
|
||||||
let containerName;
|
|
||||||
|
|
||||||
containerName = pDevTeam.codeName.toLowerCase();
|
|
||||||
|
|
||||||
blobService.getBlobToText(containerName, filePath + "/" + fileName, onFileReceived);
|
|
||||||
|
|
||||||
function onFileReceived(err, text, response) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> onFileReceived -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> onFileReceived -> filePath = " + filePath); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> onFileReceived -> fileName = " + fileName); }
|
|
||||||
|
|
||||||
let data;
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
|
|
||||||
if (err.code === "BlobNotFound" | err.code === "FileNotFound" | err.code === "ParentNotFound") {
|
|
||||||
|
|
||||||
let customErr = {
|
|
||||||
result: GLOBAL.CUSTOM_FAIL_RESPONSE.result,
|
|
||||||
message: "File does not exist."
|
|
||||||
};
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = " + customErr.message); }
|
|
||||||
|
|
||||||
callBackFunction(customErr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> containerName = " + containerName); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> filePath = " + filePath); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> fileName = " + fileName); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> Unexpected Error Ocurred."); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> err = " + err); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> text = " + text); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> response = " + response); }
|
|
||||||
|
|
||||||
if (err.message === "XHR error") {
|
|
||||||
|
|
||||||
if (pRetryCounter < MAX_RETRIES) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> Retrying to get this file. "); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> MAX_RETRIES = " + MAX_RETRIES); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> pRetryCounter = " + pRetryCounter); }
|
|
||||||
|
|
||||||
getFileRecursively(pRetryCounter + 1, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction)
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> Could not get this file from storage. "); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> MAX_RETRIES = " + MAX_RETRIES); }
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> pRetryCounter = " + pRetryCounter); }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
data = JSON.parse(text);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> getFileRecursively -> onFileReceived -> Data received is valid JSON."); }
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, data);
|
|
||||||
return;
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[WARN] getFile -> getFileRecursively -> onFileReceived -> err = " + err); }
|
|
||||||
|
|
||||||
let customErr = {
|
|
||||||
result: GLOBAL.CUSTOM_OK_RESPONSE.result,
|
|
||||||
message: "Data not in JSON Format."
|
|
||||||
};
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = " + customErr.message); }
|
|
||||||
|
|
||||||
callBackFunction(customErr, text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> onFileReceived -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> getFileRecursively -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileName === undefined) {
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> Inconsistant data. Check the following: ')
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> pDevTeam = ' + JSON.stringify(pDevTeam))
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> pBot = ' + JSON.stringify(pBot))
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> pSet = ' + JSON.stringify(pSet))
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> pExchange = ' + JSON.stringify(pExchange))
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> pMarket = ' + JSON.stringify(pMarket))
|
||||||
|
logger.write('[ERROR] getFile -> getFileRecursively -> pPeriodName = ' + JSON.stringify(pPeriodName))
|
||||||
|
|
||||||
|
throw ('Inconsistant data received.')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMarket !== undefined) {
|
||||||
|
fileName = fileName.replace('@AssetA', pMarket.assetA)
|
||||||
|
fileName = fileName.replace('@AssetB', pMarket.assetB)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDevTeam !== undefined) {
|
||||||
|
filePath = filePath.replace('@DevTeam', pDevTeam.codeName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBot !== undefined) {
|
||||||
|
filePath = filePath.replace('@Bot', pBot.codeName)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pExchange !== undefined) {
|
||||||
|
filePath = filePath.replace('@Exchange', pExchange.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath = filePath.replace('@Period', pPeriodName)
|
||||||
|
|
||||||
|
if (pDatetime !== undefined) {
|
||||||
|
filePath = filePath.replace('@Year', pDatetime.getUTCFullYear())
|
||||||
|
filePath = filePath.replace('@Month', pad(pDatetime.getUTCMonth() + 1, 2))
|
||||||
|
filePath = filePath.replace('@Day', pad(pDatetime.getUTCDate(), 2))
|
||||||
|
filePath = filePath.replace('@Hour', pad(pDatetime.getUTCHours(), 2))
|
||||||
|
filePath = filePath.replace('@Minute', pad(pDatetime.getUTCMinutes(), 2))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSequence !== undefined) {
|
||||||
|
fileName = fileName.replace('@Sequence', pSequence)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> filePath = ' + filePath) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> fileName = ' + fileName) }
|
||||||
|
|
||||||
|
let containerName
|
||||||
|
|
||||||
|
containerName = pDevTeam.codeName.toLowerCase()
|
||||||
|
|
||||||
|
blobService.getBlobToText(containerName, filePath + '/' + fileName, onFileReceived)
|
||||||
|
|
||||||
|
function onFileReceived (err, text, response) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> onFileReceived -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> onFileReceived -> filePath = ' + filePath) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> onFileReceived -> fileName = ' + fileName) }
|
||||||
|
|
||||||
|
let data
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
if (err.code === 'BlobNotFound' | err.code === 'FileNotFound' | err.code === 'ParentNotFound') {
|
||||||
|
let customErr = {
|
||||||
|
result: GLOBAL.CUSTOM_FAIL_RESPONSE.result,
|
||||||
|
message: 'File does not exist.'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = ' + customErr.message) }
|
||||||
|
|
||||||
|
callBackFunction(customErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> containerName = ' + containerName) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> filePath = ' + filePath) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> fileName = ' + fileName) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> Unexpected Error Ocurred.') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> err = ' + err) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> text = ' + text) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> response = ' + response) }
|
||||||
|
|
||||||
|
if (err.message === 'XHR error') {
|
||||||
|
if (pRetryCounter < MAX_RETRIES) {
|
||||||
|
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> Retrying to get this file. ') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> MAX_RETRIES = ' + MAX_RETRIES) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> pRetryCounter = ' + pRetryCounter) }
|
||||||
|
|
||||||
|
getFileRecursively(pRetryCounter + 1, pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, pDataRange, callBackFunction)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> Could not get this file from storage. ') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> MAX_RETRIES = ' + MAX_RETRIES) }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> pRetryCounter = ' + pRetryCounter) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
data = JSON.parse(text)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> getFileRecursively -> onFileReceived -> Data received is valid JSON.') }
|
||||||
|
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, data)
|
||||||
|
return
|
||||||
|
} catch (err) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> err = ' + err) }
|
||||||
|
|
||||||
|
let customErr = {
|
||||||
|
result: GLOBAL.CUSTOM_OK_RESPONSE.result,
|
||||||
|
message: 'Data not in JSON Format.'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[WARN] getFile -> getFileRecursively -> onFileReceived -> customErr.message = ' + customErr.message) }
|
||||||
|
|
||||||
|
callBackFunction(customErr, text)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> onFileReceived -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> getFileRecursively -> err = ' + err) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> err = " + err); }
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] getFile -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
+479
-581
File diff suppressed because it is too large.
Load diff
+247
-298
@@ -1,219 +1,192 @@
|
|||||||
|
|
||||||
function newFileSequence() {
|
function newFileSequence () {
|
||||||
|
const MODULE_NAME = 'File Sequence'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "File Sequence";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
eventHandler: undefined,
|
||||||
const ERROR_LOG = true;
|
getFile: getFile,
|
||||||
const logger = newWebDebugLog();
|
getExpectedFiles: getExpectedFiles,
|
||||||
logger.fileName = MODULE_NAME;
|
getFilesLoaded: getFilesLoaded,
|
||||||
|
initialize: initialize,
|
||||||
|
finalize: finalize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let filesLoaded = 0
|
||||||
eventHandler: undefined,
|
let fileCloud
|
||||||
getFile: getFile,
|
let files = new Map()
|
||||||
getExpectedFiles: getExpectedFiles,
|
let maxSequence = -1 // This is replaced by the content of the sequence file, which contains an index that starts on zero. In the case that the sequence file is not found the default value is -1 so when you add 1 it gives you the amount of files in the sequence, zero.
|
||||||
getFilesLoaded: getFilesLoaded,
|
let market
|
||||||
initialize: initialize,
|
let devTeam
|
||||||
finalize: finalize
|
let bot
|
||||||
|
let thisSet
|
||||||
|
let product
|
||||||
|
|
||||||
|
thisObject.eventHandler = newEventHandler()
|
||||||
|
|
||||||
|
let intervalHandle
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
|
function finalize () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> devTeam = ' + devTeam.codeName) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> bot = ' + bot.codeName) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> thisSet = ' + thisSet.codeName) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> intervalHandle = ' + intervalHandle) }
|
||||||
|
|
||||||
|
clearInterval(intervalHandle)
|
||||||
|
|
||||||
|
filesLoaded = undefined
|
||||||
|
fileCloud = undefined
|
||||||
|
files = undefined
|
||||||
|
maxSequence = undefined
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let filesLoaded = 0;
|
function initialize (pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
||||||
let fileCloud;
|
try {
|
||||||
let files = new Map;
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
let maxSequence = -1; // This is replaced by the content of the sequence file, which contains an index that starts on zero. In the case that the sequence file is not found the default value is -1 so when you add 1 it gives you the amount of files in the sequence, zero.
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
let market;
|
|
||||||
let devTeam;
|
|
||||||
let bot;
|
|
||||||
let thisSet;
|
|
||||||
let product;
|
|
||||||
|
|
||||||
thisObject.eventHandler = newEventHandler();
|
exchange = ecosystem.getExchange(pProduct, pExchange)
|
||||||
|
|
||||||
let intervalHandle;
|
if (exchange === undefined) {
|
||||||
|
throw 'Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = ' + pDevTeam.codeName + ', pBot.codeName = ' + pBot.codeName + ', pProduct.codeName = ' + pProduct.codeName + ', pExchange = ' + pExchange
|
||||||
|
}
|
||||||
|
|
||||||
return thisObject;
|
intervalHandle = setInterval(updateFiles, _1_MINUTE_IN_MILISECONDS)
|
||||||
|
|
||||||
function finalize() {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> intervalHandle = ' + intervalHandle) }
|
||||||
|
|
||||||
try {
|
market = pMarket
|
||||||
|
devTeam = pDevTeam
|
||||||
|
bot = pBot
|
||||||
|
thisSet = pSet
|
||||||
|
product = pProduct
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); }
|
fileCloud = newFileCloud()
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> devTeam = " + devTeam.codeName); }
|
fileCloud.initialize(bot)
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> bot = " + bot.codeName); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> thisSet = " + thisSet.codeName); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> intervalHandle = " + intervalHandle); }
|
|
||||||
|
|
||||||
clearInterval(intervalHandle);
|
|
||||||
|
|
||||||
filesLoaded = undefined;
|
|
||||||
fileCloud = undefined;
|
|
||||||
files = undefined;
|
|
||||||
maxSequence = undefined;
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
exchange = ecosystem.getExchange(pProduct, pExchange);
|
|
||||||
|
|
||||||
if (exchange === undefined) {
|
|
||||||
|
|
||||||
throw "Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = " + pDevTeam.codeName + ", pBot.codeName = " + pBot.codeName + ", pProduct.codeName = " + pProduct.codeName + ", pExchange = " + pExchange;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
intervalHandle = setInterval(updateFiles, _1_MINUTE_IN_MILISECONDS);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> intervalHandle = " + intervalHandle); }
|
|
||||||
|
|
||||||
market = pMarket;
|
|
||||||
devTeam = pDevTeam;
|
|
||||||
bot = pBot;
|
|
||||||
thisSet = pSet;
|
|
||||||
product = pProduct;
|
|
||||||
|
|
||||||
fileCloud = newFileCloud();
|
|
||||||
fileCloud.initialize(bot);
|
|
||||||
|
|
||||||
/* First we will get the sequence max number */
|
/* First we will get the sequence max number */
|
||||||
|
|
||||||
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, "Sequence", undefined, onSequenceFileReceived);
|
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived)
|
||||||
|
|
||||||
function onSequenceFileReceived(err, file) {
|
function onSequenceFileReceived (err, file) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> key = ' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
|
||||||
|
|
||||||
try {
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Entering function."); }
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> key = " + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName); }
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch (err.result) {
|
case GLOBAL.CUSTOM_OK_RESPONSE.result: {
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> Received CUSTOM OK Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received OK Response."); }
|
callBackFunction(err)
|
||||||
break;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received FAIL Response."); }
|
callBackFunction(err, thisObject)
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
return
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_OK_RESPONSE.result: {
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received CUSTOM OK Response."); }
|
maxSequence = Number(file)
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> maxSequence = ' + maxSequence) }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err, thisObject);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
maxSequence = Number(file);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> maxSequence = " + maxSequence); }
|
|
||||||
|
|
||||||
/* Now we will get the sequence of files */
|
/* Now we will get the sequence of files */
|
||||||
|
|
||||||
for (let i = 0; i <= maxSequence; i++) {
|
for (let i = 0; i <= maxSequence; i++) {
|
||||||
|
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived)
|
||||||
|
|
||||||
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived);
|
function onFileReceived (err, file) {
|
||||||
|
try {
|
||||||
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
|
||||||
function onFileReceived(err, file) {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
|
||||||
switch (err.result) {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received FAIL Response.') }
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received OK Response."); }
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received FAIL Response."); }
|
callBackFunction(err)
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
return
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
default: {
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received CUSTOM FAIL Response."); }
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received Unexpected Response.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> err.message = " + err.message); }
|
callBackFunction(err)
|
||||||
|
return
|
||||||
callBackFunction(err);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSequenceFileReceived -> onFileReceived -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files.set(i, file);
|
|
||||||
|
|
||||||
filesLoaded++;
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, thisObject); // Note that the callback is called for every file loaded.
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onSequenceFileReceived -> onFileReceived -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onSequenceFileReceived -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files.set(i, file)
|
||||||
|
|
||||||
|
filesLoaded++
|
||||||
|
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, thisObject) // Note that the callback is called for every file loaded.
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onSequenceFileReceived -> onFileReceived -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onSequenceFileReceived -> err = ' + err) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateFiles() {
|
function updateFiles () {
|
||||||
|
try {
|
||||||
|
let updateFiles = 0
|
||||||
|
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> Entering function.') }
|
||||||
|
|
||||||
let updateFiles = 0;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> Entering function."); }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -225,161 +198,137 @@ function newFileSequence() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let currentMaxSequence = maxSequence;
|
let currentMaxSequence = maxSequence
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> currentMaxSequence = " + currentMaxSequence); }
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> currentMaxSequence = ' + currentMaxSequence) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> intervalHandle = " + intervalHandle); }
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> intervalHandle = ' + intervalHandle) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> devTeam = " + devTeam.codeName); }
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> devTeam = ' + devTeam.codeName) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> bot = " + bot.codeName); }
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> bot = ' + bot.codeName) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> thisSet = " + thisSet.codeName); }
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> thisSet = ' + thisSet.codeName) }
|
||||||
|
|
||||||
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, "Sequence", undefined, onSequenceFileReceived);
|
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, 'Sequence', undefined, onSequenceFileReceived)
|
||||||
|
|
||||||
function onSequenceFileReceived(err, file) {
|
function onSequenceFileReceived (err, file) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> key = ' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
|
||||||
|
|
||||||
try {
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> Entering function."); }
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> key = " + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName); }
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> Received FAIL Response.') }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch (err.result) {
|
case GLOBAL.CUSTOM_OK_RESPONSE.result: {
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> Received CUSTOM OK Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> err.message = ' + err.message) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> Received OK Response."); }
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
break;
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
}
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> err.message = ' + err.message) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> Received Unexpected Response.') }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> Received FAIL Response."); }
|
maxSequence = Number(file)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_OK_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> maxSequence = ' + maxSequence) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> Received CUSTOM OK Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> err.message = " + err.message); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> err.message = " + err.message); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> Received Unexpected Response."); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
maxSequence = Number(file);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> maxSequence = " + maxSequence); }
|
|
||||||
|
|
||||||
/* Now we will get the sequence of files, but in this case only from the currentMaxSequence and above. */
|
/* Now we will get the sequence of files, but in this case only from the currentMaxSequence and above. */
|
||||||
|
|
||||||
for (let i = currentMaxSequence; i <= maxSequence; i++) {
|
for (let i = currentMaxSequence; i <= maxSequence; i++) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> i = ' + i) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> i = " + i); }
|
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived)
|
||||||
|
|
||||||
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, undefined, undefined, i, undefined, onFileReceived);
|
function onFileReceived (err, file) {
|
||||||
|
try {
|
||||||
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
|
||||||
function onFileReceived(err, file) {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
|
||||||
switch (err.result) {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received FAIL Response.') }
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received OK Response."); }
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> err.message = ' + err.message) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received FAIL Response."); }
|
default: {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received Unexpected Response.') }
|
||||||
|
return
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received CUSTOM FAIL Response."); }
|
}
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> err.message = " + err.message); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Received Unexpected Response."); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files.set(i, file);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> File Updated."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> i = " + i); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> file.length = " + file.length); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> filesLoaded = " + filesLoaded); }
|
|
||||||
|
|
||||||
if (i !== currentMaxSequence) {
|
|
||||||
|
|
||||||
filesLoaded++;
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> filesLoaded = " + filesLoaded); }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filesLoaded === maxSequence + 1) {
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent("Files Updated", undefined);
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Files Updated event Raised."); }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] updateFiles -> onSequenceFileReceived -> onFileReceived -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] updateFiles -> onSequenceFileReceived -> err = " + err); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files.set(i, file)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> File Updated.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> i = ' + i) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> file.length = ' + file.length) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> filesLoaded = ' + filesLoaded) }
|
||||||
|
|
||||||
|
if (i !== currentMaxSequence) {
|
||||||
|
filesLoaded++
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> filesLoaded = ' + filesLoaded) }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesLoaded === maxSequence + 1) {
|
||||||
|
thisObject.eventHandler.raiseEvent('Files Updated', undefined)
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onSequenceFileReceived -> onFileReceived -> Files Updated event Raised.') }
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] updateFiles -> onSequenceFileReceived -> onFileReceived -> err = ' + err) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] updateFiles -> err = " + err); }
|
if (ERROR_LOG === true) { logger.write('[ERROR] updateFiles -> onSequenceFileReceived -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] updateFiles -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFile(pSequence) {
|
function getFile (pSequence) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> pSequence = ' + pSequence) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> Entering function."); }
|
return files.get(pSequence)
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> pSequence = " + pSequence); }
|
}
|
||||||
|
|
||||||
return files.get(pSequence);
|
function getExpectedFiles () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getExpectedFiles -> Entering function.') }
|
||||||
|
|
||||||
}
|
return maxSequence + 1
|
||||||
|
}
|
||||||
|
|
||||||
function getExpectedFiles() {
|
function getFilesLoaded () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFilesLoaded -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getExpectedFiles -> Entering function."); }
|
return filesLoaded
|
||||||
|
}
|
||||||
return maxSequence + 1;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFilesLoaded() {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFilesLoaded -> Entering function."); }
|
|
||||||
|
|
||||||
return filesLoaded;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+173
-216
@@ -1,253 +1,210 @@
|
|||||||
|
|
||||||
function newMarketFiles() {
|
function newMarketFiles () {
|
||||||
|
const MODULE_NAME = 'Market Files'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Market Files";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
eventHandler: undefined,
|
||||||
const ERROR_LOG = true;
|
getFile: getFile,
|
||||||
const logger = newWebDebugLog();
|
getExpectedFiles: getExpectedFiles,
|
||||||
logger.fileName = MODULE_NAME;
|
getFilesLoaded: getFilesLoaded,
|
||||||
|
initialize: initialize,
|
||||||
|
finalize: finalize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let filesLoaded = 0
|
||||||
eventHandler: undefined,
|
|
||||||
getFile: getFile,
|
let fileCloud
|
||||||
getExpectedFiles: getExpectedFiles,
|
|
||||||
getFilesLoaded: getFilesLoaded,
|
let files = new Map()
|
||||||
initialize: initialize,
|
|
||||||
finalize: finalize
|
let market
|
||||||
|
let exchange
|
||||||
|
let devTeam
|
||||||
|
let bot
|
||||||
|
let thisSet
|
||||||
|
let periodName
|
||||||
|
|
||||||
|
thisObject.eventHandler = newEventHandler()
|
||||||
|
|
||||||
|
let intervalHandle
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
|
function finalize () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') }
|
||||||
|
|
||||||
|
clearInterval(intervalHandle)
|
||||||
|
|
||||||
|
filesLoaded = undefined
|
||||||
|
files = undefined
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let filesLoaded = 0;
|
function initialize (pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
let fileCloud;
|
exchange = ecosystem.getExchange(pProduct, pExchange)
|
||||||
|
|
||||||
let files = new Map;
|
if (exchange === undefined) {
|
||||||
|
throw 'Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = ' + pDevTeam.codeName + ', pBot.codeName = ' + pBot.codeName + ', pProduct.codeName = ' + pProduct.codeName + ', pExchange = ' + pExchange
|
||||||
|
}
|
||||||
|
|
||||||
let market;
|
intervalHandle = setInterval(updateFiles, _10_MINUTES_IN_MILISECONDS)
|
||||||
let exchange;
|
|
||||||
let devTeam;
|
|
||||||
let bot;
|
|
||||||
let thisSet;
|
|
||||||
let periodName;
|
|
||||||
|
|
||||||
thisObject.eventHandler = newEventHandler();
|
market = pMarket
|
||||||
|
devTeam = pDevTeam
|
||||||
|
bot = pBot
|
||||||
|
thisSet = pSet
|
||||||
|
|
||||||
let intervalHandle;
|
fileCloud = newFileCloud()
|
||||||
|
fileCloud.initialize(pBot)
|
||||||
return thisObject;
|
|
||||||
|
|
||||||
function finalize() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); }
|
|
||||||
|
|
||||||
clearInterval(intervalHandle);
|
|
||||||
|
|
||||||
filesLoaded = undefined;
|
|
||||||
files = undefined;
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
exchange = ecosystem.getExchange(pProduct, pExchange);
|
|
||||||
|
|
||||||
if (exchange === undefined) {
|
|
||||||
|
|
||||||
throw "Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = " + pDevTeam.codeName + ", pBot.codeName = " + pBot.codeName + ", pProduct.codeName = " + pProduct.codeName + ", pExchange = " + pExchange;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
intervalHandle = setInterval(updateFiles, _10_MINUTES_IN_MILISECONDS);
|
|
||||||
|
|
||||||
market = pMarket;
|
|
||||||
devTeam = pDevTeam;
|
|
||||||
bot = pBot;
|
|
||||||
thisSet = pSet;
|
|
||||||
|
|
||||||
fileCloud = newFileCloud();
|
|
||||||
fileCloud.initialize(pBot);
|
|
||||||
|
|
||||||
/* Now we will get the market files */
|
/* Now we will get the market files */
|
||||||
|
|
||||||
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
||||||
|
let periodTime = marketFilesPeriods[i][0]
|
||||||
|
let periodName = marketFilesPeriods[i][1]
|
||||||
|
|
||||||
let periodTime = marketFilesPeriods[i][0];
|
if (thisSet.validPeriods.includes(periodName) === true) {
|
||||||
let periodName = marketFilesPeriods[i][1];
|
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, undefined, undefined, undefined, onFileReceived)
|
||||||
|
|
||||||
if (thisSet.validPeriods.includes(periodName) === true) {
|
function onFileReceived (err, file) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Entering function.') }
|
||||||
|
|
||||||
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, undefined, undefined, undefined, onFileReceived);
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
function onFileReceived(err, file) {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Entering function."); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files.set(periodTime, file);
|
|
||||||
|
|
||||||
filesLoaded++;
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, thisObject); // Note that the callback is called for every file loaded.
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
files.set(periodTime, file)
|
||||||
|
|
||||||
|
filesLoaded++
|
||||||
|
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, thisObject) // Note that the callback is called for every file loaded.
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateFiles() {
|
function updateFiles () {
|
||||||
|
try {
|
||||||
|
let updateFiles = 0
|
||||||
|
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> Entering function.') }
|
||||||
|
|
||||||
let updateFiles = 0;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> Entering function."); }
|
|
||||||
|
|
||||||
/* Now we will get the market files */
|
/* Now we will get the market files */
|
||||||
|
|
||||||
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
for (let i = 0; i < marketFilesPeriods.length; i++) {
|
||||||
|
let periodTime = marketFilesPeriods[i][0]
|
||||||
|
let periodName = marketFilesPeriods[i][1]
|
||||||
|
|
||||||
let periodTime = marketFilesPeriods[i][0];
|
if (thisSet.validPeriods.includes(periodName) === true) {
|
||||||
let periodName = marketFilesPeriods[i][1];
|
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, undefined, undefined, undefined, onFileReceived)
|
||||||
|
|
||||||
if (thisSet.validPeriods.includes(periodName) === true) {
|
function onFileReceived (err, file) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> Entering function.') }
|
||||||
|
|
||||||
fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, undefined, undefined, undefined, onFileReceived);
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
function onFileReceived(err, file) {
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> Entering function."); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> Received FAIL Response."); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> err.message = " + err.message); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> Received Unexpected Response."); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files.set(periodTime, file);
|
|
||||||
updateFiles++;
|
|
||||||
|
|
||||||
if (updateFiles === marketFilesPeriods.length) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> All files received. "); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> devTeam = " + devTeam.codeName); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> bot = " + bot.codeName); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] updateFiles -> onFileReceived -> thisSet = " + thisSet.codeName); }
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent("Files Updated", undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] updateFiles -> onFileReceived -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> Received FAIL Response.') }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> err.message = ' + err.message) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> Received Unexpected Response.') }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
files.set(periodTime, file)
|
||||||
|
updateFiles++
|
||||||
|
|
||||||
|
if (updateFiles === marketFilesPeriods.length) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> All files received. ') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> devTeam = ' + devTeam.codeName) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> bot = ' + bot.codeName) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] updateFiles -> onFileReceived -> thisSet = ' + thisSet.codeName) }
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Files Updated', undefined)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] updateFiles -> onFileReceived -> err = ' + err) }
|
||||||
}
|
}
|
||||||
} catch (err) {
|
}
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] updateFiles -> err = " + err); }
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] updateFiles -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFile(pPeriod) {
|
function getFile (pPeriod) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> Entering function."); }
|
return files.get(pPeriod)
|
||||||
|
}
|
||||||
|
|
||||||
return files.get(pPeriod);
|
function getExpectedFiles () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getExpectedFiles -> Entering function.') }
|
||||||
|
|
||||||
}
|
return marketFilesPeriods.length
|
||||||
|
}
|
||||||
|
|
||||||
function getExpectedFiles() {
|
function getFilesLoaded () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFilesLoaded -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getExpectedFiles -> Entering function."); }
|
return filesLoaded
|
||||||
|
}
|
||||||
return marketFilesPeriods.length;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFilesLoaded() {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFilesLoaded -> Entering function."); }
|
|
||||||
|
|
||||||
return filesLoaded;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+69
-85
@@ -1,105 +1,89 @@
|
|||||||
|
|
||||||
function newSingleFile() {
|
function newSingleFile () {
|
||||||
|
const MODULE_NAME = 'Single File'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Single File";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
getFile: getFile,
|
||||||
const ERROR_LOG = true;
|
initialize: initialize
|
||||||
const logger = newWebDebugLog();
|
}
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
let thisObject = {
|
let fileCloud
|
||||||
getFile: getFile,
|
let file
|
||||||
initialize: initialize
|
|
||||||
}
|
|
||||||
|
|
||||||
let fileCloud;
|
return thisObject
|
||||||
let file;
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize (pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
let exchange = ecosystem.getExchange(pProduct, pExchange)
|
||||||
|
|
||||||
try {
|
if (pExchange !== undefined && exchange === undefined) {
|
||||||
|
// We support no exchange as a parameter, but if provided, then it must be at the list of exchanges of that product.
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
throw 'Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = ' + pDevTeam.codeName + ', pBot.codeName = ' + pBot.codeName + ', pProduct.codeName = ' + pProduct.codeName + ', pExchange = ' + pExchange
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
}
|
||||||
|
|
||||||
let exchange = ecosystem.getExchange(pProduct, pExchange);
|
fileCloud = newFileCloud()
|
||||||
|
fileCloud.initialize(pBot)
|
||||||
if (pExchange !== undefined && exchange === undefined) { // We support no exchange as a parameter, but if provided, then it must be at the list of exchanges of that product.
|
|
||||||
|
|
||||||
throw "Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = " + pDevTeam.codeName + ", pBot.codeName = " + pBot.codeName + ", pProduct.codeName = " + pProduct.codeName + ", pExchange = " + pExchange;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fileCloud = newFileCloud();
|
|
||||||
fileCloud.initialize(pBot);
|
|
||||||
|
|
||||||
/* Now we will get the file */
|
/* Now we will get the file */
|
||||||
|
|
||||||
fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, undefined, onFileReceived);
|
fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, undefined, onFileReceived)
|
||||||
|
|
||||||
function onFileReceived(err, pFile) {
|
function onFileReceived (err, pFile) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Entering function.') }
|
||||||
|
|
||||||
try {
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received OK Response.') }
|
||||||
|
break
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileReceived -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file = pFile;
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> err.message = ' + err.message) }
|
||||||
|
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file = pFile
|
||||||
|
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileReceived -> err = ' + err) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getFile() {
|
function getFile () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getFile -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getFile -> Entering function."); }
|
return file
|
||||||
|
}
|
||||||
return file;
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+649
-789
File diff suppressed because it is too large.
Load diff
+185
-219
@@ -1,274 +1,240 @@
|
|||||||
|
|
||||||
function newFloatingObject() {
|
function newFloatingObject () {
|
||||||
|
const MODULE_NAME = 'Floating Object'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const INTENSIVE_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
|
||||||
const MODULE_NAME = "Floating Object";
|
const logger = newWebDebugLog()
|
||||||
const INFO_LOG = false;
|
logger.fileName = MODULE_NAME
|
||||||
const INTENSIVE_LOG = false;
|
|
||||||
const ERROR_LOG = true;
|
|
||||||
|
|
||||||
const logger = newWebDebugLog();
|
var thisObject = {
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
var thisObject = {
|
physicsLoop: physicsLoop,
|
||||||
|
eventHandler: undefined,
|
||||||
|
|
||||||
physicsLoop: physicsLoop,
|
payload: undefined, // This is a reference to an object controlled by a Plotter. The plotter can change its internal value and we will see them from here.
|
||||||
eventHandler: undefined,
|
type: undefined, // Currently there are two types of Floating Objects: Profile Balls, and Notes.
|
||||||
|
|
||||||
payload: undefined, // This is a reference to an object controlled by a Plotter. The plotter can change its internal value and we will see them from here.
|
physicsEnabled: false,
|
||||||
type: undefined, // Currently there are two types of Floating Objects: Profile Balls, and Notes.
|
|
||||||
|
|
||||||
physicsEnabled: false,
|
initializeMass: initializeMass,
|
||||||
|
initializeRadius: initializeRadius,
|
||||||
|
initializeImageSize: initializeImageSize,
|
||||||
|
initializeFontSize: initializeFontSize,
|
||||||
|
|
||||||
initializeMass: initializeMass,
|
imageId: undefined,
|
||||||
initializeRadius: initializeRadius,
|
|
||||||
initializeImageSize: initializeImageSize,
|
|
||||||
initializeFontSize: initializeFontSize,
|
|
||||||
|
|
||||||
imageId: undefined,
|
currentPosition: 0, // Current x,y position of the floating object at the floating object's layer, where there is no displacement or zoom. This position is always changing towards the target position.
|
||||||
|
currentSpeed: 0, // This is the current speed of the floating object.
|
||||||
|
currentRadius: 0, // This is the current radius of the floating object, including its zoom applied.
|
||||||
|
currentMass: 0, // This is the current mass of the floating object, including its zoom applied.
|
||||||
|
|
||||||
currentPosition: 0, // Current x,y position of the floating object at the floating object's layer, where there is no displacement or zoom. This position is always changing towards the target position.
|
friction: 0, // This is a factor that will ultimatelly desacelerate the floating object.
|
||||||
currentSpeed: 0, // This is the current speed of the floating object.
|
|
||||||
currentRadius: 0, // This is the current radius of the floating object, including its zoom applied.
|
|
||||||
currentMass: 0, // This is the current mass of the floating object, including its zoom applied.
|
|
||||||
|
|
||||||
friction: 0, // This is a factor that will ultimatelly desacelerate the floating object.
|
rawMass: 0, // This is the mass value without zoom.
|
||||||
|
rawRadius: 0, // This is the radius of this floating object without zoom.
|
||||||
|
|
||||||
rawMass: 0, // This is the mass value without zoom.
|
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
|
||||||
rawRadius: 0, // This is the radius of this floating object without zoom.
|
|
||||||
|
|
||||||
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
|
fillStyle: '',
|
||||||
|
|
||||||
fillStyle: '',
|
labelStrokeStyle: '',
|
||||||
|
|
||||||
labelStrokeStyle: '',
|
radomizeCurrentPosition: radomizeCurrentPosition,
|
||||||
|
radomizeCurrentSpeed: radomizeCurrentSpeed,
|
||||||
|
|
||||||
radomizeCurrentPosition: radomizeCurrentPosition,
|
drawBackground: drawBackground,
|
||||||
radomizeCurrentSpeed: radomizeCurrentSpeed,
|
drawForeground: drawForeground,
|
||||||
|
|
||||||
drawBackground: drawBackground,
|
updateMass: updateMass, // Function to update the mass when the zoom level changed.
|
||||||
drawForeground: drawForeground,
|
updateRadius: updateRadius, // Function to update the radius when the zoom level changed.
|
||||||
|
|
||||||
updateMass: updateMass, // Function to update the mass when the zoom level changed.
|
linkedObject: undefined, // This is a reference to the object that this floating object is representing.
|
||||||
updateRadius: updateRadius, // Function to update the radius when the zoom level changed.
|
linkedObjectType: '', // Since there might be floating objects for different types of objects, here we store the type of object we are linking to.
|
||||||
|
|
||||||
linkedObject: undefined, // This is a reference to the object that this floating object is representing.
|
container: undefined, // This is a pointer to the object where the floating object belongs to.
|
||||||
linkedObjectType: "", // Since there might be floating objects for different types of objects, here we store the type of object we are linking to.
|
initialize: initialize
|
||||||
|
|
||||||
container: undefined, // This is a pointer to the object where the floating object belongs to.
|
}
|
||||||
initialize: initialize
|
|
||||||
|
|
||||||
};
|
let underlayingObject
|
||||||
|
|
||||||
let underlayingObject;
|
thisObject.eventHandler = newEventHandler()
|
||||||
|
|
||||||
thisObject.eventHandler = newEventHandler();
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize (pType, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
function initialize(pType, callBackFunction) {
|
switch (pType) {
|
||||||
|
|
||||||
try {
|
case 'Profile Ball': {
|
||||||
|
underlayingObject = newProfileBall()
|
||||||
|
underlayingObject.initialize(onInitialized)
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
function onInitialized (err) {
|
||||||
|
|
||||||
switch (pType) {
|
}
|
||||||
|
|
||||||
case "Profile Ball": {
|
break
|
||||||
|
|
||||||
underlayingObject = newProfileBall();
|
|
||||||
underlayingObject.initialize(onInitialized);
|
|
||||||
|
|
||||||
function onInitialized(err) {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Note": {
|
|
||||||
|
|
||||||
underlayingObject = newNote();
|
|
||||||
underlayingObject.initialize(onInitialized);
|
|
||||||
|
|
||||||
function onInitialized(err) {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.type = pType;
|
|
||||||
|
|
||||||
thisObject.eventHandler.listenToEvent("onMouseOver", onMouseOver);
|
|
||||||
canvas.eventHandler.listenToEvent("onMouseNotOver", onMouseNotOver);
|
|
||||||
thisObject.eventHandler.listenToEvent("onMouseClick", onMouseClick);
|
|
||||||
|
|
||||||
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); }
|
|
||||||
}
|
}
|
||||||
}
|
case 'Note': {
|
||||||
|
underlayingObject = newNote()
|
||||||
|
underlayingObject.initialize(onInitialized)
|
||||||
|
|
||||||
function physicsLoop(callBackFunction) {
|
function onInitialized (err) {
|
||||||
|
|
||||||
try {
|
}
|
||||||
|
break
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
|
|
||||||
underlayingObject.physicsLoop();
|
|
||||||
|
|
||||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); }
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] physicsLoop -> err.message = " + err.message); }
|
|
||||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseOver() {
|
|
||||||
|
|
||||||
thisObject.targetRadius = thisObject.rawRadius * 1.5;
|
|
||||||
thisObject.targetImageSize = thisObject.rawImageSize * 1.5;
|
|
||||||
thisObject.targetFontSize = thisObject.rawFontSize * 1.5;
|
|
||||||
|
|
||||||
underlayingObject.onMouseOver();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseNotOver() {
|
|
||||||
|
|
||||||
thisObject.targetRadius = thisObject.rawRadius * 1;
|
|
||||||
thisObject.targetImageSize = thisObject.rawImageSize * 1;
|
|
||||||
thisObject.targetFontSize = thisObject.rawFontSize * 1;
|
|
||||||
|
|
||||||
underlayingObject.onMouseNotOver();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseClick(pPoint) {
|
|
||||||
|
|
||||||
underlayingObject.onMouseClick(pPoint, thisObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawBackground() {
|
|
||||||
|
|
||||||
underlayingObject.drawBackground(thisObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawForeground() {
|
|
||||||
|
|
||||||
underlayingObject.drawForeground(thisObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeMass(suggestedValue) {
|
|
||||||
|
|
||||||
var mass = suggestedValue;
|
|
||||||
if (mass < 0.1) {
|
|
||||||
mass = 0.1;
|
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
thisObject.rawMass = mass;
|
break
|
||||||
thisObject.currentMass = mass;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeRadius(suggestedValue) {
|
|
||||||
|
|
||||||
var radius = suggestedValue;
|
|
||||||
if (radius < 2) {
|
|
||||||
radius = 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.rawRadius = radius;
|
thisObject.type = pType
|
||||||
thisObject.targetRadius = radius;
|
|
||||||
thisObject.currentRadius = radius / 3;
|
|
||||||
|
|
||||||
|
thisObject.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||||
|
canvas.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||||
|
thisObject.eventHandler.listenToEvent('onMouseClick', onMouseClick)
|
||||||
|
|
||||||
|
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 physicsLoop (callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
|
underlayingObject.physicsLoop()
|
||||||
|
|
||||||
|
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] physicsLoop -> err.message = ' + err.message) }
|
||||||
|
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseOver () {
|
||||||
|
thisObject.targetRadius = thisObject.rawRadius * 1.5
|
||||||
|
thisObject.targetImageSize = thisObject.rawImageSize * 1.5
|
||||||
|
thisObject.targetFontSize = thisObject.rawFontSize * 1.5
|
||||||
|
|
||||||
|
underlayingObject.onMouseOver()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseNotOver () {
|
||||||
|
thisObject.targetRadius = thisObject.rawRadius * 1
|
||||||
|
thisObject.targetImageSize = thisObject.rawImageSize * 1
|
||||||
|
thisObject.targetFontSize = thisObject.rawFontSize * 1
|
||||||
|
|
||||||
|
underlayingObject.onMouseNotOver()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseClick (pPoint) {
|
||||||
|
underlayingObject.onMouseClick(pPoint, thisObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawBackground () {
|
||||||
|
underlayingObject.drawBackground(thisObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawForeground () {
|
||||||
|
underlayingObject.drawForeground(thisObject)
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeMass (suggestedValue) {
|
||||||
|
var mass = suggestedValue
|
||||||
|
if (mass < 0.1) {
|
||||||
|
mass = 0.1
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeImageSize(suggestedValue) {
|
thisObject.rawMass = mass
|
||||||
|
thisObject.currentMass = mass
|
||||||
var size = suggestedValue;
|
}
|
||||||
if (size < 2) {
|
|
||||||
size = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.rawImageSize = size;
|
|
||||||
thisObject.targetImageSize = size;
|
|
||||||
thisObject.currentImageSize = size / 3;
|
|
||||||
|
|
||||||
|
function initializeRadius (suggestedValue) {
|
||||||
|
var radius = suggestedValue
|
||||||
|
if (radius < 2) {
|
||||||
|
radius = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeFontSize(suggestedValue) {
|
thisObject.rawRadius = radius
|
||||||
|
thisObject.targetRadius = radius
|
||||||
var size = suggestedValue;
|
thisObject.currentRadius = radius / 3
|
||||||
if (size < 3) {
|
}
|
||||||
size = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.rawFontSize = size;
|
|
||||||
thisObject.targetFontSize = size;
|
|
||||||
thisObject.currentFontSize = size / 3;
|
|
||||||
|
|
||||||
|
function initializeImageSize (suggestedValue) {
|
||||||
|
var size = suggestedValue
|
||||||
|
if (size < 2) {
|
||||||
|
size = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
function radomizeCurrentPosition(arroundPoint) {
|
thisObject.rawImageSize = size
|
||||||
|
thisObject.targetImageSize = size
|
||||||
|
thisObject.currentImageSize = size / 3
|
||||||
|
}
|
||||||
|
|
||||||
var position = {
|
function initializeFontSize (suggestedValue) {
|
||||||
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
|
var size = suggestedValue
|
||||||
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
|
if (size < 3) {
|
||||||
};
|
size = 3
|
||||||
|
|
||||||
thisObject.currentPosition = position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function radomizeCurrentSpeed() {
|
thisObject.rawFontSize = size
|
||||||
|
thisObject.targetFontSize = size
|
||||||
|
thisObject.currentFontSize = size / 3
|
||||||
|
}
|
||||||
|
|
||||||
var initialXDirection;
|
function radomizeCurrentPosition (arroundPoint) {
|
||||||
var randomX = Math.floor((Math.random() * 10) + 1);
|
var position = {
|
||||||
if (randomX > 5) {
|
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
|
||||||
initialXDirection = 1;
|
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
|
||||||
} else {
|
|
||||||
initialXDirection = - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var initialYDirection;
|
|
||||||
var randomY = Math.floor((Math.random() * 10) + 1);
|
|
||||||
if (randomY > 5) {
|
|
||||||
initialYDirection = 1;
|
|
||||||
} else {
|
|
||||||
initialYDirection = - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var velocity = {
|
|
||||||
x: initialXDirection * Math.floor((Math.random() * 300) + 1) / 100,
|
|
||||||
y: initialYDirection * Math.floor((Math.random() * 300) + 1) / 100
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.currentSpeed = velocity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMass() {
|
thisObject.currentPosition = position
|
||||||
|
}
|
||||||
//thisObject.currentMass = thisObject.rawMass + thisObject.rawMass * thisObject.container.zoom.incrementM * thisObject.container.zoom.levelM;
|
|
||||||
|
|
||||||
|
function radomizeCurrentSpeed () {
|
||||||
|
var initialXDirection
|
||||||
|
var randomX = Math.floor((Math.random() * 10) + 1)
|
||||||
|
if (randomX > 5) {
|
||||||
|
initialXDirection = 1
|
||||||
|
} else {
|
||||||
|
initialXDirection = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRadius() {
|
var initialYDirection
|
||||||
|
var randomY = Math.floor((Math.random() * 10) + 1)
|
||||||
//thisObject.targetRadius = thisObject.rawRadius + thisObject.rawRadius * thisObject.container.zoom.incrementR * thisObject.container.zoom.levelR;
|
if (randomY > 5) {
|
||||||
|
initialYDirection = 1
|
||||||
|
} else {
|
||||||
|
initialYDirection = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var velocity = {
|
||||||
|
x: initialXDirection * Math.floor((Math.random() * 300) + 1) / 100,
|
||||||
|
y: initialYDirection * Math.floor((Math.random() * 300) + 1) / 100
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.currentSpeed = velocity
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateMass () {
|
||||||
|
|
||||||
|
// thisObject.currentMass = thisObject.rawMass + thisObject.rawMass * thisObject.container.zoom.incrementM * thisObject.container.zoom.levelM;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateRadius () {
|
||||||
|
|
||||||
|
// thisObject.targetRadius = thisObject.rawRadius + thisObject.rawRadius * thisObject.container.zoom.incrementR * thisObject.container.zoom.levelR;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+212
-244
@@ -1,336 +1,304 @@
|
|||||||
|
|
||||||
function newNote() {
|
function newNote () {
|
||||||
|
var thisObject = {
|
||||||
|
|
||||||
var thisObject = {
|
physicsLoop: physicsLoop,
|
||||||
|
onMouseOver: onMouseOver,
|
||||||
|
onMouseClick: onMouseClick,
|
||||||
|
onMouseNotOver: onMouseNotOver,
|
||||||
|
drawBackground: drawBackground,
|
||||||
|
drawForeground: drawForeground,
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
physicsLoop: physicsLoop,
|
}
|
||||||
onMouseOver: onMouseOver,
|
|
||||||
onMouseClick: onMouseClick,
|
|
||||||
onMouseNotOver: onMouseNotOver,
|
|
||||||
drawBackground: drawBackground,
|
|
||||||
drawForeground: drawForeground,
|
|
||||||
initialize: initialize
|
|
||||||
|
|
||||||
};
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize (callBackFunction) {
|
||||||
|
callBackFunction()
|
||||||
|
}
|
||||||
|
|
||||||
function initialize(callBackFunction) {
|
function physicsLoop () {
|
||||||
|
|
||||||
callBackFunction();
|
}
|
||||||
|
|
||||||
|
function onMouseOver () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseNotOver () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseClick (pPoint, pFloatingObject) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawBackground (pFloatingObject) {
|
||||||
|
let point = {
|
||||||
|
x: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x,
|
||||||
|
y: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y
|
||||||
}
|
}
|
||||||
|
|
||||||
function physicsLoop() {
|
point = viewPort.fitIntoVisibleArea(point)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseOver() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseNotOver() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseClick(pPoint, pFloatingObject) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawBackground(pFloatingObject) {
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.x,
|
|
||||||
y: pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].position.y
|
|
||||||
};
|
|
||||||
|
|
||||||
point = viewPort.fitIntoVisibleArea(point);
|
|
||||||
|
|
||||||
if (pFloatingObject.currentRadius > 1) {
|
|
||||||
|
|
||||||
|
if (pFloatingObject.currentRadius > 1) {
|
||||||
/* Target Line */
|
/* Target Line */
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
browserCanvasContext.moveTo(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y);
|
browserCanvasContext.moveTo(pFloatingObject.currentPosition.x, pFloatingObject.currentPosition.y)
|
||||||
browserCanvasContext.lineTo(point.x, point.y);
|
browserCanvasContext.lineTo(point.x, point.y)
|
||||||
browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)';
|
browserCanvasContext.strokeStyle = 'rgba(204, 204, 204, 0.5)'
|
||||||
browserCanvasContext.setLineDash([4, 2]);
|
browserCanvasContext.setLineDash([4, 2])
|
||||||
browserCanvasContext.lineWidth = 1;
|
browserCanvasContext.lineWidth = 1
|
||||||
browserCanvasContext.stroke();
|
browserCanvasContext.stroke()
|
||||||
browserCanvasContext.setLineDash([0, 0]);
|
browserCanvasContext.setLineDash([0, 0])
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pFloatingObject.currentRadius > 0.5) {
|
|
||||||
|
|
||||||
/* Target Spot */
|
|
||||||
|
|
||||||
var radius = 1;
|
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
|
||||||
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true);
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)';
|
|
||||||
browserCanvasContext.fill();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawForeground(pFloatingObject) {
|
if (pFloatingObject.currentRadius > 0.5) {
|
||||||
|
/* Target Spot */
|
||||||
|
|
||||||
const BUBBLE_CORNERS_RADIOUS = 5;
|
var radius = 1
|
||||||
const TITLE_BAR_HEIGHT = 14;
|
|
||||||
|
|
||||||
const BUBBLE_WIDTH = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 4;
|
browserCanvasContext.beginPath()
|
||||||
const BUBBLE_HEIGHT = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 2;
|
browserCanvasContext.arc(point.x, point.y, radius, 0, Math.PI * 2, true)
|
||||||
|
browserCanvasContext.closePath()
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, 1)'
|
||||||
|
browserCanvasContext.fill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let borderPoint1;
|
function drawForeground (pFloatingObject) {
|
||||||
let borderPoint2;
|
const BUBBLE_CORNERS_RADIOUS = 5
|
||||||
let borderPoint3;
|
const TITLE_BAR_HEIGHT = 14
|
||||||
let borderPoint4;
|
|
||||||
|
|
||||||
let intialDisplace = {
|
const BUBBLE_WIDTH = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 4
|
||||||
x: pFloatingObject.currentPosition.x - BUBBLE_WIDTH / 2,
|
const BUBBLE_HEIGHT = BUBBLE_CORNERS_RADIOUS + pFloatingObject.currentRadius * 2
|
||||||
y: pFloatingObject.currentPosition.y - BUBBLE_HEIGHT / 2
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pFloatingObject.currentRadius > 5) {
|
let borderPoint1
|
||||||
|
let borderPoint2
|
||||||
|
let borderPoint3
|
||||||
|
let borderPoint4
|
||||||
|
|
||||||
|
let intialDisplace = {
|
||||||
|
x: pFloatingObject.currentPosition.x - BUBBLE_WIDTH / 2,
|
||||||
|
y: pFloatingObject.currentPosition.y - BUBBLE_HEIGHT / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pFloatingObject.currentRadius > 5) {
|
||||||
/* Rounded Background */
|
/* Rounded Background */
|
||||||
|
|
||||||
borderPoint1 = {
|
borderPoint1 = {
|
||||||
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
||||||
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
||||||
};
|
}
|
||||||
|
|
||||||
borderPoint2 = {
|
borderPoint2 = {
|
||||||
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
||||||
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
y: intialDisplace.y + BUBBLE_CORNERS_RADIOUS
|
||||||
};
|
}
|
||||||
|
|
||||||
borderPoint3 = {
|
borderPoint3 = {
|
||||||
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
x: intialDisplace.x + BUBBLE_WIDTH - BUBBLE_CORNERS_RADIOUS,
|
||||||
y: intialDisplace.y + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
y: intialDisplace.y + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
||||||
};
|
}
|
||||||
|
|
||||||
borderPoint4 = {
|
borderPoint4 = {
|
||||||
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
x: intialDisplace.x + BUBBLE_CORNERS_RADIOUS,
|
||||||
y: intialDisplace.y + + BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
y: intialDisplace.y + +BUBBLE_HEIGHT - BUBBLE_CORNERS_RADIOUS
|
||||||
};
|
}
|
||||||
|
|
||||||
titleBarPoint1 = {
|
titleBarPoint1 = {
|
||||||
x: intialDisplace.x + 0,
|
x: intialDisplace.x + 0,
|
||||||
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
||||||
};
|
}
|
||||||
|
|
||||||
titleBarPoint2 = {
|
titleBarPoint2 = {
|
||||||
x: intialDisplace.x + BUBBLE_WIDTH,
|
x: intialDisplace.x + BUBBLE_WIDTH,
|
||||||
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
y: intialDisplace.y + TITLE_BAR_HEIGHT
|
||||||
};
|
}
|
||||||
|
|
||||||
/* We paint the panel background first */
|
/* We paint the panel background first */
|
||||||
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(255, 249, 196, 0.75)';
|
browserCanvasContext.fillStyle = 'rgba(255, 249, 196, 0.75)'
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI);
|
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS);
|
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS)
|
||||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI);
|
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint3.x + BUBBLE_CORNERS_RADIOUS, borderPoint3.y);
|
browserCanvasContext.lineTo(borderPoint3.x + BUBBLE_CORNERS_RADIOUS, borderPoint3.y)
|
||||||
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, BUBBLE_CORNERS_RADIOUS, 0 * Math.PI, 0.5 * Math.PI);
|
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, BUBBLE_CORNERS_RADIOUS, 0 * Math.PI, 0.5 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + BUBBLE_CORNERS_RADIOUS);
|
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + BUBBLE_CORNERS_RADIOUS)
|
||||||
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, BUBBLE_CORNERS_RADIOUS, 0.5 * Math.PI, 1.0 * Math.PI);
|
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, BUBBLE_CORNERS_RADIOUS, 0.5 * Math.PI, 1.0 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y);
|
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y)
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
|
|
||||||
browserCanvasContext.fill();
|
browserCanvasContext.fill()
|
||||||
|
|
||||||
browserCanvasContext.lineWidth = 0.1;
|
browserCanvasContext.lineWidth = 0.1
|
||||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)';
|
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)'
|
||||||
browserCanvasContext.stroke();
|
browserCanvasContext.stroke()
|
||||||
|
|
||||||
/* We paint the title bar now */
|
/* We paint the title bar now */
|
||||||
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(244, 224, 44, 0.75)';
|
browserCanvasContext.fillStyle = 'rgba(244, 224, 44, 0.75)'
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y);
|
browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y)
|
||||||
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y);
|
browserCanvasContext.lineTo(borderPoint1.x - BUBBLE_CORNERS_RADIOUS, borderPoint1.y)
|
||||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI);
|
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, BUBBLE_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS);
|
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - BUBBLE_CORNERS_RADIOUS)
|
||||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI);
|
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, BUBBLE_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI)
|
||||||
browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y);
|
browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y)
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
browserCanvasContext.fill();
|
browserCanvasContext.fill()
|
||||||
|
|
||||||
browserCanvasContext.lineWidth = 0.1;
|
browserCanvasContext.lineWidth = 0.1
|
||||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 0.75)';
|
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', 0.75)'
|
||||||
browserCanvasContext.stroke();
|
browserCanvasContext.stroke()
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pFloatingObject.currentRadius > 0.5) {
|
|
||||||
|
|
||||||
|
if (pFloatingObject.currentRadius > 0.5) {
|
||||||
/* Image */
|
/* Image */
|
||||||
|
|
||||||
let imagePosition = {
|
let imagePosition = {
|
||||||
x: pFloatingObject.currentPosition.x,
|
x: pFloatingObject.currentPosition.x,
|
||||||
y: pFloatingObject.currentPosition.y + BUBBLE_HEIGHT / 2
|
y: pFloatingObject.currentPosition.y + BUBBLE_HEIGHT / 2
|
||||||
};
|
}
|
||||||
|
|
||||||
if (pFloatingObject.payloadImageId !== undefined) {
|
if (pFloatingObject.payloadImageId !== undefined) {
|
||||||
|
let image = document.getElementById(pFloatingObject.payloadImageId)
|
||||||
|
|
||||||
let image = document.getElementById(pFloatingObject.payloadImageId);
|
if (image !== null) {
|
||||||
|
browserCanvasContext.drawImage(image, imagePosition.x - pFloatingObject.currentImageSize / 2, imagePosition.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize, pFloatingObject.currentImageSize)
|
||||||
if (image !== null) {
|
}
|
||||||
|
}
|
||||||
browserCanvasContext.drawImage(image, imagePosition.x - pFloatingObject.currentImageSize / 2, imagePosition.y - pFloatingObject.currentImageSize / 2, pFloatingObject.currentImageSize, pFloatingObject.currentImageSize);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Image Contourn */
|
/* Image Contourn */
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
browserCanvasContext.arc(imagePosition.x, imagePosition.y, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true);
|
browserCanvasContext.arc(imagePosition.x, imagePosition.y, pFloatingObject.currentImageSize / 2, 0, Math.PI * 2, true)
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.25)';
|
browserCanvasContext.strokeStyle = 'rgba(30, 30, 30, 0.25)'
|
||||||
browserCanvasContext.lineWidth = 1;
|
browserCanvasContext.lineWidth = 1
|
||||||
browserCanvasContext.stroke();
|
browserCanvasContext.stroke()
|
||||||
|
|
||||||
/* Labels */
|
/* Labels */
|
||||||
|
|
||||||
if (pFloatingObject.currentRadius > 6) {
|
if (pFloatingObject.currentRadius > 6) {
|
||||||
|
browserCanvasContext.strokeStyle = pFloatingObject.labelStrokeStyle
|
||||||
|
|
||||||
browserCanvasContext.strokeStyle = pFloatingObject.labelStrokeStyle;
|
const SIZE_PERCENTAGE = Math.trunc(pFloatingObject.currentRadius / pFloatingObject.targetRadius * 100) / 100
|
||||||
|
let ALPHA
|
||||||
|
|
||||||
const SIZE_PERCENTAGE = Math.trunc(pFloatingObject.currentRadius / pFloatingObject.targetRadius * 100) / 100;
|
if (pFloatingObject.targetRadius > 0) {
|
||||||
let ALPHA;
|
ALPHA = 0.5 - (1 - SIZE_PERCENTAGE) * 5
|
||||||
|
} else {
|
||||||
|
// Object is dying...
|
||||||
|
|
||||||
if (pFloatingObject.targetRadius > 0) {
|
ALPHA = Math.trunc((0.5 - (100 - pFloatingObject.currentRadius / 100)) * 100) / 100
|
||||||
|
|
||||||
ALPHA = 0.5 - (1 - SIZE_PERCENTAGE) * 5;
|
if (ALPHA < 0) { ALPHA = 0 }
|
||||||
|
}
|
||||||
|
|
||||||
} else { // Object is dying...
|
let labelPoint
|
||||||
|
let fontSize = 10
|
||||||
|
|
||||||
ALPHA = Math.trunc((0.5 - (100 - pFloatingObject.currentRadius / 100) ) * 100) / 100;
|
let label
|
||||||
|
|
||||||
if (ALPHA < 0) { ALPHA = 0}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
let labelPoint;
|
|
||||||
let fontSize = 10;
|
|
||||||
|
|
||||||
let label;
|
|
||||||
|
|
||||||
/* print the title */
|
/* print the title */
|
||||||
|
|
||||||
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].title;
|
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].title
|
||||||
|
|
||||||
if (label !== undefined) {
|
if (label !== undefined) {
|
||||||
|
if (SIZE_PERCENTAGE > 0.9) {
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||||
|
|
||||||
if (SIZE_PERCENTAGE > 0.9) {
|
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO
|
||||||
|
let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
labelPoint = {
|
||||||
|
x: intialDisplace.x + BUBBLE_WIDTH / 2 - xOffset,
|
||||||
|
y: intialDisplace.y + TITLE_BAR_HEIGHT - yOffset
|
||||||
|
}
|
||||||
|
|
||||||
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO;
|
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, ' + ALPHA + ')'
|
||||||
let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2;
|
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||||
|
}
|
||||||
labelPoint = {
|
}
|
||||||
x: intialDisplace.x + BUBBLE_WIDTH / 2 - xOffset,
|
|
||||||
y: intialDisplace.y + TITLE_BAR_HEIGHT - yOffset
|
|
||||||
};
|
|
||||||
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(30, 30, 30, ' + ALPHA + ')'
|
|
||||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Message Body */
|
/* Message Body */
|
||||||
|
|
||||||
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].body;
|
label = pFloatingObject.payload.notes[pFloatingObject.payloadNoteIndex].body
|
||||||
|
|
||||||
if (label !== undefined) {
|
if (label !== undefined) {
|
||||||
|
const WORDS_PER_ROW = 5
|
||||||
|
const TOTAL_ROWS = 5
|
||||||
|
|
||||||
const WORDS_PER_ROW = 5;
|
if (SIZE_PERCENTAGE > 0.9) {
|
||||||
const TOTAL_ROWS = 5;
|
let rawLabelArray = label.split(' ')
|
||||||
|
let labelArray = []
|
||||||
if (SIZE_PERCENTAGE > 0.9) {
|
|
||||||
|
|
||||||
let rawLabelArray = label.split(" ");
|
|
||||||
let labelArray = [];
|
|
||||||
|
|
||||||
/* Lets check when words are to long we add an empty space to the same line so as to roll all other words forward. */
|
/* Lets check when words are to long we add an empty space to the same line so as to roll all other words forward. */
|
||||||
|
|
||||||
for (let i = 0; i < rawLabelArray.length; i++) {
|
for (let i = 0; i < rawLabelArray.length; i++) {
|
||||||
|
let word = rawLabelArray[i]
|
||||||
|
|
||||||
let word = rawLabelArray[i];
|
labelArray.push(word)
|
||||||
|
|
||||||
labelArray.push(word);
|
if (word.length > 8) {
|
||||||
|
labelArray.push('')
|
||||||
|
}
|
||||||
|
|
||||||
if (word.length > 8) {
|
if (word.length > 10) {
|
||||||
labelArray.push("");
|
labelArray.push('')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (word.length > 10) {
|
|
||||||
labelArray.push("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate each ROW */
|
/* Calculate each ROW */
|
||||||
|
|
||||||
let labelRows = [];
|
let labelRows = []
|
||||||
|
|
||||||
for (let i = 0; i < TOTAL_ROWS; i++) {
|
for (let i = 0; i < TOTAL_ROWS; i++) {
|
||||||
|
let labelRow = ''
|
||||||
|
|
||||||
let labelRow = "";
|
for (let j = 0; j < WORDS_PER_ROW; j++) {
|
||||||
|
let newWord = labelArray[j + i * WORDS_PER_ROW]
|
||||||
|
|
||||||
for (let j = 0; j < WORDS_PER_ROW; j++) {
|
if (newWord !== undefined && newWord !== '') {
|
||||||
|
labelRow = labelRow + ' ' + newWord
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let newWord = labelArray[j + i * WORDS_PER_ROW];
|
if (labelRow !== '') {
|
||||||
|
labelRows.push(labelRow)
|
||||||
if (newWord !== undefined && newWord !== "") {
|
}
|
||||||
|
}
|
||||||
labelRow = labelRow + " " + newWord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (labelRow !== "") {
|
|
||||||
|
|
||||||
labelRows.push(labelRow);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now we plot each row. */
|
/* Now we plot each row. */
|
||||||
|
|
||||||
for (let i = 0; i < labelRows.length; i++) {
|
for (let i = 0; i < labelRows.length; i++) {
|
||||||
|
let labelRow = labelRows[i]
|
||||||
|
|
||||||
let labelRow = labelRows[i];
|
let startingPosition = {
|
||||||
|
x: pFloatingObject.currentPosition.x,
|
||||||
|
y: pFloatingObject.currentPosition.y - labelRows.length / 2 * (fontSize * FONT_ASPECT_RATIO + 10)
|
||||||
|
}
|
||||||
|
|
||||||
let startingPosition = {
|
labelPoint = {
|
||||||
x: pFloatingObject.currentPosition.x,
|
x: startingPosition.x - labelRow.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
||||||
y: pFloatingObject.currentPosition.y - labelRows.length / 2 * (fontSize * FONT_ASPECT_RATIO + 10)
|
y: startingPosition.y + (i + 1) * (fontSize * FONT_ASPECT_RATIO + 10)
|
||||||
};
|
}
|
||||||
|
|
||||||
labelPoint = {
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||||
x: startingPosition.x - labelRow.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, ' + ALPHA + ')'
|
||||||
y: startingPosition.y + (i + 1) * (fontSize * FONT_ASPECT_RATIO + 10)
|
browserCanvasContext.fillText(labelRow, labelPoint.x, labelPoint.y)
|
||||||
};
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, ' + ALPHA + ')'
|
|
||||||
browserCanvasContext.fillText(labelRow, labelPoint.x, labelPoint.y);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+186
-222
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
function newNoteSets() {
|
function newNoteSets () {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Different plotters will identify sets of notes whithin the data they are plotting. They will create with them arrays of Notes data.
|
Different plotters will identify sets of notes whithin the data they are plotting. They will create with them arrays of Notes data.
|
||||||
On the other hand the floating space, and a floting layer in particular, manages Notes floating objects, which are visible entities
|
On the other hand the floating space, and a floting layer in particular, manages Notes floating objects, which are visible entities
|
||||||
@@ -14,48 +13,43 @@ function newNoteSets() {
|
|||||||
This module is capable of managing an array of NoteSets.
|
This module is capable of managing an array of NoteSets.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MODULE_NAME = "Note Sets";
|
const MODULE_NAME = 'Note Sets'
|
||||||
const INFO_LOG = false;
|
const INFO_LOG = false
|
||||||
const INFO_WARN = true;
|
const INFO_WARN = true
|
||||||
const ERROR_LOG = true;
|
const ERROR_LOG = true
|
||||||
const logger = newWebDebugLog();
|
const logger = newWebDebugLog()
|
||||||
logger.fileName = MODULE_NAME;
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
let thisObject = {
|
let thisObject = {
|
||||||
createNoteSet: createNoteSet,
|
createNoteSet: createNoteSet,
|
||||||
destroyNoteSet: destroyNoteSet,
|
destroyNoteSet: destroyNoteSet,
|
||||||
initialize: initialize
|
initialize: initialize
|
||||||
};
|
}
|
||||||
|
|
||||||
let noteSets = [];
|
let noteSets = []
|
||||||
let floatingLayer;
|
let floatingLayer
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(pFloatingLayer, callBackFunction) {
|
|
||||||
|
|
||||||
|
function initialize (pFloatingLayer, callBackFunction) {
|
||||||
/*
|
/*
|
||||||
During the initialization process, we receive the floatingLayer where all the floatingObjects we will be creating here will live at.
|
During the initialization process, we receive the floatingLayer where all the floatingObjects we will be creating here will live at.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
floatingLayer = pFloatingLayer
|
||||||
|
|
||||||
floatingLayer = pFloatingLayer;
|
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE)
|
||||||
|
} catch (err) {
|
||||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE);
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createNoteSet(pPayload, pEventHandler, callBackFunction) {
|
function createNoteSet (pPayload, pEventHandler, callBackFunction) {
|
||||||
|
try {
|
||||||
try {
|
|
||||||
/*
|
/*
|
||||||
During the creating of a NoteSet, no floating objects are created yet. What we do here is to create the data structure which will allocate
|
During the creating of a NoteSet, no floating objects are created yet. What we do here is to create the data structure which will allocate
|
||||||
the Notes floating objects, once we receive the array of notes raw data from the plotter. This array will come as an event raised by the
|
the Notes floating objects, once we receive the array of notes raw data from the plotter. This array will come as an event raised by the
|
||||||
@@ -63,41 +57,39 @@ function newNoteSets() {
|
|||||||
position the user gives to the viewport, but also, the plotter can be receiving actually new notes from its datasource.
|
position the user gives to the viewport, but also, the plotter can be receiving actually new notes from its datasource.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> Entering function.') }
|
||||||
|
|
||||||
let noteSet = {
|
let noteSet = {
|
||||||
imageId: pPayload.profile.imageId,
|
imageId: pPayload.profile.imageId,
|
||||||
floatingNotes: [],
|
floatingNotes: [],
|
||||||
payload: pPayload,
|
payload: pPayload,
|
||||||
handle: Math.floor((Math.random() * 10000000) + 1)
|
handle: Math.floor((Math.random() * 10000000) + 1)
|
||||||
};
|
}
|
||||||
|
|
||||||
noteSets.push(noteSet);
|
noteSets.push(noteSet)
|
||||||
|
|
||||||
pEventHandler.listenToEvent("Notes Changed", onNotesChanged, noteSets.length - 1)
|
pEventHandler.listenToEvent('Notes Changed', onNotesChanged, noteSets.length - 1)
|
||||||
|
|
||||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, noteSet.handle);
|
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, noteSet.handle)
|
||||||
|
|
||||||
function onNotesChanged(pNewNotes, pNoteSetIndex) {
|
function onNotesChanged (pNewNotes, pNoteSetIndex) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> pNewNotes.length = ' + pNewNotes.length) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> pNoteSetIndex = ' + pNoteSetIndex) }
|
||||||
|
|
||||||
try {
|
let noteSet = noteSets[pNoteSetIndex]
|
||||||
|
let found = false
|
||||||
|
let newFloatingNotes
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Entering function."); }
|
/*
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> pNewNotes.length = " + pNewNotes.length); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> pNoteSetIndex = " + pNoteSetIndex); }
|
|
||||||
|
|
||||||
let noteSet = noteSets[pNoteSetIndex];
|
|
||||||
let found = false;
|
|
||||||
let newFloatingNotes;
|
|
||||||
|
|
||||||
/*
|
|
||||||
First we remove the old notes. This means that we are going to scan all the floating objects that we have, and see one by one if they
|
First we remove the old notes. This means that we are going to scan all the floating objects that we have, and see one by one if they
|
||||||
are still present on the raw data sent by the plotter. If it is not there, that means that the floating object must be discarded.
|
are still present on the raw data sent by the plotter. If it is not there, that means that the floating object must be discarded.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes.') }
|
||||||
|
|
||||||
newFloatingNotes = []; // We will create a new array of Floating Notes as a result of this operation.
|
newFloatingNotes = [] // We will create a new array of Floating Notes as a result of this operation.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Here we scan the curren array of floating objects. We use the date + rate to create a unique key for each one, in order to be able to
|
Here we scan the curren array of floating objects. We use the date + rate to create a unique key for each one, in order to be able to
|
||||||
@@ -105,171 +97,156 @@ function newNoteSets() {
|
|||||||
that are still at the raw data array to a new array, and not adding the ones that are not.
|
that are still at the raw data array to a new array, and not adding the ones that are not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||||
|
found = false
|
||||||
|
|
||||||
found = false;
|
let floatingNote = noteSet.floatingNotes[j]
|
||||||
|
let floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString()
|
||||||
|
|
||||||
let floatingNote = noteSet.floatingNotes[j];
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> j = ' + j) }
|
||||||
let floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString();
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> j = " + j); }
|
let i
|
||||||
|
|
||||||
let i;
|
for (i = 0; i < pNewNotes.length; i++) {
|
||||||
|
let plotterNote = pNewNotes[i]
|
||||||
|
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString()
|
||||||
|
|
||||||
for (i = 0; i < pNewNotes.length; i++) {
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> i = ' + i) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNoteKey = ' + floatingNoteKey) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> plotterNoteKey = ' + plotterNoteKey) }
|
||||||
|
|
||||||
let plotterNote = pNewNotes[i];
|
if (plotterNoteKey === floatingNoteKey) {
|
||||||
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString();
|
found = true
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> i = " + i); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> found = ' + found) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNoteKey = " + floatingNoteKey); }
|
break
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> plotterNoteKey = " + plotterNoteKey); }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (plotterNoteKey === floatingNoteKey) {
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> End of For i.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> found = ' + found) }
|
||||||
found = true;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> found = " + found); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> End of For i."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> found = " + found); }
|
|
||||||
|
|
||||||
if (found === false) {
|
|
||||||
|
|
||||||
|
if (found === false) {
|
||||||
/*
|
/*
|
||||||
Each time we identify a floatingObject that is not at the raw data anymore, we request the floatinglayer to kill it.
|
Each time we identify a floatingObject that is not at the raw data anymore, we request the floatinglayer to kill it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
floatingLayer.killFloatingObject(floatingNote.floatingHandle, onObjectKilled);
|
floatingLayer.killFloatingObject(floatingNote.floatingHandle, onObjectKilled)
|
||||||
|
|
||||||
function onObjectKilled(err) {
|
function onObjectKilled (err) {
|
||||||
|
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object Not Found.') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object cannot be killed.') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Removed from Layer.') }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newFloatingNotes.push(floatingNote)
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object Not Found."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object cannot be killed."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Added to newFloatingNotes.') }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> newFloatingNotes.length = ' + newFloatingNotes.length) }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Removed from Layer."); }
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
newFloatingNotes.push(floatingNote);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Added to newFloatingNotes."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> newFloatingNotes.length = " + newFloatingNotes.length); }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We set a property at each floatingObject of which is the index of the note at the raw data array, so that it can later evaluate its position or its visibility.
|
We set a property at each floatingObject of which is the index of the note at the raw data array, so that it can later evaluate its position or its visibility.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle);
|
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle)
|
||||||
floatingObject.payloadNoteIndex = i;
|
floatingObject.payloadNoteIndex = i
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject index updated."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject index updated.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject.payloadNoteIndex = " + i); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingObject.payloadNoteIndex = ' + i) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We replace the current array, with the new one that only contains the surviving floating objects, meaning the ones that are still at the raw data received.
|
We replace the current array, with the new one that only contains the surviving floating objects, meaning the ones that are still at the raw data received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
noteSet.floatingNotes = newFloatingNotes;
|
noteSet.floatingNotes = newFloatingNotes
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> noteSet.floatingNotes.length = " + noteSet.floatingNotes.length); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> noteSet.floatingNotes.length = ' + noteSet.floatingNotes.length) }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Second we add the new notes. There might be new notes at the raw data received that we didnt have before at the NodeSet array. To figure out which
|
Second we add the new notes. There might be new notes at the raw data received that we didnt have before at the NodeSet array. To figure out which
|
||||||
ones are, we need to scan the raw data array and compare each element with the ones of the NodeSet array. Whenever we find one that is not there,
|
ones are, we need to scan the raw data array and compare each element with the ones of the NodeSet array. Whenever we find one that is not there,
|
||||||
we add it.
|
we add it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes.') }
|
||||||
|
|
||||||
newFloatingNotes = []; // We will create a new array of Floating Notes as a result of this operation.
|
newFloatingNotes = [] // We will create a new array of Floating Notes as a result of this operation.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We are using the date and rate as a unique key to identify each note. To prevent the cases of duplicate keys, we will check that at
|
We are using the date and rate as a unique key to identify each note. To prevent the cases of duplicate keys, we will check that at
|
||||||
least to consecutive records dont have the same key, and if they do, will ignore the second one.
|
least to consecutive records dont have the same key, and if they do, will ignore the second one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let lastPlotterKey = "";
|
let lastPlotterKey = ''
|
||||||
|
|
||||||
for (let i = 0; i < pNewNotes.length; i++) {
|
for (let i = 0; i < pNewNotes.length; i++) {
|
||||||
|
found = false
|
||||||
|
|
||||||
found = false;
|
let plotterNote = pNewNotes[i]
|
||||||
|
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString()
|
||||||
|
let floatingNote
|
||||||
|
let floatingNoteKey
|
||||||
|
|
||||||
let plotterNote = pNewNotes[i];
|
if (lastPlotterKey === plotterNoteKey) {
|
||||||
let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString();
|
if (INFO_WARN === true) { logger.write('[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> Duplicate record detected. Discarding it.') }
|
||||||
let floatingNote;
|
if (INFO_WARN === true) { logger.write('[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> i = ' + i) }
|
||||||
let floatingNoteKey;
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if (lastPlotterKey === plotterNoteKey) {
|
lastPlotterKey = plotterNoteKey
|
||||||
|
|
||||||
if (INFO_WARN=== true) { logger.write("[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> Duplicate record detected. Discarding it."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = ' + i) }
|
||||||
if (INFO_WARN === true) { logger.write("[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); }
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastPlotterKey = plotterNoteKey;
|
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||||
|
floatingNote = noteSet.floatingNotes[j]
|
||||||
|
floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString()
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> j = ' + j) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> floatingNoteKey = ' + floatingNoteKey) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNoteKey = ' + plotterNoteKey) }
|
||||||
|
|
||||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
if (plotterNoteKey === floatingNoteKey) {
|
||||||
|
found = true
|
||||||
|
|
||||||
floatingNote = noteSet.floatingNotes[j];
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = ' + found) }
|
||||||
floatingNoteKey = floatingNote.date.toString() + floatingNote.rate.toString();
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> j = " + j); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> End of For j.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> floatingNoteKey = " + floatingNoteKey); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = ' + found) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNoteKey = " + plotterNoteKey); }
|
|
||||||
|
|
||||||
if (plotterNoteKey === floatingNoteKey) {
|
|
||||||
|
|
||||||
found = true;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = " + found); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> End of For j."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> found = " + found); }
|
|
||||||
|
|
||||||
if (found === false) {
|
|
||||||
|
|
||||||
|
if (found === false) {
|
||||||
/*
|
/*
|
||||||
Before adding a new item to the array, we need to create a floatingObject of type Note. Once we set its basic parameters
|
Before adding a new item to the array, we need to create a floatingObject of type Note. Once we set its basic parameters
|
||||||
we can it to our array and to the floating layer.
|
we can it to our array and to the floating layer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let floatingObject = newFloatingObject();
|
let floatingObject = newFloatingObject()
|
||||||
floatingObject.initialize("Note", onInitialized);
|
floatingObject.initialize('Note', onInitialized)
|
||||||
|
|
||||||
function onInitialized(err) {
|
function onInitialized (err) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Entering function."); }
|
floatingObject.payload = noteSet.payload
|
||||||
|
floatingObject.payloadNoteIndex = i
|
||||||
|
floatingObject.payloadImageId = noteSet.imageId
|
||||||
|
|
||||||
floatingObject.payload = noteSet.payload;
|
floatingObject.friction = 0.995
|
||||||
floatingObject.payloadNoteIndex = i;
|
|
||||||
floatingObject.payloadImageId = noteSet.imageId;
|
|
||||||
|
|
||||||
floatingObject.friction = .995;
|
floatingObject.initializeMass(200)
|
||||||
|
|
||||||
floatingObject.initializeMass(200);
|
// let bodyText = pNewNotes[i].body;
|
||||||
|
let radius
|
||||||
//let bodyText = pNewNotes[i].body;
|
|
||||||
let radius;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (bodyText.length < 100) {
|
if (bodyText.length < 100) {
|
||||||
@@ -278,96 +255,83 @@ function newNoteSets() {
|
|||||||
radius = bodyText.length;
|
radius = bodyText.length;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
radius = 50;
|
radius = 50
|
||||||
|
|
||||||
floatingObject.initializeRadius(radius);
|
floatingObject.initializeRadius(radius)
|
||||||
floatingObject.initializeImageSize(15);
|
floatingObject.initializeImageSize(15)
|
||||||
|
|
||||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)';
|
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)'
|
||||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
|
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'
|
||||||
|
|
||||||
floatingLayer.addFloatingObject(floatingObject);
|
floatingLayer.addFloatingObject(floatingObject)
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> New Note added to Layer."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> New Note added to Layer.') }
|
||||||
|
|
||||||
plotterNote.floatingHandle = floatingObject.handle;
|
plotterNote.floatingHandle = floatingObject.handle
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNote.floatingHandle = " + plotterNote.floatingHandle); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> plotterNote.floatingHandle = ' + plotterNote.floatingHandle) }
|
||||||
|
|
||||||
newFloatingNotes.push(plotterNote);
|
newFloatingNotes.push(plotterNote)
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes."); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = " + newFloatingNotes.length); }
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = ' + newFloatingNotes.length) }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newFloatingNotes.push(floatingNote)
|
||||||
|
|
||||||
}
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Old Note Kept.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingNote.floatingHandle = ' + floatingNote.floatingHandle) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = ' + newFloatingNotes.length) }
|
||||||
|
|
||||||
} else {
|
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle)
|
||||||
|
floatingObject.payloadNoteIndex = i
|
||||||
|
|
||||||
newFloatingNotes.push(floatingNote);
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject index updated.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject.payloadNoteIndex = ' + i) }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Old Note Kept."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> Added to newFloatingNotes."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> newFloatingNotes.length = " + newFloatingNotes.length); }
|
|
||||||
|
|
||||||
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle);
|
|
||||||
floatingObject.payloadNoteIndex = i;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject index updated."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> onInitialized -> floatingObject.payloadNoteIndex = " + i); }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
noteSet.floatingNotes = newFloatingNotes;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> noteSet.floatingNotes.length = " + noteSet.floatingNotes.length); }
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
noteSet.floatingNotes = newFloatingNotes
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> noteSet.floatingNotes.length = ' + noteSet.floatingNotes.length) }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> onNotesChanged -> err = ' + err) }
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] createNoteSet -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function destroyNoteSet(pHandle) {
|
function destroyNoteSet (pHandle) {
|
||||||
|
try {
|
||||||
try {
|
|
||||||
/*
|
/*
|
||||||
Usually when a bot is disabled by the end user, or the zoom level changes to one where the notes must not be seen, this method
|
Usually when a bot is disabled by the end user, or the zoom level changes to one where the notes must not be seen, this method
|
||||||
to destroy an entire NoteSet is executed. What we do in this situation is to localize the NoteSet to be destroyed and we need to
|
to destroy an entire NoteSet is executed. What we do in this situation is to localize the NoteSet to be destroyed and we need to
|
||||||
kill, one by one the floating objects in it. Finally we remove this NoteSet item from the NoteSets array.
|
kill, one by one the floating objects in it. Finally we remove this NoteSet item from the NoteSets array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] destroyNoteSet -> Entering function."); }
|
if (INFO_LOG === true) { logger.write('[INFO] destroyNoteSet -> Entering function.') }
|
||||||
|
|
||||||
for (let i = 0; i < noteSets.length; i++) {
|
for (let i = 0; i < noteSets.length; i++) {
|
||||||
|
let noteSet = noteSets[i]
|
||||||
|
|
||||||
let noteSet = noteSets[i];
|
if (noteSet.handle === pHandle) {
|
||||||
|
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
||||||
|
let floatingNote = noteSet.floatingNotes[j]
|
||||||
|
|
||||||
if (noteSet.handle === pHandle) {
|
floatingLayer.killFloatingObject(floatingNote.floatingHandle)
|
||||||
|
}
|
||||||
|
|
||||||
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
|
noteSets.splice(i, 1) // Delete item from array.
|
||||||
|
return
|
||||||
let floatingNote = noteSet.floatingNotes[j];
|
|
||||||
|
|
||||||
floatingLayer.killFloatingObject(floatingNote.floatingHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
noteSets.splice(i, 1); // Delete item from array.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] destroyNoteSet -> err = " + err); }
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] destroyNoteSet -> err = ' + err) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -310,4 +310,3 @@ function newProfileBall () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
function newProfileBalls() {
|
function newProfileBalls () {
|
||||||
|
const MODULE_NAME = 'Profile Balls'
|
||||||
const MODULE_NAME = "Profile Balls";
|
const INFO_LOG = false
|
||||||
const INFO_LOG = false;
|
const ERROR_LOG = true
|
||||||
const ERROR_LOG = true;
|
const logger = newWebDebugLog()
|
||||||
const logger = newWebDebugLog();
|
logger.fileName = MODULE_NAME
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -13,65 +12,56 @@ function newProfileBalls() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let thisObject = {
|
let thisObject = {
|
||||||
|
|
||||||
createNewProfileBall: createNewProfileBall,
|
createNewProfileBall: createNewProfileBall,
|
||||||
destroyProfileBall: destroyProfileBall,
|
destroyProfileBall: destroyProfileBall,
|
||||||
initialize: initialize
|
initialize: initialize
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let floatingLayer
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
|
function initialize (pFloatingLayer, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
|
floatingLayer = pFloatingLayer
|
||||||
|
|
||||||
|
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE)
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let floatingLayer;
|
function createNewProfileBall (pPayload, callBackFunction) {
|
||||||
|
let floatingObject = newFloatingObject()
|
||||||
|
floatingObject.initialize('Profile Ball', onInitialized)
|
||||||
|
|
||||||
return thisObject;
|
function onInitialized (err) {
|
||||||
|
floatingObject.payload = pPayload
|
||||||
|
|
||||||
function initialize(pFloatingLayer, callBackFunction) {
|
floatingObject.friction = 0.995
|
||||||
|
|
||||||
try {
|
floatingObject.initializeMass(100)
|
||||||
|
floatingObject.initializeRadius(30)
|
||||||
|
floatingObject.initializeImageSize(50)
|
||||||
|
floatingObject.initializeFontSize(10)
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)'
|
||||||
|
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)'
|
||||||
|
|
||||||
floatingLayer = pFloatingLayer;
|
floatingLayer.addFloatingObject(floatingObject)
|
||||||
|
|
||||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE);
|
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, floatingObject.handle)
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createNewProfileBall(pPayload, callBackFunction) {
|
function destroyProfileBall (pFloatingObjectHandle) {
|
||||||
|
floatingLayer.killFloatingObject(pFloatingObjectHandle)
|
||||||
let floatingObject = newFloatingObject();
|
}
|
||||||
floatingObject.initialize("Profile Ball", onInitialized);
|
|
||||||
|
|
||||||
function onInitialized(err) {
|
|
||||||
|
|
||||||
floatingObject.payload = pPayload;
|
|
||||||
|
|
||||||
floatingObject.friction = .995;
|
|
||||||
|
|
||||||
floatingObject.initializeMass(100);
|
|
||||||
floatingObject.initializeRadius(30);
|
|
||||||
floatingObject.initializeImageSize(50);
|
|
||||||
floatingObject.initializeFontSize(10);
|
|
||||||
|
|
||||||
floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.5)';
|
|
||||||
floatingObject.labelStrokeStyle = 'rgba(60, 60, 60, 0.50)';
|
|
||||||
|
|
||||||
floatingLayer.addFloatingObject(floatingObject);
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE, floatingObject.handle);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function destroyProfileBall(pFloatingObjectHandle) {
|
|
||||||
|
|
||||||
floatingLayer.killFloatingObject(pFloatingObjectHandle);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,130 +1,110 @@
|
|||||||
|
|
||||||
function newFrame() {
|
function newFrame () {
|
||||||
|
const PANEL_CORNERS_RADIOUS = 5
|
||||||
|
const TITLE_BAR_HEIGHT = 14 // this must be grater than radius
|
||||||
|
|
||||||
const PANEL_CORNERS_RADIOUS = 5;
|
var frame = {
|
||||||
const TITLE_BAR_HEIGHT = 14; // this must be grater than radius
|
containerName: '', // This is for debugging purposes only.
|
||||||
|
parentFrame: undefined, // Here we store the parent cointainer zoom object.
|
||||||
|
width: browserCanvas.width,
|
||||||
|
height: browserCanvas.height,
|
||||||
|
position: undefined,
|
||||||
|
getBodyHeight: getBodyHeight,
|
||||||
|
draw: draw,
|
||||||
|
container: undefined,
|
||||||
|
frameThisPoint: frameThisPoint, // This function changes the actual frame coordinate system to the screen coordinate system.
|
||||||
|
unframeThisPoint: unframeThisPoint,
|
||||||
|
fitIntoFrame: fitIntoFrame,
|
||||||
|
isThisPointHere: isThisPointHere, // This function return true is the point received as parameter lives within this frame.
|
||||||
|
isInViewPort: isInViewPort,
|
||||||
|
canYouMoveHere: canYouMoveHere,
|
||||||
|
canYouZoomHere: canYouZoomHere,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var frame = {
|
return frame
|
||||||
containerName: "", // This is for debugging purposes only.
|
|
||||||
parentFrame: undefined, // Here we store the parent cointainer zoom object.
|
|
||||||
width: browserCanvas.width,
|
|
||||||
height: browserCanvas.height,
|
|
||||||
position: undefined,
|
|
||||||
getBodyHeight: getBodyHeight,
|
|
||||||
draw: draw,
|
|
||||||
container: undefined,
|
|
||||||
frameThisPoint: frameThisPoint, // This function changes the actual frame coordinate system to the screen coordinate system.
|
|
||||||
unframeThisPoint: unframeThisPoint,
|
|
||||||
fitIntoFrame: fitIntoFrame,
|
|
||||||
isThisPointHere: isThisPointHere, // This function return true is the point received as parameter lives within this frame.
|
|
||||||
isInViewPort: isInViewPort,
|
|
||||||
canYouMoveHere: canYouMoveHere,
|
|
||||||
canYouZoomHere: canYouZoomHere,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
return frame;
|
function initialize () {
|
||||||
|
var position = {
|
||||||
function initialize() {
|
x: 0,
|
||||||
|
y: 0
|
||||||
var position = {
|
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
this.position = position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.position = position
|
||||||
|
}
|
||||||
|
|
||||||
function getBodyHeight() {
|
function getBodyHeight () {
|
||||||
|
return frame.height - TITLE_BAR_HEIGHT
|
||||||
return frame.height - TITLE_BAR_HEIGHT;
|
}
|
||||||
|
|
||||||
|
function isInViewPort () {
|
||||||
|
point1 = {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInViewPort() {
|
point3 = {
|
||||||
|
x: frame.width,
|
||||||
point1 = {
|
y: frame.height
|
||||||
x: 0,
|
}
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
point3 = {
|
|
||||||
x: frame.width,
|
|
||||||
y: frame.height
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Now the transformations. */
|
/* Now the transformations. */
|
||||||
|
|
||||||
point1 = transformThisPoint(point1, frame.container);
|
point1 = transformThisPoint(point1, frame.container)
|
||||||
point3 = transformThisPoint(point3, frame.container);
|
point3 = transformThisPoint(point3, frame.container)
|
||||||
|
|
||||||
if (point1.x < viewPort.visibleArea.topRight.x && point1.y < viewPort.visibleArea.bottomRight.y && point3.x > viewPort.visibleArea.bottomLeft.x && point3.y > viewPort.visibleArea.topLeft.y ) {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (point1.x < viewPort.visibleArea.topRight.x && point1.y < viewPort.visibleArea.bottomRight.y && point3.x > viewPort.visibleArea.bottomLeft.x && point3.y > viewPort.visibleArea.topLeft.y) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fitIntoFrame(point) {
|
function fitIntoFrame (point) {
|
||||||
|
|
||||||
|
|
||||||
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
|
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
|
||||||
|
|
||||||
if (point.x > frame.width) {
|
if (point.x > frame.width) {
|
||||||
point.x = frame.width;
|
point.x = frame.width
|
||||||
}
|
|
||||||
|
|
||||||
if (point.x < 0) {
|
|
||||||
point.x = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.y > frame.height) {
|
|
||||||
point.y = frame.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.y < 0) {
|
|
||||||
point.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (point.x < 0) {
|
||||||
|
point.x = 0
|
||||||
function frameThisPoint(point) {
|
|
||||||
|
|
||||||
if (this.parentFrame !== undefined) {
|
|
||||||
|
|
||||||
point = this.parentFrame.frameThisPoint(point);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
point.x = point.x + frame.position.x;
|
|
||||||
point.y = point.y + frame.position.y;
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function unframeThisPoint(point) {
|
if (point.y > frame.height) {
|
||||||
|
point.y = frame.height
|
||||||
if (this.parentFrame !== undefined) {
|
|
||||||
|
|
||||||
point = this.parentFrame.unframeThisPoint(point);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
point.x = point.x - this.position.x;
|
|
||||||
point.y = point.y - this.position.y;
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function canYouMoveHere(tempDisplacement) {
|
if (point.y < 0) {
|
||||||
|
point.y = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
|
function frameThisPoint (point) {
|
||||||
|
if (this.parentFrame !== undefined) {
|
||||||
|
point = this.parentFrame.frameThisPoint(point)
|
||||||
|
}
|
||||||
|
|
||||||
|
point.x = point.x + frame.position.x
|
||||||
|
point.y = point.y + frame.position.y
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
|
function unframeThisPoint (point) {
|
||||||
|
if (this.parentFrame !== undefined) {
|
||||||
|
point = this.parentFrame.unframeThisPoint(point)
|
||||||
|
}
|
||||||
|
|
||||||
|
point.x = point.x - this.position.x
|
||||||
|
point.y = point.y - this.position.y
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
|
function canYouMoveHere (tempDisplacement) {
|
||||||
/*
|
/*
|
||||||
|
|
||||||
The current frame has a position and a displacement. We need to check that none of the boundaries points of the frame fall outside of its container frame.
|
The current frame has a position and a displacement. We need to check that none of the boundaries points of the frame fall outside of its container frame.
|
||||||
@@ -132,459 +112,427 @@ function newFrame() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
point1 = {
|
point1 = {
|
||||||
x: this.position.x,
|
x: this.position.x,
|
||||||
y: this.position.y
|
y: this.position.y
|
||||||
};
|
}
|
||||||
|
|
||||||
point2 = {
|
point2 = {
|
||||||
x: this.position.x + this.width,
|
x: this.position.x + this.width,
|
||||||
y: this.position.y
|
y: this.position.y
|
||||||
};
|
}
|
||||||
|
|
||||||
point3 = {
|
point3 = {
|
||||||
x: this.position.x + this.width,
|
x: this.position.x + this.width,
|
||||||
y: this.position.y + this.height
|
y: this.position.y + this.height
|
||||||
};
|
}
|
||||||
|
|
||||||
point4 = {
|
point4 = {
|
||||||
x: this.position.x,
|
x: this.position.x,
|
||||||
y: this.position.y + this.height
|
y: this.position.y + this.height
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Now the transformations. */
|
/* Now the transformations. */
|
||||||
|
|
||||||
if (this.parentFrame !== undefined) { // If there is not a parent then there is no point to check bounderies.
|
if (this.parentFrame !== undefined) {
|
||||||
|
// If there is not a parent then there is no point to check bounderies.
|
||||||
|
|
||||||
point1 = this.parentFrame.frameThisPoint(point1);
|
point1 = this.parentFrame.frameThisPoint(point1)
|
||||||
point2 = this.parentFrame.frameThisPoint(point2);
|
point2 = this.parentFrame.frameThisPoint(point2)
|
||||||
point3 = this.parentFrame.frameThisPoint(point3);
|
point3 = this.parentFrame.frameThisPoint(point3)
|
||||||
point4 = this.parentFrame.frameThisPoint(point4);
|
point4 = this.parentFrame.frameThisPoint(point4)
|
||||||
|
|
||||||
/* We apply the temporary displacement. */
|
/* We apply the temporary displacement. */
|
||||||
|
|
||||||
point1 = tempDisplacement.displaceThisPoint(point1);
|
point1 = tempDisplacement.displaceThisPoint(point1)
|
||||||
point2 = tempDisplacement.displaceThisPoint(point2);
|
point2 = tempDisplacement.displaceThisPoint(point2)
|
||||||
point3 = tempDisplacement.displaceThisPoint(point3);
|
point3 = tempDisplacement.displaceThisPoint(point3)
|
||||||
point4 = tempDisplacement.displaceThisPoint(point4);
|
point4 = tempDisplacement.displaceThisPoint(point4)
|
||||||
|
|
||||||
/* We add the actual displacement. */
|
/* We add the actual displacement. */
|
||||||
|
|
||||||
point1 = this.container.displacement.displaceThisPoint(point1);
|
point1 = this.container.displacement.displaceThisPoint(point1)
|
||||||
point2 = this.container.displacement.displaceThisPoint(point2);
|
point2 = this.container.displacement.displaceThisPoint(point2)
|
||||||
point3 = this.container.displacement.displaceThisPoint(point3);
|
point3 = this.container.displacement.displaceThisPoint(point3)
|
||||||
point4 = this.container.displacement.displaceThisPoint(point4);
|
point4 = this.container.displacement.displaceThisPoint(point4)
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point1) === false) {
|
if (this.parentFrame.isThisPointHere(point1) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point2) === false) {
|
if (this.parentFrame.isThisPointHere(point2) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point3) === false) {
|
if (this.parentFrame.isThisPointHere(point3) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point4) === false) {
|
if (this.parentFrame.isThisPointHere(point4) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function canYouZoomHere(tempZoom) {
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
point1 = {
|
function canYouZoomHere (tempZoom) {
|
||||||
x: this.position.x,
|
point1 = {
|
||||||
y: this.position.y
|
x: this.position.x,
|
||||||
};
|
y: this.position.y
|
||||||
|
}
|
||||||
|
|
||||||
point2 = {
|
point2 = {
|
||||||
x: this.position.x + this.width,
|
x: this.position.x + this.width,
|
||||||
y: this.position.y
|
y: this.position.y
|
||||||
};
|
}
|
||||||
|
|
||||||
point3 = {
|
point3 = {
|
||||||
x: this.position.x + this.width,
|
x: this.position.x + this.width,
|
||||||
y: this.position.y + this.height
|
y: this.position.y + this.height
|
||||||
};
|
}
|
||||||
|
|
||||||
point4 = {
|
point4 = {
|
||||||
x: this.position.x,
|
x: this.position.x,
|
||||||
y: this.position.y + this.height
|
y: this.position.y + this.height
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Now the transformations. */
|
/* Now the transformations. */
|
||||||
|
|
||||||
if (this.parentFrame !== undefined) { // If there is not a parent then there is no point to check bounderies.
|
if (this.parentFrame !== undefined) {
|
||||||
|
// If there is not a parent then there is no point to check bounderies.
|
||||||
|
|
||||||
point1 = this.parentFrame.frameThisPoint(point1);
|
point1 = this.parentFrame.frameThisPoint(point1)
|
||||||
point2 = this.parentFrame.frameThisPoint(point2);
|
point2 = this.parentFrame.frameThisPoint(point2)
|
||||||
point3 = this.parentFrame.frameThisPoint(point3);
|
point3 = this.parentFrame.frameThisPoint(point3)
|
||||||
point4 = this.parentFrame.frameThisPoint(point4);
|
point4 = this.parentFrame.frameThisPoint(point4)
|
||||||
|
|
||||||
/* We add the actual displacement. */
|
/* We add the actual displacement. */
|
||||||
|
|
||||||
point1 = this.container.displacement.displaceThisPoint(point1);
|
point1 = this.container.displacement.displaceThisPoint(point1)
|
||||||
point2 = this.container.displacement.displaceThisPoint(point2);
|
point2 = this.container.displacement.displaceThisPoint(point2)
|
||||||
point3 = this.container.displacement.displaceThisPoint(point3);
|
point3 = this.container.displacement.displaceThisPoint(point3)
|
||||||
point4 = this.container.displacement.displaceThisPoint(point4);
|
point4 = this.container.displacement.displaceThisPoint(point4)
|
||||||
|
|
||||||
/* We temp zoom. */
|
/* We temp zoom. */
|
||||||
|
|
||||||
point1 = tempZoom.zoomThisPoint(point1);
|
point1 = tempZoom.zoomThisPoint(point1)
|
||||||
point2 = tempZoom.zoomThisPoint(point2);
|
point2 = tempZoom.zoomThisPoint(point2)
|
||||||
point3 = tempZoom.zoomThisPoint(point3);
|
point3 = tempZoom.zoomThisPoint(point3)
|
||||||
point4 = tempZoom.zoomThisPoint(point4);
|
point4 = tempZoom.zoomThisPoint(point4)
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point1) === false) {
|
if (this.parentFrame.isThisPointHere(point1) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point2) === false) {
|
if (this.parentFrame.isThisPointHere(point2) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point3) === false) {
|
if (this.parentFrame.isThisPointHere(point3) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.parentFrame.isThisPointHere(point4) === false) {
|
if (this.parentFrame.isThisPointHere(point4) === false) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
function isThisPointHere(point, outsideViewPort) { // The second parameter is usefull when you want to check a point that you already know is outside the viewport.
|
function isThisPointHere (point, outsideViewPort) {
|
||||||
|
// The second parameter is usefull when you want to check a point that you already know is outside the viewport.
|
||||||
|
|
||||||
/* We need not to modify the point received, so me make a copy of it. */
|
/* We need not to modify the point received, so me make a copy of it. */
|
||||||
|
|
||||||
var checkPoint = {
|
var checkPoint = {
|
||||||
x: point.x,
|
x: point.x,
|
||||||
y: point.y
|
y: point.y
|
||||||
};
|
}
|
||||||
|
|
||||||
/* The point received is on the screen coordinates system, which already has zoom and displacement applied. We need to remove the zoom and displacement
|
/* The point received is on the screen coordinates system, which already has zoom and displacement applied. We need to remove the zoom and displacement
|
||||||
in order to have the point on the containers coordinate system and be able to compare it with its dimmensions. */
|
in order to have the point on the containers coordinate system and be able to compare it with its dimmensions. */
|
||||||
|
|
||||||
if (outsideViewPort === true) {
|
if (outsideViewPort === true) {
|
||||||
|
checkPoint = this.container.displacement.undisplaceThisPoint(checkPoint)
|
||||||
checkPoint = this.container.displacement.undisplaceThisPoint(checkPoint);
|
checkPoint = this.container.frame.unframeThisPoint(checkPoint)
|
||||||
checkPoint = this.container.frame.unframeThisPoint(checkPoint);
|
} else {
|
||||||
|
checkPoint = unTransformThisPoint(checkPoint, frame.container)
|
||||||
} else {
|
}
|
||||||
checkPoint = unTransformThisPoint(checkPoint, frame.container);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now we check if the resulting point is whin the current Frame. */
|
/* Now we check if the resulting point is whin the current Frame. */
|
||||||
|
|
||||||
if (checkPoint.x < 0 || checkPoint.y < 0 || checkPoint.x > frame.width || checkPoint.y > frame.height) {
|
if (checkPoint.x < 0 || checkPoint.y < 0 || checkPoint.x > frame.width || checkPoint.y > frame.height) {
|
||||||
|
|
||||||
/* The point received is not in this frame */
|
/* The point received is not in this frame */
|
||||||
|
|
||||||
return false;
|
return false
|
||||||
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
/* The point is within this frame. */
|
/* The point is within this frame. */
|
||||||
|
|
||||||
return true;
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function draw (drawGrid, drawBorders, drawBackground) {
|
||||||
|
if (drawBorders === true) {
|
||||||
|
borders()
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(drawGrid, drawBorders, drawBackground) {
|
if (drawGrid === true) {
|
||||||
|
grid()
|
||||||
|
|
||||||
if (drawBorders === true) {
|
|
||||||
borders();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drawGrid === true) {
|
|
||||||
grid();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drawBackground === true) {
|
|
||||||
background();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function background() {
|
if (drawBackground === true) {
|
||||||
|
background()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function background () {
|
||||||
|
borderPoint1 = {
|
||||||
|
x: PANEL_CORNERS_RADIOUS,
|
||||||
|
y: PANEL_CORNERS_RADIOUS
|
||||||
|
}
|
||||||
|
|
||||||
|
borderPoint2 = {
|
||||||
|
x: frame.width - PANEL_CORNERS_RADIOUS,
|
||||||
|
y: PANEL_CORNERS_RADIOUS
|
||||||
|
}
|
||||||
|
|
||||||
borderPoint1 = {
|
borderPoint3 = {
|
||||||
x: PANEL_CORNERS_RADIOUS,
|
x: frame.width - PANEL_CORNERS_RADIOUS,
|
||||||
y: PANEL_CORNERS_RADIOUS
|
y: frame.height - PANEL_CORNERS_RADIOUS
|
||||||
};
|
}
|
||||||
|
|
||||||
borderPoint2 = {
|
borderPoint4 = {
|
||||||
x: frame.width - PANEL_CORNERS_RADIOUS,
|
x: PANEL_CORNERS_RADIOUS,
|
||||||
y: PANEL_CORNERS_RADIOUS
|
y: frame.height - PANEL_CORNERS_RADIOUS
|
||||||
};
|
}
|
||||||
|
|
||||||
borderPoint3 = {
|
titleBarPoint1 = {
|
||||||
x: frame.width - PANEL_CORNERS_RADIOUS,
|
x: 0,
|
||||||
y: frame.height - PANEL_CORNERS_RADIOUS
|
y: TITLE_BAR_HEIGHT
|
||||||
};
|
}
|
||||||
|
|
||||||
borderPoint4 = {
|
|
||||||
x: PANEL_CORNERS_RADIOUS,
|
|
||||||
y: frame.height - PANEL_CORNERS_RADIOUS
|
|
||||||
};
|
|
||||||
|
|
||||||
titleBarPoint1 = {
|
|
||||||
x: 0,
|
|
||||||
y: TITLE_BAR_HEIGHT
|
|
||||||
};
|
|
||||||
|
|
||||||
titleBarPoint2 = {
|
|
||||||
x: frame.width,
|
|
||||||
y: TITLE_BAR_HEIGHT
|
|
||||||
};
|
|
||||||
|
|
||||||
|
titleBarPoint2 = {
|
||||||
|
x: frame.width,
|
||||||
|
y: TITLE_BAR_HEIGHT
|
||||||
|
}
|
||||||
|
|
||||||
/* Now the transformations. */
|
/* Now the transformations. */
|
||||||
|
|
||||||
borderPoint1 = frameThisPoint(borderPoint1);
|
borderPoint1 = frameThisPoint(borderPoint1)
|
||||||
borderPoint2 = frameThisPoint(borderPoint2);
|
borderPoint2 = frameThisPoint(borderPoint2)
|
||||||
borderPoint3 = frameThisPoint(borderPoint3);
|
borderPoint3 = frameThisPoint(borderPoint3)
|
||||||
borderPoint4 = frameThisPoint(borderPoint4);
|
borderPoint4 = frameThisPoint(borderPoint4)
|
||||||
|
|
||||||
titleBarPoint1 = frameThisPoint(titleBarPoint1);
|
titleBarPoint1 = frameThisPoint(titleBarPoint1)
|
||||||
titleBarPoint2 = frameThisPoint(titleBarPoint2);
|
titleBarPoint2 = frameThisPoint(titleBarPoint2)
|
||||||
|
|
||||||
/* We paint the panel background first */
|
/* We paint the panel background first */
|
||||||
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.75)';
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 0.75)'
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, PANEL_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI);
|
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, PANEL_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - PANEL_CORNERS_RADIOUS);
|
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - PANEL_CORNERS_RADIOUS)
|
||||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, PANEL_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI);
|
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, PANEL_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint3.x + PANEL_CORNERS_RADIOUS, borderPoint3.y);
|
browserCanvasContext.lineTo(borderPoint3.x + PANEL_CORNERS_RADIOUS, borderPoint3.y)
|
||||||
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, PANEL_CORNERS_RADIOUS, 0 * Math.PI, 0.5 * Math.PI);
|
browserCanvasContext.arc(borderPoint3.x, borderPoint3.y, PANEL_CORNERS_RADIOUS, 0 * Math.PI, 0.5 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + PANEL_CORNERS_RADIOUS);
|
browserCanvasContext.lineTo(borderPoint4.x, borderPoint4.y + PANEL_CORNERS_RADIOUS)
|
||||||
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, PANEL_CORNERS_RADIOUS, 0.5 * Math.PI, 1.0 * Math.PI);
|
browserCanvasContext.arc(borderPoint4.x, borderPoint4.y, PANEL_CORNERS_RADIOUS, 0.5 * Math.PI, 1.0 * Math.PI)
|
||||||
browserCanvasContext.lineTo(borderPoint1.x - PANEL_CORNERS_RADIOUS, borderPoint1.y);
|
browserCanvasContext.lineTo(borderPoint1.x - PANEL_CORNERS_RADIOUS, borderPoint1.y)
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
|
|
||||||
browserCanvasContext.fill();
|
browserCanvasContext.fill()
|
||||||
|
|
||||||
browserCanvasContext.lineWidth = 0.1;
|
browserCanvasContext.lineWidth = 0.1
|
||||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.MANGANESE_PURPLE + ', 0.75)';
|
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.MANGANESE_PURPLE + ', 0.75)'
|
||||||
browserCanvasContext.stroke();
|
browserCanvasContext.stroke()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* We paint the title bar now */
|
/* We paint the title bar now */
|
||||||
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)';
|
|
||||||
browserCanvasContext.beginPath();
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y);
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK + ', 0.75)'
|
||||||
browserCanvasContext.lineTo(borderPoint1.x - PANEL_CORNERS_RADIOUS, borderPoint1.y);
|
browserCanvasContext.beginPath()
|
||||||
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, PANEL_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI);
|
|
||||||
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - PANEL_CORNERS_RADIOUS);
|
|
||||||
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, PANEL_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI);
|
|
||||||
browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y);
|
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.moveTo(titleBarPoint1.x, titleBarPoint1.y)
|
||||||
browserCanvasContext.fill();
|
browserCanvasContext.lineTo(borderPoint1.x - PANEL_CORNERS_RADIOUS, borderPoint1.y)
|
||||||
|
browserCanvasContext.arc(borderPoint1.x, borderPoint1.y, PANEL_CORNERS_RADIOUS, 1.0 * Math.PI, 1.5 * Math.PI)
|
||||||
browserCanvasContext.lineWidth = 0.1;
|
browserCanvasContext.lineTo(borderPoint2.x, borderPoint2.y - PANEL_CORNERS_RADIOUS)
|
||||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.MANGANESE_PURPLE + ', 0.75)';
|
browserCanvasContext.arc(borderPoint2.x, borderPoint2.y, PANEL_CORNERS_RADIOUS, 1.5 * Math.PI, 2.0 * Math.PI)
|
||||||
browserCanvasContext.stroke();
|
browserCanvasContext.lineTo(titleBarPoint2.x, titleBarPoint2.y)
|
||||||
|
|
||||||
|
browserCanvasContext.closePath()
|
||||||
|
browserCanvasContext.fill()
|
||||||
|
|
||||||
|
browserCanvasContext.lineWidth = 0.1
|
||||||
|
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.MANGANESE_PURPLE + ', 0.75)'
|
||||||
|
browserCanvasContext.stroke()
|
||||||
|
|
||||||
/* print the title */
|
/* print the title */
|
||||||
|
|
||||||
let labelPoint;
|
let labelPoint
|
||||||
let fontSize = 10;
|
let fontSize = 10
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||||
|
|
||||||
let label = frame.containerName;
|
let label = frame.containerName
|
||||||
|
|
||||||
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO;
|
let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO
|
||||||
let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2;
|
let yOffset = (TITLE_BAR_HEIGHT - fontSize) / 2 + 2
|
||||||
|
|
||||||
labelPoint = {
|
labelPoint = {
|
||||||
x: frame.width / 2 - xOffset,
|
x: frame.width / 2 - xOffset,
|
||||||
y: TITLE_BAR_HEIGHT - yOffset
|
y: TITLE_BAR_HEIGHT - yOffset
|
||||||
};
|
|
||||||
|
|
||||||
labelPoint = frame.frameThisPoint(labelPoint);
|
|
||||||
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
labelPoint = frame.frameThisPoint(labelPoint)
|
||||||
|
|
||||||
function borders() {
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
|
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||||
|
}
|
||||||
|
|
||||||
|
function borders () {
|
||||||
/* Lest get the important points of the drawing so as to apply the needed transformations. */
|
/* Lest get the important points of the drawing so as to apply the needed transformations. */
|
||||||
|
|
||||||
point1 = {
|
point1 = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
point2 = {
|
point2 = {
|
||||||
x: frame.width,
|
x: frame.width,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
point3 = {
|
point3 = {
|
||||||
x: frame.width,
|
x: frame.width,
|
||||||
y: frame.height
|
y: frame.height
|
||||||
};
|
}
|
||||||
|
|
||||||
point4 = {
|
point4 = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: frame.height
|
y: frame.height
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Now the transformations. */
|
/* Now the transformations. */
|
||||||
|
|
||||||
point1 = transformThisPoint(point1, frame.container);
|
point1 = transformThisPoint(point1, frame.container)
|
||||||
point2 = transformThisPoint(point2, frame.container);
|
point2 = transformThisPoint(point2, frame.container)
|
||||||
point3 = transformThisPoint(point3, frame.container);
|
point3 = transformThisPoint(point3, frame.container)
|
||||||
point4 = transformThisPoint(point4, frame.container);
|
point4 = transformThisPoint(point4, frame.container)
|
||||||
|
|
||||||
/* Lets start the drawing. */
|
/* Lets start the drawing. */
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
browserCanvasContext.moveTo(point1.x, point1.y);
|
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||||
browserCanvasContext.lineTo(point2.x, point2.y);
|
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||||
browserCanvasContext.lineTo(point3.x, point3.y);
|
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||||
browserCanvasContext.lineTo(point4.x, point4.y);
|
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||||
browserCanvasContext.lineTo(point1.x, point1.y);
|
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
|
|
||||||
|
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)'
|
||||||
|
browserCanvasContext.lineWidth = 1
|
||||||
|
browserCanvasContext.stroke()
|
||||||
|
|
||||||
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 1)';
|
browserCanvasContext.closePath()
|
||||||
browserCanvasContext.lineWidth = 1;
|
}
|
||||||
browserCanvasContext.stroke();
|
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function grid(smallLines) {
|
|
||||||
|
|
||||||
if (smallLines === true) {
|
|
||||||
|
|
||||||
|
function grid (smallLines) {
|
||||||
|
if (smallLines === true) {
|
||||||
/* Small Lines */
|
/* Small Lines */
|
||||||
|
|
||||||
var step = frame.width / 100;
|
var step = frame.width / 100
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
for (var i = 0; i < frame.width; i = i + step) {
|
for (var i = 0; i < frame.width; i = i + step) {
|
||||||
|
for (var j = 0; j < frame.height; j = j + step) {
|
||||||
|
let point1 = {
|
||||||
|
x: 0,
|
||||||
|
y: j
|
||||||
|
}
|
||||||
|
|
||||||
for (var j = 0; j < frame.height; j = j + step) {
|
let point2 = {
|
||||||
|
x: frame.width,
|
||||||
|
y: j
|
||||||
|
}
|
||||||
|
|
||||||
let point1 = {
|
point1 = transformThisPoint(point1, frame.container)
|
||||||
x: 0,
|
point2 = transformThisPoint(point2, frame.container)
|
||||||
y: j
|
|
||||||
};
|
|
||||||
|
|
||||||
let point2 = {
|
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||||
x: frame.width,
|
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||||
y: j
|
|
||||||
};
|
|
||||||
|
|
||||||
point1 = transformThisPoint(point1, frame.container);
|
|
||||||
point2 = transformThisPoint(point2, frame.container);
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(point1.x, point1.y);
|
|
||||||
browserCanvasContext.lineTo(point2.x, point2.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
let point3 = {
|
|
||||||
x: frame.width,
|
|
||||||
y: frame.height
|
|
||||||
};
|
|
||||||
|
|
||||||
let point4 = {
|
|
||||||
x: 0,
|
|
||||||
y: frame.height
|
|
||||||
};
|
|
||||||
|
|
||||||
point3 = transformThisPoint(point3, frame.container);
|
|
||||||
point4 = transformThisPoint(point4, frame.container);
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(point3.x, point3.y);
|
|
||||||
browserCanvasContext.lineTo(point4.x, point4.y);
|
|
||||||
}
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 0.1)';
|
|
||||||
browserCanvasContext.lineWidth = 1;
|
|
||||||
browserCanvasContext.stroke();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let point3 = {
|
||||||
|
x: frame.width,
|
||||||
|
y: frame.height
|
||||||
|
}
|
||||||
|
|
||||||
|
let point4 = {
|
||||||
|
x: 0,
|
||||||
|
y: frame.height
|
||||||
|
}
|
||||||
|
|
||||||
|
point3 = transformThisPoint(point3, frame.container)
|
||||||
|
point4 = transformThisPoint(point4, frame.container)
|
||||||
|
|
||||||
|
browserCanvasContext.moveTo(point3.x, point3.y)
|
||||||
|
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||||
|
}
|
||||||
|
browserCanvasContext.closePath()
|
||||||
|
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 0.1)'
|
||||||
|
browserCanvasContext.lineWidth = 1
|
||||||
|
browserCanvasContext.stroke()
|
||||||
|
}
|
||||||
|
|
||||||
/* Main Lines */
|
/* Main Lines */
|
||||||
|
|
||||||
var step = frame.width / 20;
|
var step = frame.width / 20
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
for (var i = 0; i < frame.width; i = i + step) {
|
for (var i = 0; i < frame.width; i = i + step) {
|
||||||
|
for (var j = 0; j < frame.height; j = j + step) {
|
||||||
for (var j = 0; j < frame.height; j = j + step) {
|
let point1 = {
|
||||||
|
x: 0,
|
||||||
let point1 = {
|
y: j
|
||||||
x: 0,
|
|
||||||
y: j
|
|
||||||
};
|
|
||||||
|
|
||||||
let point2 = {
|
|
||||||
x: frame.width,
|
|
||||||
y: j
|
|
||||||
};
|
|
||||||
|
|
||||||
point1 = transformThisPoint(point1, frame.container);
|
|
||||||
point2 = transformThisPoint(point2, frame.container);
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(point1.x, point1.y);
|
|
||||||
browserCanvasContext.lineTo(point2.x, point2.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
let point3 = {
|
|
||||||
x: i,
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
let point4 = {
|
|
||||||
x: i,
|
|
||||||
y: frame.height
|
|
||||||
};
|
|
||||||
|
|
||||||
point3 = transformThisPoint(point3, frame.container);
|
|
||||||
point4 = transformThisPoint(point4, frame.container);
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(point3.x, point3.y);
|
|
||||||
browserCanvasContext.lineTo(point4.x, point4.y);
|
|
||||||
}
|
}
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.strokeStyle = 'rgba(100, 100, 100, 0.2)';
|
let point2 = {
|
||||||
browserCanvasContext.lineWidth = 1;
|
x: frame.width,
|
||||||
browserCanvasContext.stroke();
|
y: j
|
||||||
|
}
|
||||||
|
|
||||||
|
point1 = transformThisPoint(point1, frame.container)
|
||||||
|
point2 = transformThisPoint(point2, frame.container)
|
||||||
|
|
||||||
|
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||||
|
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||||
|
}
|
||||||
|
|
||||||
|
let point3 = {
|
||||||
|
x: i,
|
||||||
|
y: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
let point4 = {
|
||||||
|
x: i,
|
||||||
|
y: frame.height
|
||||||
|
}
|
||||||
|
|
||||||
|
point3 = transformThisPoint(point3, frame.container)
|
||||||
|
point4 = transformThisPoint(point4, frame.container)
|
||||||
|
|
||||||
|
browserCanvasContext.moveTo(point3.x, point3.y)
|
||||||
|
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||||
}
|
}
|
||||||
}
|
browserCanvasContext.closePath()
|
||||||
|
browserCanvasContext.strokeStyle = 'rgba(100, 100, 100, 0.2)'
|
||||||
|
browserCanvasContext.lineWidth = 1
|
||||||
|
browserCanvasContext.stroke()
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
/* User Interface Colors */
|
/* User Interface Colors */
|
||||||
|
|
||||||
UI_COLOR = {
|
UI_COLOR = {
|
||||||
DARK: "48, 48, 54",
|
DARK: "48, 48, 54",
|
||||||
|
|||||||
+127
-157
@@ -1,240 +1,210 @@
|
|||||||
function newProductsPanel() {
|
function newProductsPanel () {
|
||||||
|
var thisObject = {
|
||||||
var thisObject = {
|
container: undefined,
|
||||||
container: undefined,
|
getLoadingProductCards: getLoadingProductCards,
|
||||||
getLoadingProductCards: getLoadingProductCards,
|
draw: draw,
|
||||||
draw: draw,
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
initialize: initialize
|
||||||
initialize: initialize
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/* Cointainer stuff */
|
/* Cointainer stuff */
|
||||||
|
|
||||||
var container = newContainer();
|
var container = newContainer()
|
||||||
|
|
||||||
container.name = "Indicators and Algobots Product Panel";
|
container.name = 'Indicators and Algobots Product Panel'
|
||||||
container.initialize();
|
container.initialize()
|
||||||
|
|
||||||
container.isDraggeable = true;
|
container.isDraggeable = true
|
||||||
container.isWheelable = true;
|
container.isWheelable = true
|
||||||
|
|
||||||
thisObject.container = container;
|
thisObject.container = container
|
||||||
thisObject.container.frame.containerName = "Indicators and Algobots's Products";
|
thisObject.container.frame.containerName = "Indicators and Algobots's Products"
|
||||||
|
|
||||||
let isInitialized = false;
|
let isInitialized = false
|
||||||
let productCards = [];
|
let productCards = []
|
||||||
|
|
||||||
let visibleProductCards = [];
|
let visibleProductCards = []
|
||||||
let firstVisibleCard = 1;
|
let firstVisibleCard = 1
|
||||||
|
|
||||||
/* Needed Variables */
|
/* Needed Variables */
|
||||||
|
|
||||||
var lastY = 5;
|
var lastY = 5
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize() {
|
function initialize () {
|
||||||
|
thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE
|
||||||
|
thisObject.container.frame.height = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE;
|
||||||
|
|
||||||
thisObject.container.frame.width = UI_PANEL.WIDTH.LARGE;
|
var position = {
|
||||||
thisObject.container.frame.height = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y; //UI_PANEL.HEIGHT.LARGE;
|
x: viewPort.visibleArea.topLeft.x,
|
||||||
|
y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height
|
||||||
|
}
|
||||||
|
|
||||||
var position = {
|
thisObject.container.frame.position = position
|
||||||
x: viewPort.visibleArea.topLeft.x,
|
|
||||||
y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.container.frame.position = position;
|
|
||||||
|
|
||||||
/* First thing is to build the productCards array */
|
/* First thing is to build the productCards array */
|
||||||
|
|
||||||
let devTeams = ecosystem.getTeams();
|
let devTeams = ecosystem.getTeams()
|
||||||
|
|
||||||
for (let i = 0; i < devTeams.length; i++) {
|
for (let i = 0; i < devTeams.length; i++) {
|
||||||
|
let devTeam = devTeams[i]
|
||||||
|
|
||||||
let devTeam = devTeams[i];
|
for (let j = 0; j < devTeam.bots.length; j++) {
|
||||||
|
let bot = devTeam.bots[j]
|
||||||
|
|
||||||
for (let j = 0; j < devTeam.bots.length; j++) {
|
if (bot.products !== undefined) {
|
||||||
|
for (let k = 0; k < bot.products.length; k++) {
|
||||||
let bot = devTeam.bots[j];
|
let product = bot.products[k]
|
||||||
|
|
||||||
if (bot.products !== undefined) {
|
|
||||||
|
|
||||||
for (let k = 0; k < bot.products.length; k++) {
|
|
||||||
|
|
||||||
let product = bot.products[k];
|
|
||||||
|
|
||||||
/* Now we create Product objects */
|
/* Now we create Product objects */
|
||||||
|
|
||||||
let productCard = newProductCard();
|
let productCard = newProductCard()
|
||||||
|
|
||||||
productCard.devTeam = devTeam;
|
productCard.devTeam = devTeam
|
||||||
productCard.bot = bot;
|
productCard.bot = bot
|
||||||
productCard.product = product;
|
productCard.product = product
|
||||||
|
|
||||||
productCard.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName;
|
productCard.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName
|
||||||
|
|
||||||
/* Initialize it */
|
/* Initialize it */
|
||||||
|
|
||||||
productCard.initialize();
|
productCard.initialize()
|
||||||
|
|
||||||
/* Container Stuff */
|
/* Container Stuff */
|
||||||
|
|
||||||
productCard.container.displacement.parentDisplacement = thisObject.container.displacement;
|
productCard.container.displacement.parentDisplacement = thisObject.container.displacement
|
||||||
productCard.container.frame.parentFrame = thisObject.container.frame;
|
productCard.container.frame.parentFrame = thisObject.container.frame
|
||||||
productCard.container.parentContainer = thisObject.container;
|
productCard.container.parentContainer = thisObject.container
|
||||||
productCard.container.isWheelable = true;
|
productCard.container.isWheelable = true
|
||||||
|
|
||||||
/* Positioning within thisObject Panel */
|
/* Positioning within thisObject Panel */
|
||||||
|
|
||||||
let position = {
|
let position = {
|
||||||
x: 10,
|
x: 10,
|
||||||
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
||||||
};
|
}
|
||||||
|
|
||||||
productCard.container.frame.position.x = position.x;
|
productCard.container.frame.position.x = position.x
|
||||||
productCard.container.frame.position.y = position.y + lastY;
|
productCard.container.frame.position.y = position.y + lastY
|
||||||
|
|
||||||
lastY = lastY + productCard.container.frame.height;
|
lastY = lastY + productCard.container.frame.height
|
||||||
|
|
||||||
/* Add to the Product Array */
|
/* Add to the Product Array */
|
||||||
|
|
||||||
productCards.push(productCard);
|
productCards.push(productCard)
|
||||||
|
|
||||||
/* Add to Visible Product Array */
|
/* Add to Visible Product Array */
|
||||||
|
|
||||||
if (productCard.container.frame.position.y + productCard.container.frame.height < thisObject.container.frame.height) {
|
if (productCard.container.frame.position.y + productCard.container.frame.height < thisObject.container.frame.height) {
|
||||||
|
visibleProductCards.push(productCard)
|
||||||
visibleProductCards.push(productCard);
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Listen to Status Changes Events */
|
/* Listen to Status Changes Events */
|
||||||
|
|
||||||
productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged);
|
productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged)
|
||||||
productCard.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel);
|
productCard.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
|
||||||
}
|
isInitialized = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent("Mouse Wheel", onMouseWheel);
|
function onMouseWheel (pDelta) {
|
||||||
isInitialized = true;
|
if (pDelta > 0) {
|
||||||
|
pDelta = -1
|
||||||
|
} else {
|
||||||
|
pDelta = 1
|
||||||
|
}
|
||||||
|
|
||||||
}
|
firstVisibleCard = firstVisibleCard + pDelta
|
||||||
|
|
||||||
function onMouseWheel(pDelta) {
|
let availableSlots = visibleProductCards.length
|
||||||
|
|
||||||
if (pDelta > 0) {
|
if (firstVisibleCard < 1) { firstVisibleCard = 1 }
|
||||||
pDelta = -1;
|
if (firstVisibleCard > (productCards.length - availableSlots + 1)) { firstVisibleCard = productCards.length - availableSlots + 1 }
|
||||||
} else {
|
|
||||||
pDelta = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
firstVisibleCard = firstVisibleCard + pDelta;
|
visibleProductCards = []
|
||||||
|
var lastY = 5
|
||||||
|
|
||||||
let availableSlots = visibleProductCards.length;
|
for (let i = 0; i < productCards.length; i++) {
|
||||||
|
if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) {
|
||||||
if (firstVisibleCard < 1) { firstVisibleCard = 1; }
|
let productCard = productCards[i]
|
||||||
if (firstVisibleCard > (productCards.length - availableSlots + 1)) { firstVisibleCard = productCards.length - availableSlots + 1; }
|
|
||||||
|
|
||||||
visibleProductCards = [];
|
|
||||||
var lastY = 5;
|
|
||||||
|
|
||||||
for (let i = 0; i < productCards.length; i++) {
|
|
||||||
|
|
||||||
if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) {
|
|
||||||
|
|
||||||
let productCard = productCards[i];
|
|
||||||
|
|
||||||
/* Positioning within thisObject Panel */
|
/* Positioning within thisObject Panel */
|
||||||
|
|
||||||
let position = {
|
let position = {
|
||||||
x: 10,
|
x: 10,
|
||||||
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
||||||
};
|
}
|
||||||
productCard.container.frame.position.x = position.x;
|
productCard.container.frame.position.x = position.x
|
||||||
productCard.container.frame.position.y = position.y + lastY;
|
productCard.container.frame.position.y = position.y + lastY
|
||||||
|
|
||||||
lastY = lastY + productCard.container.frame.height;
|
lastY = lastY + productCard.container.frame.height
|
||||||
|
|
||||||
/* Add to Visible Product Array */
|
/* Add to Visible Product Array */
|
||||||
|
|
||||||
visibleProductCards.push(productCard);
|
visibleProductCards.push(productCard)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onProductCardStatusChanged(pProductCard) {
|
function onProductCardStatusChanged (pProductCard) {
|
||||||
|
thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard)
|
||||||
thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard);
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLoadingProductCards() {
|
|
||||||
|
|
||||||
|
function getLoadingProductCards () {
|
||||||
/* Returns all productCards which status is LOADING */
|
/* Returns all productCards which status is LOADING */
|
||||||
|
|
||||||
let onProducts = [];
|
let onProducts = []
|
||||||
|
|
||||||
for (let i = 0; i < productCards.length; i++) {
|
for (let i = 0; i < productCards.length; i++) {
|
||||||
|
if (productCards[i].status === PRODUCT_CARD_STATUS.LOADING) {
|
||||||
|
onProducts.push(productCards[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (productCards[i].status === PRODUCT_CARD_STATUS.LOADING) {
|
return onProducts
|
||||||
|
}
|
||||||
|
|
||||||
onProducts.push(productCards[i]);
|
function getContainer (point) {
|
||||||
}
|
var container
|
||||||
}
|
|
||||||
|
|
||||||
return onProducts;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
|
||||||
|
|
||||||
var container;
|
|
||||||
|
|
||||||
/* First we check if thisObject point is inside thisObject space. */
|
/* First we check if thisObject point is inside thisObject space. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
|
||||||
/* Now we see which is the inner most container that has it */
|
/* Now we see which is the inner most container that has it */
|
||||||
|
|
||||||
|
for (var i = 0; i < visibleProductCards.length; i++) {
|
||||||
|
container = visibleProductCards[i].getContainer(point)
|
||||||
|
|
||||||
for (var i = 0; i < visibleProductCards.length; i++) {
|
if (container !== undefined) {
|
||||||
|
|
||||||
container = visibleProductCards[i].getContainer(point);
|
|
||||||
|
|
||||||
if (container !== undefined) {
|
|
||||||
|
|
||||||
/* We found an inner container which has the point. We return it. */
|
/* We found an inner container which has the point. We return it. */
|
||||||
|
|
||||||
return container;
|
return container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return thisObject.container;
|
return thisObject.container
|
||||||
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to thisObject space. */
|
/* This point does not belong to thisObject space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function draw () {
|
||||||
|
if (isInitialized === false) { return }
|
||||||
|
|
||||||
|
thisObject.container.frame.draw(false, false, true)
|
||||||
|
|
||||||
function draw() {
|
for (let i = 0; i < visibleProductCards.length; i++) {
|
||||||
|
visibleProductCards[i].draw()
|
||||||
if (isInitialized === false) {return;}
|
}
|
||||||
|
}
|
||||||
thisObject.container.frame.draw(false, false, true);
|
}
|
||||||
|
|
||||||
for (let i = 0; i < visibleProductCards.length; i++) {
|
|
||||||
visibleProductCards[i].draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+112
-130
@@ -1,177 +1,159 @@
|
|||||||
|
|
||||||
function newTimeControlPanel() {
|
function newTimeControlPanel () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
setDatetime: setDatetime,
|
||||||
|
datetimeDisplay: undefined,
|
||||||
|
stepDisplay: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
setDatetime: setDatetime,
|
container.isDraggeable = true
|
||||||
datetimeDisplay: undefined,
|
thisObject.container = container
|
||||||
stepDisplay: undefined,
|
thisObject.container.frame.containerName = 'Current Datetime'
|
||||||
draw: draw,
|
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
let timePeriod
|
||||||
container.initialize();
|
|
||||||
container.isDraggeable = true;
|
|
||||||
thisObject.container = container;
|
|
||||||
thisObject.container.frame.containerName = "Current Datetime";
|
|
||||||
|
|
||||||
let timePeriod;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
thisObject.container.frame.width = UI_PANEL.WIDTH.SMALL
|
||||||
|
thisObject.container.frame.height = UI_PANEL.HEIGHT.SMALL
|
||||||
|
|
||||||
function initialize() {
|
let position = {
|
||||||
|
x: (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 - thisObject.container.frame.width / 2,
|
||||||
|
y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.container.frame.width = UI_PANEL.WIDTH.SMALL;
|
thisObject.container.frame.position = position
|
||||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.SMALL;
|
|
||||||
|
|
||||||
let position = {
|
let buttonPosition
|
||||||
x: (viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x) / 2 - thisObject.container.frame.width / 2,
|
|
||||||
y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.container.frame.position = position;
|
let buttonNames = ['Fast Backwards', 'Play Backwards', 'Step Backwards', 'Pause', 'Step Forward', 'Play Forward', 'Fast Forward']
|
||||||
|
let lastX = 0
|
||||||
|
|
||||||
let buttonPosition;
|
let datetime = INITIAL_DATE
|
||||||
|
|
||||||
let buttonNames = ['Fast Backwards', 'Play Backwards', 'Step Backwards', 'Pause', 'Step Forward', 'Play Forward', 'Fast Forward'];
|
let datetimeDisplay = {
|
||||||
let lastX = 0;
|
currentDatetime: datetime,
|
||||||
|
addTime: addTime,
|
||||||
|
draw: drawTimeDisplay
|
||||||
|
}
|
||||||
|
|
||||||
let datetime = INITIAL_DATE;
|
thisObject.datetimeDisplay = datetimeDisplay
|
||||||
|
|
||||||
let datetimeDisplay = {
|
|
||||||
currentDatetime: datetime,
|
|
||||||
addTime: addTime,
|
|
||||||
draw: drawTimeDisplay
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.datetimeDisplay = datetimeDisplay;
|
|
||||||
|
|
||||||
/* Here we will listen to the event when time was changed due to a Bot Execution. */
|
/* Here we will listen to the event when time was changed due to a Bot Execution. */
|
||||||
|
|
||||||
canvas.bottomSpace.playStopButton.container.eventHandler.listenToEvent("Bot Execution Changed Datetime", onBotChangedTime);
|
canvas.bottomSpace.playStopButton.container.eventHandler.listenToEvent('Bot Execution Changed Datetime', onBotChangedTime)
|
||||||
canvas.bottomSpace.playStopButton.setDatetime(datetime);
|
canvas.bottomSpace.playStopButton.setDatetime(datetime)
|
||||||
|
|
||||||
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
|
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
|
||||||
timePeriod = INITIAL_TIME_PERIOD;
|
timePeriod = INITIAL_TIME_PERIOD
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBotChangedTime(pNewDatetime) {
|
function onBotChangedTime (pNewDatetime) {
|
||||||
|
let newDatetime = new Date(pNewDatetime)
|
||||||
|
|
||||||
let newDatetime = new Date(pNewDatetime);
|
thisObject.container.eventHandler.raiseEvent('Datetime Changed', newDatetime)
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.container.eventHandler.raiseEvent("Datetime Changed", newDatetime);
|
function onZoomChanged (event) {
|
||||||
|
timePeriod = recalculatePeriod(event.newLevel)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
function onZoomChanged(event) {
|
|
||||||
|
|
||||||
timePeriod = recalculatePeriod(event.newLevel);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
/* First we check if thisObject point is inside thisObject space. */
|
/* First we check if thisObject point is inside thisObject space. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return thisObject.container;
|
return thisObject.container
|
||||||
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to thisObject space. */
|
/* This point does not belong to thisObject space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setDatetime(pDatetime) {
|
function setDatetime (pDatetime) {
|
||||||
|
thisObject.datetimeDisplay.currentDatetime = new Date(pDatetime)
|
||||||
|
canvas.bottomSpace.playStopButton.setDatetime(pDatetime)
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.datetimeDisplay.currentDatetime = new Date(pDatetime);
|
function addTime (seconds) {
|
||||||
canvas.bottomSpace.playStopButton.setDatetime(pDatetime);
|
let newDate = thisObject.datetimeDisplay.currentDatetime
|
||||||
}
|
|
||||||
|
|
||||||
function addTime(seconds) {
|
newDate.setSeconds(newDate.getSeconds() + seconds)
|
||||||
|
thisObject.datetimeDisplay.currentDatetime = newDate
|
||||||
|
}
|
||||||
|
|
||||||
let newDate = thisObject.datetimeDisplay.currentDatetime;
|
function draw () {
|
||||||
|
thisObject.container.frame.draw(false, false, true)
|
||||||
|
|
||||||
newDate.setSeconds(newDate.getSeconds() + seconds);
|
thisObject.datetimeDisplay.draw()
|
||||||
thisObject.datetimeDisplay.currentDatetime = newDate;
|
}
|
||||||
|
|
||||||
}
|
function drawTimeDisplay () {
|
||||||
|
let fontSize = 10
|
||||||
|
|
||||||
function draw() {
|
let label = thisObject.datetimeDisplay.currentDatetime.toUTCString()
|
||||||
|
let labelArray = label.split(' ')
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false, true);
|
label = labelArray[0] + ' ' + labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3]
|
||||||
|
|
||||||
thisObject.datetimeDisplay.draw();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawTimeDisplay() {
|
|
||||||
|
|
||||||
let fontSize = 10;
|
|
||||||
|
|
||||||
let label = thisObject.datetimeDisplay.currentDatetime.toUTCString();
|
|
||||||
let labelArray = label.split(" ");
|
|
||||||
|
|
||||||
label = labelArray[0] + " " + labelArray[1] + " " + labelArray[2] + " " + labelArray[3];
|
|
||||||
|
|
||||||
/* Now we transform x on the actual coordinate on the canvas. */
|
/* Now we transform x on the actual coordinate on the canvas. */
|
||||||
|
|
||||||
let labelPoint = {
|
let labelPoint = {
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
||||||
y: thisObject.container.frame.height * 4.4 / 10
|
y: thisObject.container.frame.height * 4.4 / 10
|
||||||
};
|
}
|
||||||
|
|
||||||
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint);
|
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint)
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||||
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)';
|
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'
|
||||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||||
|
|
||||||
/* The time */
|
/* The time */
|
||||||
|
|
||||||
label = labelArray[4] + " " + labelArray[5];
|
label = labelArray[4] + ' ' + labelArray[5]
|
||||||
|
|
||||||
/* Now we transform x on the actual coordinate on the canvas. */
|
/* Now we transform x on the actual coordinate on the canvas. */
|
||||||
|
|
||||||
labelPoint = {
|
labelPoint = {
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
||||||
y: thisObject.container.frame.height * 6.5 / 10
|
y: thisObject.container.frame.height * 6.5 / 10
|
||||||
};
|
|
||||||
|
|
||||||
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)';
|
|
||||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
|
||||||
|
|
||||||
if (timePeriod > _45_MINUTES_IN_MILISECONDS) {
|
|
||||||
label = timePeriod / _1_HOUR_IN_MILISECONDS + ' hs';
|
|
||||||
} else {
|
|
||||||
label = timePeriod / _1_MINUTE_IN_MILISECONDS + ' min';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now we transform x on the actual coordinate on the canvas. */
|
|
||||||
|
|
||||||
labelPoint = {
|
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
|
||||||
y: thisObject.container.frame.height * 8.5 / 10
|
|
||||||
};
|
|
||||||
|
|
||||||
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)';
|
|
||||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint)
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'
|
||||||
|
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||||
|
|
||||||
|
if (timePeriod > _45_MINUTES_IN_MILISECONDS) {
|
||||||
|
label = timePeriod / _1_HOUR_IN_MILISECONDS + ' hs'
|
||||||
|
} else {
|
||||||
|
label = timePeriod / _1_MINUTE_IN_MILISECONDS + ' min'
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now we transform x on the actual coordinate on the canvas. */
|
||||||
|
|
||||||
|
labelPoint = {
|
||||||
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
|
||||||
|
y: thisObject.container.frame.height * 8.5 / 10
|
||||||
|
}
|
||||||
|
|
||||||
|
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint)
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'
|
||||||
|
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
+482
-599
File diff suppressed because it is too large.
Load diff
+596
-667
File diff suppressed because it is too large.
Load diff
+342
-411
@@ -1,18 +1,17 @@
|
|||||||
|
|
||||||
function newProductStorage(pName) {
|
function newProductStorage (pName) {
|
||||||
|
const MODULE_NAME = 'Product Storage'
|
||||||
const MODULE_NAME = "Product Storage";
|
const INFO_LOG = false
|
||||||
const INFO_LOG = false;
|
const ERROR_LOG = true
|
||||||
const ERROR_LOG = true;
|
const logger = newWebDebugLog()
|
||||||
const logger = newWebDebugLog();
|
logger.fileName = MODULE_NAME
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This object will initialize children objects that will end up loading the data of each set defined at each product of the bot received at initialization.
|
This object will initialize children objects that will end up loading the data of each set defined at each product of the bot received at initialization.
|
||||||
Once all the underlaying objects are fully initialized it will callback.
|
Once all the underlaying objects are fully initialized it will callback.
|
||||||
|
|
||||||
At the same time it will raise an event for each underlaying file being loaded, so that the UI can reflect the progress to the end user.
|
At the same time it will raise an event for each underlaying file being loaded, so that the UI can reflect the progress to the end user.
|
||||||
|
|
||||||
Product Storage
|
Product Storage
|
||||||
|
|
|
|
||||||
@@ -26,471 +25,403 @@ function newProductStorage(pName) {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let thisObject = {
|
let thisObject = {
|
||||||
|
|
||||||
marketFiles: [],
|
marketFiles: [],
|
||||||
dailyFiles: [],
|
dailyFiles: [],
|
||||||
singleFile: [],
|
singleFile: [],
|
||||||
fileSequences: [],
|
fileSequences: [],
|
||||||
|
|
||||||
setDatetime: setDatetime,
|
setDatetime: setDatetime,
|
||||||
setTimePeriod: setTimePeriod,
|
setTimePeriod: setTimePeriod,
|
||||||
|
|
||||||
eventHandler: undefined,
|
eventHandler: undefined,
|
||||||
initialize: initialize,
|
initialize: initialize,
|
||||||
finalize: finalize
|
finalize: finalize
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thisObject.eventHandler = newEventHandler();
|
thisObject.eventHandler = newEventHandler()
|
||||||
|
|
||||||
/* We name the event Handler to easy debugging. */
|
/* We name the event Handler to easy debugging. */
|
||||||
|
|
||||||
thisObject.eventHandler.name = "Storage-" + pName;
|
thisObject.eventHandler.name = 'Storage-' + pName
|
||||||
|
|
||||||
let datetime;
|
let datetime
|
||||||
let timePeriod;
|
let timePeriod
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function finalize() {
|
function finalize () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') }
|
||||||
|
|
||||||
try {
|
for (let i = 0; i < thisObject.marketFiles.length; i++) {
|
||||||
|
let marketFile = thisObject.marketFiles[i]
|
||||||
|
marketFile.finalize()
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] finalize -> Entering function."); }
|
thisObject.marketFiles = undefined
|
||||||
|
|
||||||
for (let i = 0; i < thisObject.marketFiles.length; i++) {
|
for (let i = 0; i < thisObject.dailyFiles.length; i++) {
|
||||||
|
let dailyFile = thisObject.dailyFiles[i]
|
||||||
|
dailyFile.finalize()
|
||||||
|
}
|
||||||
|
|
||||||
let marketFile = thisObject.marketFiles[i];
|
thisObject.dailyFile = undefined
|
||||||
marketFile.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.marketFiles = undefined;
|
for (let i = 0; i < thisObject.fileSequences.length; i++) {
|
||||||
|
let fileSequence = thisObject.fileSequences[i]
|
||||||
|
fileSequence.finalize()
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < thisObject.dailyFiles.length; i++) {
|
thisObject.dailyFile = undefined
|
||||||
|
} catch (err) {
|
||||||
let dailyFile = thisObject.dailyFiles[i];
|
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err) }
|
||||||
dailyFile.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.dailyFile = undefined;
|
|
||||||
|
|
||||||
for (let i = 0; i < thisObject.fileSequences.length; i++) {
|
|
||||||
|
|
||||||
let fileSequence = thisObject.fileSequences[i];
|
|
||||||
fileSequence.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.dailyFile = undefined;
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] finalize -> err = " + err); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function initialize(pDevTeam, pBot, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
|
|
||||||
|
|
||||||
try {
|
function initialize (pDevTeam, pBot, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
datetime = pDatetime
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
timePeriod = pTimePeriod
|
||||||
|
|
||||||
datetime = pDatetime;
|
let dataSetsToLoad = 0
|
||||||
timePeriod = pTimePeriod;
|
let dataSetsLoaded = 0
|
||||||
|
|
||||||
let dataSetsToLoad = 0;
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> dataSetsToLoad = ' + dataSetsToLoad) }
|
||||||
let dataSetsLoaded = 0;
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> dataSetsLoaded = ' + dataSetsLoaded) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> dataSetsToLoad = " + dataSetsToLoad); }
|
for (let i = 0; i < pProduct.dataSets.length; i++) {
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> dataSetsLoaded = " + dataSetsLoaded); }
|
let thisSet = pProduct.dataSets[i]
|
||||||
|
|
||||||
|
switch (thisSet.type) {
|
||||||
|
case 'Market Files': {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Market Files -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
for (let i = 0; i < pProduct.dataSets.length; i++) {
|
dataSetsToLoad++
|
||||||
|
|
||||||
let thisSet = pProduct.dataSets[i];
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> dataSetsToLoad = ' + dataSetsToLoad) }
|
||||||
|
|
||||||
switch (thisSet.type) {
|
let marketFiles = newMarketFiles()
|
||||||
case 'Market Files': {
|
marketFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onMarketFileReady)
|
||||||
|
thisObject.marketFiles.push(marketFiles)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Market Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
case 'Daily Files': {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Daily Files -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
dataSetsToLoad++;
|
dataSetsToLoad++
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> dataSetsToLoad = " + dataSetsToLoad); }
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> dataSetsToLoad = ' + dataSetsToLoad) }
|
||||||
|
|
||||||
let marketFiles = newMarketFiles();
|
let dailyFiles = newDailyFiles()
|
||||||
marketFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onMarketFileReady);
|
dailyFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady)
|
||||||
thisObject.marketFiles.push(marketFiles);
|
thisObject.dailyFiles.push(dailyFiles)
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
|
|
||||||
case 'Daily Files': {
|
case 'Single File': {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Single File -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Daily Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
dataSetsToLoad++
|
||||||
|
|
||||||
dataSetsToLoad++;
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> dataSetsToLoad = ' + dataSetsToLoad) }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> dataSetsToLoad = " + dataSetsToLoad); }
|
let singleFile = newSingleFile()
|
||||||
|
singleFile.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady)
|
||||||
|
thisObject.singleFile.push(singleFile)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
let dailyFiles = newDailyFiles();
|
case 'File Sequence': {
|
||||||
dailyFiles.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onDailyFileReady);
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> File Sequence -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
thisObject.dailyFiles.push(dailyFiles);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Single File': {
|
dataSetsToLoad++
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Single File -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> dataSetsToLoad = ' + dataSetsToLoad) }
|
||||||
|
|
||||||
dataSetsToLoad++;
|
let fileSequences = newFileSequence()
|
||||||
|
fileSequences.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady)
|
||||||
|
thisObject.fileSequences.push(fileSequences)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> dataSetsToLoad = " + dataSetsToLoad); }
|
function onMarketFileReady (err, pCaller) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
let singleFile = newSingleFile();
|
switch (err.result) {
|
||||||
singleFile.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady);
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
thisObject.singleFile.push(singleFile);
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> Received OK Response.') }
|
||||||
}
|
break
|
||||||
break;
|
}
|
||||||
|
|
||||||
case 'File Sequence': {
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> File Sequence -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> err.message = ' + err.message) }
|
||||||
|
|
||||||
dataSetsToLoad++;
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> dataSetsToLoad = " + dataSetsToLoad); }
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> Received Unexpected Response.') }
|
||||||
let fileSequences = newFileSequence();
|
callBackFunction(err)
|
||||||
fileSequences.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady);
|
return
|
||||||
thisObject.fileSequences.push(fileSequences);
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMarketFileReady(err, pCaller) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
totalValue: pCaller.getExpectedFiles(),
|
|
||||||
currentValue: pCaller.getFilesLoaded()
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent('Market File Loaded', event);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> event.currentValue = " + event.currentValue); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> event.totalValue = " + event.totalValue); }
|
|
||||||
|
|
||||||
if (event.currentValue === event.totalValue) {
|
|
||||||
|
|
||||||
dataSetsLoaded++;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onMarketFileReady -> dataSetsLoaded = " + dataSetsLoaded); }
|
|
||||||
|
|
||||||
checkInitializeComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onMarketFileReady -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onDailyFileReady(err, pCaller) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
totalValue: pCaller.getExpectedFiles(),
|
|
||||||
currentValue: pCaller.getFilesLoaded()
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent('Daily File Loaded', event);
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> event.currentValue = " + event.currentValue); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> event.totalValue = " + event.totalValue); }
|
|
||||||
|
|
||||||
if (event.currentValue === event.totalValue) {
|
|
||||||
|
|
||||||
dataSetsLoaded++;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDailyFileReady -> dataSetsLoaded = " + dataSetsLoaded); }
|
|
||||||
|
|
||||||
checkInitializeComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onDailyFileReady -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSingleFileReady(err, pCaller) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
totalValue: 1,
|
|
||||||
currentValue: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent('Single File Loaded', event);
|
|
||||||
|
|
||||||
if (event.currentValue === event.totalValue) {
|
|
||||||
|
|
||||||
dataSetsLoaded++;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onSingleFileReady -> dataSetsLoaded = " + dataSetsLoaded); }
|
|
||||||
|
|
||||||
checkInitializeComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onSingleFileReady -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onFileSequenceReady(err, pCaller) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
switch (err.result) {
|
|
||||||
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received OK Response."); }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received FAIL Response."); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received CUSTOM FAIL Response."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> err.message = " + err.message); }
|
|
||||||
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady -> Received Unexpected Response."); }
|
|
||||||
callBackFunction(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
totalValue: pCaller.getExpectedFiles(),
|
|
||||||
currentValue: pCaller.getFilesLoaded()
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent('File Sequence Loaded', event);
|
|
||||||
|
|
||||||
if (event.currentValue === event.totalValue) {
|
|
||||||
|
|
||||||
dataSetsLoaded++;
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileSequenceReady = " + dataSetsLoaded); }
|
|
||||||
|
|
||||||
checkInitializeComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileSequenceReady -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkInitializeComplete() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> checkInitializeComplete -> Entering function."); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> checkInitializeComplete -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); }
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> checkInitializeComplete -> dataSetsToLoad = " + dataSetsToLoad); }
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> checkInitializeComplete -> dataSetsLoaded = " + dataSetsLoaded); }
|
|
||||||
|
|
||||||
if (dataSetsLoaded === dataSetsToLoad) {
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> checkInitializeComplete -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
let event = {
|
||||||
|
totalValue: pCaller.getExpectedFiles(),
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
currentValue: pCaller.getFilesLoaded()
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Market File Loaded', event)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> event.currentValue = ' + event.currentValue) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> event.totalValue = ' + event.totalValue) }
|
||||||
|
|
||||||
|
if (event.currentValue === event.totalValue) {
|
||||||
|
dataSetsLoaded++
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onMarketFileReady -> dataSetsLoaded = ' + dataSetsLoaded) }
|
||||||
|
|
||||||
|
checkInitializeComplete()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onMarketFileReady -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDailyFileReady (err, pCaller) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> err.message = ' + err.message) }
|
||||||
|
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let event = {
|
||||||
|
totalValue: pCaller.getExpectedFiles(),
|
||||||
|
currentValue: pCaller.getFilesLoaded()
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Daily File Loaded', event)
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> event.currentValue = ' + event.currentValue) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> event.totalValue = ' + event.totalValue) }
|
||||||
|
|
||||||
|
if (event.currentValue === event.totalValue) {
|
||||||
|
dataSetsLoaded++
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDailyFileReady -> dataSetsLoaded = ' + dataSetsLoaded) }
|
||||||
|
|
||||||
|
checkInitializeComplete()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onDailyFileReady -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSingleFileReady (err, pCaller) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> err.message = ' + err.message) }
|
||||||
|
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let event = {
|
||||||
|
totalValue: 1,
|
||||||
|
currentValue: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Single File Loaded', event)
|
||||||
|
|
||||||
|
if (event.currentValue === event.totalValue) {
|
||||||
|
dataSetsLoaded++
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onSingleFileReady -> dataSetsLoaded = ' + dataSetsLoaded) }
|
||||||
|
|
||||||
|
checkInitializeComplete()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onSingleFileReady -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFileSequenceReady (err, pCaller) {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
|
switch (err.result) {
|
||||||
|
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received OK Response.') }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received FAIL Response.') }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received CUSTOM FAIL Response.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> err.message = ' + err.message) }
|
||||||
|
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received Unexpected Response.') }
|
||||||
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let event = {
|
||||||
|
totalValue: pCaller.getExpectedFiles(),
|
||||||
|
currentValue: pCaller.getFilesLoaded()
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('File Sequence Loaded', event)
|
||||||
|
|
||||||
|
if (event.currentValue === event.totalValue) {
|
||||||
|
dataSetsLoaded++
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady = ' + dataSetsLoaded) }
|
||||||
|
|
||||||
|
checkInitializeComplete()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileSequenceReady -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkInitializeComplete () {
|
||||||
|
try {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> checkInitializeComplete -> Entering function.') }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> checkInitializeComplete -> key = ' + pDevTeam.codeName + '-' + pBot.codeName + '-' + pProduct.codeName) }
|
||||||
|
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> checkInitializeComplete -> dataSetsToLoad = ' + dataSetsToLoad) }
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> checkInitializeComplete -> dataSetsLoaded = ' + dataSetsLoaded) }
|
||||||
|
|
||||||
|
if (dataSetsLoaded === dataSetsToLoad) {
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> checkInitializeComplete -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setDatetime(pDatetime) {
|
function setDatetime (pDatetime) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setDatetime -> Entering function.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
|
|
||||||
|
|
||||||
/* If there is a change in the day, then we take some actions, otherwise, we dont. */
|
/* If there is a change in the day, then we take some actions, otherwise, we dont. */
|
||||||
|
|
||||||
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||||
let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS)
|
||||||
|
|
||||||
datetime = new Date(pDatetime);
|
datetime = new Date(pDatetime)
|
||||||
|
|
||||||
if (currentDate !== newDate) {
|
if (currentDate !== newDate) {
|
||||||
|
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
for (let i = 0; i < thisObject.dailyFiles.length; i++) {
|
||||||
|
thisObject.dailyFiles[i].setDatetime(pDatetime)
|
||||||
for (let i = 0; i < thisObject.dailyFiles.length; i++) {
|
|
||||||
|
|
||||||
thisObject.dailyFiles[i].setDatetime(pDatetime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setTimePeriod(pTimePeriod) {
|
function setTimePeriod (pTimePeriod) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setTimePeriod -> Entering function.') }
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setTimePeriod -> Entering function."); }
|
|
||||||
|
|
||||||
/* We are going to filter out the cases in which the timePeriod received is the same that the one we already know. */
|
/* We are going to filter out the cases in which the timePeriod received is the same that the one we already know. */
|
||||||
|
|
||||||
if (timePeriod !== pTimePeriod) {
|
if (timePeriod !== pTimePeriod) {
|
||||||
|
timePeriod = pTimePeriod
|
||||||
|
|
||||||
timePeriod = pTimePeriod;
|
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||||
|
for (let i = 0; i < thisObject.dailyFiles.length; i++) {
|
||||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
thisObject.dailyFiles[i].setTimePeriod(pTimePeriod, datetime)
|
||||||
|
|
||||||
for (let i = 0; i < thisObject.dailyFiles.length; i++) {
|
|
||||||
|
|
||||||
thisObject.dailyFiles[i].setTimePeriod(pTimePeriod, datetime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+480
-537
File diff suppressed because it is too large.
Load diff
+40
-51
@@ -1,67 +1,56 @@
|
|||||||
function newRigthScale() {
|
function newRigthScale () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
const RIGHT_MARGIN = 50
|
||||||
container: undefined,
|
|
||||||
draw: draw,
|
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
const RIGHT_MARGIN = 50;
|
let container = newContainer()
|
||||||
|
container.initialize()
|
||||||
|
thisObject.container = container
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = RIGHT_MARGIN
|
||||||
container.initialize();
|
thisObject.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = RIGHT_MARGIN;
|
container.frame.position.x = viewPort.visibleArea.bottomRight.x
|
||||||
thisObject.container.frame.height = viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y;
|
container.frame.position.y = TOP_SPACE_HEIGHT
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.bottomRight.x;
|
container.isDraggeable = false
|
||||||
container.frame.position.y = TOP_SPACE_HEIGHT;
|
container.isClickeable = false
|
||||||
|
container.isWheeleable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
return thisObject
|
||||||
container.isClickeable = false;
|
|
||||||
container.isWheeleable = true;
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
|
||||||
|
}
|
||||||
|
|
||||||
function initialize() {
|
function onMouseWheel (pDelta) {
|
||||||
|
if (pDelta < 0) {
|
||||||
|
pDelta = -0.1
|
||||||
|
} else {
|
||||||
|
pDelta = 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel);
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
}
|
|
||||||
|
|
||||||
function onMouseWheel(pDelta) {
|
|
||||||
|
|
||||||
if (pDelta < 0) {
|
|
||||||
pDelta = -0.1;
|
|
||||||
} else {
|
|
||||||
pDelta = 0.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw () {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
+72
-82
@@ -1,105 +1,95 @@
|
|||||||
|
|
||||||
function newBottomSpace() {
|
function newBottomSpace () {
|
||||||
|
var thisObject = {
|
||||||
|
deleteTradingHistory: undefined,
|
||||||
|
chartAspectRatio: undefined,
|
||||||
|
playStopButton: undefined,
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
deleteTradingHistory: undefined,
|
container.initialize()
|
||||||
chartAspectRatio: undefined,
|
thisObject.container = container
|
||||||
playStopButton: undefined,
|
|
||||||
container: undefined,
|
|
||||||
draw: draw,
|
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
container.isDraggeable = false
|
||||||
container.initialize();
|
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
container.isDraggeable = false;
|
resize()
|
||||||
|
|
||||||
resize();
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
thisObject.deleteTradingHistory = newDeleteTradingHistory()
|
||||||
|
thisObject.deleteTradingHistory.initialize()
|
||||||
|
|
||||||
function initialize() {
|
thisObject.chartAspectRatio = newChartAspectRatio()
|
||||||
|
thisObject.chartAspectRatio.initialize()
|
||||||
|
|
||||||
thisObject.deleteTradingHistory = newDeleteTradingHistory();
|
thisObject.playStopButton = newPlayStopButton()
|
||||||
thisObject.deleteTradingHistory.initialize();
|
thisObject.playStopButton.initialize()
|
||||||
|
|
||||||
thisObject.chartAspectRatio = newChartAspectRatio();
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
thisObject.chartAspectRatio.initialize();
|
}
|
||||||
|
|
||||||
thisObject.playStopButton = newPlayStopButton();
|
function resize () {
|
||||||
thisObject.playStopButton.initialize();
|
container.frame.position.x = 0
|
||||||
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
thisObject.container.frame.width = browserCanvas.width
|
||||||
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
function resize() {
|
container = thisObject.deleteTradingHistory.getContainer(point)
|
||||||
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
container.frame.position.x = 0;
|
container = thisObject.chartAspectRatio.getContainer(point)
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
thisObject.container.frame.width = browserCanvas.width;
|
container = thisObject.playStopButton.getContainer(point)
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
container = thisObject.deleteTradingHistory.getContainer(point);
|
|
||||||
if (container !== undefined) { return container; }
|
|
||||||
|
|
||||||
container = thisObject.chartAspectRatio.getContainer(point);
|
|
||||||
if (container !== undefined) { return container; }
|
|
||||||
|
|
||||||
container = thisObject.playStopButton.getContainer(point);
|
|
||||||
if (container !== undefined) { return container; }
|
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return thisObject.container;
|
return thisObject.container
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
drawBackground()
|
||||||
|
thisObject.deleteTradingHistory.draw()
|
||||||
|
thisObject.chartAspectRatio.draw()
|
||||||
|
thisObject.playStopButton.draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawBackground () {
|
||||||
|
let opacity = 1
|
||||||
|
|
||||||
|
let zeroPoint = {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint)
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
let breakpointsHeight = 15
|
||||||
|
const RED_LINE_HIGHT = 5
|
||||||
|
|
||||||
drawBackground();
|
browserCanvasContext.beginPath()
|
||||||
thisObject.deleteTradingHistory.draw();
|
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y + breakpointsHeight, thisObject.container.frame.width, thisObject.container.frame.height)
|
||||||
thisObject.chartAspectRatio.draw();
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK + ', ' + opacity + ')'
|
||||||
thisObject.playStopButton.draw();
|
browserCanvasContext.closePath()
|
||||||
|
browserCanvasContext.fill()
|
||||||
|
|
||||||
}
|
browserCanvasContext.beginPath()
|
||||||
|
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y + breakpointsHeight, thisObject.container.frame.width, RED_LINE_HIGHT)
|
||||||
function drawBackground() {
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
|
||||||
|
browserCanvasContext.closePath()
|
||||||
let opacity = 1;
|
browserCanvasContext.fill()
|
||||||
|
}
|
||||||
let zeroPoint = {
|
}
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
zeroPoint = thisObject.container.frame.frameThisPoint(zeroPoint);
|
|
||||||
|
|
||||||
let breakpointsHeight = 15;
|
|
||||||
const RED_LINE_HIGHT = 5;
|
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
|
||||||
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y + breakpointsHeight, thisObject.container.frame.width, thisObject.container.frame.height );
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.DARK + ', ' + opacity + ')';
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.fill();
|
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
|
||||||
browserCanvasContext.rect(zeroPoint.x, zeroPoint.y + breakpointsHeight, thisObject.container.frame.width,RED_LINE_HIGHT);
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')';
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.fill();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+69
-84
@@ -1,132 +1,117 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
The chart space is where all the charts live. What this space contains is a type of object we call Time Machine. A Time Machine is a cointainer of
|
The chart space is where all the charts live. What this space contains is a type of object we call Time Machine. A Time Machine is a cointainer of
|
||||||
charts objects. The idea is simple, all the chart objects are ploted according to the time of the Time Machine object. When the time of the Time Machine
|
charts objects. The idea is simple, all the chart objects are ploted according to the time of the Time Machine object. When the time of the Time Machine
|
||||||
changes, then all charts in it are replotted with the corresponging data.
|
changes, then all charts in it are replotted with the corresponging data.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function newChartSpace() {
|
function newChartSpace () {
|
||||||
|
const MODULE_NAME = 'Chart Space'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Chart Space";
|
var thisObject = {
|
||||||
const INFO_LOG = false;
|
container: undefined,
|
||||||
const logger = newWebDebugLog();
|
draw: draw,
|
||||||
logger.fileName = MODULE_NAME;
|
timeMachines: [],
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
timeMachines: [],
|
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
|
thisObject.container.frame.width = CHART_SPACE_WIDTH
|
||||||
|
thisObject.container.frame.height = CHART_SPACE_HEIGHT
|
||||||
|
|
||||||
var container = newContainer();
|
container.displacement.containerName = 'Chart Space'
|
||||||
container.initialize();
|
container.frame.containerName = 'Chart Space'
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = CHART_SPACE_WIDTH;
|
container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
|
||||||
thisObject.container.frame.height = CHART_SPACE_HEIGHT;
|
container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
|
||||||
|
|
||||||
container.displacement.containerName = "Chart Space";
|
container.isDraggeable = false
|
||||||
container.frame.containerName = "Chart Space";
|
|
||||||
|
|
||||||
container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2;
|
return thisObject
|
||||||
container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2;
|
|
||||||
|
|
||||||
container.isDraggeable = false;
|
function initialize (callBackFunction) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
return thisObject;
|
let initializedCounter = 0
|
||||||
|
let toInitialize = 1
|
||||||
function initialize(callBackFunction) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
|
|
||||||
let initializedCounter = 0;
|
|
||||||
let toInitialize = 1;
|
|
||||||
|
|
||||||
/* We create the first of many possible time machines that could live at the Chart Space. */
|
/* We create the first of many possible time machines that could live at the Chart Space. */
|
||||||
|
|
||||||
var timeMachine = newTimeMachine();
|
var timeMachine = newTimeMachine()
|
||||||
|
|
||||||
timeMachine.container.displacement.parentDisplacement = this.container.displacement;
|
timeMachine.container.displacement.parentDisplacement = this.container.displacement
|
||||||
timeMachine.container.frame.parentFrame = this.container.frame;
|
timeMachine.container.frame.parentFrame = this.container.frame
|
||||||
|
|
||||||
timeMachine.container.parentContainer = this.container;
|
timeMachine.container.parentContainer = this.container
|
||||||
|
|
||||||
/* We make the time machine a little bit smaller than the current space. */
|
/* We make the time machine a little bit smaller than the current space. */
|
||||||
|
|
||||||
timeMachine.container.frame.width = this.container.frame.width * 1;
|
timeMachine.container.frame.width = this.container.frame.width * 1
|
||||||
timeMachine.container.frame.height = this.container.frame.height * 1;
|
timeMachine.container.frame.height = this.container.frame.height * 1
|
||||||
|
|
||||||
timeMachine.container.frame.position.x = this.container.frame.width / 2 - timeMachine.container.frame.width / 2;
|
timeMachine.container.frame.position.x = this.container.frame.width / 2 - timeMachine.container.frame.width / 2
|
||||||
timeMachine.container.frame.position.y = this.container.frame.height / 2 - timeMachine.container.frame.height / 2;
|
timeMachine.container.frame.position.y = this.container.frame.height / 2 - timeMachine.container.frame.height / 2
|
||||||
|
|
||||||
timeMachine.initialize(onTimeMachineInitialized);
|
timeMachine.initialize(onTimeMachineInitialized)
|
||||||
|
|
||||||
function onTimeMachineInitialized(err) {
|
function onTimeMachineInitialized (err) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onTimeMachineInitialized -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onTimeMachineInitialized -> Entering function."); }
|
initializedCounter++
|
||||||
|
|
||||||
initializedCounter++;
|
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onTimeMachineInitialized -> Initialization of a Time Machine failed.') }
|
||||||
|
|
||||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onTimeMachineInitialized -> Initialization of a Time Machine failed."); }
|
thisObject.timeMachines.push(timeMachine)
|
||||||
|
|
||||||
callBackFunction(err);
|
if (initializedCounter === toInitialize) {
|
||||||
return;
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
thisObject.timeMachines.push(timeMachine);
|
|
||||||
|
|
||||||
if (initializedCounter === toInitialize) {
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw () {
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
thisObject.container.frame.draw(false, false);
|
|
||||||
|
|
||||||
/* When we draw the chart space, that means we draw all the time machines in it. */
|
/* When we draw the chart space, that means we draw all the time machines in it. */
|
||||||
|
|
||||||
for (var i = 0; i < thisObject.timeMachines.length; i++ ) {
|
for (var i = 0; i < thisObject.timeMachines.length; i++) {
|
||||||
|
var timeMachine = thisObject.timeMachines[i]
|
||||||
var timeMachine = thisObject.timeMachines[i];
|
timeMachine.draw()
|
||||||
timeMachine.draw();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
function getContainer (point) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
let container
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
/* Now we see which is the inner most container that has it */
|
/* Now we see which is the inner most container that has it */
|
||||||
|
|
||||||
for (var i = 0; i < this.timeMachines.length; i++) {
|
for (var i = 0; i < this.timeMachines.length; i++) {
|
||||||
|
container = this.timeMachines[i].getContainer(point)
|
||||||
container = this.timeMachines[i].getContainer(point);
|
|
||||||
|
|
||||||
if (container !== undefined) {
|
|
||||||
|
|
||||||
|
if (container !== undefined) {
|
||||||
/* We found an inner container which has the point. We return it. */
|
/* We found an inner container which has the point. We return it. */
|
||||||
|
|
||||||
return container;
|
return container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return this.container;
|
return this.container
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+21
-29
@@ -1,44 +1,36 @@
|
|||||||
|
|
||||||
function newFloatingSpace() {
|
function newFloatingSpace () {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The Floating Space is the place where floating elements like floatingObjects, live and are rendered.
|
The Floating Space is the place where floating elements like floatingObjects, live and are rendered.
|
||||||
This space has its own physics which helps with the animation of these objects and also preventing them to overlap.
|
This space has its own physics which helps with the animation of these objects and also preventing them to overlap.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let thisObject = {
|
let thisObject = {
|
||||||
floatingLayer: undefined, // This is the array of floatingObjects being displayed
|
floatingLayer: undefined, // This is the array of floatingObjects being displayed
|
||||||
profileBalls: undefined,
|
profileBalls: undefined,
|
||||||
noteSets: undefined,
|
noteSets: undefined,
|
||||||
initialize: initialize
|
initialize: initialize
|
||||||
};
|
}
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(callBackFunction) {
|
function initialize (callBackFunction) {
|
||||||
|
thisObject.floatingLayer = newFloatingLayer()
|
||||||
|
thisObject.floatingLayer.initialize(onFloatingLayerInitialized)
|
||||||
|
|
||||||
thisObject.floatingLayer = newFloatingLayer();
|
function onFloatingLayerInitialized (err) {
|
||||||
thisObject.floatingLayer.initialize(onFloatingLayerInitialized);
|
thisObject.profileBalls = newProfileBalls()
|
||||||
|
thisObject.profileBalls.initialize(thisObject.floatingLayer, onProfileBallsInitialized)
|
||||||
|
|
||||||
function onFloatingLayerInitialized(err) {
|
function onProfileBallsInitialized (err) {
|
||||||
|
thisObject.noteSets = newNoteSets()
|
||||||
|
thisObject.noteSets.initialize(thisObject.floatingLayer, onNoteSetsInitialized)
|
||||||
|
|
||||||
thisObject.profileBalls = newProfileBalls();
|
function onNoteSetsInitialized (err) {
|
||||||
thisObject.profileBalls.initialize(thisObject.floatingLayer, onProfileBallsInitialized);
|
|
||||||
|
|
||||||
function onProfileBallsInitialized(err) {
|
|
||||||
|
|
||||||
thisObject.noteSets = newNoteSets();
|
|
||||||
thisObject.noteSets.initialize(thisObject.floatingLayer, onNoteSetsInitialized);
|
|
||||||
|
|
||||||
function onNoteSetsInitialized(err) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
+80
-93
@@ -1,114 +1,104 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
The Panel Space y the place wehre all panels live, no matter who create them.
|
The Panel Space y the place wehre all panels live, no matter who create them.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function newPanelsSpace() {
|
function newPanelsSpace () {
|
||||||
|
var thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
createNewPanel: createNewPanel,
|
||||||
|
destroyPanel: destroyPanel,
|
||||||
|
getPanel: getPanel,
|
||||||
|
draw: draw,
|
||||||
|
panels: [],
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
createNewPanel: createNewPanel,
|
thisObject.container = container
|
||||||
destroyPanel: destroyPanel,
|
thisObject.container.isDraggeable = false
|
||||||
getPanel: getPanel,
|
|
||||||
draw: draw,
|
|
||||||
panels: [],
|
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
container.displacement.containerName = 'Panels Space'
|
||||||
container.initialize();
|
container.frame.containerName = 'Panels Space'
|
||||||
thisObject.container = container;
|
|
||||||
thisObject.container.isDraggeable = false;
|
|
||||||
|
|
||||||
container.displacement.containerName = "Panels Space";
|
return thisObject
|
||||||
container.frame.containerName = "Panels Space";
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
|
|
||||||
/* The space does not create any Panels for itself, it just sits and waits others need panels. */
|
/* The space does not create any Panels for itself, it just sits and waits others need panels. */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewPanel(pType, pParameters) {
|
function createNewPanel (pType, pParameters) {
|
||||||
|
let panel
|
||||||
|
|
||||||
let panel;
|
switch (pType) {
|
||||||
|
|
||||||
switch (pType) {
|
case 'Time Control Panel':
|
||||||
|
{
|
||||||
case "Time Control Panel":
|
panel = newTimeControlPanel()
|
||||||
{
|
panel.initialize()
|
||||||
panel = newTimeControlPanel();
|
break
|
||||||
panel.initialize();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Products Panel":
|
|
||||||
{
|
|
||||||
panel = newProductsPanel();
|
|
||||||
panel.initialize();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Plotter Panel":
|
|
||||||
{
|
|
||||||
panel = getNewPlotterPanel(pParameters.devTeam, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName);
|
|
||||||
panel.initialize();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thisObject.panels.push(panel);
|
case 'Products Panel':
|
||||||
|
{
|
||||||
panel.handle = Math.floor((Math.random() * 10000000) + 1);
|
panel = newProductsPanel()
|
||||||
|
panel.initialize()
|
||||||
return panel.handle;
|
break
|
||||||
}
|
}
|
||||||
|
case 'Plotter Panel':
|
||||||
function destroyPanel(pPanelHandle) {
|
{
|
||||||
|
panel = getNewPlotterPanel(pParameters.devTeam, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName)
|
||||||
for (let i = 0; i < thisObject.panels.length; i++) {
|
panel.initialize()
|
||||||
|
break
|
||||||
let panel = thisObject.panels[i];
|
|
||||||
|
|
||||||
if (panel.handle === pPanelHandle) {
|
|
||||||
thisObject.panels.splice(i, 1); // Delete item from array.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPanel(pPanelHandle) {
|
thisObject.panels.push(panel)
|
||||||
|
|
||||||
for (let i = 0; i < thisObject.panels.length; i++) {
|
panel.handle = Math.floor((Math.random() * 10000000) + 1)
|
||||||
|
|
||||||
let panel = thisObject.panels[i];
|
return panel.handle
|
||||||
|
}
|
||||||
|
|
||||||
if (panel.handle === pPanelHandle) {
|
function destroyPanel (pPanelHandle) {
|
||||||
return panel;
|
for (let i = 0; i < thisObject.panels.length; i++) {
|
||||||
}
|
let panel = thisObject.panels[i]
|
||||||
}
|
|
||||||
|
if (panel.handle === pPanelHandle) {
|
||||||
|
thisObject.panels.splice(i, 1) // Delete item from array.
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function draw() {
|
function getPanel (pPanelHandle) {
|
||||||
|
for (let i = 0; i < thisObject.panels.length; i++) {
|
||||||
|
let panel = thisObject.panels[i]
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
if (panel.handle === pPanelHandle) {
|
||||||
|
return panel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
/* When we draw a time machine, that means also to draw all the charts in it. */
|
/* When we draw a time machine, that means also to draw all the charts in it. */
|
||||||
|
|
||||||
for (var i = 0; i < thisObject.panels.length; i++) {
|
for (var i = 0; i < thisObject.panels.length; i++) {
|
||||||
|
let panel = thisObject.panels[i]
|
||||||
let panel = thisObject.panels[i];
|
panel.draw()
|
||||||
panel.draw();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
let container;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -117,21 +107,18 @@ function newPanelsSpace() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (var i = thisObject.panels.length - 1; i >= 0; i--) {
|
for (var i = thisObject.panels.length - 1; i >= 0; i--) {
|
||||||
|
container = thisObject.panels[i].getContainer(point)
|
||||||
container = thisObject.panels[i].getContainer(point);
|
|
||||||
|
|
||||||
if (container !== undefined) {
|
|
||||||
|
|
||||||
|
if (container !== undefined) {
|
||||||
/* We found an inner container which has the point. We return it. */
|
/* We found an inner container which has the point. We return it. */
|
||||||
|
|
||||||
return container;
|
return container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return thisObject.container;
|
return thisObject.container
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+90
-102
@@ -1,132 +1,120 @@
|
|||||||
|
|
||||||
function newTopSpace() {
|
function newTopSpace () {
|
||||||
|
var thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
companyLogo: undefined,
|
||||||
|
endUser: undefined,
|
||||||
|
devTeam: undefined,
|
||||||
|
currentBot: undefined,
|
||||||
|
currentProcess: undefined,
|
||||||
|
currentStartMode: undefined,
|
||||||
|
login: undefined,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
companyLogo: undefined,
|
|
||||||
endUser: undefined,
|
|
||||||
devTeam: undefined,
|
|
||||||
currentBot: undefined,
|
|
||||||
currentProcess: undefined,
|
|
||||||
currentStartMode: undefined,
|
|
||||||
login: undefined,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
resize()
|
||||||
container.initialize();
|
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
|
||||||
container.isDraggeable = false;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
let sharedStatus = {
|
||||||
function initialize() {
|
currentDevTeamIndex: 0,
|
||||||
|
currentUserBotIndex: 0,
|
||||||
let sharedStatus = {
|
currentProcessIndex: 0,
|
||||||
currentDevTeamIndex: 0,
|
currentBotType: '',
|
||||||
currentUserBotIndex: 0,
|
eventHandler: newEventHandler()
|
||||||
currentProcessIndex: 0,
|
|
||||||
currentBotType: "",
|
|
||||||
eventHandler: newEventHandler()
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.login = newLogin();
|
|
||||||
thisObject.login.initialize(onLoginInitialized);
|
|
||||||
|
|
||||||
thisObject.companyLogo = newCompanyLogo();
|
|
||||||
thisObject.endUser = newEndUser();
|
|
||||||
thisObject.currentBot = newCurrentBot();
|
|
||||||
thisObject.currentProcess = newCurrentProcess();
|
|
||||||
thisObject.currentStartMode = newCurrentStartMode();
|
|
||||||
thisObject.devTeam = newDevTeam();
|
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
|
||||||
|
|
||||||
function onLoginInitialized() {
|
|
||||||
|
|
||||||
thisObject.companyLogo.initialize();
|
|
||||||
thisObject.endUser.initialize();
|
|
||||||
thisObject.currentBot.initialize(sharedStatus);
|
|
||||||
thisObject.currentProcess.initialize(sharedStatus);
|
|
||||||
thisObject.currentStartMode.initialize(sharedStatus);
|
|
||||||
thisObject.devTeam.initialize(sharedStatus);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
thisObject.login = newLogin()
|
||||||
|
thisObject.login.initialize(onLoginInitialized)
|
||||||
|
|
||||||
thisObject.container.frame.width = browserCanvas.width;
|
thisObject.companyLogo = newCompanyLogo()
|
||||||
thisObject.container.frame.height = TOP_SPACE_HEIGHT;
|
thisObject.endUser = newEndUser()
|
||||||
|
thisObject.currentBot = newCurrentBot()
|
||||||
|
thisObject.currentProcess = newCurrentProcess()
|
||||||
|
thisObject.currentStartMode = newCurrentStartMode()
|
||||||
|
thisObject.devTeam = newDevTeam()
|
||||||
|
|
||||||
container.frame.position.x = 0;
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
|
||||||
|
|
||||||
|
function onLoginInitialized () {
|
||||||
|
thisObject.companyLogo.initialize()
|
||||||
|
thisObject.endUser.initialize()
|
||||||
|
thisObject.currentBot.initialize(sharedStatus)
|
||||||
|
thisObject.currentProcess.initialize(sharedStatus)
|
||||||
|
thisObject.currentStartMode.initialize(sharedStatus)
|
||||||
|
thisObject.devTeam.initialize(sharedStatus)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
function resize () {
|
||||||
|
thisObject.container.frame.width = browserCanvas.width
|
||||||
|
thisObject.container.frame.height = TOP_SPACE_HEIGHT
|
||||||
|
|
||||||
let container;
|
container.frame.position.x = 0
|
||||||
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
container = thisObject.companyLogo.getContainer(point);
|
function getContainer (point) {
|
||||||
if (container !== undefined) { return container; }
|
let container
|
||||||
|
|
||||||
container = thisObject.endUser.getContainer(point);
|
container = thisObject.companyLogo.getContainer(point)
|
||||||
if (container !== undefined) { return container; }
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
container = thisObject.devTeam.getContainer(point);
|
container = thisObject.endUser.getContainer(point)
|
||||||
if (container !== undefined) { return container; }
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
container = thisObject.currentBot.getContainer(point);
|
container = thisObject.devTeam.getContainer(point)
|
||||||
if (container !== undefined) { return container; }
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
container = thisObject.currentProcess.getContainer(point);
|
container = thisObject.currentBot.getContainer(point)
|
||||||
if (container !== undefined) { return container; }
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
container = thisObject.currentStartMode.getContainer(point);
|
container = thisObject.currentProcess.getContainer(point)
|
||||||
if (container !== undefined) { return container; }
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
container = thisObject.login.getContainer(point);
|
container = thisObject.currentStartMode.getContainer(point)
|
||||||
if (container !== undefined) { return container; }
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
|
container = thisObject.login.getContainer(point)
|
||||||
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return thisObject.container;
|
return thisObject.container
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function draw () {
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
function draw() {
|
drawBackground()
|
||||||
|
thisObject.companyLogo.draw()
|
||||||
|
thisObject.endUser.draw()
|
||||||
|
thisObject.devTeam.draw()
|
||||||
|
thisObject.currentBot.draw()
|
||||||
|
thisObject.currentProcess.draw()
|
||||||
|
thisObject.currentStartMode.draw()
|
||||||
|
thisObject.login.draw()
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
function drawBackground () {
|
||||||
|
let opacity = 1
|
||||||
|
|
||||||
drawBackground();
|
browserCanvasContext.beginPath()
|
||||||
thisObject.companyLogo.draw();
|
|
||||||
thisObject.endUser.draw();
|
|
||||||
thisObject.devTeam.draw();
|
|
||||||
thisObject.currentBot.draw();
|
|
||||||
thisObject.currentProcess.draw();
|
|
||||||
thisObject.currentStartMode.draw();
|
|
||||||
thisObject.login.draw();
|
|
||||||
|
|
||||||
}
|
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height)
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')'
|
||||||
|
|
||||||
function drawBackground() {
|
browserCanvasContext.closePath()
|
||||||
|
|
||||||
let opacity = 1;
|
browserCanvasContext.fill()
|
||||||
|
}
|
||||||
browserCanvasContext.beginPath();
|
}
|
||||||
|
|
||||||
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height);
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')';
|
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
|
|
||||||
browserCanvasContext.fill();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+95
-117
@@ -1,180 +1,158 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
The Splash Screen is to show some 'loading...' controls while the app is being loaded on the background. After the loading is complete the Splash Screens dissapears for good.
|
The Splash Screen is to show some 'loading...' controls while the app is being loaded on the background. After the loading is complete the Splash Screens dissapears for good.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function newSplashScreen() {
|
function newSplashScreen () {
|
||||||
|
var thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
timeMachines: [],
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
timeMachines: [],
|
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
|
resize()
|
||||||
|
|
||||||
var container = newContainer();
|
container.displacement.containerName = 'Splash Screen'
|
||||||
container.initialize();
|
container.frame.containerName = 'Splash Screen'
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
resize();
|
container.frame.position.x = 0
|
||||||
|
container.frame.position.y = 0
|
||||||
|
|
||||||
container.displacement.containerName = "Splash Screen";
|
container.isDraggeable = false
|
||||||
container.frame.containerName = "Splash Screen";
|
|
||||||
|
|
||||||
container.frame.position.x = 0;
|
let fadeOutCounter = 0
|
||||||
container.frame.position.y = 0;
|
let opacity = 1
|
||||||
|
|
||||||
container.isDraggeable = false;
|
let logo
|
||||||
|
let canDrawLogo = false
|
||||||
|
|
||||||
|
return thisObject
|
||||||
|
|
||||||
let fadeOutCounter = 0;
|
function initialize () {
|
||||||
let opacity = 1;
|
logo = new Image()
|
||||||
|
|
||||||
let logo;
|
logo.onload = onImageLoad
|
||||||
let canDrawLogo = false;
|
|
||||||
|
|
||||||
return thisObject;
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
|
|
||||||
logo = new Image();
|
|
||||||
|
|
||||||
logo.onload = onImageLoad;
|
|
||||||
|
|
||||||
function onImageLoad() {
|
|
||||||
canDrawLogo = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
logo.src = window.canvasApp.urlPrefix + "Images/aa-logo.png";
|
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
|
||||||
|
|
||||||
|
function onImageLoad () {
|
||||||
|
canDrawLogo = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
logo.src = window.canvasApp.urlPrefix + 'Images/aa-logo.png'
|
||||||
|
|
||||||
thisObject.container.frame.width = browserCanvas.width;
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
thisObject.container.frame.height = browserCanvas.height;
|
}
|
||||||
|
|
||||||
|
function resize () {
|
||||||
|
thisObject.container.frame.width = browserCanvas.width
|
||||||
|
thisObject.container.frame.height = browserCanvas.height
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
if (splashScreenNeeded === false) {
|
||||||
|
stepsInitializationCounter = 100
|
||||||
|
|
||||||
|
fadeOutCounter++
|
||||||
|
|
||||||
|
if (fadeOutCounter > 20) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
opacity = opacity - 0.1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
function draw() {
|
|
||||||
|
|
||||||
if (splashScreenNeeded === false) {
|
|
||||||
|
|
||||||
stepsInitializationCounter = 100;
|
|
||||||
|
|
||||||
fadeOutCounter++;
|
|
||||||
|
|
||||||
if (fadeOutCounter > 20) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
opacity = opacity - 0.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
|
||||||
|
|
||||||
/* Set the background. */
|
/* Set the background. */
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height);
|
browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height)
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')';
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')'
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
|
|
||||||
browserCanvasContext.fill();
|
browserCanvasContext.fill()
|
||||||
|
|
||||||
if (canDrawLogo === false) { return; }
|
if (canDrawLogo === false) { return }
|
||||||
|
|
||||||
/* First the AA Logo. */
|
/* First the AA Logo. */
|
||||||
|
|
||||||
let imageHeight = 96;
|
let imageHeight = 96
|
||||||
let imageWidth = 480;
|
let imageWidth = 480
|
||||||
let yDisplacement = -50;
|
let yDisplacement = -50
|
||||||
|
|
||||||
let imagePoint = {
|
let imagePoint = {
|
||||||
x: thisObject.container.frame.width * 1 / 2 - imageWidth / 2,
|
x: thisObject.container.frame.width * 1 / 2 - imageWidth / 2,
|
||||||
y: thisObject.container.frame.height * 1 / 2 - imageHeight / 2 + yDisplacement
|
y: thisObject.container.frame.height * 1 / 2 - imageHeight / 2 + yDisplacement
|
||||||
};
|
}
|
||||||
|
|
||||||
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint);
|
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
|
||||||
|
|
||||||
browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
|
browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
|
||||||
|
|
||||||
/* Second the % of Advance. */
|
/* Second the % of Advance. */
|
||||||
|
|
||||||
let label = '' + Math.trunc(stepsInitializationCounter) + ' %';
|
let label = '' + Math.trunc(stepsInitializationCounter) + ' %'
|
||||||
stepsInitializationCounter = stepsInitializationCounter + 0.5;
|
stepsInitializationCounter = stepsInitializationCounter + 0.5
|
||||||
|
|
||||||
if (stepsInitializationCounter > 99) {
|
if (stepsInitializationCounter > 99) {
|
||||||
|
splashScreenNeeded = false
|
||||||
|
stepsInitializationCounter = 99
|
||||||
|
}
|
||||||
|
|
||||||
splashScreenNeeded = false;
|
let fontSize = 10
|
||||||
stepsInitializationCounter = 99;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let labelPoint = {
|
||||||
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO - 25,
|
||||||
|
y: thisObject.container.frame.height / 2 + fontSize / 2 + fontSize * 0.1 + 80 + yDisplacement
|
||||||
|
}
|
||||||
|
|
||||||
let fontSize = 10;
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')'
|
||||||
|
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||||
|
|
||||||
let labelPoint = {
|
let title
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO - 25,
|
let titlePoint
|
||||||
y: thisObject.container.frame.height / 2 + fontSize / 2 + fontSize * 0.1 + 80 + yDisplacement
|
|
||||||
};
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')';
|
|
||||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
|
|
||||||
|
|
||||||
let title;
|
|
||||||
let titlePoint;
|
|
||||||
|
|
||||||
/* Algo Bots Competitions Sub Title */
|
/* Algo Bots Competitions Sub Title */
|
||||||
|
|
||||||
fontSize = 15;
|
fontSize = 15
|
||||||
|
|
||||||
title = "Trading Bots Competitions Platform"
|
title = 'Trading Bots Competitions Platform'
|
||||||
|
|
||||||
titlePoint = {
|
titlePoint = {
|
||||||
x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20,
|
x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20,
|
||||||
y: thisObject.container.frame.height / 2 - fontSize * 2 + 80 + yDisplacement
|
y: thisObject.container.frame.height / 2 - fontSize * 2 + 80 + yDisplacement
|
||||||
};
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')';
|
|
||||||
browserCanvasContext.fillText(title, titlePoint.x, titlePoint.y);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(0, 0, 0, ' + opacity + ')'
|
||||||
|
browserCanvasContext.fillText(title, titlePoint.x, titlePoint.y)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer (point) {
|
||||||
function getContainer(point) {
|
var container
|
||||||
|
|
||||||
var container;
|
|
||||||
|
|
||||||
/* First we check if this point is inside this space. */
|
/* First we check if this point is inside this space. */
|
||||||
|
|
||||||
if (this.container.frame.isThisPointHere(point) === true) {
|
if (this.container.frame.isThisPointHere(point) === true) {
|
||||||
|
|
||||||
/* Now we see which is the inner most container that has it */
|
/* Now we see which is the inner most container that has it */
|
||||||
|
|
||||||
// add validation of inner most containers here.
|
// add validation of inner most containers here.
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return this.container;
|
return this.container
|
||||||
|
} else {
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+75
-103
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
This Object object is responsible for defining the coordinate system in a TimeLine.
|
This Object object is responsible for defining the coordinate system in a TimeLine.
|
||||||
|
|
||||||
@@ -7,85 +7,77 @@ The scale on the Y axis depends on the data that wants to be plotted. Usually we
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function newTimeLineCoordinateSystem() {
|
function newTimeLineCoordinateSystem () {
|
||||||
|
var thisObject = {
|
||||||
|
min: undefined,
|
||||||
|
max: undefined,
|
||||||
|
scale: undefined,
|
||||||
|
transformThisPoint: transformThisPoint,
|
||||||
|
transformThisPoint2: transformThisPoint2,
|
||||||
|
unInverseTransform: unInverseTransform,
|
||||||
|
inverseTransformUncappedY: inverseTransformUncappedY,
|
||||||
|
initializeX: initializeX,
|
||||||
|
initializeY: initializeY,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var min = {
|
||||||
min: undefined,
|
x: 0,
|
||||||
max: undefined,
|
y: 0
|
||||||
scale: undefined,
|
}
|
||||||
transformThisPoint: transformThisPoint,
|
|
||||||
transformThisPoint2: transformThisPoint2,
|
|
||||||
unInverseTransform: unInverseTransform,
|
|
||||||
inverseTransformUncappedY: inverseTransformUncappedY,
|
|
||||||
initializeX: initializeX,
|
|
||||||
initializeY: initializeY,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var min = {
|
var max = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
var max = {
|
var scale = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
var scale = {
|
thisObject.min = min
|
||||||
x: 0,
|
thisObject.max = max
|
||||||
y: 0
|
thisObject.scale = scale
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.min = min;
|
let maxHeight
|
||||||
thisObject.max = max;
|
|
||||||
thisObject.scale = scale;
|
|
||||||
|
|
||||||
let maxHeight;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
|
||||||
|
|
||||||
function initialize(minValue, maxValue, maxWidth, pMaxHeight) {
|
|
||||||
|
|
||||||
|
function initialize (minValue, maxValue, maxWidth, pMaxHeight) {
|
||||||
/* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */
|
/* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */
|
||||||
|
|
||||||
thisObject.min.x = minValue.x; // * 0.999; // 0.1% less
|
thisObject.min.x = minValue.x // * 0.999; // 0.1% less
|
||||||
thisObject.max.x = maxValue.x; // * 1.001; // 0.1% more
|
thisObject.max.x = maxValue.x // * 1.001; // 0.1% more
|
||||||
|
|
||||||
thisObject.min.y = minValue.y; // * 0.999; // 0.1% less
|
thisObject.min.y = minValue.y // * 0.999; // 0.1% less
|
||||||
thisObject.max.y = maxValue.y; // * 1.001; // 0.1% more
|
thisObject.max.y = maxValue.y // * 1.001; // 0.1% more
|
||||||
|
|
||||||
/* Defines the initial Zoom level at center position. */
|
/* Defines the initial Zoom level at center position. */
|
||||||
|
|
||||||
thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x);
|
thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x)
|
||||||
thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y);
|
thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y)
|
||||||
|
|
||||||
maxHeight = pMaxHeight;
|
maxHeight = pMaxHeight
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function initializeX (minValue, maxValue, maxWidth) {
|
||||||
|
thisObject.min.x = minValue.x // * 0.999; // 0.1% less
|
||||||
|
thisObject.max.x = maxValue.x // * 1.001; // 0.1% more
|
||||||
|
|
||||||
function initializeX(minValue, maxValue, maxWidth) {
|
thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x)
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.min.x = minValue.x; // * 0.999; // 0.1% less
|
function initializeY (minValue, maxValue, pMaxHeight) {
|
||||||
thisObject.max.x = maxValue.x; // * 1.001; // 0.1% more
|
thisObject.min.y = minValue.y // * 0.999; // 0.1% less
|
||||||
|
thisObject.max.y = maxValue.y // * 1.001; // 0.1% more
|
||||||
|
|
||||||
thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x);
|
thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y)
|
||||||
|
|
||||||
}
|
maxHeight = pMaxHeight
|
||||||
|
}
|
||||||
function initializeY(minValue, maxValue, pMaxHeight) {
|
|
||||||
|
|
||||||
thisObject.min.y = minValue.y; // * 0.999; // 0.1% less
|
|
||||||
thisObject.max.y = maxValue.y; // * 1.001; // 0.1% more
|
|
||||||
|
|
||||||
thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y);
|
|
||||||
|
|
||||||
maxHeight = pMaxHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function transformThisPoint(point) {
|
|
||||||
|
|
||||||
|
function transformThisPoint (point) {
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This is the straigh fordward transformation this object provides. The input is a point on the data set that wants to be plotted in a timeline.
|
This is the straigh fordward transformation this object provides. The input is a point on the data set that wants to be plotted in a timeline.
|
||||||
@@ -99,59 +91,39 @@ function newTimeLineCoordinateSystem() {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
point = {
|
point = {
|
||||||
x: (point.x - this.min.x) * this.scale.x,
|
x: (point.x - this.min.x) * this.scale.x,
|
||||||
y: maxHeight - (point.y - this.min.y) * this.scale.y
|
y: maxHeight - (point.y - this.min.y) * this.scale.y
|
||||||
};
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
function transformThisPoint2(point) {
|
function transformThisPoint2 (point) {
|
||||||
|
point = {
|
||||||
point = {
|
x: (point.x - this.min.x) * this.scale.x,
|
||||||
x: (point.x - this.min.x) * this.scale.x,
|
y: (maxHeight - point.y - this.min.y) * this.scale.y
|
||||||
y: (maxHeight- point.y - this.min.y) * this.scale.y
|
|
||||||
};
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
function unInverseTransform(point, inverseY) {
|
function unInverseTransform (point, inverseY) {
|
||||||
|
point = {
|
||||||
point = {
|
x: (point.x / this.scale.x) + this.min.x,
|
||||||
x: (point.x / this.scale.x) + this.min.x,
|
y: (inverseY - point.y) / this.scale.y + this.min.y
|
||||||
y: (inverseY - point.y) / this.scale.y + this.min.y
|
|
||||||
};
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
function inverseTransformUncappedY(point, inverseY) {
|
function inverseTransformUncappedY (point, inverseY) {
|
||||||
|
point = {
|
||||||
point = {
|
x: (point.x - this.min.x) * this.scale.x,
|
||||||
x: (point.x - this.min.x) * this.scale.x,
|
y: (inverseY - point.y) * this.scale.y
|
||||||
y: (inverseY - point.y) * this.scale.y
|
|
||||||
};
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+113
-127
@@ -1,180 +1,166 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Markets are a function of time. When watching them, end users must be positioned at one particular point in time. The system currently allows users
|
Markets are a function of time. When watching them, end users must be positioned at one particular point in time. The system currently allows users
|
||||||
to position themselves at any time they like.
|
to position themselves at any time they like.
|
||||||
|
|
||||||
In the future, it will be usefull to explore markets and compare them at different times simultaneously. Anticipating that future this module exists.
|
In the future, it will be usefull to explore markets and compare them at different times simultaneously. Anticipating that future this module exists.
|
||||||
All the charts that depand on a datetime are children of this object Time Machine. In the future we will allow users to have more than one Time Machine,
|
All the charts that depand on a datetime are children of this object Time Machine. In the future we will allow users to have more than one Time Machine,
|
||||||
each one with it own charts, and each one positioned at an especific point in titme.
|
each one with it own charts, and each one positioned at an especific point in titme.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function newTimeMachine() {
|
function newTimeMachine () {
|
||||||
|
const MODULE_NAME = 'Time Machine'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Time Machine";
|
let thisObject = {
|
||||||
const INFO_LOG = false;
|
container: undefined,
|
||||||
const logger = newWebDebugLog();
|
draw: draw,
|
||||||
logger.fileName = MODULE_NAME;
|
charts: [],
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
charts: [],
|
thisObject.container.isDraggeable = false
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
container.displacement.containerName = 'Time Machine'
|
||||||
container.initialize();
|
container.frame.containerName = 'Time Machine'
|
||||||
thisObject.container = container;
|
|
||||||
thisObject.container.isDraggeable = false;
|
|
||||||
|
|
||||||
container.displacement.containerName = "Time Machine";
|
let controlPanelHandle // We need this to destroy the Panel when this object is itself destroyed or no longer needs it...
|
||||||
container.frame.containerName = "Time Machine";
|
let productsPanelHandle // ... also to request a reference to the object for the cases we need it.
|
||||||
|
|
||||||
let controlPanelHandle; // We need this to destroy the Panel when this object is itself destroyed or no longer needs it...
|
return thisObject
|
||||||
let productsPanelHandle; // ... also to request a reference to the object for the cases we need it.
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize (callBackFunction) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
function initialize(callBackFunction) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
|
|
||||||
/* Each Time Machine has a Control Panel. */
|
/* Each Time Machine has a Control Panel. */
|
||||||
|
|
||||||
controlPanelHandle = canvas.panelsSpace.createNewPanel("Time Control Panel");
|
controlPanelHandle = canvas.panelsSpace.createNewPanel('Time Control Panel')
|
||||||
let controlPanel = canvas.panelsSpace.getPanel(controlPanelHandle);
|
let controlPanel = canvas.panelsSpace.getPanel(controlPanelHandle)
|
||||||
|
|
||||||
productsPanelHandle = canvas.panelsSpace.createNewPanel("Products Panel");
|
productsPanelHandle = canvas.panelsSpace.createNewPanel('Products Panel')
|
||||||
let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle);
|
let productsPanel = canvas.panelsSpace.getPanel(productsPanelHandle)
|
||||||
|
|
||||||
let iteration = 0;
|
let iteration = 0
|
||||||
|
|
||||||
/* First, we initialize the market that we are going to show first on screen. Later all the other markets will be initialized on the background. */
|
/* First, we initialize the market that we are going to show first on screen. Later all the other markets will be initialized on the background. */
|
||||||
|
|
||||||
let timelineChart = newTimelineChart();
|
let timelineChart = newTimelineChart()
|
||||||
|
|
||||||
timelineChart.container.displacement.parentDisplacement = thisObject.container.displacement;
|
timelineChart.container.displacement.parentDisplacement = thisObject.container.displacement
|
||||||
timelineChart.container.frame.parentFrame = thisObject.container.frame;
|
timelineChart.container.frame.parentFrame = thisObject.container.frame
|
||||||
|
|
||||||
timelineChart.container.parentContainer = thisObject.container;
|
timelineChart.container.parentContainer = thisObject.container
|
||||||
|
|
||||||
timelineChart.container.frame.width = thisObject.container.frame.width * 1;
|
timelineChart.container.frame.width = thisObject.container.frame.width * 1
|
||||||
timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y;
|
timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y
|
||||||
|
|
||||||
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2;
|
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2
|
||||||
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration;
|
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration
|
||||||
|
|
||||||
timelineChart.initialize(productsPanel, onDefaultMarketInitialized);
|
timelineChart.initialize(productsPanel, onDefaultMarketInitialized)
|
||||||
|
|
||||||
iteration++;
|
iteration++
|
||||||
|
|
||||||
function onDefaultMarketInitialized(err) {
|
function onDefaultMarketInitialized (err) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDefaultMarketInitialized -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDefaultMarketInitialized -> Entering function."); }
|
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onDefaultMarketInitialized -> Initialization of the only market failed.') }
|
||||||
|
|
||||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
callBackFunction(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onDefaultMarketInitialized -> Initialization of the only market failed."); }
|
thisObject.charts.push(timelineChart)
|
||||||
|
|
||||||
callBackFunction(err);
|
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined)
|
||||||
return;
|
timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime)
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.charts.push(timelineChart);
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
|
|
||||||
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined);
|
// initializeTheRestOfTheMarkets();
|
||||||
timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime);
|
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
|
||||||
|
|
||||||
//initializeTheRestOfTheMarkets();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeTheRestOfTheMarkets() {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> initializeTheRestOfTheMarkets -> Entering function."); }
|
|
||||||
|
|
||||||
markets.forEach(initializeTimelineChart);
|
|
||||||
|
|
||||||
function initializeTimelineChart(item, key, mapObj) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> Entering function."); }
|
|
||||||
|
|
||||||
if (key === INITIAL_DEFAULT_MARKET) { // We skip this market since it has already been initialized.
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let timelineChart = newTimelineChart();
|
|
||||||
|
|
||||||
timelineChart.container.displacement.parentDisplacement = thisObject.container.displacement;
|
|
||||||
timelineChart.container.frame.parentFrame = thisObject.container.frame;
|
|
||||||
|
|
||||||
timelineChart.container.parentContainer = thisObject.container;
|
|
||||||
|
|
||||||
timelineChart.container.frame.width = thisObject.container.frame.width * 1;
|
|
||||||
timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y;
|
|
||||||
|
|
||||||
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2;
|
|
||||||
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration;
|
|
||||||
|
|
||||||
timelineChart.initialize(productsPanel, finalSteps);
|
|
||||||
|
|
||||||
iteration++;
|
|
||||||
|
|
||||||
function finalSteps() {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> finalSteps -> Entering function."); }
|
|
||||||
|
|
||||||
thisObject.charts.push(timelineChart);
|
|
||||||
|
|
||||||
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined);
|
|
||||||
timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function initializeTheRestOfTheMarkets () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRestOfTheMarkets -> Entering function.') }
|
||||||
|
|
||||||
this.container.frame.draw(false, false);
|
markets.forEach(initializeTimelineChart)
|
||||||
|
|
||||||
|
function initializeTimelineChart (item, key, mapObj) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> Entering function.') }
|
||||||
|
|
||||||
|
if (key === INITIAL_DEFAULT_MARKET) {
|
||||||
|
// We skip this market since it has already been initialized.
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let timelineChart = newTimelineChart()
|
||||||
|
|
||||||
|
timelineChart.container.displacement.parentDisplacement = thisObject.container.displacement
|
||||||
|
timelineChart.container.frame.parentFrame = thisObject.container.frame
|
||||||
|
|
||||||
|
timelineChart.container.parentContainer = thisObject.container
|
||||||
|
|
||||||
|
timelineChart.container.frame.width = thisObject.container.frame.width * 1
|
||||||
|
timelineChart.container.frame.height = thisObject.container.frame.height * 1 * canvas.bottomSpace.chartAspectRatio.aspectRatio.y
|
||||||
|
|
||||||
|
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2
|
||||||
|
timelineChart.container.frame.position.y = timelineChart.container.frame.height * 1.5 * iteration
|
||||||
|
|
||||||
|
timelineChart.initialize(productsPanel, finalSteps)
|
||||||
|
|
||||||
|
iteration++
|
||||||
|
|
||||||
|
function finalSteps () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> finalSteps -> Entering function.') }
|
||||||
|
|
||||||
|
thisObject.charts.push(timelineChart)
|
||||||
|
|
||||||
|
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined)
|
||||||
|
timelineChart.container.eventHandler.listenToEvent('Datetime Changed', controlPanel.setDatetime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
this.container.frame.draw(false, false)
|
||||||
|
|
||||||
/* When we draw a time machine, that means also to draw all the charts in it. */
|
/* When we draw a time machine, that means also to draw all the charts in it. */
|
||||||
|
|
||||||
for (let i = 0; i < this.charts.length; i++) {
|
for (let i = 0; i < this.charts.length; i++) {
|
||||||
|
let chart = this.charts[i]
|
||||||
let chart = this.charts[i];
|
chart.draw()
|
||||||
chart.draw();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
function getContainer (point) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
let container
|
||||||
|
|
||||||
let container;
|
|
||||||
|
|
||||||
/* Now we see which is the inner most container that has it */
|
/* Now we see which is the inner most container that has it */
|
||||||
|
|
||||||
for (let i = 0; i < this.charts.length; i++) {
|
for (let i = 0; i < this.charts.length; i++) {
|
||||||
|
container = this.charts[i].getContainer(point)
|
||||||
container = this.charts[i].getContainer(point);
|
|
||||||
|
|
||||||
if (container !== undefined) {
|
|
||||||
|
|
||||||
|
if (container !== undefined) {
|
||||||
/* We found an inner container which has the point. We return it. */
|
/* We found an inner container which has the point. We return it. */
|
||||||
|
|
||||||
return container;
|
return container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The point does not belong to any inner container, so we return the current container. */
|
/* The point does not belong to any inner container, so we return the current container. */
|
||||||
|
|
||||||
return this.container;
|
return this.container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+317
-373
@@ -1,226 +1,205 @@
|
|||||||
function newTimelineChart() {
|
function newTimelineChart () {
|
||||||
|
const MODULE_NAME = 'Timeline Chart'
|
||||||
|
const INFO_LOG = false
|
||||||
|
const INTENSIVE_LOG = false
|
||||||
|
const ERROR_LOG = true
|
||||||
|
const logger = newWebDebugLog()
|
||||||
|
logger.fileName = MODULE_NAME
|
||||||
|
|
||||||
const MODULE_NAME = "Timeline Chart";
|
let timeLineCoordinateSystem = newTimeLineCoordinateSystem()
|
||||||
const INFO_LOG = false;
|
|
||||||
const INTENSIVE_LOG = false;
|
|
||||||
const ERROR_LOG = true;
|
|
||||||
const logger = newWebDebugLog();
|
|
||||||
logger.fileName = MODULE_NAME;
|
|
||||||
|
|
||||||
let timeLineCoordinateSystem = newTimeLineCoordinateSystem();
|
let timePeriod = INITIAL_TIME_PERIOD
|
||||||
|
let datetime = INITIAL_DATE
|
||||||
|
|
||||||
let timePeriod = INITIAL_TIME_PERIOD;
|
let thisObject = {
|
||||||
let datetime = INITIAL_DATE;
|
setDatetime: setDatetime,
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
setDatetime: setDatetime,
|
container.initialize()
|
||||||
container: undefined,
|
thisObject.container = container
|
||||||
draw: draw,
|
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
container.displacement.containerName = 'Timeline Chart'
|
||||||
container.initialize();
|
container.frame.containerName = 'Timeline Chart'
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
container.displacement.containerName = "Timeline Chart";
|
let chartGrid
|
||||||
container.frame.containerName = "Timeline Chart";
|
let breakpointsBar
|
||||||
|
|
||||||
let chartGrid;
|
let initializationReady = false
|
||||||
let breakpointsBar;
|
|
||||||
|
|
||||||
let initializationReady = false;
|
let productsPanel
|
||||||
|
|
||||||
let productsPanel;
|
|
||||||
|
|
||||||
/* Background */
|
/* Background */
|
||||||
let logoAssetA;
|
let logoAssetA
|
||||||
let logoAssetB;
|
let logoAssetB
|
||||||
let logoExchange;
|
let logoExchange
|
||||||
let logoAA;
|
let logoAA
|
||||||
let canDrawLogoA = false;
|
let canDrawLogoA = false
|
||||||
let canDrawLogoB = false;
|
let canDrawLogoB = false
|
||||||
let canDrawLogoExchange = false;
|
let canDrawLogoExchange = false
|
||||||
let canDrawLogoAA = false;
|
let canDrawLogoAA = false
|
||||||
|
|
||||||
let plotterManager;
|
let plotterManager
|
||||||
|
|
||||||
return thisObject;
|
return thisObject
|
||||||
|
|
||||||
function initialize(pProductsPanel, callBackFunction) {
|
function initialize (pProductsPanel, callBackFunction) {
|
||||||
|
try {
|
||||||
try {
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
|
||||||
|
|
||||||
/* We load the logow we will need for the background. */
|
/* We load the logow we will need for the background. */
|
||||||
|
|
||||||
logoA = new Image();
|
logoA = new Image()
|
||||||
logoB = new Image();
|
logoB = new Image()
|
||||||
logoExchange = new Image();
|
logoExchange = new Image()
|
||||||
logoAA = new Image();
|
logoAA = new Image()
|
||||||
|
|
||||||
logoA.onload = onImageALoaded;
|
logoA.onload = onImageALoaded
|
||||||
|
|
||||||
function onImageALoaded() {
|
function onImageALoaded () {
|
||||||
canDrawLogoA = true;
|
canDrawLogoA = true
|
||||||
}
|
}
|
||||||
|
|
||||||
logoB.onload = onImageBLoaded;
|
logoB.onload = onImageBLoaded
|
||||||
|
|
||||||
function onImageBLoaded() {
|
function onImageBLoaded () {
|
||||||
canDrawLogoB = true;
|
canDrawLogoB = true
|
||||||
}
|
}
|
||||||
|
|
||||||
logoExchange.onload = onImageExchangeLoaded;
|
logoExchange.onload = onImageExchangeLoaded
|
||||||
|
|
||||||
function onImageExchangeLoaded() {
|
function onImageExchangeLoaded () {
|
||||||
canDrawLogoExchange = true;
|
canDrawLogoExchange = true
|
||||||
}
|
}
|
||||||
|
|
||||||
logoAA.onload = onImageAALoaded;
|
logoAA.onload = onImageAALoaded
|
||||||
|
|
||||||
function onImageAALoaded() {
|
function onImageAALoaded () {
|
||||||
canDrawLogoAA = true;
|
canDrawLogoAA = true
|
||||||
}
|
}
|
||||||
|
|
||||||
logoA.src = window.canvasApp.urlPrefix + "Images/tether-logo-background.png";
|
logoA.src = window.canvasApp.urlPrefix + 'Images/tether-logo-background.png'
|
||||||
logoB.src = window.canvasApp.urlPrefix + "Images/bitcoin-logo-background.png";
|
logoB.src = window.canvasApp.urlPrefix + 'Images/bitcoin-logo-background.png'
|
||||||
logoExchange.src = window.canvasApp.urlPrefix + "Images/poloniex-logo-background.png";
|
logoExchange.src = window.canvasApp.urlPrefix + 'Images/poloniex-logo-background.png'
|
||||||
logoAA.src = window.canvasApp.urlPrefix + "Images/aa-logo-background.png";
|
logoAA.src = window.canvasApp.urlPrefix + 'Images/aa-logo-background.png'
|
||||||
|
|
||||||
/* Remember the Products Panel */
|
/* Remember the Products Panel */
|
||||||
|
|
||||||
productsPanel = pProductsPanel;
|
productsPanel = pProductsPanel
|
||||||
|
|
||||||
chartGrid = newChartGrid();
|
chartGrid = newChartGrid()
|
||||||
chartGrid.initialize();
|
chartGrid.initialize()
|
||||||
|
|
||||||
breakpointsBar = newBreakpointsBar();
|
breakpointsBar = newBreakpointsBar()
|
||||||
breakpointsBar.initialize(container, timeLineCoordinateSystem);
|
breakpointsBar.initialize(container, timeLineCoordinateSystem)
|
||||||
|
|
||||||
|
recalculateScale()
|
||||||
|
|
||||||
|
// moveViewPortToCurrentDatetime();
|
||||||
|
moveToUserPosition(container, timeLineCoordinateSystem)
|
||||||
|
timePeriod = INITIAL_TIME_PERIOD
|
||||||
|
datetime = INITIAL_DATE
|
||||||
|
|
||||||
recalculateScale();
|
|
||||||
|
|
||||||
//moveViewPortToCurrentDatetime();
|
|
||||||
moveToUserPosition(container, timeLineCoordinateSystem);
|
|
||||||
timePeriod = INITIAL_TIME_PERIOD;
|
|
||||||
datetime = INITIAL_DATE;
|
|
||||||
|
|
||||||
/* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */
|
/* Event Subscriptions - we need this events to be fired first here and then in active Plotters. */
|
||||||
|
|
||||||
viewPort.eventHandler.listenToEvent("Offset Changed", onOffsetChanged);
|
viewPort.eventHandler.listenToEvent('Offset Changed', onOffsetChanged)
|
||||||
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
|
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
|
||||||
|
|
||||||
/* Initialize the Plotter Manager */
|
/* Initialize the Plotter Manager */
|
||||||
|
|
||||||
plotterManager = newPlottersManager();
|
plotterManager = newPlottersManager()
|
||||||
|
|
||||||
plotterManager.container.displacement.parentDisplacement = thisObject.container.displacement;
|
plotterManager.container.displacement.parentDisplacement = thisObject.container.displacement
|
||||||
plotterManager.container.frame.parentFrame = thisObject.container.frame;
|
plotterManager.container.frame.parentFrame = thisObject.container.frame
|
||||||
|
|
||||||
plotterManager.container.parentContainer = thisObject.container;
|
plotterManager.container.parentContainer = thisObject.container
|
||||||
|
|
||||||
plotterManager.container.frame.width = thisObject.container.frame.width;
|
plotterManager.container.frame.width = thisObject.container.frame.width
|
||||||
plotterManager.container.frame.height = thisObject.container.frame.height;
|
plotterManager.container.frame.height = thisObject.container.frame.height
|
||||||
|
|
||||||
plotterManager.container.frame.position.x = thisObject.container.frame.position.x;
|
plotterManager.container.frame.position.x = thisObject.container.frame.position.x
|
||||||
plotterManager.container.frame.position.y = thisObject.container.frame.position.y;
|
plotterManager.container.frame.position.y = thisObject.container.frame.position.y
|
||||||
|
|
||||||
plotterManager.initialize(pProductsPanel, onPlotterManagerReady);
|
plotterManager.initialize(pProductsPanel, onPlotterManagerReady)
|
||||||
|
|
||||||
function onPlotterManagerReady(err) {
|
function onPlotterManagerReady (err) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onPlotterManagerReady -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> onPlotterManagerReady -> Entering function."); }
|
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onPlotterManagerReady -> Plotter Manager Initialization Failed. ') }
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onPlotterManagerReady -> err.message = ' + err.message) }
|
||||||
|
|
||||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onPlotterManagerReady -> Plotter Manager Initialization Failed. "); }
|
initializationReady = true
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onPlotterManagerReady -> err.message = " + err.message); }
|
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
canvas.bottomSpace.chartAspectRatio.container.eventHandler.listenToEvent('Chart Aspect Ratio Changed', onAspectRatioChanged)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
initializationReady = true;
|
function onAspectRatioChanged (pAspectRatio) {
|
||||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
thisObject.container.frame.height = CHART_SPACE_HEIGHT * pAspectRatio.y
|
||||||
return;
|
recalculateScale()
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) }
|
||||||
|
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
canvas.bottomSpace.chartAspectRatio.container.eventHandler.listenToEvent("Chart Aspect Ratio Changed", onAspectRatioChanged);
|
function onZoomChanged (event) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] onZoomChanged -> Entering function.') }
|
||||||
function onAspectRatioChanged(pAspectRatio) {
|
|
||||||
|
|
||||||
thisObject.container.frame.height = CHART_SPACE_HEIGHT * pAspectRatio.y;
|
if (initializationReady === true) {
|
||||||
recalculateScale();
|
let currentTimePeriod = timePeriod
|
||||||
|
|
||||||
}
|
timePeriod = recalculatePeriod(event.newLevel)
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
|
|
||||||
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); }
|
|
||||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onZoomChanged(event) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onZoomChanged -> Entering function."); }
|
|
||||||
|
|
||||||
if (initializationReady === true) {
|
|
||||||
|
|
||||||
let currentTimePeriod = timePeriod;
|
|
||||||
|
|
||||||
timePeriod = recalculatePeriod(event.newLevel);
|
|
||||||
|
|
||||||
/* If the period changes, we need to spread the word in cascade towards all the depending objects. */
|
/* If the period changes, we need to spread the word in cascade towards all the depending objects. */
|
||||||
|
|
||||||
if (timePeriod !== currentTimePeriod) {
|
if (timePeriod !== currentTimePeriod) {
|
||||||
|
plotterManager.setTimePeriod(timePeriod)
|
||||||
|
}
|
||||||
|
|
||||||
plotterManager.setTimePeriod(timePeriod);
|
recalculateCurrentDatetime()
|
||||||
|
|
||||||
}
|
saveUserPosition(thisObject.container, timeLineCoordinateSystem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
recalculateCurrentDatetime();
|
function setDatetime (pDatetime) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] setDatetime -> Entering function.') }
|
||||||
saveUserPosition(thisObject.container, timeLineCoordinateSystem);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDatetime(pDatetime) {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
|
|
||||||
|
|
||||||
/* This function is used when the time is changed through the user interface, but without zooming or panning. */
|
/* This function is used when the time is changed through the user interface, but without zooming or panning. */
|
||||||
/* No matter if the day changed or not, we need to inform all visible Plotters. */
|
/* No matter if the day changed or not, we need to inform all visible Plotters. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isInViewPort()) {
|
if (thisObject.container.frame.isInViewPort()) {
|
||||||
|
plotterManager.setDatetime(pDatetime)
|
||||||
|
plotterManager.positionAtDatetime(pDatetime)
|
||||||
|
breakpointsBar.setDatetime(pDatetime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plotterManager.setDatetime(pDatetime);
|
function onOffsetChanged () {
|
||||||
plotterManager.positionAtDatetime(pDatetime);
|
if (INFO_LOG === true) { logger.write('[INFO] onOffsetChanged -> Entering function.') }
|
||||||
breakpointsBar.setDatetime(pDatetime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onOffsetChanged() {
|
if (initializationReady === true) {
|
||||||
|
if (thisObject.container.frame.isInViewPort()) {
|
||||||
|
recalculateCurrentDatetime()
|
||||||
|
saveUserPosition(thisObject.container, timeLineCoordinateSystem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] onOffsetChanged -> Entering function."); }
|
function recalculateCurrentDatetime () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] recalculateCurrentDatetime -> Entering function.') }
|
||||||
if (initializationReady === true) {
|
|
||||||
|
|
||||||
if (thisObject.container.frame.isInViewPort()) {
|
|
||||||
|
|
||||||
recalculateCurrentDatetime();
|
|
||||||
saveUserPosition(thisObject.container, timeLineCoordinateSystem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function recalculateCurrentDatetime() {
|
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] recalculateCurrentDatetime -> Entering function."); }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -229,298 +208,263 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let center = {
|
let center = {
|
||||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
|
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
|
||||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
|
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
|
||||||
};
|
}
|
||||||
|
|
||||||
center = unTransformThisPoint(center, thisObject.container);
|
center = unTransformThisPoint(center, thisObject.container)
|
||||||
center = timeLineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height);
|
center = timeLineCoordinateSystem.unInverseTransform(center, thisObject.container.frame.height)
|
||||||
|
|
||||||
let newDate = new Date(0);
|
let newDate = new Date(0)
|
||||||
newDate.setUTCSeconds(center.x / 1000);
|
newDate.setUTCSeconds(center.x / 1000)
|
||||||
|
|
||||||
datetime = newDate;
|
datetime = newDate
|
||||||
|
|
||||||
plotterManager.setDatetime(datetime);
|
plotterManager.setDatetime(datetime)
|
||||||
|
|
||||||
breakpointsBar.setDatetime(datetime);
|
breakpointsBar.setDatetime(datetime)
|
||||||
|
|
||||||
thisObject.container.eventHandler.raiseEvent("Datetime Changed", datetime);
|
thisObject.container.eventHandler.raiseEvent('Datetime Changed', datetime)
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
function getContainer (point) {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') }
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
let container
|
||||||
|
|
||||||
let container;
|
container = chartGrid.getContainer(point)
|
||||||
|
|
||||||
container = chartGrid.getContainer(point);
|
if (container !== undefined) { return container }
|
||||||
|
|
||||||
if (container !== undefined) { return container;}
|
container = breakpointsBar.getContainer(point)
|
||||||
|
|
||||||
container = breakpointsBar.getContainer(point);
|
return container
|
||||||
|
}
|
||||||
|
|
||||||
return container;
|
function recalculateScale () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] recalculateScale -> Entering function.') }
|
||||||
|
|
||||||
}
|
let minValue = {
|
||||||
|
x: EARLIEST_DATE.valueOf(),
|
||||||
|
y: 0
|
||||||
|
}
|
||||||
|
|
||||||
function recalculateScale() {
|
let maxValue = {
|
||||||
|
x: MAX_PLOTABLE_DATE.valueOf(),
|
||||||
|
y: nextPorwerOf10(USDT_BTC_HTH) / 4
|
||||||
|
}
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] recalculateScale -> Entering function."); }
|
timeLineCoordinateSystem.initialize(
|
||||||
|
|
||||||
let minValue = {
|
|
||||||
x: EARLIEST_DATE.valueOf(),
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
let maxValue = {
|
|
||||||
x: MAX_PLOTABLE_DATE.valueOf(),
|
|
||||||
y: nextPorwerOf10(USDT_BTC_HTH) / 4
|
|
||||||
};
|
|
||||||
|
|
||||||
timeLineCoordinateSystem.initialize(
|
|
||||||
minValue,
|
minValue,
|
||||||
maxValue,
|
maxValue,
|
||||||
thisObject.container.frame.width,
|
thisObject.container.frame.width,
|
||||||
thisObject.container.frame.height
|
thisObject.container.frame.height
|
||||||
);
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function tooTiny () {
|
||||||
|
if (INTENSIVE_LOG === true) { logger.write('[INFO] tooTiny -> Entering function.') }
|
||||||
|
|
||||||
function tooTiny() {
|
if (viewPort.zoomLevel < Math.trunc(-28.25 * 100) / 100) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INTENSIVE_LOG === true) { logger.write("[INFO] tooTiny -> Entering function."); }
|
function tooSmall () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] tooSmall -> Entering function.') }
|
||||||
|
|
||||||
if (viewPort.zoomLevel < Math.trunc(-28.25 * 100) / 100) {
|
if (viewPort.zoomLevel < Math.trunc(-27.25 * 100) / 100) {
|
||||||
return true;
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function draw () {
|
||||||
|
if (INTENSIVE_LOG === true) { logger.write('[INFO] draw -> Entering function.') }
|
||||||
|
|
||||||
function tooSmall() {
|
if (thisObject.container.frame.isInViewPort()) {
|
||||||
|
this.container.frame.draw()
|
||||||
|
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] tooSmall -> Entering function."); }
|
drawBackground()
|
||||||
|
|
||||||
if (viewPort.zoomLevel < Math.trunc(-27.25 * 100) / 100) {
|
chartGrid.draw(thisObject.container, timeLineCoordinateSystem)
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
plotterManager.draw()
|
||||||
|
|
||||||
function draw() {
|
breakpointsBar.draw()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (INTENSIVE_LOG === true) { logger.write("[INFO] draw -> Entering function."); }
|
function drawBackground () {
|
||||||
|
if (INTENSIVE_LOG === true) { logger.write('[INFO] drawBackground -> Entering function.') }
|
||||||
|
|
||||||
if (thisObject.container.frame.isInViewPort()) {
|
if (canDrawLogoA === false || canDrawLogoB === false || canDrawLogoExchange === false || canDrawLogoAA === false) { return }
|
||||||
|
|
||||||
this.container.frame.draw();
|
let backgroundLogoPoint1
|
||||||
|
let backgroundLogoPoint2
|
||||||
|
|
||||||
drawBackground();
|
let imageHeight = 42
|
||||||
|
let imageWidth = 150
|
||||||
|
|
||||||
chartGrid.draw(thisObject.container, timeLineCoordinateSystem);
|
let MAX_COLUMNS = 16
|
||||||
|
let MAX_ROWS = 7
|
||||||
|
let Y_TOP_MARGIN = 30
|
||||||
|
|
||||||
plotterManager.draw();
|
let point1 = {
|
||||||
|
x: viewPort.visibleArea.topLeft.x,
|
||||||
|
y: viewPort.visibleArea.topLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
breakpointsBar.draw();
|
backgroundLogoPoint1 = {
|
||||||
}
|
x: getDateFromPoint(point1, thisObject.container, timeLineCoordinateSystem).valueOf(),
|
||||||
}
|
y: getRateFromPoint(point1, thisObject.container, timeLineCoordinateSystem)
|
||||||
|
}
|
||||||
|
|
||||||
function drawBackground() {
|
let point2 = {
|
||||||
|
x: viewPort.visibleArea.topLeft.x + imageWidth * 8,
|
||||||
|
y: viewPort.visibleArea.topLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
if (INTENSIVE_LOG === true) { logger.write("[INFO] drawBackground -> Entering function."); }
|
backgroundLogoPoint2 = {
|
||||||
|
x: getDateFromPoint(point2, thisObject.container, timeLineCoordinateSystem).valueOf(),
|
||||||
|
y: getRateFromPoint(point2, thisObject.container, timeLineCoordinateSystem)
|
||||||
|
}
|
||||||
|
|
||||||
if (canDrawLogoA === false || canDrawLogoB === false || canDrawLogoExchange === false || canDrawLogoAA === false) { return; }
|
let currentCorner = {
|
||||||
|
x: getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem).valueOf(),
|
||||||
|
y: getRateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem)
|
||||||
|
}
|
||||||
|
|
||||||
let backgroundLogoPoint1;
|
currentCorner.x = Math.trunc(currentCorner.x / (backgroundLogoPoint2.x - backgroundLogoPoint1.x)) * (backgroundLogoPoint2.x - backgroundLogoPoint1.x)
|
||||||
let backgroundLogoPoint2;
|
|
||||||
|
|
||||||
let imageHeight = 42;
|
let rowHight = (viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y) / 4.5
|
||||||
let imageWidth = 150;
|
|
||||||
|
|
||||||
let MAX_COLUMNS = 16;
|
imagePoint = timeLineCoordinateSystem.transformThisPoint(currentCorner)
|
||||||
let MAX_ROWS = 7;
|
imagePoint = transformThisPoint(imagePoint, thisObject.container)
|
||||||
let Y_TOP_MARGIN = 30;
|
|
||||||
|
|
||||||
let point1 = {
|
let offSet = 0
|
||||||
x: viewPort.visibleArea.topLeft.x,
|
|
||||||
y: viewPort.visibleArea.topLeft.y
|
|
||||||
};
|
|
||||||
|
|
||||||
backgroundLogoPoint1 = {
|
for (let j = 0; j < MAX_ROWS; j++) {
|
||||||
x: getDateFromPoint(point1, thisObject.container, timeLineCoordinateSystem).valueOf(),
|
if (offSet === -imageWidth * 8) {
|
||||||
y: getRateFromPoint(point1, thisObject.container, timeLineCoordinateSystem)
|
offSet = -imageWidth * 4 - imageWidth
|
||||||
};
|
} else {
|
||||||
|
offSet = -imageWidth * 8
|
||||||
|
}
|
||||||
|
|
||||||
let point2 = {
|
for (let i = 0; i < MAX_COLUMNS; i = i + 4) {
|
||||||
x: viewPort.visibleArea.topLeft.x + imageWidth * 8,
|
let logo = logoA
|
||||||
y: viewPort.visibleArea.topLeft.y
|
|
||||||
};
|
|
||||||
|
|
||||||
backgroundLogoPoint2 = {
|
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight)
|
||||||
x: getDateFromPoint(point2, thisObject.container, timeLineCoordinateSystem).valueOf(),
|
}
|
||||||
y: getRateFromPoint(point2, thisObject.container, timeLineCoordinateSystem)
|
}
|
||||||
};
|
|
||||||
|
|
||||||
let currentCorner = {
|
offSet = 0
|
||||||
x: getDateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem).valueOf(),
|
|
||||||
y: getRateFromPoint(viewPort.visibleArea.topLeft, thisObject.container, timeLineCoordinateSystem)
|
|
||||||
};
|
|
||||||
|
|
||||||
currentCorner.x = Math.trunc(currentCorner.x / (backgroundLogoPoint2.x - backgroundLogoPoint1.x)) * (backgroundLogoPoint2.x - backgroundLogoPoint1.x);
|
for (let j = 0; j < MAX_ROWS; j++) {
|
||||||
|
if (offSet === -imageWidth * 8) {
|
||||||
|
offSet = -imageWidth * 4 - imageWidth
|
||||||
|
} else {
|
||||||
|
offSet = -imageWidth * 8
|
||||||
|
}
|
||||||
|
|
||||||
let rowHight = (viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y) / 4.5;
|
for (let i = 1; i < MAX_COLUMNS; i = i + 4) {
|
||||||
|
let logo = logoB
|
||||||
|
|
||||||
imagePoint = timeLineCoordinateSystem.transformThisPoint(currentCorner);
|
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight)
|
||||||
imagePoint = transformThisPoint(imagePoint, thisObject.container);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let offSet = 0;
|
offSet = 0
|
||||||
|
|
||||||
|
for (let j = 0; j < MAX_ROWS; j++) {
|
||||||
|
if (offSet === -imageWidth * 8) {
|
||||||
|
offSet = -imageWidth * 4 - imageWidth
|
||||||
|
} else {
|
||||||
|
offSet = -imageWidth * 8
|
||||||
|
}
|
||||||
|
|
||||||
for (let j = 0; j < MAX_ROWS; j++) {
|
for (let i = 2; i < MAX_COLUMNS; i = i + 4) {
|
||||||
|
let logo = logoExchange
|
||||||
|
|
||||||
if (offSet === -imageWidth * 8) {
|
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
offSet = -imageWidth * 4 - imageWidth;
|
offSet = 0
|
||||||
|
|
||||||
} else {
|
for (let j = 0; j < MAX_ROWS; j++) {
|
||||||
offSet = -imageWidth * 8;
|
if (offSet === -imageWidth * 8) {
|
||||||
}
|
offSet = -imageWidth * 4 - imageWidth
|
||||||
|
} else {
|
||||||
|
offSet = -imageWidth * 8
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < MAX_COLUMNS; i = i + 4) {
|
for (let i = 3; i < MAX_COLUMNS; i = i + 4) {
|
||||||
|
let logo = logoAA
|
||||||
|
|
||||||
let logo = logoA;
|
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight)
|
||||||
|
}
|
||||||
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight);
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
offSet = 0;
|
|
||||||
|
|
||||||
for (let j = 0; j < MAX_ROWS; j++) {
|
|
||||||
|
|
||||||
if (offSet === -imageWidth * 8) {
|
|
||||||
|
|
||||||
offSet = -imageWidth * 4 - imageWidth;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
offSet = -imageWidth * 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 1; i < MAX_COLUMNS; i = i + 4) {
|
|
||||||
|
|
||||||
let logo = logoB;
|
|
||||||
|
|
||||||
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
offSet = 0;
|
|
||||||
|
|
||||||
for (let j = 0; j < MAX_ROWS; j++) {
|
|
||||||
|
|
||||||
if (offSet === -imageWidth * 8) {
|
|
||||||
|
|
||||||
offSet = -imageWidth * 4 - imageWidth;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
offSet = -imageWidth * 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 2; i < MAX_COLUMNS; i = i + 4) {
|
|
||||||
|
|
||||||
let logo = logoExchange;
|
|
||||||
|
|
||||||
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
offSet = 0;
|
|
||||||
|
|
||||||
for (let j = 0; j < MAX_ROWS; j++) {
|
|
||||||
|
|
||||||
if (offSet === -imageWidth * 8) {
|
|
||||||
|
|
||||||
offSet = -imageWidth * 4 - imageWidth;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
offSet = -imageWidth * 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 3; i < MAX_COLUMNS; i = i + 4) {
|
|
||||||
|
|
||||||
let logo = logoAA;
|
|
||||||
|
|
||||||
browserCanvasContext.drawImage(logo, imagePoint.x + i * imageWidth * 2 + offSet, imagePoint.y + j * rowHight + Y_TOP_MARGIN, imageWidth, imageHeight);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We will paint some transparent background here. */
|
/* We will paint some transparent background here. */
|
||||||
|
|
||||||
let opacity = "0.9";
|
let opacity = '0.9'
|
||||||
|
|
||||||
let fromPoint = {
|
let fromPoint = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
let toPoint = {
|
let toPoint = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: thisObject.container.frame.height
|
y: thisObject.container.frame.height
|
||||||
};
|
}
|
||||||
|
|
||||||
fromPoint = transformThisPoint(fromPoint, thisObject.container);
|
fromPoint = transformThisPoint(fromPoint, thisObject.container)
|
||||||
toPoint = transformThisPoint(toPoint, thisObject.container);
|
toPoint = transformThisPoint(toPoint, thisObject.container)
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
browserCanvasContext.rect(viewPort.visibleArea.topLeft.x, fromPoint.y, viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x, toPoint.y - fromPoint.y);
|
browserCanvasContext.rect(viewPort.visibleArea.topLeft.x, fromPoint.y, viewPort.visibleArea.topRight.x - viewPort.visibleArea.topLeft.x, toPoint.y - fromPoint.y)
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')';
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + opacity + ')'
|
||||||
|
|
||||||
browserCanvasContext.closePath();
|
browserCanvasContext.closePath()
|
||||||
|
|
||||||
browserCanvasContext.fill();
|
browserCanvasContext.fill()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function moveViewPortToCurrentDatetime () {
|
||||||
|
if (INFO_LOG === true) { logger.write('[INFO] moveViewPortToCurrentDatetime -> Entering function.') }
|
||||||
|
|
||||||
function moveViewPortToCurrentDatetime() {
|
let targetPoint = {
|
||||||
|
x: datetime.valueOf(),
|
||||||
if (INFO_LOG === true) { logger.write("[INFO] moveViewPortToCurrentDatetime -> Entering function."); }
|
y: 0 // we wont touch the y axis here.
|
||||||
|
}
|
||||||
let targetPoint = {
|
|
||||||
x: datetime.valueOf(),
|
|
||||||
y: 0 // we wont touch the y axis here.
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Lets put this point in the coordinate system of the viewPort */
|
/* Lets put this point in the coordinate system of the viewPort */
|
||||||
|
|
||||||
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint);
|
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint)
|
||||||
targetPoint = transformThisPoint(targetPoint, thisObject.container);
|
targetPoint = transformThisPoint(targetPoint, thisObject.container)
|
||||||
|
|
||||||
/* Lets get the point on the viewPort coordinate system of the center of the visible screen */
|
/* Lets get the point on the viewPort coordinate system of the center of the visible screen */
|
||||||
|
|
||||||
let center = {
|
let center = {
|
||||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
|
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
|
||||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
|
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Lets calculate the displace vector, from the point we want at the center, to the current center. */
|
/* Lets calculate the displace vector, from the point we want at the center, to the current center. */
|
||||||
|
|
||||||
let displaceVector = {
|
let displaceVector = {
|
||||||
x: center.x - targetPoint.x,
|
x: center.x - targetPoint.x,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
viewPort.displace(displaceVector);
|
viewPort.displace(displaceVector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+56
-65
@@ -1,84 +1,75 @@
|
|||||||
|
|
||||||
function newCompanyLogo() {
|
function newCompanyLogo () {
|
||||||
|
var thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
thisObject.container.frame.width = 150
|
||||||
container.initialize();
|
thisObject.container.frame.height = TOP_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 150;
|
container.frame.position.x = 0
|
||||||
thisObject.container.frame.height = TOP_SPACE_HEIGHT;
|
container.frame.position.y = 0
|
||||||
|
|
||||||
container.frame.position.x = 0;
|
container.isDraggeable = false
|
||||||
container.frame.position.y = 0;
|
|
||||||
|
|
||||||
container.isDraggeable = false;
|
let logo
|
||||||
|
let canDrawLogo = false
|
||||||
|
|
||||||
let logo;
|
return thisObject
|
||||||
let canDrawLogo = false;
|
|
||||||
|
|
||||||
return thisObject;
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
|
|
||||||
if (window.canvasApp.executingAt === 'Master App') {
|
|
||||||
currentLabel = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logo = new Image();
|
|
||||||
|
|
||||||
logo.onload = onImageLoad;
|
|
||||||
|
|
||||||
function onImageLoad() {
|
|
||||||
canDrawLogo = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
logo.src = window.canvasApp.urlPrefix + "Images/aa-logo-dark-8.png";
|
|
||||||
|
|
||||||
|
function initialize () {
|
||||||
|
if (window.canvasApp.executingAt === 'Master App') {
|
||||||
|
currentLabel = ''
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
logo = new Image()
|
||||||
|
|
||||||
let container;
|
logo.onload = onImageLoad
|
||||||
|
|
||||||
|
function onImageLoad () {
|
||||||
|
canDrawLogo = true
|
||||||
|
}
|
||||||
|
|
||||||
|
logo.src = window.canvasApp.urlPrefix + 'Images/aa-logo-dark-8.png'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
if (canDrawLogo === false) { return }
|
||||||
|
|
||||||
|
let imageHeight = 24
|
||||||
|
let imageWidth = 120
|
||||||
|
|
||||||
|
let imagePoint = {
|
||||||
|
x: 10,
|
||||||
|
y: thisObject.container.frame.height / 2 - imageHeight / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
|
||||||
|
}
|
||||||
if (canDrawLogo === false) { return;}
|
}
|
||||||
|
|
||||||
let imageHeight = 24;
|
|
||||||
let imageWidth = 120;
|
|
||||||
|
|
||||||
let imagePoint = {
|
|
||||||
x: 10,
|
|
||||||
y: thisObject.container.frame.height / 2 - imageHeight / 2
|
|
||||||
};
|
|
||||||
|
|
||||||
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint);
|
|
||||||
|
|
||||||
browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+107
-126
@@ -1,156 +1,137 @@
|
|||||||
|
|
||||||
function newCurrentBot() {
|
function newCurrentBot () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = 150
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 150;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
const NOT_FOUND = ''
|
||||||
container.isClickeable = true;
|
|
||||||
|
|
||||||
const NOT_FOUND = "";
|
let sharedStatus
|
||||||
|
|
||||||
let sharedStatus;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize (pSharedStatus) {
|
||||||
|
sharedStatus = pSharedStatus
|
||||||
|
|
||||||
function initialize(pSharedStatus) {
|
if (window.USER_PROFILE.devTeams.length === 0) {
|
||||||
|
window.CURRENT_BOT_DISPLAY_NAME = NOT_FOUND
|
||||||
sharedStatus = pSharedStatus;
|
} else {
|
||||||
|
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length === 0) {
|
||||||
if (window.USER_PROFILE.devTeams.length === 0) {
|
window.CURRENT_BOT_DISPLAY_NAME = NOT_FOUND
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = NOT_FOUND;
|
window.CURRENT_BOT_REPO = 'NO REPO'
|
||||||
} else {
|
window.CURRENT_BOT_CODE_NAME = ''
|
||||||
|
} else {
|
||||||
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length === 0) {
|
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = NOT_FOUND;
|
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo
|
||||||
window.CURRENT_BOT_REPO = "NO REPO";
|
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName
|
||||||
window.CURRENT_BOT_CODE_NAME = "";
|
}
|
||||||
} else {
|
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName;
|
|
||||||
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo;
|
|
||||||
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
|
||||||
sharedStatus.eventHandler.listenToEvent("devTeam Changed", onDevTeamChanged);
|
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||||
|
sharedStatus.eventHandler.listenToEvent('devTeam Changed', onDevTeamChanged)
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 1;
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
}
|
||||||
|
|
||||||
|
function resize () {
|
||||||
|
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 1
|
||||||
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDevTeamChanged () {
|
||||||
|
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length > 0) {
|
||||||
|
sharedStatus.currentUserBotIndex = 0
|
||||||
|
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName
|
||||||
|
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo
|
||||||
|
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName
|
||||||
|
|
||||||
|
sharedStatus.eventHandler.raiseEvent('userBot Changed')
|
||||||
|
} else {
|
||||||
|
window.CURRENT_BOT_DISPLAY_NAME = NOT_FOUND
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onDevTeamChanged() {
|
function onClick () {
|
||||||
|
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||||
|
|
||||||
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length > 0) {
|
if (sessionToken === null || sessionToken === '') {
|
||||||
|
|
||||||
sharedStatus.currentUserBotIndex = 0;
|
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName;
|
|
||||||
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo;
|
|
||||||
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName;
|
|
||||||
|
|
||||||
sharedStatus.eventHandler.raiseEvent("userBot Changed");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = NOT_FOUND;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClick() {
|
|
||||||
|
|
||||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
|
||||||
|
|
||||||
if (sessionToken === null || sessionToken === "") {
|
|
||||||
/* not logged in */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedStatus.currentUserBotIndex + 1 === window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length) {
|
|
||||||
|
|
||||||
sharedStatus.currentUserBotIndex = 0;
|
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName;
|
|
||||||
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo;
|
|
||||||
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName;
|
|
||||||
|
|
||||||
sharedStatus.eventHandler.raiseEvent("userBot Changed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedStatus.currentUserBotIndex + 1 < window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length) {
|
|
||||||
|
|
||||||
sharedStatus.currentUserBotIndex++;
|
|
||||||
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName;
|
|
||||||
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo;
|
|
||||||
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName;
|
|
||||||
|
|
||||||
sharedStatus.eventHandler.raiseEvent("userBot Changed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
if (sharedStatus.currentUserBotIndex + 1 === window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length) {
|
||||||
|
sharedStatus.currentUserBotIndex = 0
|
||||||
|
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName
|
||||||
|
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo
|
||||||
|
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName
|
||||||
|
|
||||||
let container;
|
sharedStatus.eventHandler.raiseEvent('userBot Changed')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedStatus.currentUserBotIndex + 1 < window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length) {
|
||||||
|
sharedStatus.currentUserBotIndex++
|
||||||
|
window.CURRENT_BOT_DISPLAY_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].displayName
|
||||||
|
window.CURRENT_BOT_REPO = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].repo
|
||||||
|
window.CURRENT_BOT_CODE_NAME = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].codeName
|
||||||
|
|
||||||
|
sharedStatus.eventHandler.raiseEvent('userBot Changed')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* 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 */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
|
||||||
|
|
||||||
let breakpointsHeight = 14;
|
|
||||||
let fontSize = 12;
|
|
||||||
let label = window.CURRENT_BOT_DISPLAY_NAME;
|
|
||||||
if (label === undefined) { label = "" };
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
|
||||||
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
|
||||||
};
|
|
||||||
point = thisObject.container.frame.frameThisPoint(point);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, point.x, point.y);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
let breakpointsHeight = 14
|
||||||
|
let fontSize = 12
|
||||||
|
let label = window.CURRENT_BOT_DISPLAY_NAME
|
||||||
|
if (label === undefined) { label = '' };
|
||||||
|
|
||||||
|
let point = {
|
||||||
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
||||||
|
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
||||||
|
}
|
||||||
|
point = thisObject.container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
|
browserCanvasContext.fillText(label, point.x, point.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
+97
-117
@@ -1,150 +1,130 @@
|
|||||||
|
|
||||||
function newCurrentProcess() {
|
function newCurrentProcess () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = 150
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 150;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize()
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
const NOT_FOUND = ''
|
||||||
container.isClickeable = true;
|
|
||||||
|
|
||||||
const NOT_FOUND = "";
|
let sharedStatus
|
||||||
|
|
||||||
let sharedStatus;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize (pSharedStatus) {
|
||||||
|
sharedStatus = pSharedStatus
|
||||||
|
|
||||||
function initialize(pSharedStatus) {
|
if (window.USER_PROFILE.devTeams.length === 0) {
|
||||||
|
window.CURRENT_PROCESS = NOT_FOUND
|
||||||
sharedStatus = pSharedStatus;
|
} else {
|
||||||
|
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length === 0) {
|
||||||
if (window.USER_PROFILE.devTeams.length === 0) {
|
window.CURRENT_PROCESS = NOT_FOUND
|
||||||
window.CURRENT_PROCESS = NOT_FOUND;
|
} else {
|
||||||
|
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length === 0) {
|
||||||
|
window.CURRENT_PROCESS = NOT_FOUND
|
||||||
} else {
|
} else {
|
||||||
|
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name
|
||||||
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length === 0) {
|
|
||||||
window.CURRENT_PROCESS = NOT_FOUND;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length === 0) {
|
|
||||||
window.CURRENT_PROCESS = NOT_FOUND;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
|
||||||
sharedStatus.eventHandler.listenToEvent("userBot Changed", onUserBotChanged);
|
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||||
|
sharedStatus.eventHandler.listenToEvent('userBot Changed', onUserBotChanged)
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 2;
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
}
|
||||||
|
|
||||||
|
function resize () {
|
||||||
|
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 2
|
||||||
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUserBotChanged () {
|
||||||
|
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length > 0) {
|
||||||
|
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length > 0) {
|
||||||
|
sharedStatus.currentProcessIndex = 0
|
||||||
|
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUserBotChanged() {
|
window.CURRENT_PROCESS = NOT_FOUND
|
||||||
|
}
|
||||||
|
|
||||||
if ( window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots.length > 0) {
|
function onClick () {
|
||||||
|
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||||
|
|
||||||
if (window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length > 0) {
|
if (sessionToken === null || sessionToken === '') {
|
||||||
|
|
||||||
sharedStatus.currentProcessIndex = 0;
|
|
||||||
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.CURRENT_PROCESS = NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClick() {
|
|
||||||
|
|
||||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
|
||||||
|
|
||||||
if (sessionToken === null || sessionToken === "") {
|
|
||||||
/* not logged in */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedStatus.currentProcessIndex + 1 === window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length) {
|
|
||||||
|
|
||||||
sharedStatus.currentProcessIndex = 0;
|
|
||||||
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedStatus.currentProcessIndex + 1 < window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length) {
|
|
||||||
|
|
||||||
sharedStatus.currentProcessIndex++;
|
|
||||||
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
if (sharedStatus.currentProcessIndex + 1 === window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length) {
|
||||||
|
sharedStatus.currentProcessIndex = 0
|
||||||
|
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let container;
|
if (sharedStatus.currentProcessIndex + 1 < window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes.length) {
|
||||||
|
sharedStatus.currentProcessIndex++
|
||||||
|
window.CURRENT_PROCESS = window.USER_PROFILE.devTeams[sharedStatus.currentDevTeamIndex].userBots[sharedStatus.currentUserBotIndex].processes[sharedStatus.currentProcessIndex].name
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* 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 */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
|
||||||
|
|
||||||
let breakpointsHeight = 14;
|
|
||||||
let fontSize = 12;
|
|
||||||
let label = window.CURRENT_PROCESS;
|
|
||||||
if (label === undefined) { label = "" };
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
|
||||||
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
|
||||||
};
|
|
||||||
|
|
||||||
point = thisObject.container.frame.frameThisPoint(point);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, point.x, point.y);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
let breakpointsHeight = 14
|
||||||
|
let fontSize = 12
|
||||||
|
let label = window.CURRENT_PROCESS
|
||||||
|
if (label === undefined) { label = '' };
|
||||||
|
|
||||||
|
let point = {
|
||||||
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
||||||
|
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
point = thisObject.container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
|
browserCanvasContext.fillText(label, point.x, point.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,122 +1,110 @@
|
|||||||
|
|
||||||
function newCurrentStartMode() {
|
function newCurrentStartMode () {
|
||||||
|
var thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
var thisObject = {
|
var container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = newContainer();
|
thisObject.container.frame.width = 150
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 150;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
return thisObject
|
||||||
container.isClickeable = true;
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
window.CURRENT_START_MODE = window.localStorage.getItem('currentStartMode')
|
||||||
|
|
||||||
function initialize() {
|
if (window.CURRENT_START_MODE === null) {
|
||||||
|
window.CURRENT_START_MODE = 'Backtest'
|
||||||
window.CURRENT_START_MODE = window.localStorage.getItem("currentStartMode");
|
|
||||||
|
|
||||||
if (window.CURRENT_START_MODE === null) {
|
|
||||||
window.CURRENT_START_MODE = "Backtest";
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 3;
|
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
}
|
||||||
|
|
||||||
}
|
function resize () {
|
||||||
|
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 3
|
||||||
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
function onClick() {
|
function onClick () {
|
||||||
|
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||||
|
|
||||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
if (sessionToken === null || sessionToken === '') {
|
||||||
|
|
||||||
if (sessionToken === null || sessionToken === "") {
|
|
||||||
/* not logged in */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if (window.CURRENT_BOT_DISPLAY_NAME === "") { return; }
|
|
||||||
|
|
||||||
switch (window.CURRENT_START_MODE) {
|
|
||||||
|
|
||||||
case "Backtest": {
|
|
||||||
window.CURRENT_START_MODE = "Live";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Live": {
|
|
||||||
window.CURRENT_START_MODE = "Competition";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Competition": {
|
|
||||||
window.CURRENT_START_MODE = "Backtest";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
if (window.CURRENT_BOT_DISPLAY_NAME === '') { return }
|
||||||
|
|
||||||
let container;
|
switch (window.CURRENT_START_MODE) {
|
||||||
|
|
||||||
|
case 'Backtest': {
|
||||||
|
window.CURRENT_START_MODE = 'Live'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'Live': {
|
||||||
|
window.CURRENT_START_MODE = 'Competition'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'Competition': {
|
||||||
|
window.CURRENT_START_MODE = 'Backtest'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* 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 */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if (window.CURRENT_BOT_DISPLAY_NAME === "") { return;}
|
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
|
||||||
|
|
||||||
let breakpointsHeight = 14;
|
|
||||||
let fontSize = 12;
|
|
||||||
let label = window.CURRENT_START_MODE + " Mode";
|
|
||||||
if (label === "undefined Mode") { label = "" };
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
|
||||||
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
|
||||||
};
|
|
||||||
|
|
||||||
point = thisObject.container.frame.frameThisPoint(point);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, point.x, point.y);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (window.CURRENT_BOT_DISPLAY_NAME === '') { return }
|
||||||
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
let breakpointsHeight = 14
|
||||||
|
let fontSize = 12
|
||||||
|
let label = window.CURRENT_START_MODE + ' Mode'
|
||||||
|
if (label === 'undefined Mode') { label = '' };
|
||||||
|
|
||||||
|
let point = {
|
||||||
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
||||||
|
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
point = thisObject.container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
|
browserCanvasContext.fillText(label, point.x, point.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
+93
-107
@@ -1,140 +1,126 @@
|
|||||||
|
|
||||||
function newDevTeam() {
|
function newDevTeam () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = 150
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 150;
|
resize()
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
|
||||||
|
|
||||||
resize();
|
container.isDraggeable = false
|
||||||
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
const NOT_FOUND = 'Team NOT FOUND'
|
||||||
container.isClickeable = true;
|
|
||||||
|
|
||||||
const NOT_FOUND = "Team NOT FOUND";
|
let sharedStatus
|
||||||
|
let label = ''
|
||||||
|
|
||||||
let sharedStatus;
|
return thisObject
|
||||||
let label = ""
|
|
||||||
|
|
||||||
return thisObject;
|
function initialize (pSharedStatus) {
|
||||||
|
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||||
|
|
||||||
function initialize(pSharedStatus) {
|
if (sessionToken === null || sessionToken === '') {
|
||||||
|
|
||||||
let sessionToken = window.localStorage.getItem('sessionToken');
|
|
||||||
|
|
||||||
if (sessionToken === null || sessionToken === "") {
|
|
||||||
/* not logged in */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
sharedStatus = pSharedStatus;
|
|
||||||
|
|
||||||
let storedTeams = window.localStorage.getItem('userTeams');
|
|
||||||
|
|
||||||
if (storedTeams === null || storedTeams === "[]" || storedTeams === "") {
|
|
||||||
window.TEAMS = "";
|
|
||||||
window.DEV_TEAM = "";
|
|
||||||
label = NOT_FOUND;
|
|
||||||
} else {
|
|
||||||
storedTeams = JSON.parse(storedTeams)
|
|
||||||
window.TEAMS = storedTeams;
|
|
||||||
window.DEV_TEAM = storedTeams[sharedStatus.currentDevTeamIndex].slug;
|
|
||||||
label = storedTeams[sharedStatus.currentDevTeamIndex].name;
|
|
||||||
sharedStatus.eventHandler.raiseEvent("devTeam Changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
|
||||||
|
|
||||||
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
sharedStatus = pSharedStatus
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.topLeft.x + thisObject.container.frame.width * 0;
|
let storedTeams = window.localStorage.getItem('userTeams')
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
|
||||||
|
|
||||||
|
if (storedTeams === null || storedTeams === '[]' || storedTeams === '') {
|
||||||
|
window.TEAMS = ''
|
||||||
|
window.DEV_TEAM = ''
|
||||||
|
label = NOT_FOUND
|
||||||
|
} else {
|
||||||
|
storedTeams = JSON.parse(storedTeams)
|
||||||
|
window.TEAMS = storedTeams
|
||||||
|
window.DEV_TEAM = storedTeams[sharedStatus.currentDevTeamIndex].slug
|
||||||
|
label = storedTeams[sharedStatus.currentDevTeamIndex].name
|
||||||
|
sharedStatus.eventHandler.raiseEvent('devTeam Changed')
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick() {
|
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||||
|
|
||||||
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 + thisObject.container.frame.width * 0
|
||||||
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClick () {
|
||||||
|
let sessionToken = window.localStorage.getItem('sessionToken')
|
||||||
|
|
||||||
|
if (sessionToken === null || sessionToken === '') {
|
||||||
/* not logged in */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedStatus.currentDevTeamIndex + 1 === window.TEAMS.length) {
|
|
||||||
|
|
||||||
sharedStatus.currentDevTeamIndex = 0;
|
|
||||||
window.DEV_TEAM = window.TEAMS[sharedStatus.currentDevTeamIndex].slug;
|
|
||||||
label = window.TEAMS[sharedStatus.currentDevTeamIndex].name;
|
|
||||||
sharedStatus.eventHandler.raiseEvent("devTeam Changed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sharedStatus.currentDevTeamIndex + 1 < window.TEAMS.length) {
|
|
||||||
|
|
||||||
sharedStatus.currentDevTeamIndex++;
|
|
||||||
window.DEV_TEAM = window.TEAMS[sharedStatus.currentDevTeamIndex].slug;
|
|
||||||
label = window.TEAMS[sharedStatus.currentDevTeamIndex].name;
|
|
||||||
sharedStatus.eventHandler.raiseEvent("devTeam Changed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
if (sharedStatus.currentDevTeamIndex + 1 === window.TEAMS.length) {
|
||||||
|
sharedStatus.currentDevTeamIndex = 0
|
||||||
|
window.DEV_TEAM = window.TEAMS[sharedStatus.currentDevTeamIndex].slug
|
||||||
|
label = window.TEAMS[sharedStatus.currentDevTeamIndex].name
|
||||||
|
sharedStatus.eventHandler.raiseEvent('devTeam Changed')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let container;
|
if (sharedStatus.currentDevTeamIndex + 1 < window.TEAMS.length) {
|
||||||
|
sharedStatus.currentDevTeamIndex++
|
||||||
|
window.DEV_TEAM = window.TEAMS[sharedStatus.currentDevTeamIndex].slug
|
||||||
|
label = window.TEAMS[sharedStatus.currentDevTeamIndex].name
|
||||||
|
sharedStatus.eventHandler.raiseEvent('devTeam Changed')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* 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 */
|
/* not logged in */
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.container.frame.draw(false, false);
|
|
||||||
|
|
||||||
let breakpointsHeight = 14;
|
|
||||||
let fontSize = 12;
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
|
||||||
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
|
||||||
};
|
|
||||||
|
|
||||||
point = thisObject.container.frame.frameThisPoint(point);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, point.x, point.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
let breakpointsHeight = 14
|
||||||
|
let fontSize = 12
|
||||||
|
|
||||||
|
let point = {
|
||||||
|
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize / 3,
|
||||||
|
y: thisObject.container.frame.height / 2 + fontSize / 2 + breakpointsHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
point = thisObject.container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
|
browserCanvasContext.fillText(label, point.x, point.y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+57
-69
@@ -1,96 +1,84 @@
|
|||||||
|
|
||||||
function newEndUser() {
|
function newEndUser () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = 200
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 200;
|
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 5
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 5;
|
container.isDraggeable = false
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
|
||||||
|
|
||||||
container.isDraggeable = false;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
let storedUser = window.localStorage.getItem('loggedInUser')
|
||||||
function initialize() {
|
|
||||||
|
|
||||||
let storedUser = window.localStorage.getItem('loggedInUser');
|
|
||||||
|
|
||||||
if (storedUser === null || storedUser === "") {
|
|
||||||
|
|
||||||
|
if (storedUser === null || storedUser === '') {
|
||||||
// User is currently not logged in.
|
// User is currently not logged in.
|
||||||
window.USER_LOGGED_IN = "";
|
window.USER_LOGGED_IN = ''
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let loggedInUser = JSON.parse(storedUser);
|
let loggedInUser = JSON.parse(storedUser)
|
||||||
|
|
||||||
window.USER_LOGGED_IN = loggedInUser.alias;
|
window.USER_LOGGED_IN = loggedInUser.alias
|
||||||
|
|
||||||
/* Here we will rearrange the storage permissions array into a map, so that it can be easily consumed when needed. */
|
/* Here we will rearrange the storage permissions array into a map, so that it can be easily consumed when needed. */
|
||||||
|
|
||||||
let permissionsMap = new Map;
|
let permissionsMap = new Map()
|
||||||
|
|
||||||
for (i = 0; i < window.USER_PROFILE.storagePermissions.length; i++) {
|
for (i = 0; i < window.USER_PROFILE.storagePermissions.length; i++) {
|
||||||
|
let permission = window.USER_PROFILE.storagePermissions[i]
|
||||||
let permission = window.USER_PROFILE.storagePermissions[i];
|
|
||||||
|
|
||||||
permissionsMap.set(permission[0], permission[1]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
window.USER_PROFILE.storagePermissions = permissionsMap;
|
|
||||||
|
|
||||||
|
permissionsMap.set(permission[0], permission[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContainer(point) {
|
window.USER_PROFILE.storagePermissions = permissionsMap
|
||||||
|
}
|
||||||
|
|
||||||
let container;
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
return // nothing to show
|
||||||
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
let fontSize = 12
|
||||||
|
let label = window.USER_LOGGED_IN
|
||||||
|
if (label === undefined) { label = '' };
|
||||||
|
|
||||||
|
let point = {
|
||||||
|
x: thisObject.container.frame.width * 1 / 3,
|
||||||
|
y: (thisObject.container.frame.height / 2) + 4
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
point = thisObject.container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
return; // nothing to show
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
thisObject.container.frame.draw(false, false);
|
browserCanvasContext.fillText(label, point.x, point.y)
|
||||||
|
}
|
||||||
let fontSize = 12;
|
}
|
||||||
let label = window.USER_LOGGED_IN;
|
|
||||||
if (label === undefined) { label = "" };
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: thisObject.container.frame.width * 1 / 3,
|
|
||||||
y: (thisObject.container.frame.height / 2) + 4
|
|
||||||
};
|
|
||||||
|
|
||||||
point = thisObject.container.frame.frameThisPoint(point);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, point.x, point.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+136
-153
@@ -1,62 +1,58 @@
|
|||||||
|
|
||||||
function newLogin() {
|
function newLogin () {
|
||||||
|
let thisObject = {
|
||||||
|
container: undefined,
|
||||||
|
draw: draw,
|
||||||
|
getContainer: getContainer,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let container = newContainer()
|
||||||
container: undefined,
|
container.initialize()
|
||||||
draw: draw,
|
thisObject.container = container
|
||||||
getContainer: getContainer,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let container = newContainer();
|
thisObject.container.frame.width = 200
|
||||||
container.initialize();
|
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
|
||||||
thisObject.container = container;
|
|
||||||
|
|
||||||
thisObject.container.frame.width = 200;
|
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 1
|
||||||
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
|
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
|
||||||
|
|
||||||
container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 1;
|
container.isDraggeable = false
|
||||||
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
|
container.isClickeable = true
|
||||||
|
|
||||||
container.isDraggeable = false;
|
let currentLabel
|
||||||
container.isClickeable = true;
|
|
||||||
|
|
||||||
let currentLabel;
|
let userAuthorization
|
||||||
|
|
||||||
let userAuthorization;
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize (callBackFunction) {
|
||||||
|
const accessToken = window.localStorage.getItem('access_token')
|
||||||
function initialize(callBackFunction) {
|
let user = window.localStorage.getItem('user')
|
||||||
|
|
||||||
|
|
||||||
const accessToken = window.localStorage.getItem("access_token");
|
|
||||||
let user = window.localStorage.getItem("user");
|
|
||||||
|
|
||||||
if (user === null) {
|
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
// if there is no user that means that we are logged off, which means it is time to clean the local storage of things from the last log in.
|
// if there is no user that means that we are logged off, which means it is time to clean the local storage of things from the last log in.
|
||||||
|
|
||||||
window.localStorage.removeItem("loggedInUser");
|
window.localStorage.removeItem('loggedInUser')
|
||||||
window.localStorage.removeItem('sessionToken');
|
window.localStorage.removeItem('sessionToken')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user = JSON.parse(user);
|
user = JSON.parse(user)
|
||||||
|
|
||||||
const authId = user.authId;
|
const authId = user.authId
|
||||||
|
|
||||||
let sessionToken;
|
let sessionToken
|
||||||
|
|
||||||
const apolloClient = new Apollo.lib.ApolloClient({
|
const apolloClient = new Apollo.lib.ApolloClient({
|
||||||
networkInterface: Apollo.lib.createNetworkInterface({
|
networkInterface: Apollo.lib.createNetworkInterface({
|
||||||
uri: window.canvasApp.graphQL.masterAppApiUrl,
|
uri: window.canvasApp.graphQL.masterAppApiUrl,
|
||||||
transportBatching: true,
|
transportBatching: true
|
||||||
}),
|
}),
|
||||||
connectToDevTools: true,
|
connectToDevTools: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const QUERY = Apollo.gql`
|
const QUERY = Apollo.gql`
|
||||||
query($authId: String){
|
query($authId: String){
|
||||||
users_UserByAuthId (authId: $authId){
|
users_UserByAuthId (authId: $authId){
|
||||||
id
|
id
|
||||||
@@ -80,46 +76,46 @@ function newLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const getUser = () => {
|
const getUser = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
apolloClient.query({
|
apolloClient.query({
|
||||||
query: QUERY,
|
query: QUERY,
|
||||||
variables: {
|
variables: {
|
||||||
authId: authId
|
authId: authId
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
sessionToken = response.data.users_UserByAuthId.sessionToken;
|
sessionToken = response.data.users_UserByAuthId.sessionToken
|
||||||
|
|
||||||
window.localStorage.setItem('loggedInUser', JSON.stringify(response.data.users_UserByAuthId));
|
window.localStorage.setItem('loggedInUser', JSON.stringify(response.data.users_UserByAuthId))
|
||||||
resolve({ user: response.data.users_UserByAuthId})
|
resolve({ user: response.data.users_UserByAuthId})
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log("apolloClient error getting user query", error)
|
console.log('apolloClient error getting user query', error)
|
||||||
reject(error)
|
reject(error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const networkInterfaceTeams = Apollo.lib.createNetworkInterface({
|
const networkInterfaceTeams = Apollo.lib.createNetworkInterface({
|
||||||
uri: window.canvasApp.graphQL.masterAppApiUrl
|
uri: window.canvasApp.graphQL.masterAppApiUrl
|
||||||
});
|
})
|
||||||
|
|
||||||
networkInterfaceTeams.use([{
|
networkInterfaceTeams.use([{
|
||||||
applyMiddleware(req, next) {
|
applyMiddleware (req, next) {
|
||||||
req.options.headers = {
|
req.options.headers = {
|
||||||
authorization: `Bearer ${accessToken}`
|
authorization: `Bearer ${accessToken}`
|
||||||
};
|
}
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
}]);
|
}])
|
||||||
|
|
||||||
const apolloClientTeams = new Apollo.lib.ApolloClient({
|
const apolloClientTeams = new Apollo.lib.ApolloClient({
|
||||||
networkInterface: networkInterfaceTeams,
|
networkInterface: networkInterfaceTeams,
|
||||||
connectToDevTools: true,
|
connectToDevTools: true
|
||||||
});
|
})
|
||||||
|
|
||||||
const TEAM_BY_OWNER_QUERY = Apollo.gql`
|
const TEAM_BY_OWNER_QUERY = Apollo.gql`
|
||||||
query teamsByOwnerQuery {
|
query teamsByOwnerQuery {
|
||||||
teams_TeamsByOwner {
|
teams_TeamsByOwner {
|
||||||
id
|
id
|
||||||
@@ -153,113 +149,100 @@ function newLogin() {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const getTeamByOwner = () => {
|
const getTeamByOwner = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
apolloClientTeams.query({
|
apolloClientTeams.query({
|
||||||
query: TEAM_BY_OWNER_QUERY
|
query: TEAM_BY_OWNER_QUERY
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
window.localStorage.setItem('userTeams', JSON.stringify(response.data.teams_TeamsByOwner));
|
window.localStorage.setItem('userTeams', JSON.stringify(response.data.teams_TeamsByOwner))
|
||||||
resolve({ teams: response.data.teams_TeamsByOwner})
|
resolve({ teams: response.data.teams_TeamsByOwner})
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log("apolloClient error getting user teams", error)
|
console.log('apolloClient error getting user teams', error)
|
||||||
reject (error)
|
reject(error)
|
||||||
});
|
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// To avoid race conditions, add asynchronous fetches to array
|
// To avoid race conditions, add asynchronous fetches to array
|
||||||
let fetchDataPromises = [];
|
let fetchDataPromises = []
|
||||||
|
|
||||||
fetchDataPromises.push(getUser(), getTeamByOwner());
|
fetchDataPromises.push(getUser(), getTeamByOwner())
|
||||||
|
|
||||||
// When all asynchronous fetches resolve, authenticate user or throw error.
|
// When all asynchronous fetches resolve, authenticate user or throw error.
|
||||||
Promise.all(fetchDataPromises).then(result => {
|
Promise.all(fetchDataPromises).then(result => {
|
||||||
|
|
||||||
/* this is the time to authenticate the user at AAWeb */
|
/* this is the time to authenticate the user at AAWeb */
|
||||||
|
|
||||||
authenticateUser();
|
authenticateUser()
|
||||||
|
}, err => {
|
||||||
|
console.error('fetchData error', err)
|
||||||
|
})
|
||||||
|
|
||||||
}, err => {
|
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
|
||||||
console.error("fetchData error", err)
|
|
||||||
});
|
|
||||||
|
|
||||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
function authenticateUser () {
|
||||||
|
if (sessionToken === undefined) { sessionToken = '' }
|
||||||
|
|
||||||
function authenticateUser() {
|
let path = window.canvasApp.urlPrefix + 'AABrowserAPI/authenticateUser/' + sessionToken
|
||||||
|
|
||||||
if (sessionToken === undefined) { sessionToken = "" }
|
callServer(undefined, path, onServerReponded)
|
||||||
|
|
||||||
let path = window.canvasApp.urlPrefix + "AABrowserAPI/authenticateUser/" + sessionToken;
|
function onServerReponded (pResponseFromServer) {
|
||||||
|
let responseFromServer = JSON.parse(pResponseFromServer)
|
||||||
|
|
||||||
callServer(undefined, path, onServerReponded);
|
err = responseFromServer.err
|
||||||
|
|
||||||
function onServerReponded(pResponseFromServer) {
|
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||||
|
console.log('Please make sure you create a new team!')
|
||||||
let responseFromServer = JSON.parse(pResponseFromServer);
|
return
|
||||||
|
|
||||||
err = responseFromServer.err;
|
|
||||||
|
|
||||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
|
||||||
|
|
||||||
console.log("Please make sure you create a new team!");
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
window.USER_PROFILE = responseFromServer.userProfile;
|
|
||||||
window.localStorage.setItem('sessionToken', sessionToken);
|
|
||||||
|
|
||||||
currentLabel = "Logged In"
|
|
||||||
callBackFunction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.USER_PROFILE = responseFromServer.userProfile
|
||||||
|
window.localStorage.setItem('sessionToken', sessionToken)
|
||||||
|
|
||||||
|
currentLabel = 'Logged In'
|
||||||
|
callBackFunction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClick () {
|
||||||
|
|
||||||
function onClick() {
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContainer(point) {
|
function getContainer (point) {
|
||||||
|
let container
|
||||||
let container;
|
|
||||||
|
|
||||||
/* First we check if this point is inside this object UI. */
|
/* First we check if this point is inside this object UI. */
|
||||||
|
|
||||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||||
|
return this.container
|
||||||
return this.container;
|
} else {
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This point does not belong to this space. */
|
/* This point does not belong to this space. */
|
||||||
|
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
|
return // nothing to show.
|
||||||
|
|
||||||
|
thisObject.container.frame.draw(false, false)
|
||||||
|
|
||||||
|
let fontSize = 12
|
||||||
|
let label = currentLabel
|
||||||
|
if (label === undefined) { label = '' };
|
||||||
|
|
||||||
|
let point = {
|
||||||
|
x: thisObject.container.frame.width * 1 / 3,
|
||||||
|
y: (thisObject.container.frame.height / 2) + 4
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
point = thisObject.container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
return; // nothing to show.
|
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||||
|
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||||
thisObject.container.frame.draw(false, false);
|
browserCanvasContext.fillText(label, point.x, point.y)
|
||||||
|
}
|
||||||
let fontSize = 12;
|
|
||||||
let label = currentLabel;
|
|
||||||
if (label === undefined) { label = "" };
|
|
||||||
|
|
||||||
let point = {
|
|
||||||
x: thisObject.container.frame.width * 1 / 3,
|
|
||||||
y: (thisObject.container.frame.height / 2) + 4
|
|
||||||
};
|
|
||||||
|
|
||||||
point = thisObject.container.frame.frameThisPoint(point);
|
|
||||||
|
|
||||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY;
|
|
||||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)';
|
|
||||||
browserCanvasContext.fillText(label, point.x, point.y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+78
-91
@@ -1,141 +1,128 @@
|
|||||||
|
|
||||||
|
|
||||||
function transformThisPoint(point, container) {
|
|
||||||
|
|
||||||
|
function transformThisPoint (point, container) {
|
||||||
/* We make the point relative to the current frame */
|
/* We make the point relative to the current frame */
|
||||||
|
|
||||||
point = container.frame.frameThisPoint(point);
|
point = container.frame.frameThisPoint(point)
|
||||||
|
|
||||||
/* We add the possible displacement */
|
/* We add the possible displacement */
|
||||||
|
|
||||||
point = container.displacement.displaceThisPoint(point);
|
point = container.displacement.displaceThisPoint(point)
|
||||||
|
|
||||||
/* We viewport Transformation. */
|
/* We viewport Transformation. */
|
||||||
|
|
||||||
point = viewPort.zoomThisPoint(point);
|
point = viewPort.zoomThisPoint(point)
|
||||||
|
|
||||||
return point;
|
return point
|
||||||
}
|
}
|
||||||
|
|
||||||
function unTransformThisPoint(point, container) {
|
function unTransformThisPoint (point, container) {
|
||||||
|
point = viewPort.unzoomThisPoint(point)
|
||||||
|
point = container.displacement.undisplaceThisPoint(point)
|
||||||
|
point = container.frame.unframeThisPoint(point)
|
||||||
|
|
||||||
point = viewPort.unzoomThisPoint(point);
|
return point
|
||||||
point = container.displacement.undisplaceThisPoint(point);
|
|
||||||
point = container.frame.unframeThisPoint(point);
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextPorwerOf10(number) {
|
function nextPorwerOf10 (number) {
|
||||||
|
for (let i = -10; i <= 10; i++) {
|
||||||
for (let i = -10; i <= 10; i++) {
|
if (number < Math.pow(10, i)) {
|
||||||
if (number < Math.pow(10, i)) {
|
return Math.pow(10, i)
|
||||||
return Math.pow(10, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pad(str, max) {
|
function pad (str, max) {
|
||||||
str = str.toString();
|
str = str.toString()
|
||||||
return str.length < max ? pad("0" + str, max) : str;
|
return str.length < max ? pad('0' + str, max) : str
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDateFromPoint(point, container, timeLineCoordinateSystem) {
|
function getDateFromPoint (point, container, timeLineCoordinateSystem) {
|
||||||
|
point = unTransformThisPoint(point, container)
|
||||||
|
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height)
|
||||||
|
|
||||||
point = unTransformThisPoint(point, container);
|
let date = new Date(point.x)
|
||||||
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height);
|
|
||||||
|
|
||||||
let date = new Date(point.x);
|
return date
|
||||||
|
|
||||||
return date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRateFromPoint(point, container, timeLineCoordinateSystem) {
|
function getRateFromPoint (point, container, timeLineCoordinateSystem) {
|
||||||
|
point = unTransformThisPoint(point, container)
|
||||||
|
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height)
|
||||||
|
|
||||||
point = unTransformThisPoint(point, container);
|
return point.y
|
||||||
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height);
|
|
||||||
|
|
||||||
return point.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMilisecondsFromPoint(point, container, timeLineCoordinateSystem) {
|
function getMilisecondsFromPoint (point, container, timeLineCoordinateSystem) {
|
||||||
|
point = unTransformThisPoint(point, container)
|
||||||
|
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height)
|
||||||
|
|
||||||
point = unTransformThisPoint(point, container);
|
return point.x
|
||||||
point = timeLineCoordinateSystem.unInverseTransform(point, container.frame.height);
|
|
||||||
|
|
||||||
return point.x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveUserPosition(container, timeLineCoordinateSystem) {
|
function saveUserPosition (container, timeLineCoordinateSystem) {
|
||||||
|
let centerPoint = {
|
||||||
|
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2,
|
||||||
|
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2
|
||||||
|
}
|
||||||
|
|
||||||
let centerPoint = {
|
let userPosition = {
|
||||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2,
|
date: getDateFromPoint(centerPoint, container, timeLineCoordinateSystem),
|
||||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2
|
rate: getRateFromPoint(centerPoint, container, timeLineCoordinateSystem),
|
||||||
};
|
market: DEFAULT_MARKET,
|
||||||
|
zoom: viewPort.zoomTargetLevel
|
||||||
|
}
|
||||||
|
|
||||||
let userPosition = {
|
window.localStorage.setItem('userPosition', JSON.stringify(userPosition))
|
||||||
date: getDateFromPoint(centerPoint, container, timeLineCoordinateSystem),
|
|
||||||
rate: getRateFromPoint(centerPoint, container, timeLineCoordinateSystem),
|
|
||||||
market: DEFAULT_MARKET,
|
|
||||||
zoom: viewPort.zoomTargetLevel
|
|
||||||
};
|
|
||||||
|
|
||||||
window.localStorage.setItem('userPosition', JSON.stringify(userPosition));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveToUserPosition(container, timeLineCoordinateSystem) {
|
function moveToUserPosition (container, timeLineCoordinateSystem) {
|
||||||
|
let savedPosition = window.localStorage.getItem('userPosition')
|
||||||
|
let userPosition
|
||||||
|
|
||||||
let savedPosition = window.localStorage.getItem('userPosition');
|
if (savedPosition === null) {
|
||||||
let userPosition;
|
userPosition = {
|
||||||
|
date: (new Date()).toString(),
|
||||||
if (savedPosition === null) {
|
rate: timeLineCoordinateSystem.max.y / 2,
|
||||||
|
market: DEFAULT_MARKET,
|
||||||
userPosition = {
|
zoom: INITIAL_ZOOM_LEVEL
|
||||||
date: (new Date()).toString(),
|
|
||||||
rate: timeLineCoordinateSystem.max.y / 2,
|
|
||||||
market: DEFAULT_MARKET,
|
|
||||||
zoom: INITIAL_ZOOM_LEVEL
|
|
||||||
};
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
userPosition = JSON.parse(savedPosition);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
userPosition = JSON.parse(savedPosition)
|
||||||
|
}
|
||||||
|
|
||||||
let centerPoint = {
|
let centerPoint = {
|
||||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2,
|
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.topLeft.x) / 2,
|
||||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2
|
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 2
|
||||||
};
|
}
|
||||||
|
|
||||||
viewPort.newZoomLevel(userPosition.zoom);
|
viewPort.newZoomLevel(userPosition.zoom)
|
||||||
INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom);
|
INITIAL_TIME_PERIOD = recalculatePeriod(userPosition.zoom)
|
||||||
INITIAL_DATE = new Date (userPosition.date);
|
INITIAL_DATE = new Date(userPosition.date)
|
||||||
|
|
||||||
let targetPoint = {
|
let targetPoint = {
|
||||||
x: (new Date(userPosition.date)).valueOf(),
|
x: (new Date(userPosition.date)).valueOf(),
|
||||||
y: userPosition.rate
|
y: userPosition.rate
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Put this point in the coordinate system of the viewPort */
|
/* Put this point in the coordinate system of the viewPort */
|
||||||
|
|
||||||
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint);
|
targetPoint = timeLineCoordinateSystem.transformThisPoint(targetPoint)
|
||||||
targetPoint = transformThisPoint(targetPoint, container);
|
targetPoint = transformThisPoint(targetPoint, container)
|
||||||
|
|
||||||
/* Lets calculate the displace vector, from the point we want at the center, to the current center. */
|
/* Lets calculate the displace vector, from the point we want at the center, to the current center. */
|
||||||
|
|
||||||
let displaceVector = {
|
let displaceVector = {
|
||||||
x: centerPoint.x - targetPoint.x,
|
x: centerPoint.x - targetPoint.x,
|
||||||
y: centerPoint.y - targetPoint.y
|
y: centerPoint.y - targetPoint.y
|
||||||
};
|
}
|
||||||
|
|
||||||
viewPort.displace(displaceVector);
|
viewPort.displace(displaceVector)
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeTime(datetime) {
|
function removeTime (datetime) {
|
||||||
|
if (datetime === undefined) { return }
|
||||||
|
|
||||||
if (datetime === undefined) { return;}
|
let dateOnly = new Date(Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS) * ONE_DAY_IN_MILISECONDS)
|
||||||
|
|
||||||
let dateOnly = new Date(Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS) * ONE_DAY_IN_MILISECONDS);
|
return dateOnly
|
||||||
|
}
|
||||||
return dateOnly;
|
|
||||||
}
|
|
||||||
+314
-373
@@ -1,100 +1,95 @@
|
|||||||
|
|
||||||
function newViewPort() {
|
function newViewPort () {
|
||||||
|
const CONSOLE_LOG = true
|
||||||
|
|
||||||
const CONSOLE_LOG = true;
|
let ANIMATION_INCREMENT = 0.25
|
||||||
|
const TOP_MARGIN = 15 + TOP_SPACE_HEIGHT
|
||||||
|
const BOTTOM_MARGIN = 15 + BOTTOM_SPACE_HEIGHT
|
||||||
|
const LEFT_MARGIN = 50
|
||||||
|
const RIGHT_MARGIN = 50
|
||||||
|
const MIN_ZOOM_LEVEL = -28.25
|
||||||
|
|
||||||
let ANIMATION_INCREMENT = 0.25;
|
let thisObject = {
|
||||||
const TOP_MARGIN = 15 + TOP_SPACE_HEIGHT;
|
visibleArea: undefined,
|
||||||
const BOTTOM_MARGIN = 15 + BOTTOM_SPACE_HEIGHT;
|
eventHandler: undefined,
|
||||||
const LEFT_MARGIN = 50;
|
zoomTargetLevel: undefined,
|
||||||
const RIGHT_MARGIN = 50;
|
zoomLevel: undefined,
|
||||||
const MIN_ZOOM_LEVEL = -28.25
|
mousePosition: undefined,
|
||||||
|
newZoomLevel: newZoomLevel,
|
||||||
|
applyZoom: applyZoom,
|
||||||
|
isMinZoom: isMinZoom,
|
||||||
|
zoomFontSize: zoomFontSize,
|
||||||
|
zoomThisPoint: zoomThisPoint,
|
||||||
|
unzoomThisPoint: unzoomThisPoint,
|
||||||
|
isThisPointVisible: isThisPointVisible,
|
||||||
|
fitIntoVisibleArea: fitIntoVisibleArea,
|
||||||
|
displace: displace,
|
||||||
|
displaceTarget: displaceTarget,
|
||||||
|
animate: animate,
|
||||||
|
draw: draw,
|
||||||
|
raiseEvents: raiseEvents,
|
||||||
|
initialize: initialize
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
let increment = 0.035
|
||||||
visibleArea: undefined,
|
|
||||||
eventHandler: undefined,
|
|
||||||
zoomTargetLevel:undefined,
|
|
||||||
zoomLevel: undefined,
|
|
||||||
mousePosition: undefined,
|
|
||||||
newZoomLevel: newZoomLevel,
|
|
||||||
applyZoom: applyZoom,
|
|
||||||
isMinZoom: isMinZoom,
|
|
||||||
zoomFontSize: zoomFontSize,
|
|
||||||
zoomThisPoint: zoomThisPoint,
|
|
||||||
unzoomThisPoint: unzoomThisPoint,
|
|
||||||
isThisPointVisible: isThisPointVisible,
|
|
||||||
fitIntoVisibleArea: fitIntoVisibleArea,
|
|
||||||
displace: displace,
|
|
||||||
displaceTarget: displaceTarget,
|
|
||||||
animate: animate,
|
|
||||||
draw: draw,
|
|
||||||
raiseEvents: raiseEvents,
|
|
||||||
initialize: initialize
|
|
||||||
};
|
|
||||||
|
|
||||||
let increment = 0.035;
|
var offset = {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
|
}
|
||||||
|
|
||||||
var offset = {
|
var targetOffset = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
var targetOffset = {
|
let offsetIncrement = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
let offsetIncrement = {
|
thisObject.mousePosition = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
};
|
}
|
||||||
|
|
||||||
thisObject.mousePosition = {
|
thisObject.eventHandler = newEventHandler()
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.eventHandler = newEventHandler();
|
return thisObject
|
||||||
|
|
||||||
return thisObject;
|
function initialize () {
|
||||||
|
thisObject.visibleArea = {
|
||||||
|
topLeft: { x: LEFT_MARGIN, y: TOP_MARGIN },
|
||||||
|
topRight: { x: browserCanvas.width - RIGHT_MARGIN, y: TOP_MARGIN },
|
||||||
|
bottomRight: { x: browserCanvas.width - RIGHT_MARGIN, y: browserCanvas.height - BOTTOM_MARGIN},
|
||||||
|
bottomLeft: { x: LEFT_MARGIN, y: browserCanvas.height - BOTTOM_MARGIN}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initialize() {
|
function raiseEvents () {
|
||||||
|
let event = {
|
||||||
|
newOffset: offset
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.visibleArea = {
|
thisObject.eventHandler.raiseEvent('Offset Changed', event)
|
||||||
topLeft: { x: LEFT_MARGIN, y: TOP_MARGIN },
|
}
|
||||||
topRight: { x: browserCanvas.width - RIGHT_MARGIN , y: TOP_MARGIN },
|
|
||||||
bottomRight: { x: browserCanvas.width - RIGHT_MARGIN, y: browserCanvas.height - BOTTOM_MARGIN},
|
|
||||||
bottomLeft: { x: LEFT_MARGIN, y: browserCanvas.height - BOTTOM_MARGIN}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function raiseEvents() {
|
function animate () {
|
||||||
|
if (thisObject.zoomLevel < thisObject.zoomTargetLevel) {
|
||||||
|
if (thisObject.zoomTargetLevel - thisObject.zoomLevel < ANIMATION_INCREMENT) {
|
||||||
|
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel)
|
||||||
|
}
|
||||||
|
thisObject.zoomLevel = thisObject.zoomLevel + ANIMATION_INCREMENT
|
||||||
|
changeZoom(thisObject.zoomLevel - ANIMATION_INCREMENT, thisObject.zoomLevel)
|
||||||
|
}
|
||||||
|
|
||||||
let event = {
|
if (thisObject.zoomLevel > thisObject.zoomTargetLevel) {
|
||||||
newOffset: offset
|
if (thisObject.zoomLevel - thisObject.zoomTargetLevel < ANIMATION_INCREMENT) {
|
||||||
};
|
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel)
|
||||||
|
}
|
||||||
thisObject.eventHandler.raiseEvent("Offset Changed", event);
|
thisObject.zoomLevel = thisObject.zoomLevel - ANIMATION_INCREMENT
|
||||||
|
changeZoom(thisObject.zoomLevel + ANIMATION_INCREMENT, thisObject.zoomLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
function animate() {
|
|
||||||
|
|
||||||
if (thisObject.zoomLevel < thisObject.zoomTargetLevel) {
|
|
||||||
if (thisObject.zoomTargetLevel - thisObject.zoomLevel < ANIMATION_INCREMENT) {
|
|
||||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel);
|
|
||||||
}
|
|
||||||
thisObject.zoomLevel = thisObject.zoomLevel + ANIMATION_INCREMENT;
|
|
||||||
changeZoom(thisObject.zoomLevel - ANIMATION_INCREMENT, thisObject.zoomLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomLevel > thisObject.zoomTargetLevel) {
|
|
||||||
if (thisObject.zoomLevel - thisObject.zoomTargetLevel < ANIMATION_INCREMENT) {
|
|
||||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel);
|
|
||||||
}
|
|
||||||
thisObject.zoomLevel = thisObject.zoomLevel - ANIMATION_INCREMENT;
|
|
||||||
changeZoom(thisObject.zoomLevel + ANIMATION_INCREMENT, thisObject.zoomLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (offsetIncrement.x !== 0) {
|
if (offsetIncrement.x !== 0) {
|
||||||
@@ -105,344 +100,290 @@ function newViewPort() {
|
|||||||
offsetIncrement.x = 0;
|
offsetIncrement.x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (offsetIncrement.y !== 0) {
|
if (offsetIncrement.y !== 0) {
|
||||||
|
if (Math.trunc(Math.abs(targetOffset.y - offset.y) * 1000) >= Math.trunc(Math.abs(offsetIncrement.y) * 1000)) {
|
||||||
|
offset.y = offset.y + offsetIncrement.y
|
||||||
|
|
||||||
if (Math.trunc(Math.abs(targetOffset.y - offset.y) * 1000) >= Math.trunc(Math.abs(offsetIncrement.y) * 1000)) {
|
// console.log("offset.y changed to " + offset.y)
|
||||||
offset.y = offset.y + offsetIncrement.y;
|
} else {
|
||||||
|
offsetIncrement.y = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//console.log("offset.y changed to " + offset.y)
|
function displace (displaceVector) {
|
||||||
|
offset.x = offset.x + displaceVector.x
|
||||||
|
offset.y = offset.y + displaceVector.y
|
||||||
|
|
||||||
} else {
|
let event = {
|
||||||
offsetIncrement.y = 0;
|
newOffset: offset
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Offset Changed', event)
|
||||||
}
|
|
||||||
|
|
||||||
function displace(displaceVector) {
|
// console.log("displace produced new Offset x = " + offset.x + " y = " + offset.y);
|
||||||
|
}
|
||||||
|
|
||||||
offset.x = offset.x + displaceVector.x;
|
function displaceTarget (displaceVector) {
|
||||||
offset.y = offset.y + displaceVector.y;
|
targetOffset.x = targetOffset.x + displaceVector.x
|
||||||
|
targetOffset.y = targetOffset.y + displaceVector.y
|
||||||
|
|
||||||
let event = {
|
offsetIncrement = {
|
||||||
newOffset: offset
|
x: (targetOffset.x - offset.x) / 10,
|
||||||
};
|
y: (targetOffset.y - offset.y) / 10
|
||||||
|
}
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent("Offset Changed", event);
|
// console.log("displaceTarget x = " + targetOffset.x + " y = " + targetOffset.y);
|
||||||
|
}
|
||||||
|
|
||||||
//console.log("displace produced new Offset x = " + offset.x + " y = " + offset.y);
|
function newZoomLevel (level) {
|
||||||
|
thisObject.zoomTargetLevel = level
|
||||||
|
thisObject.zoomLevel = level
|
||||||
|
|
||||||
}
|
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3
|
||||||
|
|
||||||
function displaceTarget(displaceVector) {
|
let event = {
|
||||||
|
newLevel: thisObject.zoomTargetLevel,
|
||||||
|
newOffset: offset,
|
||||||
|
type: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Zoom Changed', event)
|
||||||
|
|
||||||
targetOffset.x = targetOffset.x + displaceVector.x;
|
return true
|
||||||
targetOffset.y = targetOffset.y + displaceVector.y;
|
}
|
||||||
|
|
||||||
|
function isMinZoom () {
|
||||||
offsetIncrement = {
|
|
||||||
x: (targetOffset.x - offset.x) / 10,
|
|
||||||
y: (targetOffset.y - offset.y) / 10
|
|
||||||
};
|
|
||||||
|
|
||||||
//console.log("displaceTarget x = " + targetOffset.x + " y = " + targetOffset.y);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function newZoomLevel(level) {
|
|
||||||
|
|
||||||
thisObject.zoomTargetLevel = level;
|
|
||||||
thisObject.zoomLevel = level;
|
|
||||||
|
|
||||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3;
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
newLevel: thisObject.zoomTargetLevel,
|
|
||||||
newOffset: offset,
|
|
||||||
type: undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent("Zoom Changed", event);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isMinZoom() {
|
|
||||||
/* returns true is we are currently at the min zoom level. */
|
/* returns true is we are currently at the min zoom level. */
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel === MIN_ZOOM_LEVEL) { return true; } else { return false;}
|
if (thisObject.zoomTargetLevel === MIN_ZOOM_LEVEL) { return true } else { return false }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function applyZoom (amount) {
|
||||||
|
// console.log("applyZoom amount: " + amount);
|
||||||
|
|
||||||
function applyZoom(amount) {
|
if (amount > 0) {
|
||||||
|
if (thisObject.zoomTargetLevel > -5) {
|
||||||
|
amount = amount * 2
|
||||||
|
}
|
||||||
|
|
||||||
//console.log("applyZoom amount: " + amount);
|
if (thisObject.zoomTargetLevel > 10) {
|
||||||
|
amount = amount * 3
|
||||||
if (amount > 0) {
|
}
|
||||||
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel > -5) {
|
|
||||||
amount = amount * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel > 10) {
|
|
||||||
amount = amount * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel > 15) {
|
|
||||||
amount = amount * 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amount < 0) {
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel > -4) {
|
|
||||||
amount = amount * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel > 13) {
|
|
||||||
amount = amount * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel > 19) {
|
|
||||||
amount = amount * 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel + amount > 1000) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel <= -27 && amount < 0) {
|
|
||||||
amount = amount / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel < -27 && amount > 0) {
|
|
||||||
amount = amount / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thisObject.zoomTargetLevel + amount < MIN_ZOOM_LEVEL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount;
|
|
||||||
|
|
||||||
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3;
|
|
||||||
|
|
||||||
let event = {
|
|
||||||
newLevel: thisObject.zoomTargetLevel,
|
|
||||||
newOffset: offset,
|
|
||||||
type: undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
if (amount > 0) {
|
|
||||||
event.type = "Zoom In";
|
|
||||||
} else {
|
|
||||||
event.type = "Zoom Out";
|
|
||||||
}
|
|
||||||
|
|
||||||
thisObject.eventHandler.raiseEvent("Zoom Changed", event);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function changeZoom(oldLevel, newLevel) {
|
|
||||||
|
|
||||||
let mouseNoZoom = unzoomThisPoint(thisObject.mousePosition, oldLevel);
|
|
||||||
let newMouse = zoomThisPoint(mouseNoZoom, newLevel);
|
|
||||||
|
|
||||||
offset.x = offset.x - newMouse.x + thisObject.mousePosition.x;
|
|
||||||
offset.y = offset.y - newMouse.y + thisObject.mousePosition.y;
|
|
||||||
|
|
||||||
targetOffset.x = offset.x
|
|
||||||
targetOffset.y = offset.y ;
|
|
||||||
|
|
||||||
offsetIncrement = {
|
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
|
if (thisObject.zoomTargetLevel > 15) {
|
||||||
|
amount = amount * 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (amount < 0) {
|
||||||
|
if (thisObject.zoomTargetLevel > -4) {
|
||||||
|
amount = amount * 2
|
||||||
|
}
|
||||||
|
|
||||||
function zoomFontSize(baseSize, level) {
|
if (thisObject.zoomTargetLevel > 13) {
|
||||||
|
amount = amount * 3
|
||||||
|
}
|
||||||
|
|
||||||
let zoomFactor = increment; // + increment * thisObject.zoomLevel / 100;
|
if (thisObject.zoomTargetLevel > 19) {
|
||||||
|
amount = amount * 4
|
||||||
if (level === undefined) {
|
}
|
||||||
|
|
||||||
baseSize = baseSize * (1 + zoomFactor * thisObject.zoomLevel);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
baseSize = baseSize * (1 + zoomFactor * level);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fitIntoVisibleArea(point) {
|
if (thisObject.zoomTargetLevel + amount > 1000) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisObject.zoomTargetLevel <= -27 && amount < 0) {
|
||||||
|
amount = amount / 4
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisObject.zoomTargetLevel < -27 && amount > 0) {
|
||||||
|
amount = amount / 4
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thisObject.zoomTargetLevel + amount < MIN_ZOOM_LEVEL) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.zoomTargetLevel = thisObject.zoomTargetLevel + amount
|
||||||
|
|
||||||
|
ANIMATION_INCREMENT = Math.abs(thisObject.zoomTargetLevel - thisObject.zoomLevel) / 3
|
||||||
|
|
||||||
|
let event = {
|
||||||
|
newLevel: thisObject.zoomTargetLevel,
|
||||||
|
newOffset: offset,
|
||||||
|
type: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount > 0) {
|
||||||
|
event.type = 'Zoom In'
|
||||||
|
} else {
|
||||||
|
event.type = 'Zoom Out'
|
||||||
|
}
|
||||||
|
|
||||||
|
thisObject.eventHandler.raiseEvent('Zoom Changed', event)
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeZoom (oldLevel, newLevel) {
|
||||||
|
let mouseNoZoom = unzoomThisPoint(thisObject.mousePosition, oldLevel)
|
||||||
|
let newMouse = zoomThisPoint(mouseNoZoom, newLevel)
|
||||||
|
|
||||||
|
offset.x = offset.x - newMouse.x + thisObject.mousePosition.x
|
||||||
|
offset.y = offset.y - newMouse.y + thisObject.mousePosition.y
|
||||||
|
|
||||||
|
targetOffset.x = offset.x
|
||||||
|
targetOffset.y = offset.y
|
||||||
|
|
||||||
|
offsetIncrement = {
|
||||||
|
x: 0,
|
||||||
|
y: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function zoomFontSize (baseSize, level) {
|
||||||
|
let zoomFactor = increment // + increment * thisObject.zoomLevel / 100;
|
||||||
|
|
||||||
|
if (level === undefined) {
|
||||||
|
baseSize = baseSize * (1 + zoomFactor * thisObject.zoomLevel)
|
||||||
|
} else {
|
||||||
|
baseSize = baseSize * (1 + zoomFactor * level)
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseSize
|
||||||
|
}
|
||||||
|
|
||||||
|
function fitIntoVisibleArea (point) {
|
||||||
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
|
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
|
||||||
|
|
||||||
if (point.x > thisObject.visibleArea.bottomRight.x + 1) {
|
if (point.x > thisObject.visibleArea.bottomRight.x + 1) {
|
||||||
point.x = thisObject.visibleArea.bottomRight.x + 1;
|
point.x = thisObject.visibleArea.bottomRight.x + 1
|
||||||
}
|
|
||||||
|
|
||||||
if (point.x < thisObject.visibleArea.topLeft.x - 1) {
|
|
||||||
point.x = thisObject.visibleArea.topLeft.x - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.y > thisObject.visibleArea.bottomRight.y + 1) {
|
|
||||||
point.y = thisObject.visibleArea.bottomRight.y + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.y < thisObject.visibleArea.topLeft.y - 1) {
|
|
||||||
point.y = thisObject.visibleArea.topLeft.y - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (point.x < thisObject.visibleArea.topLeft.x - 1) {
|
||||||
function zoomThisPoint(point, level) {
|
point.x = thisObject.visibleArea.topLeft.x - 1
|
||||||
|
|
||||||
let zoomFactor = increment; // + increment * thisObject.zoomLevel / 100;
|
|
||||||
|
|
||||||
if (level === undefined) {
|
|
||||||
|
|
||||||
point.x = point.x * (1 + zoomFactor * thisObject.zoomLevel) + offset.x;
|
|
||||||
point.y = point.y * (1 + zoomFactor * thisObject.zoomLevel) + offset.y;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
point.x = point.x * (1 + zoomFactor * level) + offset.x;
|
|
||||||
point.y = point.y * (1 + zoomFactor * level) + offset.y;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function unzoomThisPoint(pointWithZoom, level) {
|
if (point.y > thisObject.visibleArea.bottomRight.y + 1) {
|
||||||
|
point.y = thisObject.visibleArea.bottomRight.y + 1
|
||||||
let pointWithoutZoom;
|
|
||||||
let zoomFactor = increment; // + increment * thisObject.zoomLevel / 100;
|
|
||||||
|
|
||||||
if (level === undefined) {
|
|
||||||
|
|
||||||
pointWithoutZoom = {
|
|
||||||
x: (pointWithZoom.x - offset.x) / (1 + zoomFactor * thisObject.zoomLevel),
|
|
||||||
y: (pointWithZoom.y - offset.y) / (1 + zoomFactor * thisObject.zoomLevel)
|
|
||||||
};
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
pointWithoutZoom = {
|
|
||||||
x: (pointWithZoom.x - offset.x) / (1 + zoomFactor * level),
|
|
||||||
y: (pointWithZoom.y - offset.y) / (1 + zoomFactor * level)
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
return pointWithoutZoom;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (point.y < thisObject.visibleArea.topLeft.y - 1) {
|
||||||
|
point.y = thisObject.visibleArea.topLeft.y - 1
|
||||||
|
|
||||||
function isThisPointVisible(point) {
|
|
||||||
|
|
||||||
if (visibleArea === undefined) {
|
|
||||||
|
|
||||||
getVisibleArea();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (point.x < visibleArea.topLeft.x || point.x > visibleArea.bottomRight.x || point.y < visibleArea.topLeft.y || point.y > visibleArea.bottomRight.y) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
function draw() {
|
function zoomThisPoint (point, level) {
|
||||||
|
let zoomFactor = increment // + increment * thisObject.zoomLevel / 100;
|
||||||
|
|
||||||
|
if (level === undefined) {
|
||||||
|
point.x = point.x * (1 + zoomFactor * thisObject.zoomLevel) + offset.x
|
||||||
|
point.y = point.y * (1 + zoomFactor * thisObject.zoomLevel) + offset.y
|
||||||
|
} else {
|
||||||
|
point.x = point.x * (1 + zoomFactor * level) + offset.x
|
||||||
|
point.y = point.y * (1 + zoomFactor * level) + offset.y
|
||||||
|
}
|
||||||
|
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
|
||||||
|
function unzoomThisPoint (pointWithZoom, level) {
|
||||||
|
let pointWithoutZoom
|
||||||
|
let zoomFactor = increment // + increment * thisObject.zoomLevel / 100;
|
||||||
|
|
||||||
|
if (level === undefined) {
|
||||||
|
pointWithoutZoom = {
|
||||||
|
x: (pointWithZoom.x - offset.x) / (1 + zoomFactor * thisObject.zoomLevel),
|
||||||
|
y: (pointWithZoom.y - offset.y) / (1 + zoomFactor * thisObject.zoomLevel)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pointWithoutZoom = {
|
||||||
|
x: (pointWithZoom.x - offset.x) / (1 + zoomFactor * level),
|
||||||
|
y: (pointWithZoom.y - offset.y) / (1 + zoomFactor * level)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pointWithoutZoom
|
||||||
|
}
|
||||||
|
|
||||||
|
function isThisPointVisible (point) {
|
||||||
|
if (visibleArea === undefined) {
|
||||||
|
getVisibleArea()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (point.x < visibleArea.topLeft.x || point.x > visibleArea.bottomRight.x || point.y < visibleArea.topLeft.y || point.y > visibleArea.bottomRight.y) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw () {
|
||||||
/*
|
/*
|
||||||
drawGrid(10);
|
drawGrid(10);
|
||||||
drawGrid(1);
|
drawGrid(1);
|
||||||
drawGrid(0.1);
|
drawGrid(0.1);
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawGrid (step) {
|
||||||
|
let squareWidth = (thisObject.visibleArea.bottomRight.x - thisObject.visibleArea.bottomLeft.x) / step
|
||||||
|
squareWidth = squareWidth + squareWidth * increment * thisObject.zoomLevel
|
||||||
|
|
||||||
|
let startingX = offset.x - Math.trunc(offset.x / squareWidth) * squareWidth
|
||||||
|
let startingY = offset.y - Math.trunc(offset.y / squareWidth) * squareWidth
|
||||||
|
let lineWidth = 10 / step + 10 / step * increment * thisObject.zoomLevel
|
||||||
|
|
||||||
|
if (lineWidth < 0.5) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawGrid(step) {
|
if (lineWidth > 2) {
|
||||||
|
lineWidth = 2
|
||||||
let squareWidth = (thisObject.visibleArea.bottomRight.x - thisObject.visibleArea.bottomLeft.x) / step;
|
|
||||||
squareWidth = squareWidth + squareWidth * increment * thisObject.zoomLevel;
|
|
||||||
|
|
||||||
let startingX = offset.x - Math.trunc(offset.x / squareWidth) * squareWidth;
|
|
||||||
let startingY = offset.y - Math.trunc(offset.y / squareWidth) * squareWidth;
|
|
||||||
let lineWidth = 10 / step + 10 / step * increment * thisObject.zoomLevel;
|
|
||||||
|
|
||||||
if (lineWidth < 0.5) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lineWidth > 2) {
|
|
||||||
lineWidth = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
browserCanvasContext.beginPath();
|
|
||||||
|
|
||||||
for (var i = startingX; i < thisObject.visibleArea.bottomRight.x; i = i + squareWidth) {
|
|
||||||
|
|
||||||
for (var j = startingY; j < thisObject.visibleArea.bottomRight.y; j = j + squareWidth) {
|
|
||||||
|
|
||||||
let point1 = {
|
|
||||||
x: thisObject.visibleArea.bottomLeft.x,
|
|
||||||
y: j
|
|
||||||
};
|
|
||||||
|
|
||||||
let point2 = {
|
|
||||||
x: thisObject.visibleArea.bottomRight.x,
|
|
||||||
y: j
|
|
||||||
};
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(point1.x, point1.y);
|
|
||||||
browserCanvasContext.lineTo(point2.x, point2.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
let point3 = {
|
|
||||||
x: i,
|
|
||||||
y: thisObject.visibleArea.topLeft.y
|
|
||||||
};
|
|
||||||
|
|
||||||
let point4 = {
|
|
||||||
x: i,
|
|
||||||
y: thisObject.visibleArea.bottomLeft.y
|
|
||||||
};
|
|
||||||
|
|
||||||
browserCanvasContext.moveTo(point3.x, point3.y);
|
|
||||||
browserCanvasContext.lineTo(point4.x, point4.y);
|
|
||||||
}
|
|
||||||
browserCanvasContext.closePath();
|
|
||||||
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 0.' + Math.trunc(lineWidth + 1) + ')';
|
|
||||||
|
|
||||||
browserCanvasContext.lineWidth = lineWidth;
|
|
||||||
|
|
||||||
browserCanvasContext.stroke();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
browserCanvasContext.beginPath()
|
||||||
|
|
||||||
|
for (var i = startingX; i < thisObject.visibleArea.bottomRight.x; i = i + squareWidth) {
|
||||||
|
for (var j = startingY; j < thisObject.visibleArea.bottomRight.y; j = j + squareWidth) {
|
||||||
|
let point1 = {
|
||||||
|
x: thisObject.visibleArea.bottomLeft.x,
|
||||||
|
y: j
|
||||||
|
}
|
||||||
|
|
||||||
|
let point2 = {
|
||||||
|
x: thisObject.visibleArea.bottomRight.x,
|
||||||
|
y: j
|
||||||
|
}
|
||||||
|
|
||||||
|
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||||
|
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||||
|
}
|
||||||
|
|
||||||
|
let point3 = {
|
||||||
|
x: i,
|
||||||
|
y: thisObject.visibleArea.topLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
|
let point4 = {
|
||||||
|
x: i,
|
||||||
|
y: thisObject.visibleArea.bottomLeft.y
|
||||||
|
}
|
||||||
|
|
||||||
|
browserCanvasContext.moveTo(point3.x, point3.y)
|
||||||
|
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||||
|
}
|
||||||
|
browserCanvasContext.closePath()
|
||||||
|
browserCanvasContext.strokeStyle = 'rgba(150, 150, 150, 0.' + Math.trunc(lineWidth + 1) + ')'
|
||||||
|
|
||||||
|
browserCanvasContext.lineWidth = lineWidth
|
||||||
|
|
||||||
|
browserCanvasContext.stroke()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+9
-11
@@ -1,12 +1,10 @@
|
|||||||
function newVolumeBar() {
|
function newVolumeBar () {
|
||||||
|
var volumeBar = {
|
||||||
|
amountBuy: 0,
|
||||||
|
amountSell: 0,
|
||||||
|
begin: undefined,
|
||||||
|
end: undefined
|
||||||
|
}
|
||||||
|
|
||||||
var volumeBar = {
|
return volumeBar
|
||||||
amountBuy: 0,
|
}
|
||||||
amountSell: 0,
|
|
||||||
begin: undefined,
|
|
||||||
end: undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
return volumeBar;
|
|
||||||
|
|
||||||
}
|
|
||||||
+16
-18
@@ -1,20 +1,18 @@
|
|||||||
|
|
||||||
function newWebDebugLog() {
|
function newWebDebugLog () {
|
||||||
|
let thisObject = {
|
||||||
|
write: write,
|
||||||
|
fileName: undefined
|
||||||
|
}
|
||||||
|
|
||||||
let thisObject = {
|
return thisObject
|
||||||
write: write,
|
|
||||||
fileName: undefined
|
function write (pText) {
|
||||||
|
console.log(spacePad(thisObject.fileName, 50) + ' : ' + pText)
|
||||||
|
|
||||||
|
function spacePad (str, max) {
|
||||||
|
str = str.toString()
|
||||||
|
return str.length < max ? spacePad(' ' + str, max) : str
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return thisObject;
|
}
|
||||||
|
|
||||||
function write(pText) {
|
|
||||||
|
|
||||||
console.log(spacePad(thisObject.fileName, 50) + " : " + pText);
|
|
||||||
|
|
||||||
function spacePad(str, max) {
|
|
||||||
str = str.toString();
|
|
||||||
return str.length < max ? spacePad(" " + str, max) : str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user