diff --git a/Ecosystem.js b/Ecosystem.js
index 11a633278..f9825c192 100644
--- a/Ecosystem.js
+++ b/Ecosystem.js
@@ -12,6 +12,7 @@ function newEcosystem() {
getExchange: getExchange,
getPlotter: getPlotter,
getPlotterModule: getPlotterModule,
+ getAACloudConfig: getAACloudConfig,
initialize: initialize
}
@@ -25,6 +26,11 @@ function newEcosystem() {
}
+ function getAACloudConfig() {
+
+ return ECOSYSTEM.AACloud;
+ }
+
function getHost(pHostCodeName) {
for (let i = 0; i < ECOSYSTEM.hosts.length; i++) {
diff --git a/Project.njsproj b/Project.njsproj
index 8f4bd1d4a..1c0978988 100644
--- a/Project.njsproj
+++ b/Project.njsproj
@@ -32,7 +32,10 @@
-
+
+ Code
+
+
Code
@@ -147,6 +150,7 @@
+
diff --git a/Server/ConfigReader.js b/Server/ConfigReader.js
index 21c605894..03aa390df 100644
--- a/Server/ConfigReader.js
+++ b/Server/ConfigReader.js
@@ -27,13 +27,13 @@
ecosystem = pEcosystem;
ecosystemObject = pEcosystemObject;
- readServerConfig();
+ readAAWebConfig();
- function readServerConfig() {
+ function readAAWebConfig() {
try {
- if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readServerConfig -> Entering function."); }
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAAWebConfig -> Entering function."); }
let fs = require('fs');
@@ -44,7 +44,7 @@
try {
- if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readServerConfig -> onFileRead -> Entering function."); }
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAAWebConfig -> onFileRead -> Entering function."); }
let fileText;
@@ -53,7 +53,7 @@
serverConfig = JSON.parse(fileText);
- if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readServerConfig -> onFileRead -> fileText = " + fileText); }
+ if (LOG_FILE_CONTENT === true) { console.log("[INFO] ConfigReader -> readAAWebConfig -> onFileRead -> fileText = " + fileText); }
CONSOLE_LOG = serverConfig.webServerLog.console;
LOG_FILE_CONTENT = serverConfig.webServerLog.fileContent;
@@ -66,13 +66,13 @@
callBackFunction(serverConfig);
}
catch (err) {
- console.log("[ERROR] ConfigReader -> readServerConfig -> onFileRead -> File = " + fileName + " Error = " + err);
+ console.log("[ERROR] ConfigReader -> readAAWebConfig -> onFileRead -> File = " + fileName + " Error = " + err);
}
}
}
catch (err) {
- console.log("[ERROR] ConfigReader -> readServerConfig -> Error = " + err);
+ console.log("[ERROR] ConfigReader -> readAAWebConfig -> Error = " + err);
}
}
}
@@ -113,7 +113,7 @@
ecosystem = ecosystem.trim(); // remove first byte with some encoding.
ecosystemObject = JSON.parse(ecosystem);
- readHostsConfigs();
+ readAACloudConfig();
}
catch (err) {
console.log("[ERROR] ConfigReader -> readEcosystemConfig -> Cloud -> onDataArrived -> Error = " + err);
@@ -142,7 +142,7 @@
ecosystem = ecosystem.trim(); // remove first byte with some encoding.
ecosystemObject = JSON.parse(ecosystem);
- readHostsConfigs();
+ readAACloudConfig();
}
catch (err) {
console.log("[ERROR] ConfigReader -> readEcosystemConfig -> File System -> onFileRead -> File = " + fileName + " Error = " + err);
@@ -172,7 +172,7 @@
ecosystem = ecosystem.trim(); // remove first byte with some encoding.
ecosystemObject = JSON.parse(ecosystem);
- readHostsConfigs();
+ readAACloudConfig();
}
catch (err) {
console.log("[ERROR] ConfigReader -> readEcosystemConfig -> Github -> onDataArrived -> Error = " + err);
@@ -187,6 +187,107 @@
}
}
+ function readAACloudConfig() {
+
+ try {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> Entering function."); }
+
+ switch (serverConfig.configAndPlugins.Location) {
+
+ case 'Cloud': {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> Cloud -> Entering Case."); }
+
+ storage.getStorageData('AdvancedAlgos', 'AACloud', 'this.config.json', onDataArrived);
+
+ function onDataArrived(pData) {
+
+ try {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> Cloud -> onDataArrived -> Entering function."); }
+
+ let data = pData.toString();
+ data = data.trim(); // remove first byte with some encoding.
+
+ let dataObject = JSON.parse(data);
+ ecosystemObject.AACloud = dataObject;
+ readHostsConfigs();
+ }
+ catch (err) {
+ console.log("[ERROR] ConfigReader -> readAACloudConfig -> Cloud -> onDataArrived -> Error = " + err);
+ }
+ }
+
+ break;
+ }
+
+ case 'File System': {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> File System -> Entering Case."); }
+
+ let fs = require('fs');
+ try {
+ let fileName = '../AACloud/this.config.json';
+ fs.readFile(fileName, onFileRead);
+
+ function onFileRead(err, pData) {
+
+ try {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> File System -> onFileRead -> Entering function."); }
+
+ let data = pData.toString();
+ data = data.trim(); // remove first byte with some encoding.
+
+ let dataObject = JSON.parse(data);
+ ecosystemObject.AACloud = dataObject;
+ readHostsConfigs();
+ }
+ catch (err) {
+ console.log("[ERROR] ConfigReader -> readAACloudConfig -> File System -> onFileRead -> File = " + fileName + " Error = " + err);
+ }
+
+ }
+ }
+ catch (err) {
+ console.log("[ERROR] ConfigReader -> readAACloudConfig -> File System -> File = " + fileName + " Error = " + err);
+ }
+ break;
+ }
+
+ case 'Github': {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> Github -> Entering Case."); }
+
+ github.getGithubData('AdvancedAlgos', 'AAWeb', 'this.config.json', onDataArrived);
+
+ function onDataArrived(pData) {
+
+ try {
+
+ if (CONSOLE_LOG === true) { console.log("[INFO] ConfigReader -> readAACloudConfig -> Github -> onDataArrived -> Entering function."); }
+
+ let data = pData.toString();
+ data = data.trim(); // remove first byte with some encoding.
+
+ let dataObject = JSON.parse(data);
+ ecosystemObject.AACloud = dataObject;
+ readHostsConfigs();
+ }
+ catch (err) {
+ console.log("[ERROR] ConfigReader -> readAACloudConfig -> Github -> onDataArrived -> Error = " + err);
+ }
+ }
+ break;
+ }
+ }
+ }
+ catch (err) {
+ console.log("[ERROR] ConfigReader -> readAACloudConfig -> Error = " + err);
+ }
+ }
+
function readHostsConfigs() {
try {
@@ -934,5 +1035,7 @@
console.log("[ERROR] ConfigReader -> readDevTeamsConfigs -> Error = " + err);
}
}
+
+
}
}
\ No newline at end of file
diff --git a/CloudSupport.js b/WebVM/CloudSupport.js
similarity index 86%
rename from CloudSupport.js
rename to WebVM/CloudSupport.js
index 7fea049cf..b3f55a4dc 100644
--- a/CloudSupport.js
+++ b/WebVM/CloudSupport.js
@@ -18,12 +18,13 @@ function runBot() {
function webRequire(pModulePath) {
+ switch (pModulePath) {
- if (pModulePath === '') {
-
+ case 'fs': {
+ return newWebFS();
+ }
}
-
}
function downloadModule(pPath) {
@@ -34,4 +35,6 @@ function downloadModule(pPath) {
console.log("Dummy Web Loaded");
});
-}
\ No newline at end of file
+}
+
+
diff --git a/WebVM/WebFS.js b/WebVM/WebFS.js
new file mode 100644
index 000000000..c4d0178c4
--- /dev/null
+++ b/WebVM/WebFS.js
@@ -0,0 +1,75 @@
+function newWebFS() {
+
+ const MODULE_NAME = "Web FS";
+ const INFO_LOG = false;
+ const ERROR_LOG = true;
+ const logger = newDebugLog();
+ logger.fileName = MODULE_NAME;
+
+ /*
+
+ This is the module emulates the NodeJS 'fs'.
+
+ */
+
+ var thisObject = {
+ readFileSync: readFileSync,
+ appendFileSync: appendFileSync,
+ mkdirSync: mkdirSync,
+ statSync: statSync,
+ readdir: readdir,
+ readdirSync: readdirSync,
+ readFile: readFile
+ };
+
+
+ return thisObject;
+
+ function readFileSync(pPath, pEncoding) {
+
+ switch (pPath) {
+
+ case 'this.config.json': {
+
+ /* This is AAWeb Config File. */
+
+ return JSON.stringify(ecosystem.getAACloudConfig());
+
+ break;
+ }
+ }
+ }
+
+ 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) {
+
+ /* We will return an empty array of files. */
+ callBackFunction([]);
+ }
+
+ function readdirSync(pPath, callBackFunction) {
+
+
+ }
+
+ function mkdirSync(pPath) {
+
+ /* Again we do nothing. */
+ }
+
+ function readFile(pPath) {
+
+ /* Again we do nothing. */
+ }
+
+ function statSync(pPath) {
+
+ let stats
+ stats.size = 0;
+ return stats
+ }
+}
\ No newline at end of file
diff --git a/index.html b/index.html
index 3a73e380a..e91d56c6b 100644
--- a/index.html
+++ b/index.html
@@ -9,9 +9,11 @@
-
-
+
+
+
+
diff --git a/server.js b/server.js
index b5adfee5f..a9ea1fe9f 100644
--- a/server.js
+++ b/server.js
@@ -338,6 +338,14 @@ function onBrowserRequest(request, response) {
}
break;
+ case "WebVM": // This means the Scripts folder.
+ {
+
+ respondWithFile('./WebVM/' + requestParameters[2], response);
+
+ }
+ break;
+
case "Scripts": // This means the Scripts folder.
{