Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenhuynh committed Nov 6, 2023
2 parents bf1f569 + c767c02 commit f2ab7e9
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 144 deletions.
14 changes: 11 additions & 3 deletions assets/classroom/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ function removePlaylistDiv(index) {
let items = document.getElementsByClassName('playlistItem')

items[index].remove()
playlist[index].remove()

items = document.getElementsByClassName('playlistItem')
// items = document.getElementsByClassName('playlistItem')

for (let i = 0; i < items.length; i ++) {
items[i].children[0].innerHTML = i + 1
Expand Down Expand Up @@ -532,8 +533,15 @@ document.addEventListener('DOMContentLoaded', function() {
let codeVerifier2 = localStorage.getItem('code_verifier');
const urlParams = new URLSearchParams(window.location.search);
let code = urlParams.get('code');
// const redirectUri = 'http://127.0.0.1:4100/classroom';
const redirectUri = 'https://classroomjukebox.com/classroom';
var redirectUri = "";
var siteUrl = "{{ site.url }}"
if (siteUrl.includes("localhost")){
redirectUri = 'http://127.0.0.1:4100/classroom';
}
else {
redirectUri = 'https://classroomjukebox.com/classroom';
}

const clientId = 'a76d4532c6e14dd7bd7393e3fccc1185';

let body = new URLSearchParams({
Expand Down
48 changes: 38 additions & 10 deletions assets/search/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,33 @@
height: 5em;
width: auto;
}
@import url("https://fonts.googleapis.com/css?family=Rubik%20Mono%20One:900&display=swap");
body{
background-color: #191414;
background-image: url('../../images/purple-bg.jpeg');

}
table {
table-layout: fixed;
width: 100%;
width: 95%;
border-collapse: collapse;
border: 3px solid purple;
/*border: 3px solid purple;*/
}
.center {
margin-left: auto;
margin-right: auto;
}
thead th:nth-child(1) {
width: 20%;
}
thead th:nth-child(2) {
width: 20%;
}
thead th:nth-child(3) {
width: 15%;
width: 12.5%;
}
thead th:nth-child(4) {
width: 25%;
width: 27.5%;
}
thead th:nth-child(5) {
width: 15%;
Expand All @@ -33,12 +40,13 @@ html {
font-family: "helvetica neue", helvetica, arial, sans-serif;
}
thead th, tfoot th {
font-family: "Rock Salt", cursive;
font-family: 'Rubik Mono One', sans-serif; /* Apply the imported font */
}
th {
letter-spacing: 2px;
letter-spacing: 1.5px;
text-align: center;
max-height: 5%;
font-size: 20px;
}
td {
letter-spacing: 1px;
Expand All @@ -60,7 +68,7 @@ thead th, tfoot th, tfoot td {
rgba(0, 0, 0, 0.1),
rgba(0, 0, 0, 0.5)
);
border: 3px solid rgb(101, 178, 216);
border: 2px solid white;
}
tr {
font-weight: bold;
Expand All @@ -72,14 +80,21 @@ tbody tr:nth-child(even) {
background-color: #e597e2;
}
table {
background-color: #a023d5;
background-color: #924bee;
}
.center {
margin-left: auto;
margin-right: auto;
}
/* .metadata {
height: 0px;
} */

/* Code for the Search Input */
.input-group{
display: flex;
justify-content: space-between;
flex: 2;
margin: auto;
margin-top: auto;
width: 80%;
Expand All @@ -94,7 +109,7 @@ table {
}

.button-elements {

margin-left: 10px;
}

.button-elements button {
Expand All @@ -111,4 +126,17 @@ table {
}
.button-elements button:hover {
background-color: #df7bda;
}
}

.table button{
margin: auto;
display: block;
background-color: #924bee;
color: #fff;
border: none;
border-radius: 25px;
padding: 10px 20px;
cursor: pointer;
font-size: 18px;
margin-bottom: 20px;
}
68 changes: 9 additions & 59 deletions assets/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ function fetchData() {
const preview = document.createElement("td");
const playSong = document.createElement("td");

image.style.display = "flex";
image.style.justifyContent = "center";

const playButton = document.createElement("button")
playButton.innerHTML = "Request Your Song!"
playButton.onclick = function() {sendMessage(row.uri.slice(14))}
Expand Down Expand Up @@ -128,63 +131,10 @@ function fetchData() {
.catch(error => {
console.error('Error:', error);
});
}

// fetch(url, headers)
// .then(response => {
// if (response.status !== 200) {
// const errorMsg = 'Database response error: ' + response.status;
// console.log(errorMsg);
// const tr = document.createElement("tr");
// const td = document.createElement("td");
// td.innerHTML = errorMsg;
// tr.appendChild(td);
// resultContainer.appendChild(tr);
// return;
// }

// response.json().then(data => {
// console.log(data);

// for (const row of data.results) {
// console.log(row);

// const tr = document.createElement("tr");

// const artist = document.createElement("td");
// const track = document.createElement("td");
// const image = document.createElement("td");
// const preview = document.createElement("td");

// artist.innerHTML = row.artistName;
// track.innerHTML = row.trackName;
// const img = document.createElement("img");
// img.src = row.artworkUrl100;
// image.appendChild(img);

// const audio = document.createElement("audio");
// audio.controls = true;
// const source = document.createElement("source");
// source.src = row.previewUrl;
// source.type = "audio/mp4";
// audio.appendChild(source);
// preview.appendChild(audio);

// tr.appendChild(artist);
// tr.appendChild(track);
// tr.appendChild(image);
// tr.appendChild(preview);

// resultContainer.appendChild(tr);
// }
// })
// })
// .catch(err => {
// console.error(err);
// const tr = document.createElement("tr");
// const td = document.createElement("td");
// td.innerHTML = err;
// tr.appendChild(td);
// resultContainer.appendChild(tr);
// });
}
document.addEventListener("keydown", function (key) {
if (key.code === "Enter") {
fetchData();
}
});
55 changes: 27 additions & 28 deletions assets/sign-in/script.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
function signIn(event) {
event.preventDefault();
document.getElementById('signInForm').addEventListener('submit', function(event) {
event.preventDefault();

// Get email and password from the form
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;

// authentication logic (validate email and password)
/*
if (email == (get email data) && password == (get password data)) {
const isAuthenticated = true;
}
else {
const isAuthenticated = false;
}
*/
// Make a POST request to your authentication endpoint
fetch('https://cj-backend.stu.nighthawkcodingsociety.com/human/authenticate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
password: password
})
})
.then(response => response.json())
.then(data => {
// Assuming the response contains a 'token' field
var token = data.token;
// Store the token in localStorage or a cookie for future use
// For simplicity, we're using localStorage here
console.log(token);
localStorage.setItem('token', token);

// For demo purposes, let's assume successful authentication
const isAuthenticated = true;

if (isAuthenticated) {
// Set a cookie with the user's email
document.cookie = `userEmail=${email}; expires=Sun, 1 Jan 2023 00:00:00 UTC; path=/`;

// Redirect to the home page
window.location.href = '/';
} else {
// Display an error message (you can customize this based on your authentication logic)
alert('Authentication failed. Please check your email and password.');
}
}
alert('Sign in successful!');
})
.catch(error => console.error('Error:', error));
});
12 changes: 3 additions & 9 deletions search.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,18 @@
</style>

<body>
<div style="margin-top: 4%;">
<div style="margin-top:4%;">
<div class="input-group">
<input type="text" id="filterInput" placeholder="Enter">
<div class="button-elements">
<button id="search">Search</button>
</div>
<div class="button-elements"><button id="search">Search</button></div>
</div>
<link
href="https://fonts.googleapis.com/css?family=Rock+Salt"
rel="stylesheet"
type="text/css"/>
<link rel="stylesheet" type="text/css" href="/assets/search/search.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
<script src="/assets/search/search.js" type="module">
</script>
</div>
<table>
<table class="center">
<thead>
<tr>
<div class="metadata">
Expand Down
33 changes: 1 addition & 32 deletions sign_in.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,7 @@ <h2>Sign In</h2>
</form>
</div>

<script>
document.getElementById('signInForm').addEventListener('submit', function(event) {
event.preventDefault();

var email = document.getElementById('email').value;
var password = document.getElementById('password').value;

// Make a POST request to your authentication endpoint
fetch('https://cj-backend.stu.nighthawkcodingsociety.com/human/authenticate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
password: password
})
})
.then(response => response.json())
.then(data => {
// Assuming the response contains a 'token' field
var token = data.token;
// Store the token in localStorage or a cookie for future use
// For simplicity, we're using localStorage here
console.log(token);
localStorage.setItem('token', token);

alert('Sign in successful!');
})
.catch(error => console.error('Error:', error));
});
</script>
<script src="{{site.baseurl}}/assets/sign-in/script.js"> </script>

</body>
</html>
Loading

0 comments on commit f2ab7e9

Please sign in to comment.