Get ZenCard link pointing same ipfs/astroport host (LAN or WAN)

This commit is contained in:
fred 2023-11-24 03:39:10 +01:00
parent 06dd9affc1
commit 314c718866
1 changed files with 20 additions and 3 deletions

View File

@ -187,7 +187,7 @@ if (deg <= 0.01) {
const button = document.createElement('button'); const button = document.createElement('button');
button.textContent = 'Land Here'; button.textContent = 'Get ZenCard';
button.style.width = '100%'; button.style.width = '100%';
button.style.height = '100px'; // Customize the button height button.style.height = '100px'; // Customize the button height
button.style.backgroundColor = '#0074d9'; button.style.backgroundColor = '#0074d9';
@ -196,9 +196,26 @@ if (deg <= 0.01) {
button.style.fontSize = '24px'; // Customize the font size button.style.fontSize = '24px'; // Customize the font size
button.style.color = '#fff'; // Customize the font color 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', () => { button.addEventListener('click', () => {
// const url = `http://astroport.localhost:1234/?uplanet=@&salt=${southWestLat}&pepper=${southWestLon}`; const url = `${station}/?uplanet=@&salt=${southWestLat}&pepper=${southWestLon}`;
const url = `https://astroport.copylaradio.com/?uplanet=@&salt=${southWestLat}&pepper=${southWestLon}`;
window.location.href = url; window.location.href = url;
}); });