aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/app.js142
-rw-r--r--src/js/arching-kaos-fetch.js52
-rw-r--r--src/js/arching-kaos-generator.js4
-rw-r--r--src/js/arching-kaos-log.js8
-rw-r--r--src/js/arching-kaos-modules-comments.js39
-rw-r--r--src/js/arching-kaos-modules-files.js5
-rw-r--r--src/js/arching-kaos-modules-mixtapes.js13
-rw-r--r--src/js/arching-kaos-modules-news.js37
-rw-r--r--src/js/arching-kaos-modules-references.js20
-rw-r--r--src/js/arching-kaos-spa-router.js28
-rw-r--r--src/js/arching-kaos-stellar-network.js68
-rw-r--r--src/js/arching-kaos-tools.js180
-rw-r--r--src/js/arching-kaos-web-ui-settings.js22
-rw-r--r--src/js/environment-setup.js177
-rw-r--r--src/js/ui/footer.js81
-rw-r--r--src/js/ui/header.js29
-rw-r--r--src/js/ui/main.js121
-rw-r--r--src/js/ui/mainLayout.js33
-rw-r--r--src/js/ui/menu.js260
-rw-r--r--src/js/ui/sections/radioSection.js3
-rw-r--r--src/js/ui/sections/settingsSection.js53
-rw-r--r--src/js/ui/sections/welcomeSection.js70
-rw-r--r--src/js/url-generators.js19
23 files changed, 920 insertions, 544 deletions
diff --git a/src/js/app.js b/src/js/app.js
index b84be92..fd92c87 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -10,40 +10,96 @@
* TODO: Figure out why it doesn't work in fullscreen App mode (android)
*
*/
-body.width = window.innerWidth;
-body.height = window.innerHeight;
-pageLayout.width = window.innerWidth;
-pageLayout.height = window.innerHeight;
-mainContainer.style.display = 'block';
-window.innerWidth <= 850 ? isMobile = true : isMobile = false;
+import { makeElement } from "./arching-kaos-generator.js";
+import { locationHashOnChange } from "./arching-kaos-spa-router.js";
+import { doubleFloorMenu, menuinit, menusel, stellarSubToggle, modulesSubToggle, exploreSubToggle } from './ui/menu.js';
+import { mainLayoutSpawn } from "./ui/mainLayout.js";
+import { scanStellarNetworkForPeers } from "./arching-kaos-stellar-network.js";
-function onWindowResize()
+window.menusel = menusel;
+window.locationHashOnChange = locationHashOnChange;
+window.stellarSubToggle = stellarSubToggle;
+window.modulesSubToggle = modulesSubToggle;
+window.exploreSubToggle = exploreSubToggle;
+window.scanStellarNetworkForPeers = scanStellarNetworkForPeers;
+
+export function body()
{
- body.width = window.innerWidth;
- body.height = window.innerHeight;
- pageLayout.width = window.innerWidth;
- pageLayout.height = window.innerHeight;
- window.innerWidth <= 850 ? isMobile = true : isMobile = false;
- isMobile ? doubleFloorMenu.style.display = 'none':doubleFloorMenu.style.display = 'flex';
+ return document.querySelector('body');
+}
+
+export function pageLayout()
+{
+ return document.querySelector('.page-layout');
}
-window.addEventListener('resize', onWindowResize, false);
+export function mainContainer()
+{
+ return document.querySelector('.main');
+}
-progressPlaceholder.value = '0';
+window.isMobile = false;
-progressPlaceholder.max++;
+export function aknet()
+{
+ return document.querySelector('.aknet-network')
+}
+
+export function resultsArea()
+{
+ return document.querySelector('.results-area')
+}
+
+export function progressPlaceholder()
+{
+ return document.querySelector('#total-progress');
+}
+
+export function httpProgressPlaceholder()
+{
+ return document.querySelector('#http-progress');
+}
-if ( settings.stellar.scan )
+export function currentLogMessageElement()
{
- scanStellarNetworkForPeers();
+ return document.querySelector('#current-log-message');
}
-if ( settings.ak.scan )
+export function logsAreaElement()
{
- ringlocalbell();
- setInterval(ringlocalbell, 10*60*1000);
+ return document.querySelector("#logs-area-element");
}
+export function radio()
+{
+ return document.querySelector("#radio-player");
+}
+
+export function radioButton()
+{
+ return document.querySelector("#radio-button-controller");
+}
+
+
+body().width = window.innerWidth;
+body().height = window.innerHeight;
+pageLayout().width = window.innerWidth;
+pageLayout().height = window.innerHeight;
+mainContainer().style.display = 'block';
+window.innerWidth <= 850 ? window.isMobile = true : window.isMobile = false;
+
+function onWindowResize()
+{
+ body.width = window.innerWidth;
+ body.height = window.innerHeight;
+ pageLayout.width = window.innerWidth;
+ pageLayout.height = window.innerHeight;
+ window.innerWidth <= 850 ? window.isMobile = true : window.isMobile = false;
+ window.isMobile ? doubleFloorMenu().style.display = 'none': doubleFloorMenu().style.display = 'flex';
+}
+window.addEventListener('resize', onWindowResize, false);
+
+
//scanStellarNetworkForPeers();
// setInterval(scanStellarNetworkForPeers, 60000);
@@ -53,30 +109,24 @@ var root = {
html: document.querySelector('html')
};
-var scripts = [
- {
- element:"script",
- src:"./js/ui/mainLayout.js"
- }
-];
-//,
-// {
-// element:"script",
-// src:"./js/page-navigation.js"
-// },
-// {
-// element:"script",
-// src:"./js/page-projects.js"
-// },
-// {
-// element:"script",
-// src:"./js/menu.js"
-// }
-//];
-
-for ( var i = 0; i < scripts.length; i++ )
-{
- makeElement(scripts[i], root.body);
-}
+// var scripts = [
+// {
+// element:"script",
+// type: "module",
+// src:"./js/ui/mainLayout.js"
+// }
+// ];
+//
+// for ( var i = 0; i < scripts.length; i++ )
+// {
+// makeElement(scripts[i], root.body);
+// }
+
+mainLayoutSpawn();
+// And call
+menuinit();
+locationHashOnChange();
+
+window.isMobile ? doubleFloorMenu().style.display = 'none': doubleFloorMenu().style.display = 'flex';
// vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4
// @license-end
diff --git a/src/js/arching-kaos-fetch.js b/src/js/arching-kaos-fetch.js
index 523baff..15394b2 100644
--- a/src/js/arching-kaos-fetch.js
+++ b/src/js/arching-kaos-fetch.js
@@ -5,7 +5,10 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
-function archingKaosFetchJSON( url, callback, params ){
+import { archingKaosLog } from "./arching-kaos-log.js";
+import { httpProgressPlaceholder, progressPlaceholder } from "./app.js";
+
+export function archingKaosFetchJSON( url, callback, params ){
const request = new XMLHttpRequest();
request.addEventListener("load", ()=>{
var json = JSON.parse(request.response);
@@ -16,38 +19,49 @@ function archingKaosFetchJSON( url, callback, params ){
}
});
request.addEventListener("error", ()=>{
- console.log("An error occured.");
+ // console.log("An error occured.");
});
request.addEventListener("progress", (event)=>{
- if (event.lengthComputable && progressPlaceholder){
- httpProgressPlaceholder.value = (event.loaded / event.total) * 100;
+ if (event.lengthComputable && progressPlaceholder()){
+ httpProgressPlaceholder().value = (event.loaded / event.total) * 100;
} else {
- httpProgressPlaceholder.value = 0;
- console.log("Supposingly zeroed progressPlaceholder");
+ httpProgressPlaceholder().value = 0;
+ // console.log("Supposingly zeroed progressPlaceholder");
}
});
request.addEventListener("abort", ()=>{
- console.log("Request aborted.");
+ // console.log("Request aborted.");
});
request.open("GET", url);
request.send();
}
-async function archingKaosFetchText( url, callback ){
- return fetch(url, {
- method:'GET',
- headers:{
- Accept: 'application/json'
+export async function archingKaosFetchText( url, callback, params ){
+ const request = new XMLHttpRequest();
+ request.addEventListener("load", ()=>{
+ var text = request.response;
+ if(request.status !== 404){
+ callback(text, params);
+ } else {
+ archingKaosLog(`ERROR ${request.status} while loading ${url}`);
}
- }).then(response=>{
- if(response.ok){
- response.text().then(text=>{
- return callback(text);
- })
+ });
+ request.addEventListener("error", ()=>{
+ // console.log("An error occured.");
+ });
+ request.addEventListener("progress", (event)=>{
+ if (event.lengthComputable && progressPlaceholder()){
+ httpProgressPlaceholder().value = (event.loaded / event.total) * 100;
} else {
- console.log(e);
+ httpProgressPlaceholder.value = 0;
+ // console.log("Supposingly zeroed progressPlaceholder");
}
- })
+ });
+ request.addEventListener("abort", ()=>{
+ // console.log("Request aborted.");
+ });
+ request.open("GET", url);
+ request.send();
}
// @license-end
diff --git a/src/js/arching-kaos-generator.js b/src/js/arching-kaos-generator.js
index 9c80954..9a0398d 100644
--- a/src/js/arching-kaos-generator.js
+++ b/src/js/arching-kaos-generator.js
@@ -5,7 +5,7 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
-function makeElement(obj, attachTo)
+export function makeElement(obj, attachTo)
{
if (obj.element !== 'head' && obj.element !== 'body' )
{
@@ -50,7 +50,7 @@ function makeElement(obj, attachTo)
attachTo.appendChild(temp);
}
-function makeUpSite(tree, root){
+export function makeUpSite(tree, root){
if ( tree !== undefined && Array.isArray(tree) )
{
for (var i = 0; i < tree.length; i++)
diff --git a/src/js/arching-kaos-log.js b/src/js/arching-kaos-log.js
index 1f79994..e348ee6 100644
--- a/src/js/arching-kaos-log.js
+++ b/src/js/arching-kaos-log.js
@@ -5,14 +5,16 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
+import { currentLogMessageElement, logsAreaElement } from "./app.js";
+import { makeElement } from "./arching-kaos-generator.js";
-function archingKaosLog(message){
+export function archingKaosLog(message){
var lts = new Date(Date.now());
var sta = {
element:"div",
innerText: lts.toISOString() + " " + message
};
- currentLogMessageElement.innerText = sta.innerText;
- makeElement(sta, logsAreaElement);
+ currentLogMessageElement().innerText = sta.innerText;
+ makeElement(sta, logsAreaElement());
}
// @license-end
diff --git a/src/js/arching-kaos-modules-comments.js b/src/js/arching-kaos-modules-comments.js
index aad581f..8db1b57 100644
--- a/src/js/arching-kaos-modules-comments.js
+++ b/src/js/arching-kaos-modules-comments.js
@@ -5,32 +5,37 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
-function akModuleComments(zblockIPFSHash, blockObject, json){
+import { makeElement } from "./arching-kaos-generator.js";
+import {
+ getFullText,
+ getNicknameAssossiatedWithGPG
+} from "./arching-kaos-tools.js";
+import { archingKaosFetchText } from "./arching-kaos-fetch.js";
+import { getIPFSURL } from "./url-generators.js";
+
+export function akModuleComments(zblockIPFSHash, blockObject, json){
if (!document.querySelector('#comment-'+zblockIPFSHash)){
var divs = document.querySelector('#comments-section');
var art = {
element:"article",
- id: 'comment-'+zblockIPFSHash
+ id: `comment-${zblockIPFSHash}`,
+ innerHTML: [
+ {
+ element:"p",
+ innerText:"Published: " + new Date(json.datetime*1000)
+ },
+ {
+ element:"p",
+ innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg)
+ }
+ ]
};
makeElement(art, divs);
- art = document.querySelector('#comment-'+zblockIPFSHash);
- if(json.datetime){
- var small = {
- element:"p",
- innerText:"Published: " + new Date(json.datetime*1000)
- };
- makeElement(small, art);
- }
- var small = {
- element:"p",
- innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg)
- };
- makeElement(small, art);
if(json.ipfs){
- getipfstext(json.ipfs,art.id);
+ archingKaosFetchText(getIPFSURL(json.ipfs), getFullText, [`#comment-${zblockIPFSHash}`]);
}
if (document.querySelector("#comments-sec-not-found")) document.querySelector("#comments-sec-not-found").hidden=true;
- makeElement(document.createElement("hr"), divs);
+ makeElement({element:"hr"}, divs);
}
}
// @license-end
diff --git a/src/js/arching-kaos-modules-files.js b/src/js/arching-kaos-modules-files.js
index b566226..fb325aa 100644
--- a/src/js/arching-kaos-modules-files.js
+++ b/src/js/arching-kaos-modules-files.js
@@ -5,7 +5,10 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
-function akModuleFiles(zblockIPFSHash, blockObject, json){
+import { getNicknameAssossiatedWithGPG } from "./arching-kaos-tools.js";
+import { makeElement } from "./arching-kaos-generator.js";
+
+export function akModuleFiles(zblockIPFSHash, blockObject, json){
if (!document.querySelector('#file-'+zblockIPFSHash)){
var divs = document.querySelector('#files-section');
var art = {
diff --git a/src/js/arching-kaos-modules-mixtapes.js b/src/js/arching-kaos-modules-mixtapes.js
index ac23ed4..bf11d9d 100644
--- a/src/js/arching-kaos-modules-mixtapes.js
+++ b/src/js/arching-kaos-modules-mixtapes.js
@@ -5,8 +5,11 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
+import { makeElement } from "./arching-kaos-generator.js";
+import { getIPFSURL } from "./url-generators.js";
+import { addMixtapeID, setMixtape, getMixtapes } from "./environment-setup.js";
-function akModuleMixtapes(zblockIPFSHash, zblockObject, blockObject, json){
+export function akModuleMixtapes(zblockIPFSHash, zblockObject, blockObject, json){
if(!document.querySelector('#mixtape-'+zblockIPFSHash)){
var divs = document.querySelector('#mixtapes-section');
var art = {
@@ -37,10 +40,10 @@ function akModuleMixtapes(zblockIPFSHash, zblockObject, blockObject, json){
makeElement(art, divs);
var audio = document.querySelector('#mixtape-player-'+zblockIPFSHash);
audio.setAttribute('controls','');
- mixtapeIds.push('mixtape-player-'+zblockIPFSHash);
+ addMixtapeID(zblockIPFSHash);
audio.addEventListener( "loadedmetadata", ()=>{
- if ( mixtapes[zblockIPFSHash] === undefined ){
- mixtapes[zblockIPFSHash]={
+ if ( getMixtapes()[zblockIPFSHash] === undefined ){
+ setMixtape(zblockIPFSHash, {
zblock:zblockIPFSHash,
block:zblockObject.block,
block_signature:zblockObject.block_signature,
@@ -52,7 +55,7 @@ function akModuleMixtapes(zblockIPFSHash, zblockObject, blockObject, json){
gpg:blockObject.gpg,
timestamp:blockObject.timestamp,
audioDuration:audio.duration
- };
+ });
}
/* console.log(
zblockIPFSHash+"'s duration is: "+
diff --git a/src/js/arching-kaos-modules-news.js b/src/js/arching-kaos-modules-news.js
index d1ebc23..49dfb0a 100644
--- a/src/js/arching-kaos-modules-news.js
+++ b/src/js/arching-kaos-modules-news.js
@@ -5,8 +5,16 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
+import { makeElement } from "./arching-kaos-generator.js";
+import { archingKaosFetchText } from "./arching-kaos-fetch.js";
+import {
+ getNicknameAssossiatedWithGPG,
+ getFullText,
+ getPreviewText
+} from "./arching-kaos-tools.js";
+import { getIPFSURL } from "./url-generators.js";
-function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){
+export function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){
if (!document.querySelector('#news-'+zblockIPFSHash)){
var newsSectionDivElement = document.querySelector('#news-section');
var articleContainerElement = {
@@ -14,7 +22,9 @@ function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){
id:`news-${zblockIPFSHash}`,
innerHTML: [
{ element:"a", innerText : json.title, href : '#news-'+zblockIPFSHash },
+ { element:"span", innerText : ' '},
{ element:"a", innerText:'[permalink]', target: '_blank', href:'https://news.arching-kaos.net/?from_zblock='+zblockIPFSHash },
+ { element:"p", innerText:`zblock: ${zblockIPFSHash}` },
{ element:"p", innerText:"Published: " + new Date(blockObject.timestamp*1000) },
{ element:"p", innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg) },
{ element:"hr" }
@@ -24,15 +34,28 @@ function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){
if(json.ipfs){
archingKaosFetchText(getIPFSURL(json.ipfs), getFullText,[`#news-${zblockIPFSHash}`]);
}
+ if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true;
+ makeElement({ element:"hr"}, newsSectionDivElement);
+ }
+ if (!document.querySelector('#news-preview-'+zblockIPFSHash)){
+ var newsSectionDivElement = document.querySelector('.preview');
+ var articleContainerElement = {
+ element:"article",
+ id:`news-preview-${zblockIPFSHash}`,
+ innerHTML: [
+ { element:"a", innerText : json.title, href : '#news-'+zblockIPFSHash },
+ { element:"span", innerText : ' '},
+ { element:"a", innerText:'[permalink]', target: '_blank', href:'https://news.arching-kaos.net/?from_zblock='+zblockIPFSHash },
+ { element:"p", innerText:"Published: " + new Date(blockObject.timestamp*1000) },
+ { element:"p", innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg) },
+ { element:"hr" }
+ ]
};
- makeElement(small, articleContainerElement);
- var hr = { element:"hr" };
- makeElement(hr, articleContainerElement);
+ makeElement(articleContainerElement, newsSectionDivElement);
if(json.ipfs){
- getipfstext(json.ipfs,articleContainerElement.id);
+ archingKaosFetchText(getIPFSURL(json.ipfs), getPreviewText, [`#news-preview-${zblockIPFSHash}`]);
}
- if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true;
- makeElement(hr, newsSectionDivElement);
+ makeElement({ element:"hr"}, newsSectionDivElement);
}
}
// @license-end
diff --git a/src/js/arching-kaos-modules-references.js b/src/js/arching-kaos-modules-references.js
index f609d3a..c6aca8a 100644
--- a/src/js/arching-kaos-modules-references.js
+++ b/src/js/arching-kaos-modules-references.js
@@ -5,17 +5,25 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
-function resolveReferences(references){
- for( entry in references ){
+import {
+ getReferences,
+ setReference,
+ getReference
+} from "./environment-setup.js";
+
+export function resolveReferences(){
+ console.log(getReferences());
+ const references = getReferences();
+ for( var entry = 0; entry < references.length; entry++ ){
var comment = document.querySelector('#comment-'+references[entry].dataExpansion.reference);
var article = document.querySelector('#news-'+references[entry].dataExpansion.refer_to);
article.appendChild(comment);
}
}
-function storeReference(zblockIPFSHash, zblockObject, blockObject, json, references){
- if ( references[zblockIPFSHash] === undefined ){
- references[zblockIPFSHash]={
+export function storeReference(zblockIPFSHash, zblockObject, blockObject, json, references){
+ if ( getReference(zblockIPFSHash) === undefined ){
+ setReference(zblockIPFSHash, {
zblock:zblockIPFSHash,
block:zblockObject.block,
block_signature:zblockObject.block_signature,
@@ -26,7 +34,7 @@ function storeReference(zblockIPFSHash, zblockObject, blockObject, json, referen
detach:blockObject.detach,
gpg:blockObject.gpg,
timestamp:blockObject.timestamp
- };
+ });
}
}
// @license-end
diff --git a/src/js/arching-kaos-spa-router.js b/src/js/arching-kaos-spa-router.js
index 1775d24..162a316 100644
--- a/src/js/arching-kaos-spa-router.js
+++ b/src/js/arching-kaos-spa-router.js
@@ -17,17 +17,31 @@
* the "route" we got from `location.search`.
*
*/
+import { menuinit, menuids } from "./ui/menu.js";
-function locationHashSetter(value){
+export function locationHashSetter(value)
+{
window.location.hash = value;
locationHashOnChange();
}
-function locationHashGetter(){
+export function locationHashGetter()
+{
return window.location.hash;
}
-function locationHashOnChange(){
+export function getWelcomeSection()
+{
+ return document.querySelector('#welcome-section');
+}
+
+export function getSoftError()
+{
+ return document.querySelector('#not-found-section');
+}
+
+export function locationHashOnChange()
+{
var route = new Object;
route.full = locationHashGetter();
route.args = route.full.split('/');
@@ -35,19 +49,19 @@ function locationHashOnChange(){
route.subcommand = route.args[2];
menuinit();
if ( (locationHashGetter() !== 'undefined') && (locationHashGetter() === '') ){
- document.querySelector('#welcome-section').hidden=false;
+ getWelcomeSection.hidden=false;
}
else if ( route.args[1] == "route" ) {
- document.querySelector('#welcome-section').hidden=false;
+ getWelcomeSection.hidden=false;
if ( route.args.length === 4 ) {
if ( route.args[2] === "zblock" ) {
seekZblock(route.args[3], ['search', false]);
}
}
- } else if ( (locationHashGetter() !== 'undefined') && ( menuids.includes(route.menuid))){
+ } else if ( (locationHashGetter() !== 'undefined') && ( menuids().includes(route.menuid))){
document.querySelector(route.menuid).hidden=false;
} else {
- document.querySelector('#not-found-section').hidden=false;
+ getSoftError().hidden=false;
}
}
diff --git a/src/js/arching-kaos-stellar-network.js b/src/js/arching-kaos-stellar-network.js
index ca4d586..a08147e 100644
--- a/src/js/arching-kaos-stellar-network.js
+++ b/src/js/arching-kaos-stellar-network.js
@@ -5,21 +5,39 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
+import { archingKaosLog } from "./arching-kaos-log.js";
+import { archingKaosFetchJSON } from "./arching-kaos-fetch.js";
+import {
+ getStellarConfigurationVariableURL,
+ getTrustlinesURL,
+ getHoldersOfActiveAssetURL
+} from "./url-generators.js";
+
+import { progressPlaceholder } from "./app.js";
+
+import {
+ increaseStellarNetworkConfiguredAddresses,
+ addToFoundHolders,
+ setStellarParticipants,
+ setStellarParticipantsScanned
+} from "./environment-setup.js";
+
+import { makeElement } from "./arching-kaos-generator.js";
+import { getConfiguration } from "./arching-kaos-tools.js";
+
+var lastPage = '';
function getNumberOfTrustlinesAndRenderThem(json){
var number = json._embedded.records[0].accounts.authorized;
var stats = document.querySelector('.stellar-network').querySelector('summary');
if(!document.querySelector("#stellar-participants-sum")){
- var small = document.createElement("span");
- small.id = 'stellar-participants-sum';
- stats.appendChild(small);
+ makeElement({element: "span", id: 'stellar-participants-sum', innerText: `( ${number} )`}, stats);
}
- document.querySelector("#stellar-participants-sum").innerText = ' (' + number + ')';
archingKaosLog("Loading trustlines... Found "+number+"!");
- progressPlaceholder.value++;
- stellarParticipants=number;
- stellarParticipantsScanned=number;
+ progressPlaceholder().value++;
+ setStellarParticipants(number);
+ setStellarParticipantsScanned(number);
}
function renderStellarAddress(stellarAddress){
@@ -38,11 +56,11 @@ function renderStellarAddress(stellarAddress){
function renderStellarAddressesAndProceed(json){
var records = json._embedded.records;
- for ( index in records ){
- holders.push(records[index].account_id);
- progressPlaceholder.max++;
- renderStellarAddress(records[index].account_id);
- checkAddressForConfigurationVariable(records[index].account_id);
+ for ( var i = 0; i < records.length; i++ ){
+ addToFoundHolders(records[i].account_id);
+ progressPlaceholder().max++;
+ renderStellarAddress(records[i].account_id);
+ checkAddressForConfigurationVariable(records[i].account_id);
}
if (json._links.next) getHolders(json._links.next.href);
}
@@ -50,7 +68,7 @@ function renderStellarAddressesAndProceed(json){
function renderConfigurationIPNSLinkAndProceed(json, stellarAddress){
renderStellarAddress(stellarAddress);
document.querySelector('#'+stellarAddress).style="color: #3dbb3d;"
- stellarNetworkConfiguredAddresses += 1;
+ increaseStellarNetworkConfiguredAddresses();
console.log(atob(json.value));
console.log(stellarAddress);
getConfiguration(atob(json.value),stellarAddress);
@@ -80,27 +98,17 @@ function getHolders(a=0){
}
lastPage=url;
if (doIt) {
- archingKaosFetchJSON(url, renderStellarAddressesAndProceed);
+ archingKaosFetchJSON(url, renderStellarAddressesAndProceed, null);
}
archingKaosLog("Searching holders... Done!");
}
-function getStellarConfigurationVariableURL(stellarAddress){
- return settings.stellar.horizon.list[settings.stellar.horizon.active]+
- 'accounts/'+
- stellarAddress+
- '/data/'+
- settings.stellar.variableNames.list[settings.stellar.variableNames.active];
-}
-
function checkAddressForConfigurationVariable(stellarAddress) {
archingKaosLog("Checking configuration for "+ stellarAddress+ "...");
archingKaosFetchJSON(getStellarConfigurationVariableURL(stellarAddress), renderConfigurationIPNSLinkAndProceed, stellarAddress);
- progressPlaceholder.value++;
+ progressPlaceholder().value++;
}
-var server = new StellarSdk.Server(settings.stellar.horizon.list[settings.stellar.horizon.active], {allowHttp:true});
-
function steptwo(i){
var ta=document.querySelector("#stellar-balances-table");
for (b in i.balances) {
@@ -113,8 +121,8 @@ function steptwo(i){
]
}
makeElement(amount, ta);
- progressPlaceholder.max++;
- progressPlaceholder.value++;
+ progressPlaceholder().max++;
+ progressPlaceholder().value++;
if(document.querySelector("#stellar-balances-not-found")) document.querySelector("#stellar-balances-not-found").hidden = true;
}
}
@@ -144,8 +152,8 @@ async function fetchNodeInfoFromClientWallet(stellarAddress){
innerText:atob(json.value)
};
makeElement(cnf, document.querySelector('#stellar-data-config'));
- progressPlaceholder.max++;
- progressPlaceholder.value++;
+ progressPlaceholder().max++;
+ progressPlaceholder().value++;
getConfiguration(atob(json.value),stellarAddress);
});
}
@@ -186,7 +194,7 @@ function connect(){
// }
}
-function scanStellarNetworkForPeers(){
+export function scanStellarNetworkForPeers(){
getTrustlines();
getHolders();
}
diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js
index 0f62fd5..1ebda52 100644
--- a/src/js/arching-kaos-tools.js
+++ b/src/js/arching-kaos-tools.js
@@ -5,6 +5,28 @@
* @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
*
*/
+import { archingKaosLog } from "./arching-kaos-log.js";
+import { makeElement } from "./arching-kaos-generator.js";
+import { progressPlaceholder } from "./app.js";
+import { archingKaosFetchJSON } from "./arching-kaos-fetch.js";
+import { getIPFSURL, getIPNSURL } from "./url-generators.js";
+import {
+ stellarParticipantInfo,
+ getStellarParticipantsScanned,
+ getStellarNetworkConfiguredAddresses,
+ setFullZblock,
+ setZblock,
+ setData,
+ getParticipants,
+ setZchainLoadingStatus,
+ getZchainLoadingStatuses
+} from "./environment-setup.js";
+import { akModuleComments } from "./arching-kaos-modules-comments.js";
+import { akModuleFiles } from "./arching-kaos-modules-files.js";
+import { akModuleMixtapes } from "./arching-kaos-modules-mixtapes.js";
+import { akModuleNews } from "./arching-kaos-modules-news.js";
+import { storeReference, resolveReferences } from "./arching-kaos-modules-references.js";
+
function getArrayLength(array){
var length = 0;
for ( e in array ) {
@@ -52,28 +74,33 @@ function renderStellarAddressPlaceholder(stellarAddress){
function nodeInfoRender(json, stellarAddress){
var divs = renderStellarAddressPlaceholder(stellarAddress);
- for( key in Object.keys(json) ){
- if ( typeof(json[Object.keys(json)[key]]) === "string" ) {
- if(!document.querySelector('#'+Object.keys(json)[key]+'-'+stellarAddress)){
- var p = document.createElement("p");
- p.id = Object.keys(json)[key]+'-'+stellarAddress;
- p.innerText = Object.keys(json)[key] + ": " +json[Object.keys(json)[key]];
- divs.appendChild(p);
+ console.log(json);
+ const keys = Object.keys(json);
+ for( var i = 0; i < keys.length; i++ )
+ {
+ if ( typeof(json[keys[i]]) === "string" ) {
+ if(!document.querySelector('#'+keys[i]+'-'+stellarAddress)){
+ var p = {
+ element:"p",
+ id: `${keys[i]}-${stellarAddress}`,
+ innerText: `${keys[i]}: ${json[keys[i]]}`
+ };
+ makeElement(p, divs);
}
}
- else if ( typeof(json[Object.keys(json)[key]]) === "Object"||"Array" ) {
- nodeInfoRender(json[Object.keys(json)[key]], stellarAddress);
+ else if ( typeof(json[keys[i]]) === "Object"||"Array" ) {
+ nodeInfoRender(json[keys[i]], stellarAddress);
}
}
}
function nodeInfoRenderAndProceed(json, stellarAddress){
nodeInfoRender(json, stellarAddress);
- participants[stellarAddress]=json;
- if ( stellarParticipantsScanned === 0 ) {
+ stellarParticipantInfo(stellarAddress, json);
+ if ( getStellarParticipantsScanned() === 0 ) {
archingKaosLog('Scanned all Stellar participants');
}
- progressPlaceholder.value++;
+ progressPlaceholder().value++;
if (json.zlatest) {
seekZblock(json.zlatest, [json.gpg, json]);
}