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

+177 -230
View File
@@ -1,86 +1,75 @@
function newDeleteTradingHistory() {

function newDeleteTradingHistory () {
const MODULE_NAME = 'Delete Trading History'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
const MODULE_NAME = "Delete Trading History";
const INFO_LOG = false;
const ERROR_LOG = true;
const logger = newWebDebugLog();
logger.fileName = MODULE_NAME;
var thisObject = {
container: undefined,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
}
var thisObject = {
container: undefined,
draw: draw,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
};
var container = newContainer()
container.initialize()
thisObject.container = container
var container = newContainer();
container.initialize();
thisObject.container = container;
thisObject.container.frame.width = 50
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT
thisObject.container.frame.width = 50;
thisObject.container.frame.height = BOTTOM_SPACE_HEIGHT;
resize()
resize();
container.isDraggeable = false
container.isClickeable = true
container.isDraggeable = false;
container.isClickeable = true;
let icon
let canDrawIcon = false
let icon;
let canDrawIcon = false;
return thisObject
return thisObject;
function initialize (callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
function initialize(callBackFunction) {
icon = new Image()
try {
icon.onload = onImageLoad
if (INFO_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
function onImageLoad () {
canDrawIcon = true
}
icon = new Image();
icon.src = window.canvasApp.urlPrefix + 'Images/Icons/trash.png'
icon.onload = onImageLoad;
thisObject.container.eventHandler.listenToEvent('onMouseClick', onClick)
function onImageLoad() {
canDrawIcon = true;
}
icon.src = window.canvasApp.urlPrefix + "Images/Icons/trash.png";
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
window.canvasApp.eventHandler.listenToEvent("Browser Resized", resize);
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); }
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err.message = " + err.message); }
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); }
}
window.canvasApp.eventHandler.listenToEvent('Browser Resized', resize)
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err.message = ' + err.message) }
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) }
}
}
function resize() {
function resize () {
container.frame.position.x = viewPort.visibleArea.topRight.x
container.frame.position.y = viewPort.visibleArea.bottomLeft.y
}
container.frame.position.x = viewPort.visibleArea.topRight.x;
container.frame.position.y = viewPort.visibleArea.bottomLeft.y;
function onClick () {
try {
if (INFO_LOG === true) { logger.write('[INFO] onClick -> Entering function.') }
}
let sessionToken = window.localStorage.getItem('sessionToken')
function onClick() {
try {
if (INFO_LOG === true) { logger.write("[INFO] onClick -> Entering function."); }
let sessionToken = window.localStorage.getItem('sessionToken');
if (sessionToken === null || sessionToken === "") {
if (sessionToken === null || sessionToken === '') {
/* not logged in */
return;
}
return
}
/*
@@ -94,243 +83,201 @@ function newDeleteTradingHistory() {
6. Delete every execution context file found.
7. Delete the execution history file after finishing the interation.
8. Delete the Sequence file belonging to the received Start Mode.
9. Save the Status Report without the records of this Start Mode.
9. Save the Status Report without the records of this Start Mode.
*/
let storage = AzureStorage.Blob;
let storage = AzureStorage.Blob
let readOnlyBlobService;
let writeOnlyBlobService;
let deleteOnlyBlobService;
let readOnlyBlobService
let writeOnlyBlobService
let deleteOnlyBlobService
let readConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + "." + "READ");
let readConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'READ')
if (readConnectionString !== undefined) {
readOnlyBlobService = storage.createBlobService(readConnectionString);
}
if (readConnectionString !== undefined) {
readOnlyBlobService = storage.createBlobService(readConnectionString)
}
let writeConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + "." + "WRITE");
let writeConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'WRITE')
if (writeConnectionString !== undefined) {
writeOnlyBlobService = storage.createBlobService(writeConnectionString);
}
if (writeConnectionString !== undefined) {
writeOnlyBlobService = storage.createBlobService(writeConnectionString)
}
let deleteConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + "." + "DELETE");
let deleteConnectionString = window.USER_PROFILE.storagePermissions.get(window.DEV_TEAM + '.' + 'DELETE')
if (deleteConnectionString !== undefined) {
deleteOnlyBlobService = storage.createBlobService(deleteConnectionString);
}
if (deleteConnectionString !== undefined) {
deleteOnlyBlobService = storage.createBlobService(deleteConnectionString)
}
let containerName = window.DEV_TEAM.toLowerCase();
let containerName = window.DEV_TEAM.toLowerCase()
let statusReportFilePath = window.DEV_TEAM + "/" + window.CURRENT_BOT_CODE_NAME + ".1.0" + "/" + "AACloud.1.1" + "/" + "Poloniex" + "/" + "dataSet.V1" + "/" + "Reports" + "/" + "Trading-Process";
let statusReportFileName = window.CURRENT_START_MODE + "." + "Status.Report.USDT_BTC.json";
let statusReportFilePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Reports' + '/' + 'Trading-Process'
let statusReportFileName = window.CURRENT_START_MODE + '.' + 'Status.Report.USDT_BTC.json'
readOnlyBlobService.getBlobToText(containerName, statusReportFilePath + "/" + statusReportFileName, onStatusReport);
readOnlyBlobService.getBlobToText(containerName, statusReportFilePath + '/' + statusReportFileName, onStatusReport)
function onStatusReport(err, text, response) {
function onStatusReport (err, text, response) {
try {
if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> Entering function.') }
try {
if (err && err.code === 'BlobNotFound') {
console.log(statusReportFilePath + '/' + statusReportFileName + ' not found. No history detected for this start mode.')
return
}
if (INFO_LOG === true) { logger.write("[INFO] onClick -> onStatusReport -> Entering function."); }
let statusReport = JSON.parse(text)
if (err && err.code === 'BlobNotFound') {
console.log(statusReportFilePath + "/" + statusReportFileName + " not found. No history detected for this start mode.");
return;
}
let statusReport = JSON.parse(text);
let toBeDeleted = 0;
let deleted = 0;
for (let i = 0; i < statusReport.runs.length; i++) {
let toBeDeleted = 0
let deleted = 0
for (let i = 0; i < statusReport.runs.length; i++) {
/* For each record, we will get the execution history file. */
let filePath = window.DEV_TEAM + "/" + window.CURRENT_BOT_CODE_NAME + ".1.0" + "/" + "AACloud.1.1" + "/" + "Poloniex" + "/" + "dataSet.V1" + "/" + "Output" + "/" + "Trading-Process";
let fileName = "Execution.History." + window.CURRENT_START_MODE + "." + i + ".json";
let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process'
let fileName = 'Execution.History.' + window.CURRENT_START_MODE + '.' + i + '.json'
readOnlyBlobService.getBlobToText(containerName, filePath + "/" + fileName, onExecutionHistory);
readOnlyBlobService.getBlobToText(containerName, filePath + '/' + fileName, onExecutionHistory)
function onExecutionHistory(err, text, response) {
function onExecutionHistory (err, text, response) {
let executionHistory = JSON.parse(text)
let executionHistory = JSON.parse(text);
for (let j = 0; j < executionHistory.length; j++) {
let dateTime = new Date(executionHistory[j][0])
for (let j = 0; j < executionHistory.length; j++) {
let datePath = dateTime.getUTCFullYear() + '/' + pad(dateTime.getUTCMonth() + 1, 2) + '/' + pad(dateTime.getUTCDate(), 2) + '/' + pad(dateTime.getUTCHours(), 2) + '/' + pad(dateTime.getUTCMinutes(), 2)
let dateTime = new Date(executionHistory[j][0]);
let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process' + '/' + datePath
let fileName = 'Execution.Context.' + window.CURRENT_START_MODE + '.' + i + '.json'
let datePath = dateTime.getUTCFullYear() + "/" + pad(dateTime.getUTCMonth() + 1, 2) + "/" + pad(dateTime.getUTCDate(), 2) + "/" + pad(dateTime.getUTCHours(), 2) + "/" + pad(dateTime.getUTCMinutes(), 2);
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted)
let filePath = window.DEV_TEAM + "/" + window.CURRENT_BOT_CODE_NAME + ".1.0" + "/" + "AACloud.1.1" + "/" + "Poloniex" + "/" + "dataSet.V1" + "/" + "Output" + "/" + "Trading-Process" + "/" + datePath;
let fileName = "Execution.Context." + window.CURRENT_START_MODE + "." + i + ".json";
toBeDeleted++
deleteOnlyBlobService.deleteBlob(containerName, filePath + "/" + fileName, onDeleted);
function onDeleted (err, text, response) {
if (err) {
toBeDeleted++;
console.log(filePath + '/' + fileName + ' NOT deleted.')
console.log('err.message = ' + err.message)
} else {
function onDeleted(err, text, response) {
console.log(filePath + '/' + fileName + ' deleted.')
}
if (err) {
deleted++
console.log(filePath + "/" + fileName + " NOT deleted.");
console.log("err.message = " + err.message);
} else {
if (toBeDeleted === deleted) {
console.log(filePath + "/" + fileName + " deleted.");
}
deleted++;
if (toBeDeleted === deleted) {
updateStatusReport();
}
}
}
updateStatusReport()
}
}
}
/* Now we delete the execution history file. */
deleteOnlyBlobService.deleteBlob(containerName, filePath + "/" + fileName, onExecutionHistoryDeleted);
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onExecutionHistoryDeleted)
function onExecutionHistoryDeleted(err, text, response) {
function onExecutionHistoryDeleted (err, text, response) {
console.log(filePath + '/' + fileName + ' deleted.')
}
}
}
console.log(filePath + "/" + fileName + " deleted.");
function updateStatusReport () {
try {
if (INFO_LOG === true) { logger.write('[INFO] onClick -> onStatusReport -> updateStatusReport -> Entering function.') }
}
}
}
function updateStatusReport() {
try {
if (INFO_LOG === true) { logger.write("[INFO] onClick -> onStatusReport -> updateStatusReport -> Entering function."); }
statusReport.runs = [];
statusReport.runs = []
/* Here is where we update the current Status Report file with the new version without records for the current Start Mode. */
let fileContent = JSON.stringify(statusReport);
let fileContent = JSON.stringify(statusReport)
writeOnlyBlobService.createBlockBlobFromText(containerName, statusReportFilePath + "/" + statusReportFileName, fileContent, onStatusReportUpdated);
writeOnlyBlobService.createBlockBlobFromText(containerName, statusReportFilePath + '/' + statusReportFileName, fileContent, onStatusReportUpdated)
function onStatusReportUpdated(err, text, response) {
console.log(statusReportFilePath + "/" + statusReportFileName + " updated.");
}
function onStatusReportUpdated (err, text, response) {
console.log(statusReportFilePath + '/' + statusReportFileName + ' updated.')
}
/* Finally we delete the sequence file. */
let filePath = window.DEV_TEAM + "/" + window.CURRENT_BOT_CODE_NAME + ".1.0" + "/" + "AACloud.1.1" + "/" + "Poloniex" + "/" + "dataSet.V1" + "/" + "Output" + "/" + "Trading-Process";
let fileName = "Execution.History." + window.CURRENT_START_MODE + "." + "Sequence" + ".json";
let filePath = window.DEV_TEAM + '/' + window.CURRENT_BOT_CODE_NAME + '.1.0' + '/' + 'AACloud.1.1' + '/' + 'Poloniex' + '/' + 'dataSet.V1' + '/' + 'Output' + '/' + 'Trading-Process'
let fileName = 'Execution.History.' + window.CURRENT_START_MODE + '.' + 'Sequence' + '.json'
deleteOnlyBlobService.deleteBlob(containerName, filePath + "/" + fileName, onDeleted);
deleteOnlyBlobService.deleteBlob(containerName, filePath + '/' + fileName, onDeleted)
function onDeleted(err, text, response) {
console.log(filePath + "/" + fileName + " deleted.");
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onClick -> onStatusReport -> updateStatusReport -> err.message = " + err.message); }
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onClick -> onStatusReport -> err.message = " + err.message); }
}
function onDeleted (err, text, response) {
console.log(filePath + '/' + fileName + ' deleted.')
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> updateStatusReport -> err.message = ' + err.message) }
}
function pad(str, max) {
str = str.toString();
return str.length < max ? pad("0" + str, max) : str;
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] onClick -> err.message = " + err.message); }
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> onStatusReport -> err.message = ' + err.message) }
}
}
function pad (str, max) {
str = str.toString()
return str.length < max ? pad('0' + str, max) : str
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] onClick -> err.message = ' + err.message) }
}
}
function getContainer(point) {
function getContainer (point) {
try {
if (INFO_LOG === true) { logger.write('[INFO] getContainer -> Entering function.') }
try {
if (INFO_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
let container;
let container
/* First we check if this point is inside this object UI. */
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return this.container;
} else {
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
return this.container
} else {
/* This point does not belong to this space. */
return undefined;
}
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] getContainer -> err.message = " + err.message); }
}
return undefined
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err.message = ' + err.message) }
}
}
function draw() {
function draw () {
try {
if (INFO_LOG === true) { logger.write('[INFO] draw -> Entering function.') }
try {
let sessionToken = window.localStorage.getItem('sessionToken')
if (INFO_LOG === true) { logger.write("[INFO] draw -> Entering function."); }
let sessionToken = window.localStorage.getItem('sessionToken');
if (sessionToken === null || sessionToken === "") {
if (sessionToken === null || sessionToken === '') {
/* not logged in */
return;
}
return
}
thisObject.container.frame.draw(false, false);
thisObject.container.frame.draw(false, false)
if (canDrawIcon === false) { return; }
if (canDrawIcon === false) { return }
let breakpointsHeight = 14;
let breakpointsHeight = 14
let imageHeight = 15;
let imageWidth = 15;
let imageHeight = 15
let imageWidth = 15
let imagePoint = {
x: 10,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
};
let imagePoint = {
x: 10,
y: thisObject.container.frame.height / 2 - imageHeight / 2 + breakpointsHeight
}
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint);
imagePoint = thisObject.container.frame.frameThisPoint(imagePoint)
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight);
} catch (err) {
if (ERROR_LOG === true) { logger.write("[ERROR] draw -> err.message = " + err.message); }
}
browserCanvasContext.drawImage(icon, imagePoint.x, imagePoint.y, imageWidth, imageHeight)
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err.message = ' + err.message) }
}
}
}
}