52 lines
1.7 KiB
HTML
52 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>DecentraSanta</title>
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"/>
|
|
<script type="text/javascript" src="{{ url_for('static', filename='pyodide.js') }}"></script>
|
|
</head>
|
|
<body>
|
|
<div class="bodyDiv">
|
|
<h1>DecentraSanta</h1>
|
|
<p>Welcome to the decentralised secret santa exchange. This website uses cryptography to distribute secret santas
|
|
in such a way that no one but you, not even the server the communication goes through, can know who you're
|
|
giving a
|
|
gift to.</p>
|
|
|
|
<p>You can either start a new secret santa exchange, or join an existing one.</p>
|
|
|
|
<br/>
|
|
<button id="start_new" onclick="onNewExchange();">Start new exchange</button>
|
|
<br/>
|
|
<br/>
|
|
<input type="text" id="existing_address" />
|
|
<br/>
|
|
<button id="join_existing" onclick="onJoinExchange();">Join existing exchange</button>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
function onNewExchange() {
|
|
const byteArray = new Uint8Array(8);
|
|
self.crypto.getRandomValues(byteArray);
|
|
let randomHexString = Array.from(byteArray).map(x => x.toString(16)).reduce((a, c) => a + c);
|
|
var urlString = window.location.href;
|
|
if (!urlString.endsWith('/')) {
|
|
urlString = urlString + '/';
|
|
}
|
|
urlString = urlString + randomHexString;
|
|
window.location.href = urlString;
|
|
}
|
|
|
|
function onJoinExchange() {
|
|
const existingExchange = document.getElementById('existing_address').value;
|
|
var urlString = window.location.href;
|
|
if (!urlString.endsWith('/')) {
|
|
urlString = urlString + '/';
|
|
}
|
|
urlString = urlString + existingExchange;
|
|
window.location.href = urlString;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |