Restore web server files
This commit is contained in:
1 parent
c52629cda2
commit
9def104a84
7 files changed
+145
-71
No files matched your search
@@ -73,11 +73,13 @@ exports.newDesktopApp = function newDesktopApp() {
|
||||
|
||||
/* TODO refactor this into something better */
|
||||
|
||||
require('./UI/WebAppPreLoader').loadSuperalgos();
|
||||
|
||||
/* let react = require('./scripts/start');
|
||||
react.start(JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort);*/
|
||||
/*
|
||||
require('./src/UI/WebAppPreLoader').loadSuperalgos();
|
||||
*/
|
||||
|
||||
/* let react = require('./scripts/start');
|
||||
react.start(JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort);
|
||||
*/
|
||||
|
||||
/* thisObject.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface()
|
||||
thisObject.httpInterface.initialize()*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Root object*/
|
||||
/* Root objects*/
|
||||
exports.UI = {
|
||||
let UI = {
|
||||
projects: {},
|
||||
schemas: { projectSchema: undefined },
|
||||
environment: undefined,
|
||||
@@ -8,7 +8,10 @@ exports.UI = {
|
||||
webApp: undefined
|
||||
}
|
||||
|
||||
exports.SA = { projects: {} }
|
||||
|
||||
let SA = { projects: {} }
|
||||
/*
|
||||
We will use this to load functions originally intended for Nodejs
|
||||
*/
|
||||
let exports = {}
|
||||
|
||||
|
||||
+3
-15
@@ -5,7 +5,7 @@ function newWebApp() {
|
||||
Everything is being coded here until some structure emerges.
|
||||
*/
|
||||
let thisObject = {
|
||||
messageReceived: messageReceived,
|
||||
messageReceived: messageReceived,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
@@ -21,7 +21,6 @@ function newWebApp() {
|
||||
setupRootObject(UI, 'UI')
|
||||
setupRootObject(SA, 'SA')
|
||||
await UI.projects.socialTrading.modules.webSocketsWebAppClient.initialize()
|
||||
// loadReactDom();
|
||||
loadWUserProfileTimeline()
|
||||
loadWhoToFollow()
|
||||
setupEventHandlers()
|
||||
@@ -101,15 +100,6 @@ function newWebApp() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadReactDom() {
|
||||
|
||||
reactReqs.ReactDOM.render(
|
||||
reactReqs.ReactBase,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
async function loadWUserProfileTimeline() {
|
||||
let queryMessage = {
|
||||
queryType: SA.projects.socialTrading.globals.queryTypes.EVENTS,
|
||||
@@ -173,7 +163,8 @@ function newWebApp() {
|
||||
postDiv.appendChild(textNode)
|
||||
contentDiv.appendChild(postDiv)
|
||||
}
|
||||
} catch (err) {
|
||||
}
|
||||
catch (err) {
|
||||
console.log('[ERROR] err.stack = ' + err.stack)
|
||||
}
|
||||
}
|
||||
@@ -294,7 +285,6 @@ function newWebApp() {
|
||||
function updateTextArea() {
|
||||
textArea.value = ""
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
case 'Follow Profile': {
|
||||
@@ -312,7 +302,6 @@ function newWebApp() {
|
||||
button.setAttribute("class", "profile-to-unfollow-button")
|
||||
button.name = 'Unfollow Profile'
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
case 'Unfollow Profile': {
|
||||
@@ -330,7 +319,6 @@ function newWebApp() {
|
||||
button.setAttribute("class", "profile-to-follow-button")
|
||||
button.name = 'Follow Profile'
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
+29
-23
@@ -1,29 +1,34 @@
|
||||
|
||||
exports.newWebAppLoader = (UI) => {
|
||||
function newWebAppLoader() {
|
||||
|
||||
try {
|
||||
let modulesArray = [
|
||||
'WebDebugLog.js',
|
||||
'WebApp.js'
|
||||
]
|
||||
let thisObject = {
|
||||
loadModules: loadModules
|
||||
}
|
||||
|
||||
for (let i = 0; i < UI.schemas.projectSchema.length; i++) {
|
||||
let project = UI.schemas.projectSchema[i]
|
||||
return thisObject
|
||||
|
||||
if (project.UI !== undefined) {
|
||||
if (project.UI.functionLibraries !== undefined) {
|
||||
for (let j = 0; j < project.UI.functionLibraries.length; j++) {
|
||||
let fileName = project.UI.functionLibraries[j].fileName
|
||||
if (fileName === undefined) {
|
||||
fileName = project.UI.functionLibraries[j].name.replaceAll(' ', '') + '.js'
|
||||
async function loadModules() {
|
||||
try {
|
||||
let modulesArray = [
|
||||
'WebDebugLog.js',
|
||||
'WebApp.js'
|
||||
]
|
||||
|
||||
for (let i = 0; i < UI.schemas.projectSchema.length; i++) {
|
||||
let project = UI.schemas.projectSchema[i]
|
||||
|
||||
if (project.UI !== undefined) {
|
||||
if (project.UI.functionLibraries !== undefined) {
|
||||
for (let j = 0; j < project.UI.functionLibraries.length; j++) {
|
||||
let fileName = project.UI.functionLibraries[j].fileName
|
||||
if (fileName === undefined) {fileName = project.UI.functionLibraries[j].name.replaceAll(' ', '') + '.js'}
|
||||
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
|
||||
}
|
||||
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
|
||||
}
|
||||
}
|
||||
if (project.UI.utilities !== undefined) {
|
||||
for (let j = 0; j < project.UI.utilities.length; j++) {
|
||||
let fileName = project.UI.utilities[j].fileName
|
||||
if (fileName === undefined) {fileName = project.UI.utilities[j].name.replaceAll(' ', '') + '.js'}
|
||||
if (project.UI.utilities !== undefined) {
|
||||
for (let j = 0; j < project.UI.utilities.length; j++) {
|
||||
let fileName = project.UI.utilities[j].fileName
|
||||
if (fileName === undefined) {fileName = project.UI.utilities[j].name.replaceAll(' ', '') + '.js'}
|
||||
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Utilities' + '/' + fileName)
|
||||
}
|
||||
}
|
||||
@@ -104,9 +109,10 @@ exports.newWebAppLoader = (UI) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('[ERROR] loadModules -> err = ' + err.stack)
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] loadModules -> err = ' + err.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,111 @@
|
||||
exports.loadSuperalgos = () => {
|
||||
|
||||
function loadSuperalgos() {
|
||||
|
||||
let browser = checkBrowserVersion()
|
||||
if ((browser.name !== "Chrome" && browser.name !== "Safari") || (browser.name === "Chrome" && parseInt(browser.version) < 85) || (browser.name === "Safari" && parseInt(browser.version) < 13)) {
|
||||
alert("Superalgos is officially supported on Google Chrome 85 or Safari 13.1 and above. Your browser version has been detected as potentially beneath this. If you continue you may experience some functionaility issues.\n\nDetected Browser: " + browser.name + "\nVersion: " + browser.version)
|
||||
}
|
||||
|
||||
loadGlobals()
|
||||
|
||||
function loadGlobals() {
|
||||
let {UI} = require('./Globals');
|
||||
setupEnvironment(UI);
|
||||
let path = "Globals.js"
|
||||
REQUIREJS([path], onRequired)
|
||||
|
||||
function onRequired(pModule) {
|
||||
setupEnvironment()
|
||||
}
|
||||
}
|
||||
|
||||
function setupEnvironment(UI) {
|
||||
let ENVIRONMENT = require('../../Environment');
|
||||
UI.environment = ENVIRONMENT.newEnvironment();
|
||||
setupClientNode(UI);
|
||||
function setupEnvironment() {
|
||||
httpRequest(undefined, 'Environment', onResponse)
|
||||
|
||||
function onResponse(err, file) {
|
||||
UI.environment = JSON.parse(file)
|
||||
setupClientNode()
|
||||
}
|
||||
}
|
||||
|
||||
function setupClientNode(UI) {
|
||||
UI.clientNode = DK.desktopApp.p2pNetworkClient.node;
|
||||
setupProjectsSchema(UI);
|
||||
function setupClientNode() {
|
||||
httpRequest(undefined, 'ClientNode', onResponse)
|
||||
|
||||
function onResponse(err, file) {
|
||||
UI.clientNode = JSON.parse(file)
|
||||
setupProjectsSchema()
|
||||
}
|
||||
}
|
||||
|
||||
function setupProjectsSchema(UI) {
|
||||
UI.schemas.projectSchema = require('../../Projects/ProjectsSchema.json');
|
||||
loadModules(UI)
|
||||
function setupProjectsSchema() {
|
||||
httpRequest(undefined, 'ProjectsSchema', onResponse)
|
||||
|
||||
function onResponse(err, file) {
|
||||
UI.schemas.projectSchema = JSON.parse(file)
|
||||
loadModules()
|
||||
}
|
||||
}
|
||||
|
||||
function loadModules(UI) {
|
||||
let react = require('../scripts/start');
|
||||
react.start(JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort);
|
||||
function loadModules() {
|
||||
let path = "WebAppLoader.js"
|
||||
REQUIREJS([path], onRequired)
|
||||
|
||||
/* let APP_LOADER_MODULE = require('./WebAppLoader');
|
||||
APP_LOADER_MODULE.newWebAppLoader(UI);*/
|
||||
function onRequired(pModule) {
|
||||
let APP_LOADER_MODULE = newWebAppLoader()
|
||||
APP_LOADER_MODULE.loadModules()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function httpRequest(pContentToSend, pPath, callBackFunction) {
|
||||
let xmlHttpRequest = new XMLHttpRequest()
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
try {
|
||||
callBackFunction(undefined, xmlHttpRequest.responseText)
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpRequest -> httpRequest -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpRequest -> httpRequest -> pContentToSend = ' + pContentToSend)
|
||||
console.log('[ERROR] httpRequest -> httpRequest -> pPath = ' + pPath)
|
||||
console.log('[ERROR] httpRequest -> httpRequest -> xmlHttpRequest.responseText = ' + xmlHttpRequest.responseText)
|
||||
console.log('[ERROR] httpRequest -> httpRequest -> callBackFunction = ' + callBackFunction)
|
||||
|
||||
}
|
||||
return
|
||||
} else if (this.readyState === 4 && this.status === 404) {
|
||||
callBackFunction({ result: "Fail", message: xmlHttpRequest.responseText.trim(), code: xmlHttpRequest.responseText.trim() })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (pContentToSend === undefined) {
|
||||
xmlHttpRequest.open("GET", pPath, true)
|
||||
xmlHttpRequest.send()
|
||||
} else {
|
||||
try {
|
||||
let blob = new Blob([pContentToSend], { type: 'text/plain' })
|
||||
xmlHttpRequest.open("POST", pPath, true)
|
||||
xmlHttpRequest.send(blob)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { console.log("[ERROR] callServer -> err.message = " + err.message) }
|
||||
callBackFunction({ result: "Fail", message: err.message })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkBrowserVersion() {
|
||||
|
||||
let ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []
|
||||
if (/trident/i.test(M[1])) {
|
||||
tem = /\brv[ :]+(\d+)/g.exec(ua) || []
|
||||
return { name: 'IE', version: (tem[1] || '') }
|
||||
}
|
||||
if (M[1] === 'Chrome') {
|
||||
tem = ua.match(/\bOPR|Edge\/(\d+)/)
|
||||
if (tem != null) { return { name: 'Opera', version: tem[1] } }
|
||||
}
|
||||
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']
|
||||
if ((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1, 1, tem[1]) }
|
||||
return {
|
||||
name: M[0],
|
||||
version: M[1]
|
||||
}
|
||||
}
|
||||
@@ -62,12 +62,11 @@ module.exports = {
|
||||
appPackageJson: resolveApp('package.json'),
|
||||
appSrc: resolveApp('Desktop/src'),
|
||||
appNodeModules: resolveApp('node_modules'),
|
||||
globals: resolveApp('Desktop/UI/Globals'),
|
||||
projects: resolveApp('Projects'),
|
||||
environment: resolveApp('Environments'),
|
||||
schema: resolveApp('Projects/ProjectsSchema'),
|
||||
publicUrlOrPath,
|
||||
};
|
||||
|
||||
/* globals: resolveApp('Desktop/UI/Globals'),
|
||||
projects: resolveApp('Projects'),
|
||||
environment: resolveApp('Environments'),
|
||||
schema: resolveApp('Projects/ProjectsSchema'),*/
|
||||
|
||||
module.exports.moduleFileExtensions = moduleFileExtensions;
|
||||
@@ -6,10 +6,8 @@
|
||||
<meta name="description" content="Free and Open Source Crypto Social Trading">
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"/>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function loadApp() {
|
||||
// Prevent click-jacking
|
||||
|
||||
Reference in new issue
Block a user