-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathscript.js
More file actions
56 lines (52 loc) · 1.68 KB
/
Copy pathscript.js
File metadata and controls
56 lines (52 loc) · 1.68 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
var app = new Vue({
el: '#app',
data: {
shortcuts:[],
newLinkName:null,
newLinkUrl:null
},
mounted() {
if (localStorage.getItem('shortcuts')) {
try {
this.shortcuts = JSON.parse(localStorage.getItem('shortcuts'));
} catch(e) {
localStorage.removeItem('shortcuts');
}
}
},
methods: {
addNewLink(){
this.shortcuts.push({
name: this.newLinkName,
target: this.newLinkUrl,
img: 'https://www.google.com/s2/favicons?domain=' + this.newLinkUrl
}),
this.newLinkName = '';
this.newLinkUrl = '';
this.saveToLocal();
ToggleAddModal();
},
removeLink(x){
this.shortcuts.splice(x,1);
this.saveToLocal();
},
saveToLocal(){
localStorage.setItem('shortcuts', JSON.stringify(this.shortcuts));
}
}
})
function ToggleAddModal(){
document.getElementById("add-link-modal").classList.toggle("show-flex");
}
function addModalContent(){
document.getElementById("modal-content-btn-1").classList.add("active");
document.getElementById("modal-content-1").classList.add("show");
document.getElementById("modal-content-btn-2").classList.remove("active");
document.getElementById("modal-content-2").classList.remove("show");
}
function listModalContent(){
document.getElementById("modal-content-btn-1").classList.remove("active");
document.getElementById("modal-content-1").classList.remove("show");
document.getElementById("modal-content-btn-2").classList.add("active");
document.getElementById("modal-content-2").classList.add("show");
}