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

+38 -50
View File
@@ -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 LOG_FILE_CONTENT = false;
const MODULE_NAME = 'Cloud Require'
const MODULE_NAME = "Cloud Require";
let thisObject = {
downloadBot: downloadBot,
downloadCommons: downloadCommons
}
let thisObject = {
downloadBot: downloadBot,
downloadCommons: downloadCommons
};
return thisObject
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);
return;
}
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] downloadBot -> err = " + err.message);
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);
}
}
};
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
View File
@@ -1,4 +1,4 @@

/*
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': {
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. ");
}
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. ')
}
}
}
function downloadModule(pPath, callBackFunction) {
function downloadModule (pPath, callBackFunction) {
/* 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;
callBackFunction(MODULE);
}
let MODULE = {}
MODULE.newUserBot = newUserBot
callBackFunction(MODULE)
}
}
+107 -130
View File
@@ -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";
const INFO_LOG = false;
const ERROR_LOG = true;
const logger = newWebDebugLog();
logger.fileName = MODULE_NAME;
var thisObject = {
onBotPlayPressed: onBotPlayPressed,
onBotStopPressed: onBotStopPressed
}
var thisObject = {
onBotPlayPressed: onBotPlayPressed,
onBotStopPressed: onBotStopPressed
};
let root = newRoot()
let intervalHandler
let previousBotCode = ''
let errorsCheckingForBotCodeChanges = 0
let root = newRoot();
let intervalHandler;
let previousBotCode = "";
let errorsCheckingForBotCodeChanges = 0;
return thisObject
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.SHALL_BOT_STOP = false;
errorsCheckingForBotCodeChanges = 0;
window.CURRENT_ENVIRONMENT = "Develop";
window.CURRENT_EXECUTION_AT = "Browser";
window.STORAGE_PERMISSIONS = ecosystem.getStoragePermissions();
window.EXCHANGE_NAME = "Poloniex";
window.MARKET = {
assetA: "USDT",
assetB: "BTC"
};
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
session token the user received when he logged in.
*/
window.EXCHANGE_KEYS = {
Poloniex: {
Key: "",
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); }
window.EXCHANGE_KEYS = {
Poloniex: {
Key: '',
Secret: ''
}
}
}
function onBotStopPressed() {
if (INFO_LOG === true) { logger.write("[INFO] onBotStopPressed -> Entering function."); }
window.SHALL_BOT_STOP = true;
errorsCheckingForBotCodeChanges = 0;
}
function checkForChangesInBotCode() {
root.initialize(pUI_COMMANDS, onInitialized)
function onInitialized () {
try {
if (INFO_LOG === true) { logger.write('[INFO] onBotPlayPressed -> Entering function.') }
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;
}
root.start()
intervalHandler = setInterval(checkForChangesInBotCode, 10000)
} 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);
}
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 () {
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
View File
@@ -1,71 +1,64 @@
function newWebFS() {
const MODULE_NAME = "Web FS";
const INFO_LOG = false;
const ERROR_LOG = true;
const logger = newWebDebugLog();
logger.fileName = MODULE_NAME;
function newWebFS () {
const MODULE_NAME = 'Web FS'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
/*
This is the module emulates the NodeJS 'fs'.
This is the module emulates the NodeJS 'fs'.
*/
var thisObject = {
readFileSync: readFileSync,
appendFileSync: appendFileSync,
mkdirSync: mkdirSync,
statSync: statSync,
readdir: readdir,
readdirSync: readdirSync,
readFile: readFile
};
var thisObject = {
readFileSync: readFileSync,
appendFileSync: appendFileSync,
mkdirSync: mkdirSync,
statSync: statSync,
readdir: readdir,
readdirSync: readdirSync,
readFile: readFile
}
return thisObject
return thisObject;
function readFileSync (pPath, pEncoding) {
switch (pPath) {
function readFileSync(pPath, pEncoding) {
case '': {
break
}
}
}
switch (pPath) {
case '': {
break;
}
}
}
function appendFileSync(pPath, pText) {
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. */
}
function readdir(pPath, callBackFunction) {
}
function readdir (pPath, callBackFunction) {
/* 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. */
}
}
function readFile(pPath) {
function readFile (pPath) {
/* Again we do nothing. */
}
}
function statSync(pPath) {
let stats
stats.size = 0;
return stats
}
}
function statSync (pPath) {
let stats
stats.size = 0
return stats
}
}