Added webAppServer features
This commit is contained in:
parent
1396012858
commit
02ae6936d4
157
index.html
157
index.html
@ -504,11 +504,13 @@
|
|||||||
|
|
||||||
//for cloud apps
|
//for cloud apps
|
||||||
subAdmins: [],
|
subAdmins: [],
|
||||||
|
webAppURL: "167.172.219.249:8368",
|
||||||
application: "TestApp",
|
application: "TestApp",
|
||||||
vectorClock: {},
|
vectorClock: {},
|
||||||
appObjects: {},
|
appObjects: {},
|
||||||
generalData: {},
|
generalData: {},
|
||||||
generalVC: {}
|
generalVC: {}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -1059,7 +1061,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
// Constructor function of Global SecureRandom object
|
// Constructor function of Global SecureRandom object
|
||||||
var sr = window.SecureRandom = function () {};
|
var sr = window.SecureRandom = function () { };
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
sr.state;
|
sr.state;
|
||||||
@ -2935,7 +2937,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// A "null" reducer
|
// A "null" reducer
|
||||||
var NullExp = window.NullExp = function NullExp() {}
|
var NullExp = window.NullExp = function NullExp() { }
|
||||||
NullExp.prototype.convert = function (x) {
|
NullExp.prototype.convert = function (x) {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
@ -3026,7 +3028,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
// Constructor function of Global EllipticCurve object
|
// Constructor function of Global EllipticCurve object
|
||||||
var ec = window.EllipticCurve = function () {};
|
var ec = window.EllipticCurve = function () { };
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
// ECFieldElementFp constructor
|
// ECFieldElementFp constructor
|
||||||
@ -3173,8 +3175,8 @@
|
|||||||
|
|
||||||
// No-operation padding, used for stream ciphers
|
// No-operation padding, used for stream ciphers
|
||||||
C_pad.NoPadding = {
|
C_pad.NoPadding = {
|
||||||
pad: function (cipher, message) {},
|
pad: function (cipher, message) { },
|
||||||
unpad: function (cipher, message) {}
|
unpad: function (cipher, message) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Zero Padding.
|
// Zero Padding.
|
||||||
@ -4972,7 +4974,7 @@
|
|||||||
//bitTrx.js
|
//bitTrx.js
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
var bitjs = window.bitjs = function () {};
|
var bitjs = window.bitjs = function () { };
|
||||||
|
|
||||||
/* public vars */
|
/* public vars */
|
||||||
bitjs.pub = 0x23; // flochange - changed the prefix to FLO Mainnet PublicKey Prefix 0x23
|
bitjs.pub = 0x23; // flochange - changed the prefix to FLO Mainnet PublicKey Prefix 0x23
|
||||||
@ -5994,7 +5996,7 @@
|
|||||||
if (pubkey.getBitcoinAddress().toString() == address) {
|
if (pubkey.getBitcoinAddress().toString() == address) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
}
|
}
|
||||||
throw "Unable to find valid recovery factor";
|
throw "Unable to find valid recovery factor";
|
||||||
}
|
}
|
||||||
@ -6531,7 +6533,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
// duck typing method
|
// duck typing method
|
||||||
hasMethods: function (obj /*, method list as strings */ ) {
|
hasMethods: function (obj /*, method list as strings */) {
|
||||||
var i = 1,
|
var i = 1,
|
||||||
methodName;
|
methodName;
|
||||||
while ((methodName = arguments[i++])) {
|
while ((methodName = arguments[i++])) {
|
||||||
@ -6547,7 +6549,7 @@
|
|||||||
(function (ellipticCurveType) {
|
(function (ellipticCurveType) {
|
||||||
|
|
||||||
//Defining Elliptic Encryption Object
|
//Defining Elliptic Encryption Object
|
||||||
var ellipticEncryption = window.ellipticCurveEncryption = function () {};
|
var ellipticEncryption = window.ellipticCurveEncryption = function () { };
|
||||||
|
|
||||||
ellipticEncryption.rng = new SecureRandom();
|
ellipticEncryption.rng = new SecureRandom();
|
||||||
|
|
||||||
@ -7138,7 +7140,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
product = (product + config.logs[at ^ x[j]] - config.logs[x[i] ^ x[j]] + config
|
product = (product + config.logs[at ^ x[j]] - config.logs[x[i] ^ x[j]] + config
|
||||||
.max /* to make sure it's not negative */ ) %
|
.max /* to make sure it's not negative */) %
|
||||||
config.max;
|
config.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9728,27 +9730,74 @@
|
|||||||
reactor.addEventListener("startUpErrorLog", log => console.error(log))
|
reactor.addEventListener("startUpErrorLog", log => console.error(log))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script id="webAppClient">
|
||||||
// helper functions
|
//Add this to the client script to request data from floWebappServer
|
||||||
(async () => {
|
const webAppClient = {
|
||||||
let repourl = "https://api.github.com/repos/ranchimall/articles/contents"
|
util: {
|
||||||
let repocontent = null
|
|
||||||
window.articles = {}
|
|
||||||
window.parsedarticles = {}
|
|
||||||
|
|
||||||
repocontent = await (await fetch(repourl)).json();
|
requestData(request = []) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var websocket = new WebSocket("ws://" + floGlobals.webAppURL + "/ws");
|
||||||
|
websocket.onmessage = (evt => {
|
||||||
|
if (evt.data == '$+') {
|
||||||
|
websocket.send(`?${JSON.stringify(request)}`);
|
||||||
|
} else if (evt.data == '$-') {
|
||||||
|
reject(`webApp not available`)
|
||||||
|
websocket.close()
|
||||||
|
} else {
|
||||||
|
resolve(JSON.parse(evt.data));
|
||||||
|
websocket.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
websocket.onerror = (evt) => {
|
||||||
|
reject(`webApp server not found`)
|
||||||
|
};
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
for (let i = 0; i < repocontent.length; i++) {
|
requestGeneralData: function (type, vectorClock = '0') {
|
||||||
articlehtml = await (await fetch(repocontent[i]["download_url"])).text()
|
if (typeof vectorClock !== 'string')
|
||||||
if (repocontent[i]['name'].slice(-5, repocontent[i]['name'].length) == '.html' && repocontent[i]['name'].slice(0, -5) != 'index') {
|
vectorClock.toString()
|
||||||
articles[repocontent[i]['name'].slice(0, repocontent[i]['name'].length - 5)] = articlehtml
|
return new Promise((resolve, reject) => {
|
||||||
|
this.util.requestData([floGlobals.application, 'generalData', type, vectorClock])
|
||||||
|
.then(
|
||||||
|
result => {
|
||||||
|
if (result[0])
|
||||||
|
resolve(result[1])
|
||||||
|
else
|
||||||
|
reject(result[1])
|
||||||
|
}).catch(error => reject(error))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
requestObjectData: function (keyPath) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.util.requestData([floGlobals.application, 'appObjects'].concat(keyPath)).then(
|
||||||
|
result => {
|
||||||
|
if (result[0])
|
||||||
|
resolve(result[1])
|
||||||
|
else
|
||||||
|
reject(result[1])
|
||||||
|
}).catch(error => reject(error))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
requestSubAdminList: function () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.util.requestData([floGlobals.application, 'subAdmins']).then(
|
||||||
|
result => {
|
||||||
|
if (result[0])
|
||||||
|
resolve(result[1])
|
||||||
|
else
|
||||||
|
reject(result[1])
|
||||||
|
}).catch(error => reject(error))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
parseArticles(articles)
|
<script id="onLoadStartUp">
|
||||||
renderColumns(parsedarticles)
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
async function fetchArticleDetails() {
|
async function fetchArticleDetails() {
|
||||||
let applicants = await floCloudAPI.requestGeneralData('test')
|
let applicants = await floCloudAPI.requestGeneralData('test')
|
||||||
@ -9792,9 +9841,10 @@
|
|||||||
numberOfColumns = Object.keys(parsedarticles).length
|
numberOfColumns = Object.keys(parsedarticles).length
|
||||||
let columns = document.getElementById('columnsmain')
|
let columns = document.getElementById('columnsmain')
|
||||||
let parsedArticlesKeys = Object.keys(parsedarticles)
|
let parsedArticlesKeys = Object.keys(parsedarticles)
|
||||||
|
let map_articlekey_column = {}
|
||||||
|
|
||||||
for (let i = 0; i < parsedArticlesKeys.length; i++) {
|
for (let i = 0; i < parsedArticlesKeys.length; i++) {
|
||||||
columnhtml = `<div class="column" id="column${i+1}" data-articlekey="${parsedArticlesKeys[i]}">
|
columnhtml = `<div class="column" id="column${i + 1}" data-articlekey="${parsedArticlesKeys[i]}">
|
||||||
<div class="head">
|
<div class="head">
|
||||||
<span class="headline hl3">${parsedarticles[parsedArticlesKeys[i]].title}</span>
|
<span class="headline hl3">${parsedarticles[parsedArticlesKeys[i]].title}</span>
|
||||||
<p><span class="headline hl4">${parsedarticles[parsedArticlesKeys[i]].subtitle}</span></p>
|
<p><span class="headline hl4">${parsedarticles[parsedArticlesKeys[i]].subtitle}</span></p>
|
||||||
@ -9803,14 +9853,17 @@
|
|||||||
<span><a href='./${parsedArticlesKeys[i]}.html'>Read article
|
<span><a href='./${parsedArticlesKeys[i]}.html'>Read article
|
||||||
<i class="fa fa-angle-double-right" aria-hidden="true"></i>
|
<i class="fa fa-angle-double-right" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
<span style="float:right"><span id="column${i+1}_count"></span><i class="fa fa-thumbs-o-up" aria-hidden="true" style="padding-left:0.5rem; cursor:pointer" id="column${i+1}_thumbs" onclick="clickProcess(this)"></i></span>
|
<span style="float:right"><span id="column${i + 1}_count"></span><i class="fa fa-thumbs-o-up" aria-hidden="true" style="padding-left:0.5rem; cursor:pointer" id="column${i + 1}_thumbs" onclick="clickProcess(this)"></i></span>
|
||||||
<span>
|
<span>
|
||||||
|
|
||||||
</div>`
|
</div>`
|
||||||
//columns.append(columnhtml)
|
//columns.append(columnhtml)
|
||||||
columns.innerHTML += columnhtml
|
columns.innerHTML += columnhtml
|
||||||
|
map_articlekey_column[parsedArticlesKeys[i]] = `column${i + 1}`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return map_articlekey_column
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchtoArticle(element) {
|
function switchtoArticle(element) {
|
||||||
@ -9864,9 +9917,8 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
|
|
||||||
<script id="onLoadStartUp">
|
|
||||||
function updateVotes(articles_votesmapping, map_articlekey_column) {
|
function updateVotes(articles_votesmapping, map_articlekey_column) {
|
||||||
|
|
||||||
var articleKeys = Object.keys(map_articlekey_column)
|
var articleKeys = Object.keys(map_articlekey_column)
|
||||||
@ -9878,6 +9930,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let repourl = "https://api.github.com/repos/ranchimall/articles/contents"
|
||||||
|
|
||||||
|
Promise.all([fetch(repourl), webAppClient.requestGeneralData('test')]).then(async (values) => {
|
||||||
|
|
||||||
|
let repocontent = null
|
||||||
|
window.articles = {}
|
||||||
|
window.parsedarticles = {}
|
||||||
|
|
||||||
|
repocontent = await values[0].json()
|
||||||
|
|
||||||
|
for (let i = 0; i < repocontent.length; i++) {
|
||||||
|
articlehtml = await (await fetch(repocontent[i]["download_url"])).text()
|
||||||
|
if (repocontent[i]['name'].slice(-5, repocontent[i]['name'].length) == '.html' && repocontent[i]['name'].slice(0, -5) != 'index') {
|
||||||
|
articles[repocontent[i]['name'].slice(0, repocontent[i]['name'].length - 5)] = articlehtml
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parseArticles(articles)
|
||||||
|
let map_articlekey_column = renderColumns(parsedarticles)
|
||||||
|
let articleInfo = values[1]
|
||||||
|
let articles_votesmapping = {}
|
||||||
|
|
||||||
|
for (let i = 0; i < articleInfo.length; i++) {
|
||||||
|
|
||||||
|
let article_message = JSON.parse(articleInfo[i].message)
|
||||||
|
|
||||||
|
if (!(article_message.articlekey in articles_votesmapping)) {
|
||||||
|
articles_votesmapping[article_message.articlekey] = 1
|
||||||
|
} else {
|
||||||
|
articles_votesmapping[article_message.articlekey]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateVotes(articles_votesmapping, map_articlekey_column)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
let myCustomLogin = function () {
|
let myCustomLogin = function () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
@ -9894,9 +9986,8 @@
|
|||||||
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
|
||||||
floDapps.setCustomPrivKeyInput(myCustomLogin);
|
floDapps.setCustomPrivKeyInput(myCustomLogin);
|
||||||
|
|
||||||
floCloudAPI.requestGeneralData('test');
|
|
||||||
|
|
||||||
floDapps.launchStartUp().then(result => {
|
floDapps.launchStartUp().then(result => {
|
||||||
|
|
||||||
document.getElementById("login-button").style.display = 'none'
|
document.getElementById("login-button").style.display = 'none'
|
||||||
document.getElementById("user-button").style.display = 'initial'
|
document.getElementById("user-button").style.display = 'initial'
|
||||||
console.log(result)
|
console.log(result)
|
||||||
@ -9943,9 +10034,9 @@
|
|||||||
updateVotes(articles_votesmapping, map_articlekey_column)
|
updateVotes(articles_votesmapping, map_articlekey_column)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}).catch(error => console.error(error))
|
}).catch(error => console.error(error))
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user