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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<html>
<head>
<meta charset="utf-8" />
<link rel="manifest" href="./manifest.json" />
<style>
/* Normalize font-family, rather than letting the UA decide */
html {
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
}
/* Setup the popup overlay */
.overlay {
/* TODO: Consider moving it to the top right of the screen, like an actual popup usually is */
position: fixed;
top: 0px;
left: 0px;
display: none;
width: 100%;
height: 100%;
background-color: #0007;
backdrop-filter: blur(12px);
color: white;
justify-content: center;
}
.overlay > iframe {
margin: auto;
border: 1px solid #666;
}
#wallet-window {
border: 1px solid #666;
border-radius: 4px;
/* TODO: why arbitrary 38px? also why no flexbox? */
height: calc(100% - 38px);
width: min(850px, calc(100% - 8px));
}
/* firefox's native button styles more or less, because conistency is good */
button {
background: #e9e9ed;
color: #151516;
border: 1px solid #828282;
border-radius: 4px;
}
button:hover {
background: #c0c0c0;
}
</style>
</head>
<body>
<script>
function openPopup() {
document.getElementById("popup-overlay").style.display = "flex";
window.frames["popup"].location = "popup.html";
}
function closePopup() {
document.getElementById("popup-overlay").style.display = "none";
}
function redirectWallet(url) {
window.frames["wallet"].location = url;
}
function openWallet() {
redirectWallet("wallet.html");
}
function closeWallet() {
redirectWallet("about:blank");
}
function reloadWallet() {
window.frames["wallet"].location.reload();
}
function openPage() {
window.frames["other"].location =
document.getElementById("page-url").value;
}
</script>
<button onclick="openPopup()">Open Popup</button>
<button onclick="closeWallet();openWallet()">Restart Wallet</button>
<button onclick="reloadWallet()">Refresh Frame</button>
<div style="height: 8px"></div>
<iframe id="wallet-window" name="wallet" src="wallet.html" width="">
</iframe>
<div class="overlay" id="popup-overlay" onclick="closePopup()">
<iframe
id="popup-window"
name="popup"
src="about:blank"
width="500"
height="325"
>
</iframe>
</div>
<!-- <hr />
<iframe src="tests.html" name="wallet" width="800" height="100%"> </iframe> -->
<!-- <hr />
<iframe src="stories.html" name="wallet" width="800" height="100%"> -->
<script type="module" src="background.dev.js"></script>
<script type="module">
if ("serviceWorker" in navigator) {
try {
const registration = await navigator.serviceWorker.register("sw.js", {
scope: "/app/",
});
if (registration.installing) {
console.log("Service worker installing");
} else if (registration.waiting) {
console.log("Service worker installed");
} else if (registration.active) {
console.log("Service worker active");
}
} catch (error) {
console.error(`Registration failed with ${error}`);
}
}
</script>
</body>
</html>
|