-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
196 lines (151 loc) · 5.45 KB
/
index.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE HTML>
<html>
<head>
<title>Gamerbits Cold Storage</title>
<meta charset="utf-8" />
<link rel="icon" href="favicon4.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><![endif]-->
<link rel="stylesheet" href="assets/css/main.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->
</head>
<body class="homepage">
<div id="page-wrapper">
<div id="phaser-game" style="background-color: black;">
<!-- Logo -->
<div id="uglyguy-logo-image">
<h1 style="margin-bottom: -190px">
<a href="index.html">
<img src="images/logo2.png" style="width:30vw;height:45vh;padding-top:55px;z-index:3;background-color:white;background-image:url('images/gif.gif');background-size: contain;margin-top:10px;background-repeat:none;">
</a>
</h1>
</div>
</div>
<!-- Footer -->
<div id="footer-wrapper" class="wrapper">
<div class="title">Gamerbits Cold Storage</div>
<div id="footer" class="container">
<div class="container">
<center>
<div class="container">
<center>
<button id="authorise" class="waves-effect waves-red btn black">Authorise</button>
<br>
<br>
<span id="buttonz">
<input type="text" placeholder="TYPE CONTENT HERE" id="mdContent" />
<input type="submit" value="UPLOAD AS MD" onclick="uploadMD()" />
</span>
<div id="output">
</div>
</div>
<script>
window.onload = function () {
document.getElementById('buttonz').style.display = 'none';
};
var file = document.getElementById("file");
var filepath = document.getElementById("filepath");
var app = {
name: "Safe Cold Storage",
id: "safecoldstorage",
version: '1.0',
vendor: "Gamerbits",
};
var permissions = {
'_public': [
'Read',
'Insert',
'Update',
'Delete',
'ManagePermissions'
],
'_publicNames': [
'Read',
'Insert',
'Update',
'Delete',
'ManagePermissions'
]
};
var owncontainer = {
own_container: true
};
var auth = null;
var container = "apps/safecoldstorage";
//Finds and adds EventListener on buttons
window.document.getElementById("authorise").addEventListener("click", function () {
authorise();
});
//initialises and authorises with the network
function authorise() {
window.safeApp.initialise(app)
.then((appToken) => {
console.log("Initialise Token: " + appToken);
window.safeApp.authorise(appToken, permissions, owncontainer)
.then((auth) => {
window.safeApp.connectAuthorised(appToken, auth)
.then((authorisedAppToken) => {
window.auth = authorisedAppToken;
console.log('Authorised App Token ' + authorisedAppToken);
document.getElementById('authorise').style.display = "none";
document.getElementById('buttonz').style.display = "block";
showData();
});
});
}, (err) => {
console.error(err);
// Materialize.toast(err, 3000, 'rounded');
});
}
function uintToString(uintArray) {
return new TextDecoder("utf-8").decode(uintArray);
}
function showData() {
var parEl = document.getElementById('output');
parEl.textContent = "";
window.safeApp.getContainer(auth, container)
.then((mdHandle) => {
console.log('Handle ' + mdHandle);
window.safeMutableData.getEntries(mdHandle)
.then((entries) => {
window.safeMutableDataEntries.len(entries).then((len) => console.log("Number of entries found in the container (" + container + ") is :" + len));
window.safeMutableDataEntries.forEach(entries, (key, value) => {
var childEl = document.createElement('div');
childEl.textContent = value.buf;
parEl.appendChild(childEl);
});
});
},
(err) => {
console.error('Error listing data' + err);
});
}
async function uploadMD() {
var key = "";
document.getElementById('buttonz').style.display = "block";
var element = document.getElementById('mdContent');
var content = element.value;
element.value = "";
await window.safeMutableData.newRandomPrivate(auth, 15001)
.then((mdHandle) => window.safeMutableData.getNameAndTag(mdHandle))
.then((r) => key = r.name.buffer);
window.safeApp.getContainer(auth, container)
.then((mdHandle) => {
window.safeMutableData.newMutation(auth)
.then((mutationHandle) =>
window.safeMutableDataMutation.insert(mutationHandle, key, content).then(() =>
window.safeMutableData.applyEntriesMutation(mdHandle, mutationHandle)).then(() => {
console.log('New mutation entry has been committed to the network. Container : ' + container);
showData();
})
);
},
(err) => {
console.error(err);
});
}
</script>
<script src="app.js"></script>
<script src="phaser.js"></script>
</body>
</html>