-
Notifications
You must be signed in to change notification settings - Fork 5
/
popup.js
50 lines (37 loc) · 1.44 KB
/
popup.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
function showAddresses() {
var bg = chrome.extension.getBackgroundPage();
if (bg.current_tab === null) return;
var addresses = bg.addresses[bg.current_tab];
if (!addresses) return;
var list = document.getElementById('bitcoin-list');
for (var i = 0; i < addresses.bitcoin.length; i++) {
var a = addresses.bitcoin[i];
var title = a.label || a.address;
var item = document.createElement('li');
var link = document.createElement('a');
link.setAttribute('href', a.url);
link.setAttribute('target', '_blank');
link.appendChild(document.createTextNode(title));
item.appendChild(link);
item.appendChild(document.createTextNode(' ('));
var qrLink = document.createElement('a');
qrLink.setAttribute('href', 'http://chart.googleapis.com/chart?chs=200x200&cht=qr&chld=H|0&chl='+encodeURIComponent(a.url));
qrLink.setAttribute('target', '_blank');
qrLink.appendChild(document.createTextNode('QR'));
item.appendChild(qrLink);
item.appendChild(document.createTextNode(')'));
list.appendChild(item);
}
var list = document.getElementById('other-list');
for (var i = 0; i < addresses.other.length; i++) {
var url = addresses.other[i];
var item = document.createElement('li');
var link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('target', '_blank');
link.appendChild(document.createTextNode(url));
item.appendChild(link);
list.appendChild(item);
}
}
window.onload = showAddresses;