Skip to content
Snippets Groups Projects
Commit 503d310e authored by Jan Hartig's avatar Jan Hartig
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Raumfreischaltung - PTB VC</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 50px;
}
input[type="text"] {
padding: 8px;
font-size: 16px;
margin-bottom: 10px;
border: .1rem solid #212529;
border-radius: .375rem;
width: 10rem;
}
button {
padding: 10px 20px;
font-size: 16px;
background-color: #212529;
color: white;
border: none;
border-radius: .375rem;
cursor: pointer;
}
button:disabled {
transition: background-color .5s ease-in-out;
background-color: #495057;
}
button:hover {
transition: background-color 0.12s ease-in-out;
background-color: #45a049;
}
button:hover:disabled {
pointer-events: none;
}
#hiddenField {
margin-top: 5rem;
opacity: 0;
transition: opacity 0.25s ease-in;
}
#hiddenField.visible {
opacity: 1;
}
#roomUrl {
width: 40rem;
margin-bottom: 1.5rem;
}
</style>
</head>
<body>
<h1>Raumfreischaltung</h1>
<input type="text" id="room" name="raumname" placeholder="Raumname" minlength="1">
<button type="button" onclick="process_form()" id="unlock">Freischalten</button>
<div id="hiddenField" aria-hidden="true">
<p id="urlText"></p>
<p id="urlTime"></p>
<input type="text" id="roomUrl" readonly>
<br>
<button id="copyButton" onclick="copyToClipboard()">Link in Zwischenablage kopieren</button>
</div>
<script>
const baseUrl = window.location.protocol + "//" + window.location.host
const unlockButton = document.getElementById('unlock')
const roomField = document.getElementById('room')
const hiddenField = document.getElementById('hiddenField');
const urlText = document.getElementById('urlText');
const urlTime = document.getElementById('urlTime');
const roomUrl = document.getElementById('roomUrl');
let room = window.location.href.substring(window.location.href.lastIndexOf('/') + 1)
if (room !== "raumfreischaltung") {
roomField.value = room;
get_room();
}
function get_room() {
fetch(baseUrl + "/unlockroom", {
method: "POST",
body: JSON.stringify({"room": room}),
headers: {"Content-Type": "application/json"}
}).then(data => {
data.json().then(data => {
urlText.innerHTML = "Dieser Link öffnet den Raum <b>" + data.room + "</b> ohne Zertifikat.";
urlTime.innerHTML = "Gültig bis <b>" + new Date(Date.now() - data.valid_for * 24 * 60 * 60 * 1000).toLocaleDateString() + "</b>";
roomUrl.value = baseUrl + "/" + data.room + "?jwt=" + data.jwt;
})
})
unlockButton.disabled = true;
roomField.disabled = true;
hiddenField.classList.add('visible');
hiddenField.ariaHidden = "false";
}
function process_form() {
room = roomField.value
get_room()
}
function copyToClipboard() {
roomUrl.select();
document.execCommand('copy');
}
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment