Merge pull request #1 from Codesamp-Rohan/main

This commit is contained in:
Raven Scott 2025-01-07 00:11:30 -05:00
parent 8d5b35a7b1
commit d906b8bf5d
3 changed files with 313 additions and 41 deletions

35
app.js
View File

@ -15,9 +15,7 @@ let conns = []; // Store Hyperswarm connections
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
console.log("DOM fully loaded and parsed"); console.log("DOM fully loaded and parsed");
document.getElementById('create-station').addEventListener('click', () => { document.getElementById('create-station').addEventListener('click', () => {
console.log("Create Station button clicked"); showModal('createStationModal');
const createStationModal = new bootstrap.Modal(document.getElementById('createStationModal'));
createStationModal.show();
}); });
document.getElementById('generate-new-key').addEventListener('click', () => { document.getElementById('generate-new-key').addEventListener('click', () => {
@ -33,27 +31,44 @@ document.addEventListener("DOMContentLoaded", () => {
console.log("Creating station with key:", b4a.toString(stationKey, 'hex')); console.log("Creating station with key:", b4a.toString(stationKey, 'hex'));
setupStation(stationKey); setupStation(stationKey);
const createStationModal = bootstrap.Modal.getInstance(document.getElementById('createStationModal')); hideModal('createStationModal');
createStationModal.hide();
}); });
document.getElementById('create-station-cancel-button').addEventListener('click', () => {
hideModal('createStationModal');
})
document.getElementById('leave-stream').addEventListener('click', () => { document.getElementById('leave-stream').addEventListener('click', () => {
console.log("Leave Stream button clicked"); console.log("Leave Stream button clicked");
leaveStation(); leaveStation();
}); });
document.getElementById('join-station-button').addEventListener('click', () => { document.getElementById('open-join-modal').addEventListener('click', () => {
console.log("Join Station button clicked"); showModal('joinModal');
joinStation();
const joinModal = bootstrap.Modal.getInstance(document.getElementById('joinModal'));
joinModal.hide();
}); });
document.getElementById('join-station-button').addEventListener('click', () => {
joinStation();
hideModal('joinModal');
});
document.getElementById('join-station-cancel-button').addEventListener('click', () => {
hideModal('joinModal');
})
document.getElementById('apply-audio-source').addEventListener('click', applyAudioSource); document.getElementById('apply-audio-source').addEventListener('click', applyAudioSource);
populateAudioInputSources(); populateAudioInputSources();
}); });
function showModal(modalId) {
document.getElementById(modalId).classList.remove('hidden');
}
function hideModal(modalId) {
document.getElementById(modalId).classList.add('hidden');
}
async function populateAudioInputSources() { async function populateAudioInputSources() {
try { try {
const devices = await navigator.mediaDevices.enumerateDevices(); const devices = await navigator.mediaDevices.enumerateDevices();

View File

@ -3,33 +3,16 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="./assets/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="./style.css">
<title>pearCast</title> <title>pearCast</title>
<style>
#titlebar {
-webkit-app-region: drag;
height: 30px;
width: 100%;
background-color: #343a40;
}
body {
margin: 0;
font-family: Arial, sans-serif;
}
pear-ctrl[data-platform="darwin"] {
float: left;
margin-top: 15px;
margin-left: 5px;
}
</style>
</head> </head>
<body class="bg-dark text-light"> <body class="bg-dark text-light">
<div id="titlebar"> <div id="titlebar">
<pear-ctrl></pear-ctrl> <pear-ctrl></pear-ctrl>
</div> </div>
<div class="container mt-5 text-center"> <div class="container text-center">
<h1>pearCast</h1> <h1>pearCast</h1>
<div id="setup" class="btn-group mt-4"> <div id="setup" class="create-join-btn-div">
<button id="create-station" class="btn btn-primary">Create Station</button> <button id="create-station" class="btn btn-primary">Create Station</button>
<button id="open-join-modal" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#joinModal">Join Station</button> <button id="open-join-modal" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#joinModal">Join Station</button>
</div> </div>
@ -52,7 +35,7 @@
</div> </div>
<!-- Join Modal --> <!-- Join Modal -->
<div class="modal fade" id="joinModal" tabindex="-1" aria-labelledby="joinModalLabel" aria-hidden="true"> <div class="modal fade hidden" id="joinModal" tabindex="-1" aria-labelledby="joinModalLabel" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content bg-dark text-light"> <div class="modal-content bg-dark text-light">
<div class="modal-header"> <div class="modal-header">
@ -63,7 +46,7 @@
<input type="text" id="station-id" class="form-control" placeholder="Enter Station ID"> <input type="text" id="station-id" class="form-control" placeholder="Enter Station ID">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> <button type="button" class="btn btn-secondary" id="join-station-cancel-button" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="join-station-button">Join</button> <button type="button" class="btn btn-primary" id="join-station-button">Join</button>
</div> </div>
</div> </div>
@ -71,28 +54,29 @@
</div> </div>
<!-- Create Station Modal --> <!-- Create Station Modal -->
<div class="modal fade" id="createStationModal" tabindex="-1" aria-labelledby="createStationModalLabel" aria-hidden="true"> <div class="modal fade hidden" id="createStationModal" tabindex="-1" aria-labelledby="createStationModalLabel" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content bg-dark text-light"> <div class="modal-content bg-dark text-light">
<div class="modal-header"> <div class="modal-header">
<div class="modal-body-container">
<h5 class="modal-title" id="createStationModalLabel">Create Station</h5> <h5 class="modal-title" id="createStationModalLabel">Create Station</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <p style="font-size: 9px; font-weight: 900; color: #bbb;">Generate a new station ID or<br /> use an existing ID?</p>
</div>
<button id="generate-new-key" class="btn btn-primary mt-2">Generate New ID</button>
<!-- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> -->
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Generate a new station ID or use an existing ID?</p> <input type="text" id="existing-key" class="form-control" placeholder="You may manually enter an ID here">
<button id="generate-new-key" class="btn btn-primary mt-2">Generate New ID</button>
<input type="text" id="existing-key" class="form-control mt-3" placeholder="You may manually enter an ID here">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> <button type="button" class="btn btn-secondary" id="create-station-cancel-button" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="create-station-button">Create Station</button> <button type="button" class="btn btn-primary" id="create-station-button">Create Station</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Bootstrap JavaScript Bundle (includes Popper) -->
<script src="./assets/bootstrap.bundle.min.js"></script>
<script type="module" src="app.js"></script> <script type="module" src="app.js"></script>
</body> </body>
</html> </html>
<!-- 8741a7bf2d7709dceb733e910f3397855a5abee01b9f9509c1405af08191abc9 -->

273
style.css Normal file
View File

@ -0,0 +1,273 @@
#titlebar {
-webkit-app-region: drag;
height: 40px;
width: 100%;
position: fixed;
top: 0;
background-color: #111;
border-bottom: 0.2px solid #444;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
background-color: #111;
color: #ddd;
width: 100%;
height: 540px;
}
pear-ctrl[data-platform="darwin"] {
float: left;
margin-top: 15px;
margin-left: 5px;
}
.hidden{
display: none !important;
}
h1 {
font-size: 16px;
margin: 0;
}
input{
background-color: #222;
border: 0;
color: #bbb;
font-weight: 900;
font-size: 14px;
}
button:focus, input:focus{
outline: none;
}
/* Button Styles */
.btn {
display: inline-block;
font-weight: 900;
text-align: center;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
padding: 0.5rem 0.75rem;
font-size: 12px;
line-height: 1.5;
border-radius: 0.5rem;
transition: all 0.15s ease-in-out;
min-width: 120px;
}
.create-join-btn-div{
display: flex;
}
#create-station{
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#open-join-modal{
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
#station-info{
font-size: 11px;
color: #aaa;
font-weight: 900;
}
.btn-primary {
color: #ddd;
background-color: #6e45fc;
border: 1px solid #8B5DFF;
}
.btn-primary:hover {
background-color: #7d59fd;
border-color: #7d59fd;
}
.btn-secondary {
color: #9678ff;
background-color: #111;
border: 1px solid #333;
}
.btn-secondary:hover {
border: 1px solid #6e45fc;
}
.btn-danger {
color: #dc3545;
background-color: #dc35462a;
border: 1px solid #dc3545;
}
.btn-danger:hover {
background-color: #bb2d3b52;
border-color: #b02a37;
}
.btn-success {
color: #73EC8B;
background-color: #73EC8B2d;
border-color: #73EC8B;
}
.btn-success:hover {
background-color: #73EC8B52;
border-color: #73EC8B;
}
.btn-close {
background: none;
border: none;
color: #fff;
font-size: 1.25rem;
cursor: pointer;
}
/* Container Styles */
.container {
width: 100%;
height: 100%;
margin: 0 auto;
padding: 1rem;
gap: 10px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
/* Modal Styles */
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
outline: 0;
display: none;
}
.modal.fade {
display: block;
opacity: 1;
}
.modal-dialog {
position: absolute;
margin: auto;
width: 80%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 0 20px #181818;
border-radius: 10px;
}
.modal-content {
background-color: #111;
border: 1px solid #444;
border-radius: 15px;
padding: 1rem;
}
.modal-header, .modal-footer {
display: flex;
justify-content: space-between;
}
.modal-title {
font-size: 12px;
}
.modal-body {
padding-block: 1rem;
}
.modal-body-container{
display: flex;
flex-direction: column;
justify-content: space-between;
}
.modal-footer {
border-top: 1px solid #444;
padding-top: 1rem;
}
/* Form Styles */
.form-control {
display: block;
width: 100%;
padding: 0.5rem 0.75rem;
line-height: 1.5;
background-clip: padding-box;
border-radius: 0.25rem;
}
.form-control::placeholder {
color: #adb5bd;
}
.form-label {
display: inline-block;
margin-bottom: 0.5rem;
font-size: 12px;
color: #ddd;
font-weight: 900;
}
.form-select {
display: block;
width: 100%;
padding: 0.375rem 1.75rem 0.375rem 0.75rem;
font-size: 12px;
line-height: 1.5;
color: #bbb;
background-color: #222;
background-image: none;
border: 1px solid #444;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
cursor: pointer;
}
.form-select:focus {
border-color: #666;
outline: 0;
}
/* Utility Classes */
.text-center {
text-align: center;
}
.mt-2 {
margin-top: 0.5rem;
}
.mt-3 {
margin-top: 1rem;
}
.mt-4 {
margin-top: 1.5rem;
}
.mt-5 {
margin-top: 3rem;
}
.d-none {
display: none;
}
.d-inline-block {
display: inline-block;
}