Autoformatter applied on all js files

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

No files matched your search

+127 -157
View File
@@ -1,240 +1,210 @@
function newProductsPanel() {
var thisObject = {
container: undefined,
getLoadingProductCards: getLoadingProductCards,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
};
function newProductsPanel () {
var thisObject = {
container: undefined,
getLoadingProductCards: getLoadingProductCards,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
}
/* Cointainer stuff */
var container = newContainer();
var container = newContainer()
container.name = "Indicators and Algobots Product Panel";
container.initialize();
container.name = 'Indicators and Algobots Product Panel'
container.initialize()
container.isDraggeable = true;
container.isWheelable = true;
container.isDraggeable = true
container.isWheelable = true
thisObject.container = container;
thisObject.container.frame.containerName = "Indicators and Algobots's Products";
thisObject.container = container
thisObject.container.frame.containerName = "Indicators and Algobots's Products"
let isInitialized = false;
let productCards = [];
let isInitialized = false
let productCards = []
let visibleProductCards = [];
let firstVisibleCard = 1;
let visibleProductCards = []
let firstVisibleCard = 1
/* 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;
thisObject.container.frame.height = viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y; //UI_PANEL.HEIGHT.LARGE;
var position = {
x: viewPort.visibleArea.topLeft.x,
y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height
}
var position = {
x: viewPort.visibleArea.topLeft.x,
y: viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height
};
thisObject.container.frame.position = position;
thisObject.container.frame.position = position
/* 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++) {
let bot = devTeam.bots[j];
if (bot.products !== undefined) {
for (let k = 0; k < bot.products.length; k++) {
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 */
let productCard = newProductCard();
let productCard = newProductCard()
productCard.devTeam = devTeam;
productCard.bot = bot;
productCard.product = product;
productCard.devTeam = devTeam
productCard.bot = bot
productCard.product = product
productCard.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName;
productCard.code = devTeam.codeName + '-' + bot.codeName + '-' + product.codeName
/* Initialize it */
productCard.initialize();
productCard.initialize()
/* Container Stuff */
productCard.container.displacement.parentDisplacement = thisObject.container.displacement;
productCard.container.frame.parentFrame = thisObject.container.frame;
productCard.container.parentContainer = thisObject.container;
productCard.container.isWheelable = true;
productCard.container.displacement.parentDisplacement = thisObject.container.displacement
productCard.container.frame.parentFrame = thisObject.container.frame
productCard.container.parentContainer = thisObject.container
productCard.container.isWheelable = true
/* Positioning within thisObject Panel */
let position = {
x: 10,
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
};
let position = {
x: 10,
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
}
productCard.container.frame.position.x = position.x;
productCard.container.frame.position.y = position.y + lastY;
productCard.container.frame.position.x = position.x
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 */
productCards.push(productCard);
productCards.push(productCard)
/* Add to Visible Product Array */
if (productCard.container.frame.position.y + productCard.container.frame.height < thisObject.container.frame.height) {
visibleProductCards.push(productCard);
}
if (productCard.container.frame.position.y + productCard.container.frame.height < thisObject.container.frame.height) {
visibleProductCards.push(productCard)
}
/* Listen to Status Changes Events */
productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged);
productCard.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel);
productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged)
productCard.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
}
}
}
}
}
}
}
}
thisObject.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel)
isInitialized = true
}
thisObject.container.eventHandler.listenToEvent("Mouse Wheel", onMouseWheel);
isInitialized = true;
function onMouseWheel (pDelta) {
if (pDelta > 0) {
pDelta = -1
} else {
pDelta = 1
}
}
firstVisibleCard = firstVisibleCard + pDelta
function onMouseWheel(pDelta) {
let availableSlots = visibleProductCards.length
if (pDelta > 0) {
pDelta = -1;
} else {
pDelta = 1;
}
if (firstVisibleCard < 1) { firstVisibleCard = 1 }
if (firstVisibleCard > (productCards.length - availableSlots + 1)) { firstVisibleCard = productCards.length - availableSlots + 1 }
firstVisibleCard = firstVisibleCard + pDelta;
visibleProductCards = []
var lastY = 5
let availableSlots = visibleProductCards.length;
if (firstVisibleCard < 1) { firstVisibleCard = 1; }
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];
for (let i = 0; i < productCards.length; i++) {
if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) {
let productCard = productCards[i]
/* Positioning within thisObject Panel */
let position = {
x: 10,
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
};
productCard.container.frame.position.x = position.x;
productCard.container.frame.position.y = position.y + lastY;
let position = {
x: 10,
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
}
productCard.container.frame.position.x = position.x
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 */
visibleProductCards.push(productCard);
}
}
}
visibleProductCards.push(productCard)
}
}
}
function onProductCardStatusChanged(pProductCard) {
thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard);
}
function getLoadingProductCards() {
function onProductCardStatusChanged (pProductCard) {
thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard)
}
function getLoadingProductCards () {
/* 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]);
}
}
return onProducts;
}
function getContainer(point) {
var container;
function getContainer (point) {
var container
/* 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 */
for (var i = 0; i < visibleProductCards.length; i++) {
container = visibleProductCards[i].getContainer(point)
for (var i = 0; i < visibleProductCards.length; i++) {
container = visibleProductCards[i].getContainer(point);
if (container !== undefined) {
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 thisObject.container;
} else {
return thisObject.container
} else {
/* 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() {
if (isInitialized === false) {return;}
thisObject.container.frame.draw(false, false, true);
for (let i = 0; i < visibleProductCards.length; i++) {
visibleProductCards[i].draw();
}
}
}
for (let i = 0; i < visibleProductCards.length; i++) {
visibleProductCards[i].draw()
}
}
}
+112 -130
View File
@@ -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 = {
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 container = newContainer()
container.initialize()
container.isDraggeable = true
thisObject.container = container
thisObject.container.frame.containerName = 'Current Datetime'
let container = newContainer();
container.initialize();
container.isDraggeable = true;
thisObject.container = container;
thisObject.container.frame.containerName = "Current Datetime";
let timePeriod
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.height = UI_PANEL.HEIGHT.SMALL;
thisObject.container.frame.position = position
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
};
let buttonPosition
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 lastX = 0;
let datetimeDisplay = {
currentDatetime: datetime,
addTime: addTime,
draw: drawTimeDisplay
}
let datetime = INITIAL_DATE;
let datetimeDisplay = {
currentDatetime: datetime,
addTime: addTime,
draw: drawTimeDisplay
};
thisObject.datetimeDisplay = datetimeDisplay;
thisObject.datetimeDisplay = datetimeDisplay
/* 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.setDatetime(datetime);
canvas.bottomSpace.playStopButton.container.eventHandler.listenToEvent('Bot Execution Changed Datetime', onBotChangedTime)
canvas.bottomSpace.playStopButton.setDatetime(datetime)
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
timePeriod = INITIAL_TIME_PERIOD;
}
viewPort.eventHandler.listenToEvent('Zoom Changed', onZoomChanged)
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 onZoomChanged(event) {
timePeriod = recalculatePeriod(event.newLevel);
}
function getContainer(point) {
let container;
function getContainer (point) {
let container
/* 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. */
return thisObject.container;
} else {
return thisObject.container
} else {
/* 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);
canvas.bottomSpace.playStopButton.setDatetime(pDatetime);
}
function addTime (seconds) {
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.currentDatetime = newDate;
thisObject.datetimeDisplay.draw()
}
}
function drawTimeDisplay () {
let fontSize = 10
function draw() {
let label = thisObject.datetimeDisplay.currentDatetime.toUTCString()
let labelArray = label.split(' ')
thisObject.container.frame.draw(false, false, true);
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];
label = labelArray[0] + ' ' + labelArray[1] + ' ' + labelArray[2] + ' ' + labelArray[3]
/* Now we transform x on the actual coordinate on the canvas. */
let labelPoint = {
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
y: thisObject.container.frame.height * 4.4 / 10
};
let labelPoint = {
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
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.fillStyle = 'rgba(60, 60, 60, 0.50)';
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y);
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.SECONDARY
browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)'
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
/* The time */
label = labelArray[4] + " " + labelArray[5];
label = labelArray[4] + ' ' + labelArray[5]
/* 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 * 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 = {
x: thisObject.container.frame.width / 2 - label.length / 2 * fontSize * FONT_ASPECT_RATIO,
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)
}
}