-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcandidateUpdate.js
104 lines (100 loc) · 3.27 KB
/
candidateUpdate.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
$(window).on('load',function() {
//console.log("Username : " +getUsername());
console.log(localStorage.getItem("id"));
$('#headerName').text(`${localStorage.getItem("name")}`);
$('#userName').text(`${localStorage.getItem("name")}`);
$('#skills').text(`${localStorage.getItem("skills")}`);
$('#resumeDisplay').attr('src',`https://resume-bucket-bsb.s3.amazonaws.com/resume_${localStorage.getItem("id")}`)
/*$.ajax({
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
},
contentType: "application/json",
method: "GET",
url: "https://ofdgpvz74k.execute-api.us-east-1.amazonaws.com/dev/getjobrecs",
data: {
'candidate_id': localStorage.getItem("id")
}
}).done(function(response) {
console.log(response);
let jobIds = Object.keys(response);
let toAppendDOM = "";
for (let i=0;i<jobIds.length;i++) {
toAppendDOM += `<div> ${response[jobIds[i]].positionName.S} <button style="float: right; margin-left: 100px;"> Apply </button> <div>${response[jobIds[i]].companyName.S}</div></div>`
}
$('#joblist')[0].innerHTML = toAppendDOM;
});*/
});
let temp;
function convertToBase64(selectedFile) {
//Read File
//Check File is not Empty
console.log(selectedFile)
if (selectedFile) {
console.log("Inside if")
// Select the very first file from list
var fileToLoad = selectedFile;
// FileReader function for read the file.
var fileReader = new FileReader();
var base64;
// Onload of file read the file content
fileReader.onload = function(fileLoadedEvent) {
temp = fileLoadedEvent.target.result;
// Print data in console
console.log(base64);
};
// Convert data to base64
console.log("Filetoload")
console.log(fileToLoad)
let toReturn = fileReader.readAsDataURL(fileToLoad);
console.log("done")
console.log(toReturn);
return temp;
}
}
function resolveUpload(File){
console.log("Filee")
console.log(temp)
$.ajax({headers:{
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'OPTIONS, POST',
},
url: "https://jwjkqbwke5.execute-api.us-east-1.amazonaws.com/dev/updateresume",
method: "POST",
data: temp,
isBase64Encoded: false
}).done(function (response) {
console.log(response);
$('#skills').text(response);
localStorage.setItem("skills",response);
});
}
function rejectUpload(inp){
console.log(inp)
}
$('#updateProfile').on('click',function () {
console.log("UPDATE");
var fd = new FormData();
var File = document.getElementById("resume-upload").files[0];
let promise = new Promise((resolve, reject) => {
convertToBase64(File);
let that = this;
setTimeout(() => {
console.log("The file sent in resolve");
console.log(temp);
resolve(temp);
}, 3000);
});
promise.then(
function() {
console.log("Inside resolve");
resolveUpload(File);
},
function(Fie){
rejectUpload(File);
}
);
});