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
+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
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
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";
|
||||
const INFO_LOG = false;
|
||||
const logger = newWebDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
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 = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
timeMachines: [],
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
};
|
||||
var container = newContainer()
|
||||
container.initialize()
|
||||
thisObject.container = container
|
||||
|
||||
thisObject.container.frame.width = CHART_SPACE_WIDTH
|
||||
thisObject.container.frame.height = CHART_SPACE_HEIGHT
|
||||
|
||||
var container = newContainer();
|
||||
container.initialize();
|
||||
thisObject.container = container;
|
||||
container.displacement.containerName = 'Chart Space'
|
||||
container.frame.containerName = 'Chart Space'
|
||||
|
||||
thisObject.container.frame.width = CHART_SPACE_WIDTH;
|
||||
thisObject.container.frame.height = CHART_SPACE_HEIGHT;
|
||||
container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2
|
||||
container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2
|
||||
|
||||
container.displacement.containerName = "Chart Space";
|
||||
container.frame.containerName = "Chart Space";
|
||||
container.isDraggeable = false
|
||||
|
||||
container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2;
|
||||
container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2;
|
||||
return thisObject
|
||||
|
||||
container.isDraggeable = false;
|
||||
function initialize (callBackFunction) {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
|
||||
let initializedCounter = 0;
|
||||
let toInitialize = 1;
|
||||
let initializedCounter = 0
|
||||
let toInitialize = 1
|
||||
|
||||
/* 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.frame.parentFrame = this.container.frame;
|
||||
timeMachine.container.displacement.parentDisplacement = this.container.displacement
|
||||
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. */
|
||||
|
||||
timeMachine.container.frame.width = this.container.frame.width * 1;
|
||||
timeMachine.container.frame.height = this.container.frame.height * 1;
|
||||
timeMachine.container.frame.width = this.container.frame.width * 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.y = this.container.frame.height / 2 - timeMachine.container.frame.height / 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.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);
|
||||
return;
|
||||
}
|
||||
|
||||
thisObject.timeMachines.push(timeMachine);
|
||||
|
||||
if (initializedCounter === toInitialize) {
|
||||
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE);
|
||||
|
||||
}
|
||||
}
|
||||
if (initializedCounter === toInitialize) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
|
||||
thisObject.container.frame.draw(false, false);
|
||||
function draw () {
|
||||
thisObject.container.frame.draw(false, false)
|
||||
|
||||
/* 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++ ) {
|
||||
|
||||
var timeMachine = thisObject.timeMachines[i];
|
||||
timeMachine.draw();
|
||||
|
||||
}
|
||||
|
||||
for (var i = 0; i < thisObject.timeMachines.length; i++) {
|
||||
var timeMachine = thisObject.timeMachines[i]
|
||||
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 */
|
||||
|
||||
for (var i = 0; i < this.timeMachines.length; i++) {
|
||||
|
||||
container = this.timeMachines[i].getContainer(point);
|
||||
|
||||
if (container !== undefined) {
|
||||
for (var i = 0; i < this.timeMachines.length; i++) {
|
||||
container = this.timeMachines[i].getContainer(point)
|
||||
|
||||
if (container !== undefined) {
|
||||
/* 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. */
|
||||
|
||||
return this.container;
|
||||
|
||||
}
|
||||
}
|
||||
return this.container
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user