From 01e121aa59f76c45b04ba82090ba1534a600e82f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 20 Oct 2020 11:35:42 +0200 Subject: [PATCH] Mantainance --- BackendServers.njsproj | 307 -------------------------------------- WebServer/AppLoader.js | 170 --------------------- WebServer/AppPreLoader.js | 158 -------------------- WebServer/index.html | 2 +- 4 files changed, 1 insertion(+), 636 deletions(-) delete mode 100644 BackendServers.njsproj delete mode 100644 WebServer/AppLoader.js delete mode 100644 WebServer/AppPreLoader.js diff --git a/BackendServers.njsproj b/BackendServers.njsproj deleted file mode 100644 index 6abd252b5..000000000 --- a/BackendServers.njsproj +++ /dev/null @@ -1,307 +0,0 @@ - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - BackendServers - BackendServer - - - - Debug - 2.0 - 6a53ad2e-c389-4d2c-bded-23dbab231315 - - - server.js - False - - - . - . - v4.0 - {3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD} - false - - - true - - - true - - - - Code - - - - Code - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WebServer/AppLoader.js b/WebServer/AppLoader.js deleted file mode 100644 index 73ae8149a..000000000 --- a/WebServer/AppLoader.js +++ /dev/null @@ -1,170 +0,0 @@ -let postLoader - -function newAppLoader() { - const MODULE_NAME = 'App Loader' - const INFO_LOG = false - const ERROR_LOG = true - const logger = newWebDebugLog() - logger.fileName = MODULE_NAME - - let thisObject = { - loadModules: loadModules - } - - return thisObject - - async function loadModules() { - try { - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Entering function.') } - - let plotters - let modulesArray = [] - - plotters = defaultPlotters() - - modulesArray = modulesArray.concat([ - - 'Globals.js', - 'Workspace.js', - - 'Files/SingleFile.js', - 'Files/FileCloud.js', - 'Files/MarketFiles.js', - 'Files/DailyFiles.js', - 'Files/FileCursor.js', - 'Files/FileSequence.js', - 'Files/FileStorage.js', - - 'EventsServerClient.js', - - 'LegacyPlotter.js', - 'PlotterPanel.js', - - 'VideoRecorder.js', - 'ProductStorage.js', - 'Canvas.js', - 'EventHandler.js', - 'Frame.js', - 'Animation.js', - 'Container.js', - 'Utilities.js', - 'PostLoader.js' - ]) - - modulesArray = modulesArray.concat(plotters) - - functionLibraries() - - function functionLibraries() { - let url = 'ListFunctionLibraries' - callWebServer(undefined, url, onResponse) - - function onResponse(err, fileList) { - let urlArray = [] - let fileArray = JSON.parse(fileList) - for (let i = 0; i < fileArray.length; i++) { - let item = fileArray[i] - - project = item[0] - fileName = item[1] - urlArray.push('Projects' + '/' + project + '/' + 'Function-Libraries' + '/' + fileName) - } - - modulesArray = modulesArray.concat(urlArray) - utilities() - } - } - - function utilities() { - let url = 'ListUtilitiesFiles' - callWebServer(undefined, url, onResponse) - - function onResponse(err, fileList) { - let urlArray = [] - let fileArray = JSON.parse(fileList) - for (let i = 0; i < fileArray.length; i++) { - let item = fileArray[i] - - project = item[0] - fileName = item[1] - urlArray.push('Projects' + '/' + project + '/' + 'Utilities' + '/' + fileName) - } - - modulesArray = modulesArray.concat(urlArray) - spaces() - } - } - - function spaces() { - let url = 'ListSpaceFiles' - callWebServer(undefined, url, onResponse) - - function onResponse(err, fileList) { - let urlArray = [] - let fileArray = JSON.parse(fileList) - for (let i = 0; i < fileArray.length; i++) { - let path = fileArray[i] - urlArray.push('Projects' + '/' + path) - } - - modulesArray = modulesArray.concat(urlArray) - downloadIncludedFiles() - } - } - - function downloadIncludedFiles() { - - let downloadedCounter = 0 - - for (let i = 0; i < modulesArray.length; i++) { - let path = modulesArray[i] - - REQUIREJS([path], onRequired) - - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Module Requested.') } - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> path = ' + path) } - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> total requested = ' + (i + 1)) } - - function onRequired(pModule) { - try { - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Entering function.') } - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Module Downloaded.') } - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> path = ' + path) } - - downloadedCounter++ - - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> downloadedCounter = ' + downloadedCounter) } - - if (downloadedCounter === modulesArray.length) { - if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Starting Advanced Algos Platform.') } - setTimeout(() => { - postLoader = newPostLoader() - postLoader.start() - }, 500) - - } - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> onRequired -> err = ' + err.stack) } - } - } - } - } - - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> err = ' + err.stack) } - } - } - - function defaultPlotters() { - return [ - 'Plotters/Masters/Plotters-Candles-Volumes/Candles.js', - 'Plotters/Masters/Plotters-Candles-Volumes/CandlePanel.js', - 'Plotters/Masters/Plotters-Candles-Volumes/Volumes.js', - 'Plotters/Masters/Plotters-Candles-Volumes/VolumePanel.js', - 'Plotters/Masters/Plotters-Bollinger-Bands/BollingerBands.js', - 'Plotters/Masters/Plotters-Bollinger-Bands/BollingerBandsPanel.js', - 'Plotters/Masters/Plotters-Bollinger-Bands/PercentageBandwidth.js' - ] - } -} - diff --git a/WebServer/AppPreLoader.js b/WebServer/AppPreLoader.js deleted file mode 100644 index fc08202d3..000000000 --- a/WebServer/AppPreLoader.js +++ /dev/null @@ -1,158 +0,0 @@ - -/* Callbacks default responses. */ - -let GLOBAL = {}; - -GLOBAL.DEFAULT_OK_RESPONSE = { - result: "Ok", - message: "Operation Succeeded" -}; - -GLOBAL.DEFAULT_FAIL_RESPONSE = { - result: "Fail", - message: "Operation Failed" -}; - -GLOBAL.DEFAULT_RETRY_RESPONSE = { - result: "Retry", - message: "Retry Later" -}; - -GLOBAL.CUSTOM_OK_RESPONSE = { - result: "Ok, but check Message", - message: "Custom Message" -}; - -GLOBAL.CUSTOM_FAIL_RESPONSE = { - result: "Fail Because", - message: "Custom Message" -}; - -let browserCanvas; // This is the canvas object of the browser. - -function spacePad(str, max) { - str = str.toString(); - return str.length < max ? spacePad(" " + str, max) : str; -} - -function loadSuperalgos() { - - const MODULE_NAME = "App Pre-Loader"; - const INFO_LOG = false; - - setupHTMLTextArea() - setupHTMLInput() - setupHTMLCanvas() - loadDebugModule() - - function setupHTMLTextArea() { - let textArea = document.createElement('textarea'); - textArea.id = "textArea"; - textArea.spellcheck = false; - textArea.style = 'resize: none;' + - ' border: none;' + - ' outline: none;' + - 'box-shadow: none;' + - 'overflow:hidden;' + - 'font-family: ' + 'Saira' + ';' + - 'font-size: 12px;' + - 'background-color: rgb(255, 255, 255);' + - 'color:rgb(255, 255, 255);' + - 'width: ' + 600 + 'px;' + - 'height: ' + 400 + 'px' - - let textAreaDiv = document.getElementById('textAreaDiv'); - textAreaDiv.appendChild(textArea); - textAreaDiv.style = 'position:fixed; top:' + -1500 + 'px; left:' + 500 + 'px; z-index:10; ' - } - - function setupHTMLInput() { - let input = document.createElement('input'); - input.id = "input"; - input.spellcheck = false; - input.style = "border: none; outline: none; box-shadow: none; overflow:hidden; width: 0px; height: 0px;"; - - let inputDiv = document.getElementById('inputDiv'); - inputDiv.appendChild(input); - } - - function setupHTMLCanvas() { - let canvas = document.createElement('canvas'); - - canvas.id = "canvas"; - canvas.width = 1400; - canvas.height = 600; - canvas.style.border = "0"; - canvas.style = "position:absolute; top:0px; left:0px; z-index:1"; - - let canvasApp = document.getElementById('canvasApp'); - canvasApp.appendChild(canvas); - - browserCanvas = document.getElementById('canvas'); - - browserCanvas.width = window.innerWidth; - browserCanvas.height = window.innerHeight; - browserCanvas.style.border = "none"; - - browserCanvas.style.top = 0 + 'px'; - } - - function loadDebugModule() { - let path = "WebDebugLog.js"; - REQUIREJS([path], onRequired); - - function onRequired(pModule) { - if (INFO_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[INFO] " + path + " downloaded."); } - setUpProjects(); - } - } - - function setUpProjects() { - let url = 'ProjectNames' - callWebServer(undefined, url, onResponse) - - function onResponse(err, projects) { - window.PROJECTS = JSON.parse(projects) - loadModules() - } - } - - /* And Finally, we start loading all the scripts we will inmediatelly need. */ - function loadModules() { - let path = "WebServer/AppLoader.js"; - REQUIREJS([path], onRequired); - - function onRequired(pModule) { - if (INFO_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[INFO] " + path + " downloaded."); } - let APP_LOADER_MODULE = newAppLoader(); - APP_LOADER_MODULE.loadModules(); - } - } -} - -function callWebServer(pContentToSend, pPath, callBackFunction) { - let xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function () { - if (this.readyState === 4 && this.status === 200) { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, xhttp.responseText); - return; - } else if (this.readyState === 4 && this.status === 404) { - callBackFunction({ result: "Fail", message: xhttp.responseText.trim(), code: xhttp.responseText.trim() }); - return; - } - }; - - if (pContentToSend === undefined) { - xhttp.open("GET", pPath, true); - xhttp.send(); - } else { - try { - let blob = new Blob([pContentToSend], { type: 'text/plain' }); - xhttp.open("POST", pPath, true); - xhttp.send(blob); - } catch (err) { - if (ERROR_LOG === true) { console.log(spacePad(MODULE_NAME, 50) + " : " + "[ERROR] callServer -> err.message = " & err.message); } - callBackFunction({ result: "Fail", message: err.message }) - } - } -} diff --git a/WebServer/index.html b/WebServer/index.html index 92ee556bd..7330e2f80 100644 --- a/WebServer/index.html +++ b/WebServer/index.html @@ -8,7 +8,7 @@ - +