OSM2IPFS/earth/g1visa.html

148 lines
4.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>G1Visa Application</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background-color: #ffffff;
border-radius: 8px;
padding: 20px;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
max-width: 400px;
width: 100%;
text-align: center;
}
input[type="email"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>G1Visa Application</h1>
<form onsubmit="constructURL(); return false;">
<label for="email">Email:</label>
<input type="email" id="email" name="uplanet" required pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$">
<input type="hidden" id="lat" name="lat" value="">
<input type="hidden" id="lon" name="lon" value="">
<input type="submit" value="Submit">
</form>
</div>
<center><div id="countdown"></div></center>
<script>
// Extract latitude and longitude from URL parameters
const urlParams = new URLSearchParams(window.location.search);
const lat = urlParams.get('lat').toFixed(2);
const lon = urlParams.get('lon').toFixed(2);
// Set latitude and longitude values to hidden inputs
document.getElementById('lat').value = lat;
document.getElementById('lon').value = lon;
async function homeAstroportStation(myURL, option = '', duration = 3000) {
try {
let one = await fetch(myURL); // Gets a promise
var doc = await one.text();
var regex = /url='([^']+)/i; // Get response PORT
const match = doc.match(regex);
if (match) {
const redirectURL = match[1];
} else {
const redirectURL = myURL;
}
console.log(option + " ... Teleportation ... in " + duration + " ms ... " + redirectURL)
// start countdown
var timeLeft = Math.floor(duration / 1000);
var elem = document.getElementById("countdown");
var timerId = setInterval(countdown, 1000);
function countdown() {
if (timeLeft == -1) {
clearTimeout(timerId);
switch(option) {
case "tab":
window.open( redirectURL, "AstroTab");
break;
case "page":
window.location.replace(redirectURL);
break;
case "parent":
window.parent.location.href = redirectURL;
break;
case "aframe":
document.getElementById("aframe").src = redirectURL;
break;
case "ainfo":
ainfo(redirectURL);
break;
default:
window.location.href = redirectURL;
}
if (document.getElementById("countdown").innerHTML !== '') {
document.getElementById("countdown").innerHTML = "<a href='"+redirectURL+"' target='aframe'>OK</a>";
}
} else {
elem.innerHTML = timeLeft + " s";
timeLeft--;
}
}
} catch (err) {
console.log('Fetch error:' + err + myURL ); // Error handling
}
}
//// Create G1Visa wit Astroport.ONE API
function constructURL() {
// Get email, latitude, and longitude values
const email = document.getElementById('email').value;
const lat = document.getElementById('lat').value;
const lon = document.getElementById('lon').value;
// Construct the URL with parameters
const myURL = `https://astroport.copylaradio.com/?uplanet=${email}&${lat}=${lon}`;
// Call homeAstroportStation function with the constructed URL
homeAstroportStation(myURL, 'tab', 3000);
}
</script>
</body>
</html>