From a84f6765711e92c668ecb3becd2b1ee12b36abe7 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 22 Dec 2024 04:49:34 +0200 Subject: Peering look up --- src/js/arching-kaos-tools.js | 52 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'src/js/arching-kaos-tools.js') 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..."); -- cgit v1.2.3