From 314c7188661eeeaa4b3e40fc8e48b6dcd5d81b37 Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 24 Nov 2023 03:39:10 +0100 Subject: [PATCH] Get ZenCard link pointing same ipfs/astroport host (LAN or WAN) --- earth/map_render.html | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/earth/map_render.html b/earth/map_render.html index 80590d0..b30d8e4 100644 --- a/earth/map_render.html +++ b/earth/map_render.html @@ -187,7 +187,7 @@ if (deg <= 0.01) { const button = document.createElement('button'); - button.textContent = 'Land Here'; + button.textContent = 'Get ZenCard'; button.style.width = '100%'; button.style.height = '100px'; // Customize the button height button.style.backgroundColor = '#0074d9'; @@ -196,9 +196,26 @@ if (deg <= 0.01) { button.style.fontSize = '24px'; // Customize the font size button.style.color = '#fff'; // Customize the font color + // Extract the hostname (e.g., "https://ipfs.domain.tld" or "http://ipfs.localhost:8080") + var currentURL = new URL(window.location.href); + var hostname = currentURL.hostname; + var port = currentURL.port; + var protocol = currentURL.protocol.split(":")[0]; + + // Check and replace the port if it's 8080 + if (port === "8080") { + port = "1234"; + } + + var zHost = hostname.replace("ipfs", "astroport"); + + // Create the "station" variable with the specified format + var station = protocol + "://" + zHost + (port ? (":" + port) : ""); + + console.log(station) + button.addEventListener('click', () => { -// const url = `http://astroport.localhost:1234/?uplanet=@&salt=${southWestLat}&pepper=${southWestLon}`; - const url = `https://astroport.copylaradio.com/?uplanet=@&salt=${southWestLat}&pepper=${southWestLon}`; + const url = `${station}/?uplanet=@&salt=${southWestLat}&pepper=${southWestLon}`; window.location.href = url; });