PreLoading functionality complete.

This commit is contained in:
Luis Fernando Molina committed 2018-05-29 19:07:11 +02:00
1 parent e89bf315fa
commit 38fe8dfa2b
4 files changed
+128 -96

No files matched your search

+6
View File
@@ -15,6 +15,12 @@
let modulesArray = [
/* CloudWebScripts */
/* Plotters */
/* PlotterPanels */
"Panels/TimeControlPanel.js",
"Panels/ProductsPanel.js",
+7 -7
View File
@@ -101,7 +101,7 @@
modulesRetrieved++;
if (modulesRetrieved === pCloudWebConfig.webModules.length) {
createHTML(callBackfunction);
createJS(callBackfunction);
}
}
@@ -125,21 +125,21 @@
}
}
function createHTML(callBackfunction) {
function createJS(callBackfunction) {
let links = "";
let htmlLine = '' + '\n' + ' <script type="text/javascript" src="AACloud/@module@"></script>'
let lines = "";
let jsLine = '' + '\n' + ' "AACloud/@module@",'
for (let i = 0; i < pCloudWebConfig.webModules.length; i++) {
let webModule = pCloudWebConfig.webModules[i].name + '.js';
let htmlLineCopy = htmlLine;
let htmlLineCopy = jsLine;
let newLink = htmlLineCopy.replace('@module@', webModule);
links = links + newLink;
lines = lines + newLink;
}
callBackfunction(links);
callBackfunction(lines);
}
}
-4
View File
@@ -7,10 +7,6 @@
<script type="text/javascript" src="Scripts/Require.js"></script>
<script type="text/javascript" src="Scripts/AppPreLoader.js"></script>
<!--CloudWebScripts-->
<!--Plotters-->
<!--PlotterPanels-->
<style type="text/css">
browserCanvas {
border: 1px solid black;
+115 -85
View File
@@ -414,8 +414,122 @@ function onBrowserRequest(request, response) {
case "Scripts": // This means the Scripts folder.
{
respondWithFile('./Scripts/' + requestParameters[2], response);
if (requestParameters[2] === "AppLoader.js") {
let fs = require('fs');
try {
let fileName = './Scripts/' + 'AppLoader.js';
fs.readFile(fileName, onFileRead);
function onFileRead(err, file) {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> Entering function."); }
try {
let fileContent = file.toString();
addCloudWebScripts();
addPlotters();
function addCloudWebScripts() {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addCloudWebScripts -> Entering function."); }
let firstPart = fileContent.substring(0, fileContent.indexOf('/* CloudWebScripts */') + 21);
let secondPart = fileContent.substring(fileContent.indexOf('/* CloudWebScripts */') + 21);
fileContent = firstPart + HTMLCloudScripts + secondPart;
}
function addPlotters() {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> Entering function."); }
let htmlLinePlotter = '' + '\n' +
' "Plotters/@devTeam@/@repo@/@module@.js",'
let htmlLinePlotterPanel = '' + '\n' +
' "PlotterPanels/@devTeam@/@repo@/@module@.js",'
let devTeams = ecosystemObject.devTeams;
let hosts = ecosystemObject.hosts;
addScript(devTeams);
addScript(hosts);
function addScript(pDevTeamsOrHosts) {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> addScript -> Entering function."); }
for (let i = 0; i < pDevTeamsOrHosts.length; i++) {
let devTeam = pDevTeamsOrHosts[i];
for (let j = 0; j < devTeam.plotters.length; j++) {
let plotter = devTeam.plotters[j];
if (plotter.modules !== undefined) {
for (let k = 0; k < plotter.modules.length; k++) {
let module = plotter.modules[k];
let htmlLineCopy = htmlLinePlotter;
let stringToInsert;
stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName);
stringToInsert = stringToInsert.replace('@repo@', plotter.repo);
stringToInsert = stringToInsert.replace('@module@', module.moduleName);
let firstPart = fileContent.substring(0, fileContent.indexOf('/* Plotters */') + 14);
let secondPart = fileContent.substring(fileContent.indexOf('/* Plotters */') + 14);
fileContent = firstPart + stringToInsert + secondPart;
if (module.panels !== undefined) {
for (let l = 0; l < module.panels.length; l++) {
let panel = module.panels[l];
let htmlLineCopy = htmlLinePlotterPanel;
let stringToInsert;
stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName);
stringToInsert = stringToInsert.replace('@repo@', plotter.repo);
stringToInsert = stringToInsert.replace('@module@', panel.moduleName);
let firstPart = fileContent.substring(0, fileContent.indexOf('/* PlotterPanels */') + 19);
let secondPart = fileContent.substring(fileContent.indexOf('/* PlotterPanels */') + 19);
fileContent = firstPart + stringToInsert + secondPart;
}
}
}
}
}
}
}
}
respondWithContent(fileContent, response);
}
catch (err) {
console.log("[ERROR] server -> onBrowserRequest -> File Not Found: " + fileName + " or Error = " + err);
}
}
}
catch (err) {
console.log(err);
}
} else {
respondWithFile('./Scripts/' + requestParameters[2], response);
}
}
break;
@@ -605,92 +719,8 @@ function onBrowserRequest(request, response) {
let fileContent = file.toString();
addCloudWebScripts();
addPlotters();
addImages();
function addCloudWebScripts() {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addCloudWebScripts -> Entering function."); }
let firstPart = fileContent.substring(0, fileContent.indexOf('<!--CloudWebScripts-->') + 22);
let secondPart = fileContent.substring(fileContent.indexOf('<!--CloudWebScripts-->') + 22);
fileContent = firstPart + HTMLCloudScripts + secondPart;
}
function addPlotters() {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> Entering function."); }
let htmlLinePlotter = '' + '\n' +
' <script type="text/javascript" src="Plotters/@devTeam@/@repo@/@module@.js"></script>'
let htmlLinePlotterPanel = '' + '\n' +
' <script type="text/javascript" src="PlotterPanels/@devTeam@/@repo@/@module@.js"></script>'
let devTeams = ecosystemObject.devTeams;
let hosts = ecosystemObject.hosts;
addScript(devTeams);
addScript(hosts);
function addScript(pDevTeamsOrHosts) {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> addScript -> Entering function."); }
for (let i = 0; i < pDevTeamsOrHosts.length; i++) {
let devTeam = pDevTeamsOrHosts[i];
for (let j = 0; j < devTeam.plotters.length; j++) {
let plotter = devTeam.plotters[j];
if (plotter.modules !== undefined) {
for (let k = 0; k < plotter.modules.length; k++) {
let module = plotter.modules[k];
let htmlLineCopy = htmlLinePlotter;
let stringToInsert;
stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName);
stringToInsert = stringToInsert.replace('@repo@', plotter.repo);
stringToInsert = stringToInsert.replace('@module@', module.moduleName);
let firstPart = fileContent.substring(0, fileContent.indexOf('<!--Plotters-->') + 15);
let secondPart = fileContent.substring(fileContent.indexOf('<!--Plotters-->') + 15);
fileContent = firstPart + stringToInsert + secondPart;
if (module.panels !== undefined) {
for (let l = 0; l < module.panels.length; l++) {
let panel = module.panels[l];
let htmlLineCopy = htmlLinePlotterPanel;
let stringToInsert;
stringToInsert = htmlLineCopy.replace('@devTeam@', devTeam.codeName);
stringToInsert = stringToInsert.replace('@repo@', plotter.repo);
stringToInsert = stringToInsert.replace('@module@', panel.moduleName);
let firstPart = fileContent.substring(0, fileContent.indexOf('<!--PlotterPanels-->') + 20);
let secondPart = fileContent.substring(fileContent.indexOf('<!--PlotterPanels-->') + 20);
fileContent = firstPart + stringToInsert + secondPart;
}
}
}
}
}
}
}
}
function addImages() {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> onBrowserRequest -> onFileRead -> addImages -> Entering function."); }