forked from richardyrh/Cal-Course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.js
More file actions
58 lines (53 loc) · 1.41 KB
/
add.js
File metadata and controls
58 lines (53 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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() {
}