Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cal Course - Add</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
<script src="qrcode.min.js"></script>
<script src="add.js"></script>
</head>
<body>
<div id="main-container">
<h1>Cal Course</h1>
<pre> </pre>
<h2>- Add Course Info</h2>
<input id="course-code" type="text" placeholder="COMPSCI 61"></input>
<input id="course-name" type="text" placeholder="Structure and Interpretation of Crafted Procrastination"></input>
<h3>Select QR Code</h3>
<input id="qr" type="file" accept="image/jpg,image/png,image/jpeg"></input>
<button class="preview-button" onclick="loadPreview()">Preview</button>
<div id = "img-container">
<img id="qr-preview" src="src/qr-place-holder.png" style = "max-width: 150px; max-height: 150px">
</div>
<button class="submit-button" onclick="loadPreview()">Submit</button>
</div>
</body>
</html>
58 changes: 58 additions & 0 deletions add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
let token = '';

$(() => {
$.ajax({
type: 'POST',
url: "http://118.25.79.158:3000/api/v1/auth/",
contentType: 'application/json',
dataType: 'json',
data: {
email: "oski@berkeley.edu",
},
success: (response) => {
token = concat(response.token);
console.log(response);
},
error: (response) => {
console.log(response);
},
})
});

function submitInfo() {
$.ajax({
type: 'POST',
url: 'http://118.25.79.158:3000/api/v1/courses/',
headers: {
'Authorization': 'Bearer: ' + token,
},
contentType: 'application/json',
dataType: 'json',
data: {
code: $("#course-code").val(),
name: $("#course-name").val(),
qr_code: (getURL()),
},
success: (response) => {
console.log(response);
},
error: (response) => {
console.log(response);
},
})
}

function loadPreview() {
let qrCodeFile = document.getElementById('qr').files[0];
let previewer = new FileReader();
previewer.onload = function (e) {
let qrCodeImg = document.getElementById("qr-preview");
qrCodeImg.src = e.target.result;
qrCodeImg.style = "max-width: 150px; max-height: 150px";
};
previewer.readAsDataURL(qrCodeFile);
}

function getURL() {

}
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ <h1>Cal Course</h1>
<div id="about-container" class="hidden">
Made with ♥️ by ... <br /><br />
Prototype: Yufeng Chi <br />
Front end: Ruohan Yan <br />
Front end: Ruohan Yan<br />
Front end: Yuanhan Li<br />
Back end: Shufan Li
<button class="toggle-button">&times;</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let api = "http://118.25.79.158:3000/api/v1/courses/";
let api = "http://118.25.79.158:3000/api/vvv/courses/";

$(() => {
$.ajax({url: api, headers: {
Expand Down
Binary file added src/qr-place-holder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 53 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ h1 {
color: var(--p-fg);
}

#course-code {
background-color: transparent;
border: none;
outline: none;
border-bottom: solid 1px var(--accent);
font-size: 18px;
color: var(--p-fg);
}

#course-name {
background-color: transparent;
border: none;
outline: none;
border-bottom: solid 1px var(--accent);
font-size: 18px;
color: var(--p-fg);
}

#qr {
display: block;
background-color: transparent;
outline: none;
font-size: 18px;
color: var(--accent);
}

#card-container {
display: grid;
grid-gap: 32px;
Expand Down Expand Up @@ -127,7 +153,7 @@ h1 {
#about-container {
position: fixed;
top: 10vh;
height: 200px;
height: 220px;
width: 300px;
left: calc(50vw - 150px);
background-color: var(--p-bg);
Expand Down Expand Up @@ -167,3 +193,29 @@ h1 {
cursor: pointer;
font-size: 14px;
}

.submit-button {
display: block;
border: solid 2px var(--accent);
padding: 3px;
background-color: var(--accent);
color: white;
cursor: pointer;
font-size: 20px;
margin: 0px;
}

.preview-button {
display: block;
border: solid 2px var(--accent);
padding: 3px;
background-color: white;
color: var(--accent);
cursor: pointer;
font-size: 15px;
margin-bottom: 35px;
}

.img-container {
margin: 0px;
}