-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgettlinks.js
45 lines (31 loc) · 1.24 KB
/
gettlinks.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
function codeAddress2(){
var i = -1;
links = JSON.parse(localStorage.getItem("links"));
titles = JSON.parse(localStorage.getItem("titles"));
for(x of links){
i = i + 1;
var button1 = document.createElement("BUTTON");
button1.setAttribute("onclick", "window.open(" + "'" + titles[i] + "'" + ")");
button1.setAttribute("class", "linkbutton");
button1.setAttribute("id", "linkbut")
button1.textContent = x;
document.getElementById("linki").appendChild(button1);
}
}
window.onload = codeAddress2();
var links = [];
var titles = [];
function addbutton(){
var link = document.getElementById("link").value;
var title = document.getElementById("linkname").value;
var button = document.createElement("BUTTON");
links.push(link);
titles.push(title);
button.setAttribute("onclick", "window.open( " + "'" + title + "'" + ")");
button.setAttribute("class", "linkbutton");
button.setAttribute("id", "linkbut")
button.textContent = link;
document.getElementById("linki").appendChild(button);
localStorage.setItem("links", JSON.stringify(links))
localStorage.setItem("titles", JSON.stringify(titles))
}