diff --git a/Images/aa-logo-dark-8.png b/Images/aa-logo-dark-8.png new file mode 100644 index 000000000..a6bcfcb90 Binary files /dev/null and b/Images/aa-logo-dark-8.png differ diff --git a/Project.njsproj b/Project.njsproj index 7238b1f57..25d499c05 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -82,6 +82,9 @@ Code + + Code + Code diff --git a/Scripts/AppLoader.js b/Scripts/AppLoader.js index f7da204c7..809b2d07b 100644 --- a/Scripts/AppLoader.js +++ b/Scripts/AppLoader.js @@ -21,6 +21,7 @@ /* PlotterPanels */ + "TopSpace/CompanyLogo.js", "TopSpace/CurrentStartMode.js", "TopSpace/CurrentProcess.js", "TopSpace/CurrentBot.js", diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 31fd88d01..8e06cebd6 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -23,6 +23,7 @@ function newTopSpace() { container.isDraggeable = false; + let companyLogo; let endUser; let devTeam; let currentBot; @@ -33,6 +34,9 @@ function newTopSpace() { function initialize() { + companyLogo = newCompanyLogo(); + companyLogo.initialize(); + endUser = newEndUser(); endUser.initialize(); @@ -54,6 +58,9 @@ function newTopSpace() { let container; + container = companyLogo.getContainer(point); + if (container !== undefined) { return container; } + container = endUser.getContainer(point); if (container !== undefined) { return container; } @@ -80,6 +87,7 @@ function newTopSpace() { thisObject.container.frame.draw(false, false); drawBackground(); + companyLogo.draw(); endUser.draw(); devTeam.draw(); currentBot.draw(); diff --git a/TopSpace/CompanyLogo.js b/TopSpace/CompanyLogo.js new file mode 100644 index 000000000..e71b6ba70 --- /dev/null +++ b/TopSpace/CompanyLogo.js @@ -0,0 +1,79 @@ + +function newCompanyLogo() { + + 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; + + thisObject.container.frame.width = 150; + thisObject.container.frame.height = TOP_SPACE_HEIGHT; + + container.frame.position.x = 0; + container.frame.position.y = 0; + + container.isDraggeable = false; + + let logo; + let canDrawLogo = false; + + return thisObject; + + function initialize() { + + logo = new Image(); + + logo.onload = onImageLoad; + + function onImageLoad() { + canDrawLogo = true; + } + + logo.src = "Images/aa-logo-dark-8.png"; + document.body.append(logo); + } + + function getContainer(point) { + + 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 { + + /* This point does not belong to this space. */ + + return undefined; + } + + } + + function draw() { + + thisObject.container.frame.draw(false, false); + + if (canDrawLogo === false) { return;} + + let imageHeight = 24; + let imageWidth = 120; + + let imagePoint = { + x: 10, + y: thisObject.container.frame.height / 2 - imageHeight / 2 + }; + + imagePoint = thisObject.container.frame.frameThisPoint(imagePoint); + + browserCanvasContext.drawImage(logo, imagePoint.x, imagePoint.y, imageWidth, imageHeight); + } +} \ No newline at end of file diff --git a/index.html b/index.html index 894ba6760..9b91a18a8 100644 --- a/index.html +++ b/index.html @@ -13,9 +13,8 @@ } - - - - - + + + + \ No newline at end of file diff --git a/server.js b/server.js index 6ccb14dd0..47f82da44 100644 --- a/server.js +++ b/server.js @@ -383,6 +383,13 @@ function onBrowserRequest(request, response) { } break; + case "Images": // This means the Scripts folder. + { + + respondWithImage('./Images/' + requestParameters[2], response); + + } + break; case "TopSpace": // This means the TopSpace folder. { @@ -886,7 +893,7 @@ function respondWithFile(fileName, response) { response.setHeader("Expires", "0"); // Proxies. response.setHeader("Access-Control-Allow-Origin", "*"); // Allows to access data from other domains. - response.writeHead(200, { 'Content-Type': 'text/html' }); + //response.writeHead(200, { 'Content-Type': 'text/html' }); response.write(htmlResponse); response.end("\n"); //console.log("File Sent: " + fileName); @@ -894,7 +901,6 @@ function respondWithFile(fileName, response) { } catch (err) { returnEmptyArray(); - console.log("File Not Found: " + fileName); console.log("[ERROR] server -> respondWithFile -> onFileRead -> File Not Found: " + fileName + " or Error = " + err); } @@ -905,6 +911,42 @@ function respondWithFile(fileName, response) { } } +function respondWithImage(fileName, response) { + + if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithImage -> Entering function."); } + + let fs = require('fs'); + try { + + fs.readFile(fileName, onFileRead); + + function onFileRead(err, file) { + + if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithImage -> onFileRead -> Entering function."); } + + try { + + response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. + response.setHeader("Pragma", "no-cache"); // HTTP 1.0. + response.setHeader("Expires", "0"); // Proxies. + response.setHeader("Access-Control-Allow-Origin", "*"); // Allows to access data from other domains. + + response.writeHead(200, { 'Content-Type': 'image/png' }); + response.end(file, 'binary'); + + } + catch (err) { + + console.log("[ERROR] server -> respondWithImage -> onFileRead -> File Not Found: " + fileName + " or Error = " + err); + } + + } + } + catch (err) { + console.log("[ERROR] server -> respondWithImage -> err = " + err); + } +} + function returnEmptyArray() { try {