-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
233 lines (189 loc) · 7.79 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
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
227
228
229
230
231
232
233
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
/* h6.ans {
color: rgb(100,50,50);
} */
form.col.s12.av-form {
margin: 5% 2% 2% 2%;
padding-right: 7%;
}
</style>
</head>
<body>
<!-- Modal Structure -->
<div id="modal1" class="modal card-panel orange lighten-2">
<div class="modal-content">
<div id="entry0" class="">
<h6 class="qn">Do you know why there is noise in digital social media?</h6>
<h6 class="ans">It is because it is free to post content. </h6>
<h6 class="ans">Check our Twitter like platform which uses Free Market principles
</h6>
</div>
<div id="entry1" class="">
<h6 class="qn">Do you know why the F word and G word company sell data?</h6>
<h6 class="ans"> Because the data is owned by those corporates and not the user. Check our Twitter like
platform but based on Algorand Blockchain </h6>
</div>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Continue</a>
</div>
</div>
<div id="modal2" class="modal card-panel deep-orange accent-2">
<div class="modal-content">
<h6> You need to install the Algorand Chrome Extension from <a
href="https://chrome.google.com/webstore/detail/algosigner/kmmolakhbgdlpkjkcjkebenjheonagdm"> this
link</a> and create an account in that extension and then refresh this page to experience the new
world.
</h6>
</div>
</div>
<!-- header -->
<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo">Algo Social Media</a>
</div>
</nav>
<!-- form -->
<div class="row">
<form class="col s12 av-form" onsubmit="sendMsg()">
<div class="row">
<div class="input-field col s9 m6">
<i class="material-icons prefix">mode_edit</i>
<textarea id="messageToB" class="materialize-textarea" data-length="900"></textarea>
<label for="messageToB">Post Message to the world</label>
</div>
<div class="input-field col s3 m2">
<input id="algoA" type="number" class="validate" value=1 step=0.1>
<label for="algoA">Algo to send</label>
</div>
<div style="margin: 0 1% 0 1%" class="col s3 m2">
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
<i class="material-icons right">send</i>
</button>
</div>
</div>
</form>
</div>
<!-- Card -->
<div class="row" id="row"></div>
<template id="template">
<div class="col s6 m4">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<p class="note"> </p>
</div>
<div class="card-action">
<span class="amount"> </span>
<span class="date"> </span>
</div>
</div>
</div>
</template>
<!--JavaScript at end of body for optimized loading-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
M.AutoInit();
var elem = document.querySelector('#modal1');
var instance = M.Modal.getInstance(elem);
instance.open();
});
</script>
<!-- algorand sign transaction -->
<script>
async function sendMsg() {
accounts = await AlgoSigner.accounts({
ledger: 'MainNet'
})
txParams = await AlgoSigner.algod({
ledger: 'MainNet',
path: '/v2/transactions/params',
});
amount = Number(document.querySelector("#algoA").value)
let txn = {
from: accounts[0].address,
to: 'GVZFXMO3QO5JMLQGQCYZG7SOWHZJ47BYUWXA6WDZOVJPFKX2M46X5C2YEU',
fee: txParams['min-fee'],
type: 'pay',
amount: amount * 1000000,
firstRound: txParams['last-round'],
lastRound: txParams['last-round'] + 1000,
genesisID: txParams['genesis-id'],
genesisHash: txParams['genesis-hash'],
note: document.querySelector("#messageToB").value,
};
signedTx = await AlgoSigner.sign(txn);
statusAv = await AlgoSigner.send({
ledger: 'MainNet',
tx: signedTx.blob,
});
console.log(statusAv)
location.reload();
// await setData()
}
</script>
<!-- Algorand sign in -->
<script>
async function ready() {
try {
d = await AlgoSigner.connect()
console.log(JSON.stringify(d));
setData()
}
catch (e) {
console.error("Algo signer is not installed");
var elems = document.querySelector('#modal2');
options = { dismissible: false }
var instances = M.Modal.init(elems, options);
var instance1 = M.Modal.getInstance(elems);
instance1.open()
}
}
// Fetch and set data
async function fetchData() {
algoResponse = await AlgoSigner.indexer({
ledger: 'MainNet',
path: '/v2/accounts/GVZFXMO3QO5JMLQGQCYZG7SOWHZJ47BYUWXA6WDZOVJPFKX2M46X5C2YEU/transactions',
});
function getData(value, index, array) {
try {
note = window.atob(value.note);
return { note: note, amount: value['payment-transaction'].amount, date: value['round-time'] }
}
catch{
return {}
}
}
datas = algoResponse.transactions.map(getData);
return datas
}
async function setData() {
datas = await fetchData();
document.querySelector('#row').innerHTML = ""
for (let data of datas) {
var template = document.querySelector('#template');
var clone = document.importNode(template.content, true);
clone.querySelector(".note").textContent = data.note
clone.querySelector(".amount").textContent = Number(data.amount) / 1000000 + " Algo"
var utcSeconds = Number(data.date);
var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
d.setUTCSeconds(utcSeconds);
clone.querySelector(".date").innerHTML = `<pre>Time- ${d.getHours()}:${d.getMinutes()} Date- ${d.getDate()}/${d.getMonth()}</pre>`
var host = document.querySelector('#row');
host.appendChild(clone);
}
}
document.addEventListener("click", ready, { once: true });
document.querySelector(`#entry${Math.floor(Math.random() * 2)}`).remove();
</script>
</body>
</html>