-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
226 lines (217 loc) · 6.04 KB
/
index.html
File metadata and controls
226 lines (217 loc) · 6.04 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>Web3.Storage + Lit Integration Example</title>
<meta
name="description"
content="Test the full stack of Web3 Storage + Lit components in a web browser."
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
/>
<style>
body {
background-color: #f7f7f9;
display: flex;
flex-direction: column;
height: 100vh;
overflow: auto;
padding-top: 25px;
}
header {
text-align: center;
}
h1 {
font-size: 2rem;
}
h3 {
font-size: 1.5rem;
/* margin-left: 40px; */
}
p {
font-size: 1.2rem;
}
main {
max-width: 600px;
}
img {
height: 100px;
width: 100px;
}
.logo {
height: 75px;
width: 75px;
margin-right: auto;
margin-left: auto;
}
.hide {
display: none;
padding: 0;
margin: 0;
}
.center {
margin: 0 auto;
}
.loader {
display: inline-block;
width: 2rem;
height: 2rem;
vertical-align: text-bottom;
border: 0.25em solid currentColor;
border-right-color: transparent;
border-radius: 50%;
-webkit-animation: spin 1s linear infinite;
-moz-animation: spin 1s linear infinite;
animation: spin 1s linear infinite;
margin-right: 10px;
}
@-moz-keyframes spin {
100% {
-moz-transform: rotate(360deg);
}
}
@-webkit-keyframes spin {
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.alert {
margin-top: 15px;
}
.space-around {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
.ceramic-btn.active {
background-color: #f87237 !important;
color: white !important;
}
.idx-btn.active {
background-color: #6535ff !important;
color: white !important;
}
ul {
padding-left: 20px;
}
.documentation {
resize: both;
overflow: auto;
height: 200px;
width: 100%;
border: 1px solid transparent;
display: none;
}
.fileUpload {
display: inline-block;
}
</style>
</head>
<body>
<div class="container">
<header>
<div class="row">
<div class="col-xs-12 alert hide" role="alert" id="alerts"></div>
<div class="col-xs-offset-10 col-xs-2">
<span class="badge rounded-pill bg-secondary" id="userDID">Not Connected</span>
</div>
</div>
<div>
<img id="logo" src="images/lit-logo.png" alt="lit logo" />
+
<img id="logo" src="images/web3-storage-logo.svg" alt="web3 storage logo" />
</div>
<h1>Web3.Storage + Lit Integration Example</h1>
<p>
Test out the Web3.Storage + Lit Integration Example.
<br />
Encrypt with Lit and store in Web3 Storage
<br />
then read from it back using Web3 Storage and decrypt with Lit.
</p>
<div class="fileUpload">
<label for="uploadInput">File:</label>
<input id="uploadInput" type="file" name="myFile"/>
<br />
<p>Size: <span id="fileSize">0</span></p>
</div>
</header>
<main class="container center">
<div class="row">
<div class="col-xs-12 space-around">
<br />
<br />
<div id="cid"></div>
</div>
<div class="col-xs-12 col-lg-6">
<iframe
class="documentation"
src="https://developers.ceramic.network/build/javascript/quick-start/"
id="ceramic_docs"
>
</iframe>
</div>
<div class="col-xs-12 col-lg-6 text-right">
<iframe
class="documentation"
src="https://developers.idx.xyz/build/quick-start/"
id="idx_docs"
></iframe>
</div>
</div>
<div id="encryptLit">
<button
id="encryptLit"
type="button"
class="btn btn-primary center"
style="display: inherit; margin: 20px auto"
>
Encrypt w/ Lit + Web3.Storage upload
</button>
</div>
<div id="retrieveFromWeb3Storage">
<button
id="retrieveFromWeb3Storage"
type="button"
class="btn btn-primary center"
style="display: inherit; margin: 20px auto"
>
Retrieve from Web3.Storage and Decrypt w/ Lit
</button>
</div>
<div id="decryption"></div>
</main>
</div>
</body>
<script type="module" src="src/app.ts"></script>
<script>
function updateSize() {
let nBytes = 0,
oFiles = this.files,
nFiles = oFiles.length;
for (let nFileId = 0; nFileId < nFiles; nFileId++) {
nBytes += oFiles[nFileId].size;
}
let sOutput = nBytes + " bytes";
// optional code for multiples approximation
const aMultiples = ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
for (nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) {
sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)";
}
// end of optional code
document.getElementById("fileSize").innerHTML = sOutput;
}
document.getElementById("uploadInput").addEventListener("change", updateSize, false);
</script>
</html>