<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document Download</title>
<style>
body {
font-family: Cambria, sans-serif;
background: #E0F7FA;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.form-box {
background: #00FFFF;
padding: 20px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
border-radius: 10px;
text-align: center;
width: 350px;
max-width: 90%;
}
input, button {
padding: 10px;
margin: 10px 0;
width: 100%;
box-sizing: border-box;
}
a button {
background: #007BFF;
color: white;
border: none;
cursor: pointer;
padding: 10px 20px;
width: auto;
margin-top: 5px;
}
a button:hover {
background: #0056b3;
}
#result {
margin-top: 20px;
font-weight: bold;
}
.not-available {
color: red;
margin: 5px 0;
}
.loader {
width: 50px;
height: 50px;
position: relative;
margin: 20px auto;
display: none;
}
.loader::before {
content: '';
position: absolute;
border: 5px solid #007BFF;
border-radius: 50%;
width: 30px;
height: 30px;
top: 0;
left: 0;
animation: spin 1s linear infinite;
border-right-color: transparent;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="form-box">
<h2>Download Important Documents of the Trainees<br>Session 2025–2027</h2>
<input type="text" id="regNo" placeholder="Enter Registration Number"><br>
<input type="text" id="traineeName" placeholder="Enter Your Name"><br>
<button id="submitBtn" onclick="checkDocuments()">Submit</button>
<div class="loader" id="loader"></div>
<div id="result"></div>
</div>
<script>
function checkDocuments() {
const regNo = document.getElementById("regNo").value.trim();
const traineeName = document.getElementById("traineeName").value.trim().toLowerCase();
const resultDiv = document.getElementById("result");
const submitBtn = document.getElementById("submitBtn");
const loader = document.getElementById("loader");
if (!regNo || !traineeName) {
alert("Please enter both Registration Number and Trainee Name");
return;
}
resultDiv.innerHTML = "";
loader.style.display = "block";
submitBtn.disabled = true;
const apiUrl = `https://script.google.com/macros/s/AKfycbxIEcEHZ2gokJPGLeU6y8mrjJG4rbJoOfSubjqfqxw46i3ilXc-t2Bl13e1jOfabJ7L/exec?regNo=${encodeURIComponent(regNo)}&traineeName=${encodeURIComponent(traineeName)}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (Object.keys(data).length > 0) {
let links = `<p>Hello, ${traineeName.toUpperCase()}!</p>`;
// Get all keys ending with ' Link'
const linkKeys = Object.keys(data).filter(key => key.endsWith(' Link'));
if (linkKeys.length === 0) {
links += `<p class="not-available">No downloadable documents found.</p>`;
} else {
linkKeys.forEach(key => {
const label = key.replace(" Link", "");
if (data[key]) {
links += `<a href="${data[key]}" target="_blank" rel="noopener noreferrer">
<button>Download ${label}</button>
</a>`;
} else {
links += `<p class="not-available">${label}: Document not available yet.</p>`;
}
});
}
resultDiv.innerHTML = links;
} else {
resultDiv.innerHTML = "<p class='not-available'>No documents found for this registration number and name.</p>";
}
})
.catch(error => {
console.error(error);
resultDiv.innerHTML = "<p class='not-available'>Documents not Available.</p>";
})
.finally(() => {
loader.style.display = "none";
submitBtn.disabled = false;
});
}
</script>
</body>
</html>