Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
78 lines (65 loc) · 1.97 KB
/
Copy pathindex.js
File metadata and controls
78 lines (65 loc) · 1.97 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
let postingsList = [];
let chromeSyncList = [];
const clearBtn = document.getElementById("clear-btn");
const addBtn = document.getElementById("save-tab");
const displayList = document.getElementById("displayList");
const leadsInLocalStorage = JSON.parse(localStorage.getItem("postingsList"));
if(leadsInLocalStorage) {
postingsList = leadsInLocalStorage
render()
}
class Job {
constructor() {
this.jobstage = jobstage;
this.notes = notes;
}
}
const notes = document.querySelector("#notes");
const jobstage = document.querySelector("#jobstage");
addBtn.addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
let link = tabs[0].url;
let newJob = new Job();
newJob.url = link;
postingsList.push(newJob);
localStorage.setItem("postingsList", JSON.stringify(postingsList))
newJob.notes = notes.value;
newJob.jobstage = jobstage.value;
localStorage.setItem("postingsList", JSON.stringify(postingsList))
//Chrome Storage Sunc
chrome.storage.sync.set({key: postingsList}, function() {
console.log('Value is set to ' + postingsList[0].url);
});
render()
})
})
clearBtn.addEventListener("click", () => {
localStorage.clear()
postingsList = [];
while (displayList.firstChild) {
displayList.removeChild(displayList.firstChild);
}
render();
})
function render() {
chrome.storage.sync.get(['key'], function(result) {
console.log(postingsList.forEach((post) => {
console.log(post.url);
console.log(post.notes);
console.log(post.jobstage);
} ) );
chromeSyncList = postingsList;
});
let listItems = ""
for(let i = 0; i < chromeSyncList.length; i++) {
listItems += `
<h3>${i+1}. ${chromeSyncList[i].notes}</h3></br>
<a target="_blank" href=${chromeSyncList[i].url}>${chromeSyncList[i].url}</a> </br>
<li>
${chromeSyncList[i].jobstage}
</li></br>
</hr>
`
}
displayList.innerHTML = listItems
}