forked from supertestnet/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onboard.html
172 lines (168 loc) · 5.9 KB
/
onboard.html
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Pulsar</title>
<link rel="shortcut icon" type="image/png" href="favicon.png" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Chakra+Petch&family=Source+Code+Pro&family=UnifrakturCook:wght@700&display=swap"
rel="stylesheet"
/>
<script src="https://bundle.run/[email protected]"></script>
<link rel="stylesheet" href="index.css?v=12" />
<script>
var $ = document.querySelector.bind(document);
var $$ = document.querySelectorAll.bind(document);
var url_params = new URLSearchParams(window.location.search);
var url_keys = url_params.keys();
var $_GET = {};
for (var key of url_keys) $_GET[key] = url_params.get(key);
</script>
<script>
function bytesToHex(bytes) {
return bytes.reduce(
(str, byte) => str + byte.toString(16).padStart(2, "0"),
""
);
}
function textToHex(text) {
var encoder = new TextEncoder().encode(text);
return [...new Uint8Array(encoder)]
.map((x) => x.toString(16).padStart(2, "0"))
.join("");
}
function hexToText(hex) {
var bytes = new Uint8Array(Math.ceil(hex.length / 2));
for (var i = 0; i < hex.length; i++)
bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
var text = new TextDecoder().decode(bytes);
return text;
}
function modalVanish() {
$(".black-bg").style.display = "none";
$(".modal").style.display = "none";
}
function showModal(content, block_til_clear) {
if (block_til_clear)
var fn = `modalVanish();sessionStorage[ 'modal_cleared' ] = true;`;
else var fn = `modalVanish();`;
$(
".modal"
).innerHTML = `<div style="position: absolute;right: 1rem;top: 0.5rem;font-size: 2rem; cursor: pointer;" onclick="${fn}">×</div>`;
$(
".modal"
).innerHTML += `<div style="overflow-y: scroll; max-height: 80vh; margin-top: 1.5rem;">${content}</div>`;
$(".black-bg").style.display = "block";
$(".modal").style.display = "block";
}
</script>
</head>
<body>
<header>
<div class="title-container">
<h1>Pulsar</h1>
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div>
</header>
<p class="subtitle">Privacy with a pulse</p>
<div class="landing-container">
<div class="hero-container">
<p>Generate a secret key for a new chat room</p>
<button class="generate">Generate</button>
</div>
<div class="hero-container">
<p>Enter an already created chat room with your secret key</p>
<button class="generate"><a class="clicker">Enter</a></button>
</div>
</div>
<div
style="
flex-direction: column;
justify-content: center;
align-items: center;
word-wrap: break-word;
overflow-wrap: anywhere;
padding: 1rem;
border: 1px solid black;
margin-top: 1rem;
display: none;
"
class="magic_string_box"
>
<p style="font-weight: bold; text-decoration: underline">
Your chat string
</p>
<div class="magic_string"></div>
</div>
<script>
var relays;
var defaultRelays = [
"wss://nostrue.com/",
"wss://relay.damus.io/",
"wss://relay.nostr.band/",
"wss://relay.snort.social/",
"wss://nostr21.com/",
"wss://nos.lol/",
"wss://relay.primal.net/",
];
if (localStorage.getItem("relays")) {
relays = JSON.parse(localStorage.getItem("relays"));
} else {
console.log("elese");
relays = defaultRelays;
localStorage.setItem("relays", JSON.stringify(relays));
}
var index =
window.location.pathname.indexOf("onboard.htm") > -1
? window.location.pathname.indexOf("onboard.htm")
: 100000;
var extra_slash = window.location.pathname
.substring(0, index)
.endsWith("/")
? ""
: "/";
var url =
window.location.protocol +
"//" +
window.location.hostname +
window.location.pathname.substring(0, index) +
extra_slash +
"index.html?relays=" +
encodeURI(JSON.stringify(relays));
$(".clicker").href = url;
var genString = () => {
$(".magic_string_box").style.display = "flex";
$(".magic_string").innerText = "•";
$(".magic_string").style.fontSize = "250%";
setTimeout(function () {
$(".magic_string").innerText = "••";
}, 200);
setTimeout(function () {
$(".magic_string").innerText = "•••";
}, 400);
setTimeout(function () {
$(
".magic_string_box"
).innerHTML = `<p style="font-weight: bold; text-decoration: underline;">Your chat string</p><div class="magic_string" style="text-align: center;"></div><p class="followup" style="text-align: center;"></p>`;
$(".magic_string").style.fontSize = "100%";
// $( '.magic_string' ).innerText = bytesToHex( nobleSecp256k1.utils.randomPrivateKey() ) + textToHex( JSON.stringify( relays ) );
$(".magic_string").innerText = bytesToHex(
nobleSecp256k1.utils.randomPrivateKey()
);
$(
".followup"
).innerHTML = `Now copy it and <a href="${url}">use it here</a> -- and share it, along with this site's url, with anyone you want in your group`;
}, 600);
};
$(".generate").onclick = genString;
</script>
<div class="black-bg"></div>
<div class="modal"></div>
</body>
</html>