Working more on web server
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Exchange</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
|
||||
<script src="{{ url_for('static', filename='socket.io.min.js') }}" integrity="sha384-mkQ3/7FUtcGyoppY6bz/PORYoGqOl7/aSUMn2ymDOJcapfS6PHqxhRTMh1RR0Q6+" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Santa exchange</h1>
|
||||
<label for="own_name">Your name: </label><br /><input type="text" id="own_name" /><br />
|
||||
<br />
|
||||
<label for="info_for_santa">Info for your santa (e.g. shipping address or similar):</label><br />
|
||||
<textarea id="info_for_santa"></textarea><br />
|
||||
<button id="submit_info_button">Submit your info</button>
|
||||
<br /><br /><br />
|
||||
<p id="statusParagraph"></p>
|
||||
<button>Start with current participants</button>
|
||||
<p>Current participants:</p>
|
||||
<div id='participantList'></div>
|
||||
<!--<script type="text/javascript">
|
||||
const socket = io();
|
||||
const client_id = Math.floor(Math.random() * 2**64)
|
||||
socket.emit('join', {room: window.location.pathname, 'client_id': client_id})
|
||||
|
||||
socket.on('message', data => {
|
||||
// All messages are broadcast to everyone, so discard messages that were actually sent from ourselves
|
||||
data = JSON.parse(data);
|
||||
if (data['client_id'] != client_id) {
|
||||
console.log(data);
|
||||
console.log(data['message']);
|
||||
window.pass_message_to_python(JSON.stringify(data['message']));
|
||||
}
|
||||
});
|
||||
</script>-->
|
||||
|
||||
<script type="text/javascript">
|
||||
const exchangeWorker = new Worker("{{ url_for('static', filename='exchange_worker.js') }}", { type: 'module' });
|
||||
|
||||
exchangeWorker.onmessage = (e) => {
|
||||
console.log('Received message:');
|
||||
console.log(e);
|
||||
document.getElementById('statusParagraph').innerHTML = e.data;
|
||||
};
|
||||
|
||||
exchangeWorker.postMessage('Nothing');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user