Files
syncapp/public/client.html

167 lines
5.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Room ID Form</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65"
crossorigin="anonymous"
/>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
#form-container {
text-align: center;
border: 1px solid #ccc;
padding: 20px;
border-radius: 5px;
background-color: #f7f7f7;
}
</style>
</head>
<body>
<div id="form-container">
<form id="roomForm">
<h2>Room ID</h2>
<label for="roomId">Room ID:</label>
<input type="text" id="roomId" required />
<br /><br />
<button type="submit" id="submitBtn">Join</button>
</form>
<div id="mainPage" style="display: none">
<div class="container text-center">
<div class="row">
<div class="col">
<img height="80" src="http://localhost:3000/api/file/files/img.png" />
</div>
</div>
<div class="row">
<div class="col">
<video
id="video_field"
height="300"
src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
controls
></video>
</div>
<div class="col">
<h4>Host? <span id="host_field"></span></h4>
<h4 id="room_field">Room ID:</h4>
<h4 id="name_field">Your name:</h4>
<h4>Other connected clients:</h4>
<p id="clients_field"></p>
</div>
<div class="col-5">
<p
id="global_field"
style="height: 200px; overflow-x: hidden; overflow-y: scroll"
></p>
<div style="display: flex; justify-content: center">
<input
style="width: 200px; margin-right: 10px"
type="text"
id="global_input"
class="form-control"
/>
<button
onclick="ClientInstance.sendGlobal()"
class="btn btn-primary small-button"
>
Send Global
</button>
</div>
</div>
<div class="col">
<button
onclick="ClientInstance.makeHost()"
class="btn btn-primary small-button"
>
Make Host
</button>
<div
style="display: flex; justify-content: center; padding: 10px"
>
<input
placeholder="Change name:"
style="width: 200px; margin-right: 10px"
type="text"
id="name_input"
class="form-control"
/>
<button
onclick="ClientInstance.changeName()"
class="btn btn-primary small-button"
>
Change Name
</button>
</div>
<div style="display: flex; justify-content: center">
<input
placeholder="Put link:"
style="width: 200px; margin-right: 10px"
type="text"
id="link_input"
class="form-control"
/>
<button
style="margin-right: 10px"
onclick="ClientInstance.setLink()"
class="btn btn-primary small-button"
>
Set Link
</button>
<button
onclick="ClientInstance.syncVideo()"
class="btn btn-primary small-button"
>
Sync
</button>
</div>
</div>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js"
integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"
></script>
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</div>
</div>
<script src="/utils.js"></script>
<script src="/client.js"></script>
<script>
const UTL = new Utils();
let ClientInstance;
document.addEventListener('DOMContentLoaded', () => {
const roomForm = UTL.$('roomForm');
const mainPage = UTL.$('mainPage');
roomForm.addEventListener('submit', (event) => {
event.preventDefault();
const ID = UTL.$('roomId').value;
mainPage.style.display = 'block';
roomForm.style.display = 'none';
ClientInstance = new Client(ID);
ClientInstance.connect();
});
});
</script>
</body>
</html>