aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2022-11-15 03:16:32 +0200
committerkaotisk <kaotisk@arching-kaos.org>2022-11-15 03:16:32 +0200
commit5349871a810d7d53a73897e240b0bb6747fdda26 (patch)
treef8034b7522f6f8b1f9517b85075e79017919cfcd /src/js
parent7f1eafddc704574be97cc25ad24957040a7bca21 (diff)
downloadarching-kaos-web-ui-5349871a810d7d53a73897e240b0bb6747fdda26.tar.gz
arching-kaos-web-ui-5349871a810d7d53a73897e240b0bb6747fdda26.tar.bz2
arching-kaos-web-ui-5349871a810d7d53a73897e240b0bb6747fdda26.zip
Fixed border line in logo, fixed ident in app.js and added some failsafe...v0.1.0
Diffstat (limited to 'src/js')
-rw-r--r--src/js/app.js1459
1 files changed, 735 insertions, 724 deletions
diff --git a/src/js/app.js b/src/js/app.js
index 906dd73..e37a01a 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -1,771 +1,782 @@
- var progressPlaceholder = document.querySelector('#total-progress');
- var logtextPlaceholder = document.querySelector('#logtext');
- progressPlaceholder.value = '0';
- /*
- * Show and hide the menu
- */
- function hsm(){
- var m = document.querySelector('.sidebar');
- var t = document.querySelector('.hsm');
- var c = document.querySelector('.main');
- if (m.hidden===true){
- m.hidden=false;
- t.innerHTML = "Hide menu";
- c.style.maxWidth = "100vw"
- c.style.left = "27vw";
- } else {
- m.hidden=true;
- t.innerHTML = "Show menu";
- c.style.maxWidth = "100vw";
- c.style.left = "1vw";
- }
+var progressPlaceholder = document.querySelector('#total-progress');
+var logtextPlaceholder = document.querySelector('#logtext');
+progressPlaceholder.value = '0';
+/*
+ * Show and hide the menu
+ */
+function hsm(){
+ var m = document.querySelector('.sidebar');
+ var t = document.querySelector('.hsm');
+ var c = document.querySelector('.main');
+ if (m.hidden===true){
+ m.hidden=false;
+ t.innerHTML = "Hide menu";
+ c.style.maxWidth = "100vw"
+ c.style.left = "27vw";
+ } else {
+ m.hidden=true;
+ t.innerHTML = "Show menu";
+ c.style.maxWidth = "100vw";
+ c.style.left = "1vw";
}
+}
- var profilemenuids = [];
- /*
- * Array of all the menu-panes IDs
- */
- var menuids = ['#welcome-section','#about-section','#zchain-data-section','#news-section','#stats-section','#mixtapes-section','#chat-section','#mypage-section','#stellar-balances','#stellar-data-config','#arching-kaos-id', '#loading-status', '#files-section'];
- // Function to hide all the panes
- function menuinit(){
- menuids.forEach(m=>document.querySelector(m).hidden=true);
- }
- // And call
- menuinit();
- // We bring up the default pane ( #welcome-section )
- document.querySelector('#welcome-section').hidden=false;
+var profilemenuids = [];
+/*
+ * Array of all the menu-panes IDs
+ */
+var menuids = ['#welcome-section','#about-section','#zchain-data-section','#news-section','#stats-section','#mixtapes-section','#chat-section','#mypage-section','#stellar-balances','#stellar-data-config','#arching-kaos-id', '#loading-status', '#files-section'];
+// Function to hide all the panes
+function menuinit(){
+ menuids.forEach(m=>document.querySelector(m).hidden=true);
+}
+// And call
+menuinit();
+// We bring up the default pane ( #welcome-section )
+document.querySelector('#welcome-section').hidden=false;
- /*
- * Function called on clicks on the menu bar
- * Unhides the pane connected to the clicked menu entry
- */
- function menusel(m){
- menuinit();
- document.querySelector(m.hash).hidden=false;
- }
+/*
+ * Function called on clicks on the menu bar
+ * Unhides the pane connected to the clicked menu entry
+ */
+function menusel(m){
+ menuinit();
+ document.querySelector(m.hash).hidden=false;
+}
- // Here we store the participants found
- var participants = [];
+// Here we store the participants found
+var participants = [];
- // loading-status element
- var lse = document.querySelector("#loading-status");
- /*
- * Get Trustlines for ARCHINGKAOS asset
- * Returns DOM element with number of trustlines
- */
- function gettrustlines(){
- var sta = document.createElement("pre");
- sta.innerHTML = "Loading trustlines...";
- logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- var url='https://horizon.stellar.org/assets?asset_code=ARCHINGKAOS&asset_issuer=GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2';
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- var stats = document.querySelector('#stats-section')
- var small = document.createElement("small")
- small.innerHTML = 'Connected trustlines: ' + json._embedded.records[0].accounts.authorized
- stats.appendChild(small)
- })
- }
- sta.innerHTML+=" Done!"
- logtextPlaceholder.innerHTML = sta.innerHTML;
- progressPlaceholder.max++;
- progressPlaceholder.value++;
- })
- }
- gettrustlines()
- /*
- * Get addresses that trust the asset
- * Limit is 200 addresses cause horizon API limitations.
- *
- * TODO: Crawl through the pagination
- *
- * Returns div DOM elements for each found address, embedding
- * the address both in innerHTML and in id of the div.
- */
- function getholders(a=0){
- var sta = document.createElement("pre");
- sta.innerHTML = "Searching holders..."
+// loading-status element
+var lse = document.querySelector("#loading-status");
+/*
+ * Get Trustlines for ARCHINGKAOS asset
+ * Returns DOM element with number of trustlines
+ */
+function gettrustlines(){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Loading trustlines...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ var url='https://horizon.stellar.org/assets?asset_code=ARCHINGKAOS&asset_issuer=GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2';
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ var stats = document.querySelector('#stats-section')
+ var small = document.createElement("small")
+ small.innerHTML = 'Connected trustlines: ' + json._embedded.records[0].accounts.authorized
+ stats.appendChild(small)
+ })
+ }
+ sta.innerHTML+=" Done!"
logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- var url='https://horizon.stellar.org/accounts?asset=ARCHINGKAOS:GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2&limit=200'
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- var stats = document.querySelector('#stats-section')
- json._embedded.records.forEach(r=>{
- var p = document.createElement("div")
- p.innerHTML = r.account_id
- p.id = r.account_id
- checkforconfig(r.account_id)
- stats.appendChild(p)
- })
- // if (json._links.next) getholders(json._links.next.href)
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ })
+}
+gettrustlines()
+/*
+ * Get addresses that trust the asset
+ * Limit is 200 addresses cause horizon API limitations.
+ *
+ * TODO: Crawl through the pagination
+ *
+ * Returns div DOM elements for each found address, embedding
+ * the address both in innerHTML and in id of the div.
+ */
+function getholders(a=0){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Searching holders..."
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ var url='https://horizon.stellar.org/accounts?asset=ARCHINGKAOS:GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2&limit=200'
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ var stats = document.querySelector('#stats-section')
+ json._embedded.records.forEach(r=>{
+ var p = document.createElement("div")
+ p.innerHTML = r.account_id
+ p.id = r.account_id
+ checkforconfig(r.account_id)
+ stats.appendChild(p)
})
- }
- })
- sta.innerHTML+=" Done"
- logtextPlaceholder.innerHTML = sta.innerHTML;
+ // if (json._links.next) getholders(json._links.next.href)
+ })
+ }
+ })
+ sta.innerHTML+=" Done"
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+}
+getholders()
+
+/*
+ * Function that checks the address' variable 'config' to see
+ * if it's set up.
+ *
+ * Returns the IPNS link in the DOM as p element and proceeds to
+ * get nickname from the variables
+ */
+function checkforconfig(addr) {
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Checking configuration for "+ addr+ "..."
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ url='https://horizon.stellar.org/accounts/'+addr+'/data/config'
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ var cnf = document.createElement("p")
+ if(document.querySelector("#stellar-data-config-not-found")) document.querySelector("#stellar-data-config-not-found").hidden = true;
+ cnf.innerHTML = atob(json.value)
+ document.querySelector('#'+addr).appendChild(cnf)
+ document.querySelector('#'+addr).style="color: #3dbb3d;"
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ getnickname(atob(json.value),addr)
+ })
+ }
+ })
+}
+
+/*
+ * Function that gets nickname and parses the config variable.
+ *
+ * Returns the key:value pairs of the configuration and proceeds
+ * to get the zchain
+ */
+function getnickname(a,eid){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Parsing the configuration..."
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ url='https://ipfs.arching-kaos.com/ipns/'+a
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ /* Could be json object with
+ * - genesis
+ * - gpg
+ * - profile {
+ * - nickname
+ * }
+ * - zchain
+ */
+ var divs = document.querySelector('#'+eid)
+ if(json.genesis){
+ var p = document.createElement("p")
+ p.innerHTML="Genesis: " +json.genesis
+ divs.appendChild(p)
+ }
+ if(json.gpg){
+ var p = document.createElement("p")
+ p.innerHTML="GPG: " +json.gpg
+ divs.appendChild(p)
+ }
+ if(json.profile.nickname){
+ var p = document.createElement("p")
+ p.innerHTML="Nickname: " +json.profile.nickname
+ divs.appendChild(p)
+ }
+ if(json.zchain){
+ var p = document.createElement("p")
+ p.innerHTML="zchain: " +json.zchain
+ divs.appendChild(p)
+ }
+ participants[eid]=json;
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ zseek(json.zchain);
+ })
+ }
+ })
+}
+
+/*
+ * We now connect our client to horizon
+ */
+var server = new StellarSdk.Server('https://horizon.stellar.org');
+// We ask for the 'a' stellar address the balances
+function letme(a){
+ server.accounts()
+ .accountId(a)
+ .call().then(function(r){ const L = r; putit(r); });
+}
+// We print them
+function putit(i){
+ var ta=document.querySelector("#stellar-balances-table");
+ readit(i);
+ for (b in i.balances) {
+ var row = document.createElement("tr");
+ x = i.balances[b];
+ var amount = document.createElement("td");
+ var assetCode = document.createElement("td");
+ amount.innerHTML = x.balance;
+ assetCode.innerHTML = ( x.asset_code && x.asset_code != "undefined" ? x.asset_code : 'XLM');
+ row.appendChild(assetCode);
+ row.appendChild(amount);
+ ta.appendChild(row);
progressPlaceholder.max++;
progressPlaceholder.value++;
+ if(document.querySelector("#stellar-balances-not-found")) document.querySelector("#stellar-balances-not-found").hidden = true;
}
- getholders()
+}
+// We also search for a config file and display it
+async function dataf(i){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Loading your profile...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ url='https://horizon.stellar.org/accounts/'+i+'/data/config'
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ var cnf = document.createElement("p");
+ cnf.innerHTML = atob(json.value);
+ document.querySelector('#stellar-data-config').appendChild(cnf);
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ akiseek(atob(json.value));
+ })
+ }
+ })
+}
+// Although we implemented something similar already,
+// it seems like I was not happy so JRM
+// #TODO : Revisit this
- /*
- * Function that checks the address' variable 'config' to see
- * if it's set up.
- *
- * Returns the IPNS link in the DOM as p element and proceeds to
- * get nickname from the variables
- */
- function checkforconfig(addr) {
- var sta = document.createElement("pre");
- sta.innerHTML = "Checking configuration for "+ addr+ "..."
- logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- url='https://horizon.stellar.org/accounts/'+addr+'/data/config'
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- var cnf = document.createElement("p")
- if(document.querySelector("#stellar-data-config-not-found")) document.querySelector("#stellar-data-config-not-found").hidden = true;
- cnf.innerHTML = atob(json.value)
- document.querySelector('#'+addr).appendChild(cnf)
- document.querySelector('#'+addr).style="color: #3dbb3d;"
- progressPlaceholder.max++;
- progressPlaceholder.value++;
- getnickname(atob(json.value),addr)
- })
- }
- })
- }
+/*
+ * Function to seek configuration for any address i
+ * it's used to seek specifically the Freighter user's address.
+ *
+ * Returns p DOM elements on #arching-kaos-id pane
+ */
+function akiseek(i){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Parsing AKID...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ url='https://ipfs.arching-kaos.com/ipns/'+i;
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ /* Could be json object with
+ * - genesis
+ * - gpg
+ * - profile {
+ * - nickname
+ * }
+ * - zchain
+ */
+ var divs = document.querySelector('#arching-kaos-id');
+ if(json.genesis){
+ var p = document.createElement("p");
+ p.innerHTML="Genesis: " +json.genesis;
+ divs.appendChild(p);
+ }
+ if(json.gpg){
+ var p = document.createElement("p");
+ p.innerHTML="GPG: " +json.gpg;
+ divs.appendChild(p);
+ }
+ if(json.profile.nickname){
+ var p = document.createElement("p");
+ p.innerHTML="Nickname: " +json.profile.nickname;
+ divs.appendChild(p);
+ }
+ if(json.zchain){
+ var p = document.createElement("p");
+ p.innerHTML="zchain: " +json.zchain;
+ divs.appendChild(p);
+ }
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ zseek(json.zchain,eid,json);
+ })
+ }
+ })
+}
+/*
+ * Function to seek Zblocks
+ *
+ * Returns Block and Signature for each ZBLOCK found.
+ *
+ * Proceeds to the blocks found.
+ */
+function zseek(i,d,j){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Seeking zchain "+i+"...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ var divs = document.querySelector('#zchain-data-section');
+ var details = document.createElement("details");
+ details.id = 'zd-' + i;
+ divs.appendChild(details);
- /*
- * Function that gets nickname and parses the config variable.
- *
- * Returns the key:value pairs of the configuration and proceeds
- * to get the zchain
- */
- function getnickname(a,eid){
- var sta = document.createElement("pre");
- sta.innerHTML = "Parsing the configuration..."
- logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- url='https://ipfs.arching-kaos.com/ipns/'+a
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- /* Could be json object with
- * - genesis
- * - gpg
- * - profile {
- * - nickname
- * }
- * - zchain
- */
- var divs = document.querySelector('#'+eid)
- if(json.genesis){
- var p = document.createElement("p")
- p.innerHTML="Genesis: " +json.genesis
- divs.appendChild(p)
- }
- if(json.gpg){
- var p = document.createElement("p")
- p.innerHTML="GPG: " +json.gpg
- divs.appendChild(p)
- }
- if(json.profile.nickname){
- var p = document.createElement("p")
- p.innerHTML="Nickname: " +json.profile.nickname
- divs.appendChild(p)
- }
- if(json.zchain){
- var p = document.createElement("p")
- p.innerHTML="zchain: " +json.zchain
- divs.appendChild(p)
- }
- participants[eid]=json;
- progressPlaceholder.max++;
- progressPlaceholder.value++;
- zseek(json.zchain);
- })
- }
- })
+ if(i){
+ var p = document.createElement("summary");
+ p.innerHTML="zchain: " +i;
+ details.appendChild(p);
}
+ lse.appendChild(sta);
+ url = 'https://ipfs.arching-kaos.com/ipns/'+i;
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ /* Could be json object with
+ * - block
+ * - block_signature
+ */
+ var divs = document.querySelector('#zchain-data-section');
+ if(json.block){
+ var p = document.createElement("p");
+ p.innerHTML="Block: " +json.block;
+ details.appendChild(p);
+ }
+ if(json.block_signature){
+ var p = document.createElement("p");
+ p.innerHTML="Signature: " +json.block_signature;
+ details.appendChild(p);
+ }
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ seekblock(json.block,i,d,j);
+ })
+ }
+ })
+}
- /*
- * We now connect our client to horizon
- */
- var server = new StellarSdk.Server('https://horizon.stellar.org');
- // We ask for the 'a' stellar address the balances
- function letme(a){
- server.accounts()
- .accountId(a)
- .call().then(function(r){ const L = r; putit(r); });
- }
- // We print them
- function putit(i){
- var ta=document.querySelector("#stellar-balances-table");
- readit(i);
- for (b in i.balances) {
- var row = document.createElement("tr");
- x = i.balances[b];
- var amount = document.createElement("td");
- var assetCode = document.createElement("td");
- amount.innerHTML = x.balance;
- assetCode.innerHTML = ( x.asset_code && x.asset_code != "undefined" ? x.asset_code : 'XLM');
- row.appendChild(assetCode);
- row.appendChild(amount);
- ta.appendChild(row);
- progressPlaceholder.max++;
- progressPlaceholder.value++;
- if(document.querySelector("#stellar-balances-not-found")) document.querySelector("#stellar-balances-not-found").hidden = true;
+/*
+ * Seeks a block and parses it.
+ *
+ * Returns each element found in #zchain-data-section pane.
+ *
+ * Proceeds to execute the block.
+ */
+function seekblock(i,l,d,j){
+ console.log(i,l,d,j);
+ console.log(l);
+ detailsPlace = document.querySelector('#zd-'+l);
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Seeking block "+i+"...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ url = 'https://ipfs.arching-kaos.com/ipfs/'+i;
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
}
- }
- // We also search for a config file and display it
- async function dataf(i){
- var sta = document.createElement("pre");
- sta.innerHTML = "Loading your profile...";
- logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- url='https://horizon.stellar.org/accounts/'+i+'/data/config'
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- var cnf = document.createElement("p");
- cnf.innerHTML = atob(json.value);
- document.querySelector('#stellar-data-config').appendChild(cnf);
- progressPlaceholder.max++;
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ /* Could be json object with
+ * - action
+ * - data
+ * - gpg
+ * - timestamp
+ * - previous
+ * - detach
+ */
+ var divs = document.querySelector('#zchain-data-section');
+ if(json.action){
+ var p = document.createElement("p");
+ p.innerHTML="Action: " +json.action;
+ if(detailsPlace!== null) detailsPlace.appendChild(p);
+ }
+ if(json.detach){
+ var p = document.createElement("p");
+ p.innerHTML="Detach: " +json.detach;
+ if(detailsPlace!== null) detailsPlace.appendChild(p);
+ }
+ if(json.gpg){
+ var p = document.createElement("p");
+ p.innerHTML="GPG: " +json.gpg;
+ if(detailsPlace!== null) detailsPlace.appendChild(p);
+ }
+ if(json.data){
+ var p = document.createElement("p");
+ var a = document.createElement("a");
+ a.href = 'https://ipfs.arching-kaos.com/ipfs/'+json.data;
+ a.innerHTML = json.data;
+ p.innerHTML="Data: ";
+ p.appendChild(a);
+ if(detailsPlace!== null) detailsPlace.appendChild(p);
+ }
+ if(json.timestamp){
+ var p = document.createElement("p");
+ p.innerHTML="Timestamp: " +json.timestamp;
+ if(detailsPlace!== null) detailsPlace.appendChild(p);
+ }
+ if(json.previous){
+ var p = document.createElement("p");
+ p.innerHTML="Previous: " +json.previous;
+ if(detailsPlace!== null) detailsPlace.appendChild(p);
+ }
+ if(detailsPlace!== null) detailsPlace.appendChild(document.createElement("hr"));
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ exe(json.action,json.data,json,l,d,j);
+ if(json.previous!="QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH"){
+ seekzblock(json.previous);
+ } else {
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Reached genesis link: "+json.previous+"!";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
progressPlaceholder.value++;
- akiseek(atob(json.value));
- })
- }
- })
- }
- // Although we implemented something similar already,
- // it seems like I was not happy so JRM
- // #TODO : Revisit this
+ }
+ })
+ }
+ })
+}
- /*
- * Function to seek configuration for any address i
- * it's used to seek specifically the Freighter user's address.
- *
- * Returns p DOM elements on #arching-kaos-id pane
- */
- function akiseek(i){
- var sta = document.createElement("pre");
- sta.innerHTML = "Parsing AKID...";
- logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- url='https://ipfs.arching-kaos.com/ipns/'+i;
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- /* Could be json object with
- * - genesis
- * - gpg
- * - profile {
- * - nickname
- * }
- * - zchain
- */
- var divs = document.querySelector('#arching-kaos-id');
- if(json.genesis){
- var p = document.createElement("p");
- p.innerHTML="Genesis: " +json.genesis;
- divs.appendChild(p);
- }
- if(json.gpg){
- var p = document.createElement("p");
- p.innerHTML="GPG: " +json.gpg;
- divs.appendChild(p);
- }
- if(json.profile.nickname){
- var p = document.createElement("p");
- p.innerHTML="Nickname: " +json.profile.nickname;
- divs.appendChild(p);
- }
- if(json.zchain){
- var p = document.createElement("p");
- p.innerHTML="zchain: " +json.zchain;
- divs.appendChild(p);
- }
- progressPlaceholder.max++;
- progressPlaceholder.value++;
- zseek(json.zchain,eid,json);
- })
- }
- })
+// seeks a zblock obviously. another double function
+// TODO: figure out why the second one exists
+
+/*
+ * Function gets ZBLOCK and parses it
+ *
+ * Returns Block and Signature elements on DOM as p
+ *
+ * Proceeds to seek the block found
+ */
+function seekzblock(i){
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Seeking ZBLOCK "+i+"...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ var divs = document.querySelector('#zchain-data-section');
+ if (document.querySelector("#zchain-data-sec-not-found")) document.querySelector("#zchain-data-sec-not-found").hidden=true;
+ if(i){
+ var p = document.createElement("p");
+ p.innerHTML="zblock: " +i;
+ divs.appendChild(p);
}
- /*
- * Function to seek Zblocks
- *
- * Returns Block and Signature for each ZBLOCK found.
- *
- * Proceeds to the blocks found.
- */
- function zseek(i,d,j){
- var sta = document.createElement("pre");
- sta.innerHTML = "Seeking zchain "+i+"...";
- logtextPlaceholder.innerHTML = sta.innerHTML;
- var divs = document.querySelector('#zchain-data-section');
- if(i){
- var p = document.createElement("p");
- p.innerHTML="zchain: " +i;
- divs.appendChild(p);
+ lse.appendChild(sta);
+ url = 'https://ipfs.arching-kaos.com/ipfs/'+i;
+ fetch(url, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
}
- lse.appendChild(sta);
- url = 'https://ipfs.arching-kaos.com/ipns/'+i;
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- /* Could be json object with
- * - block
- * - block_signature
- */
- var divs = document.querySelector('#zchain-data-section');
- if(json.block){
- var p = document.createElement("p");
- p.innerHTML="Block: " +json.block;
- divs.appendChild(p);
- }
- if(json.block_signature){
- var p = document.createElement("p");
- p.innerHTML="Signature: " +json.block_signature;
- divs.appendChild(p);
- }
- progressPlaceholder.max++;
- progressPlaceholder.value++;
- seekblock(json.block,i,d,j);
- })
- }
- })
- }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ /* Could be json object with
+ * - block
+ * - block_signature
+ */
+ var divs = document.querySelector('#zchain-data-section');
+ if(json.block){
+ var p = document.createElement("p");
+ p.innerHTML="Block: " +json.block;
+ p.id=i;
+ divs.appendChild(p);
+ }
+ if(json.block_signature){
+ var p = document.createElement("p");
+ p.innerHTML="Signature: " +json.block_signature;
+ divs.appendChild(p);
+ }
+ progressPlaceholder.max++;
+ progressPlaceholder.value++;
+ seekblock(json.block,i);
+ })
+ }
+ })
+}
- /*
- * Seeks a block and parses it.
- *
- * Returns each element found in #zchain-data-section pane.
- *
- * Proceeds to execute the block.
- */
- function seekblock(i,l,d,j){
- console.log(i,l,d,j);
- var sta = document.createElement("pre");
- sta.innerHTML = "Seeking block "+i+"...";
- logtextPlaceholder.innerHTML = sta.innerHTML;
- lse.appendChild(sta);
- url = 'https://ipfs.arching-kaos.com/ipfs/'+i;
- fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
- }
- }).then(response=>{
- if(response.ok){
- response.json().then(json=>{
- /* Could be json object with
- * - action
- * - data
- * - gpg
- * - timestamp
- * - previous
- * - detach
- */
- var divs = document.querySelector('#zchain-data-section');
- if(json.action){
- var p = document.createElement("p");
- p.innerHTML="Action: " +json.action;
- divs.appendChild(p);
- }
- if(json.detach){
- var p = document.createElement("p");
- p.innerHTML="Detach: " +json.detach;
- divs.appendChild(p);
- }
- if(json.gpg){
- var p = document.createElement("p");
- p.innerHTML="GPG: " +json.gpg;
- divs.appendChild(p);
+/*
+ * Function that executes a specified block
+ *
+ * Returns the result of execution on the proper page in DOM
+ */
+function exe(a,d,j,x,y,z){
+ console.log("Executing...",a,d,j,x,y,z)
+ var sta = document.createElement("pre");
+ sta.innerHTML = "Executing block "+d+"...";
+ logtextPlaceholder.innerHTML = sta.innerHTML;
+ lse.appendChild(sta);
+ gurl = 'https://ipfs.arching-kaos.com/ipfs/'
+ fetch(gurl+d, {
+ method:'GET',
+ headers:{
+ Accept: 'application/json'
+ }
+ }).then(response=>{
+ if(response.ok){
+ response.json().then(json=>{
+ /* Could be json object with
+ * - block
+ * - block_signature
+ */
+ if (a == "files/add") {
+ var divs = document.querySelector('#files-section');
+ var art = document.createElement("article");
+ art.id = d;
+ if(json.title){
+ var h3 = document.createElement("h3");
+ h3.innerHTML = json.filename;
+ art.appendChild(h3);
}
- if(json.data){
- var p = document.createElement("p");
- var a = document.createElement("a");
- a.hr