diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/app.js | 4 | ||||
-rw-r--r-- | src/js/arching-kaos-modules-news.js | 10 | ||||
-rw-r--r-- | src/js/arching-kaos-tools.js | 52 | ||||
-rw-r--r-- | src/js/arching-kaos-web-ui-settings.js | 5 | ||||
-rw-r--r-- | src/js/ui/sections/welcomeSection.js | 29 | ||||
-rw-r--r-- | src/js/url-generators.js | 15 |
6 files changed, 94 insertions, 21 deletions
diff --git a/src/js/app.js b/src/js/app.js index a73c0c3..066d598 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -9,7 +9,7 @@ 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"; -import { checkLocalNodeInfo, checkLocalPeers, checkLocalSchain, seekZblock } from "./arching-kaos-tools.js"; +import { checkLocalNodeInfo, checkLocalPeers, checkLocalSchain, seekPeer, seekZblock, showResult } from "./arching-kaos-tools.js"; import { refreshChat, refreshRadio, setDebug } from "./utils.js"; window.menusel = menusel; @@ -25,6 +25,8 @@ window.checkLocalSchain = checkLocalSchain; window.refreshChat = refreshChat; window.refreshRadio = refreshRadio; window.setDebug = setDebug; +window.showResult = showResult; +window.seekPeer = seekPeer; export function body() { diff --git a/src/js/arching-kaos-modules-news.js b/src/js/arching-kaos-modules-news.js index f9143bc..1834d2c 100644 --- a/src/js/arching-kaos-modules-news.js +++ b/src/js/arching-kaos-modules-news.js @@ -39,6 +39,13 @@ export function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ } if (!document.querySelector('#news-preview-'+zblockIPFSHash)){ var newsSectionDivElement = document.querySelector('.preview'); + var button = { + element:'button', + className:'read-more-button', + // innerText:`${blockObject.action.split('/')[0]}-${zblockIPFSHash} 📖`, + innerText:`Read more`, + onclick: `showResult("${blockObject.action.split('/')[0]}-${zblockIPFSHash}")` + } var articleContainerElement = { element:"article", id:`news-preview-${zblockIPFSHash}`, @@ -48,12 +55,13 @@ export function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ { 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) }, + button, { element:"hr" } ] }; makeElement(articleContainerElement, newsSectionDivElement); if(json.ipfs){ - archingKaosFetchText(getIPFSURL(json.ipfs), getPreviewText, [`#news-preview-${zblockIPFSHash}`]); + archingKaosFetchText(getIPFSURL(json.ipfs), getPreviewText, [`#news-preview-${zblockIPFSHash}`, button]); } makeElement({ element:"hr"}, newsSectionDivElement); } diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js index 310ca62..e0d9eb4 100644 --- a/src/js/arching-kaos-tools.js +++ b/src/js/arching-kaos-tools.js @@ -35,24 +35,35 @@ import { debugLog } from "./utils.js"; var settings = getSettings(); -function showResult(id) +export function showResult(id) { const found = document.querySelector(`#${id}`).cloneNode(true); - const overlay = document.createElement('div'); - overlay.id = 'unique-overlay'; const title = { element:'h3', innerText : "Result" }; - makeElement(title, overlay); var closeButton = { element:'button', innerHTML: 'x', id:"buttonCloseResult" }; - makeElement(closeButton, overlay); - makeElement(found, overlay); + var resultsHeader = { + element: 'div', + id: 'results-header', + innerHTML:[ + title, + closeButton + ] + }; + const overlay = { + element:'div', + id:'unique-overlay', + innerHTML:[ + resultsHeader + ] + }; makeElement(overlay, resultsArea()); + document.querySelector('#unique-overlay').appendChild(found); closeButton = document.querySelector('#buttonCloseResult'); closeButton.addEventListener("click", ()=>{ document.querySelector('#unique-overlay').remove(); @@ -466,15 +477,21 @@ function exe(action,dataIPFSHash,blockObject,zblockIPFSHash,group,zblockObject,r export function getPreviewText(text, params) { - var [ articleid ] = params; + var [ articleid, button ] = params; var divs = document.querySelector(articleid); if(text) { var newtext = text.substring(0, 500); var pre = { element:"div", - className:"news-text", - innerHTML:DOMPurify.sanitize(marked.parse(newtext)) + innerHTML:[ + { + element:"div", + className:"news-text", + innerHTML:DOMPurify.sanitize(marked.parse(newtext)) + }, + button + ] }; makeElement(pre, divs); } @@ -574,11 +591,24 @@ function checkPeers(json) { for ( var peer = 0; peer < json.length; peer++) { - archingKaosLog("Checking peer: "+json[peer].cjdns.ip); - checkIfZchainAndProceed(json[peer].node_info, [json[peer].node_info.gpg]); + if ( json[peer].cjdns !== undefined ) + { + archingKaosLog("Checking peer: "+json[peer].cjdns.ip); + checkIfZchainAndProceed(json[peer].node_info, [json[peer].node_info.gpg]); + } + if ( json[peer].yggdrasil !== undefined ) + { + archingKaosLog("Checking peer: "+json[peer].yggdrasil.ip); + checkIfZchainAndProceed(json[peer].node_info, [json[peer].node_info.gpg]); + } } } +export function seekPeer(value) +{ + archingKaosFetchJSON(`http://[${value}]:8610/v0/node_info`, checkIfZchainAndProceed, ["custom"]); +} + export function checkLocalPeers() { archingKaosLog("🔎 Querying for peers..."); diff --git a/src/js/arching-kaos-web-ui-settings.js b/src/js/arching-kaos-web-ui-settings.js index 1277eea..ddd32fe 100644 --- a/src/js/arching-kaos-web-ui-settings.js +++ b/src/js/arching-kaos-web-ui-settings.js @@ -75,7 +75,7 @@ var default_settings = { connect: { list: [ 'http://127.0.0.1:8610', - 'http://[fc59:6076:6299:6776:c13d:fbb2:1226:ead0]:8610', + 'http://z.kaotisk-hund.com:8610', 'http://api.aknet.z.kaotisk-hund.com/' ], active: 1 @@ -83,7 +83,7 @@ var default_settings = { radio: { list: [ 'http://127.0.0.1:8010', - 'http://api.radio.z.kaotisk-hund.com', + 'http://z.kaotisk-hund.com:8610', 'https://api.radio.arching-kaos.com' ], active: 2 @@ -119,6 +119,7 @@ if (( location.origin === "http://z.kaotisk-hund.com") || ( location.origin === "http://[fc59:6076:6299:6776:c13d:fbb2:1226:ead0]")) { settings.ipfs.gateway.active = 1; settings.stellar.horizon.active = 1; + settings.ak.connect.active = 1; settings.ak.radio.active = 1; } else if ( location.origin === "http://localhost:3000" ) { settings.ipfs.gateway.active = 2; diff --git a/src/js/ui/sections/welcomeSection.js b/src/js/ui/sections/welcomeSection.js index 31f7d4b..873063b 100644 --- a/src/js/ui/sections/welcomeSection.js +++ b/src/js/ui/sections/welcomeSection.js @@ -88,6 +88,30 @@ var renderForm = { ] }; +var manualPeerTitle = { + element : "h3", + innerText: "Connect to specific peer manually" +}; + +var manualPeerForm = { + element: "div", + style:"padding: 1vh 1vw; display: flex; flex-direction: row; align-items: center; gap: 10px;", + innerHTML: [ + { + element: "input", + id:"peer-field", + type:"text", + name:"search", + placeholder:"Enter an arching-kaos node address" + }, + { + element:"button", + onclick:"seekPeer(this.parentElement.querySelector('#peer-field').value, ['search', false])", + innerText:"Try" + } + ] +}; + var content = { element : "div", className: "content", @@ -96,12 +120,14 @@ var content = { homeGrid, renderTitle, renderForm, + manualPeerTitle, + manualPeerForm, { element: "div", className: "results-area", innerHTML: [ { - elements: "h3", + element: "h3", innerText: "Results" } ] @@ -164,6 +190,7 @@ var content = { }, { element: "div", + style: "font-size: 9px;", id: "logs-area-element" } ] diff --git a/src/js/url-generators.js b/src/js/url-generators.js index 239ce53..1bfe881 100644 --- a/src/js/url-generators.js +++ b/src/js/url-generators.js @@ -18,7 +18,8 @@ import { getSettings } from "./arching-kaos-web-ui-settings.js"; const settings = getSettings(); -export function getStellarConfigurationVariableURL(stellarAddress){ +export function getStellarConfigurationVariableURL(stellarAddress) +{ return settings.stellar.horizon.list[settings.stellar.horizon.active]+ 'accounts/'+ stellarAddress+ @@ -26,15 +27,18 @@ export function getStellarConfigurationVariableURL(stellarAddress){ settings.stellar.variableNames.list[settings.stellar.variableNames.active]; } -export function getIPNSURL(ipnsKey){ +export function getIPNSURL(ipnsKey) +{ return settings.ipfs.gateway.list[settings.ipfs.gateway.active]+'ipns/'+ipnsKey; } -export function getIPFSURL(ipfsHash){ +export function getIPFSURL(ipfsHash) +{ return settings.ipfs.gateway.list[settings.ipfs.gateway.active]+'ipfs/'+ipfsHash; } -export function getHoldersOfActiveAssetURL(){ +export function getHoldersOfActiveAssetURL() +{ return settings.stellar.horizon.list[settings.stellar.horizon.active]+ 'accounts?asset='+ settings.stellar.asset.list[settings.stellar.asset.active].code+ @@ -43,7 +47,8 @@ export function getHoldersOfActiveAssetURL(){ '&limit=200'; } -export function getTrustlinesURL(code=null, issuer=null){ +export function getTrustlinesURL(code=null, issuer=null) +{ var code = (code === null)? settings.stellar.asset.list[settings.stellar.asset.active].code : code; var issuer = (issuer === null) ? settings.stellar.asset.list[settings.stellar.asset.active].issuer : issuer; return settings.stellar.horizon.list[settings.stellar.horizon.active]+ |