-
Notifications
You must be signed in to change notification settings - Fork 0
/
steemitapi03.html
45 lines (41 loc) · 1.8 KB
/
steemitapi03.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
<!doctype html>
<html lang="en">
<head>
<title>Voting Power</title>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://github.com/steemit/steem-js/releases/download/v0.7.7/steem.min.js"></script>
<script>
let username;
function saveUserName(){
username = window.location.hash;// #username
if (username == null || username.trim().length == 0){
username = "#steemitblog";
}
username = username.substr(1);//#を取る
username = decodeURI(username).trim();//デコード、トリム
}
async function getAccountsAsync(){
let accounts = await steem.api.getAccountsAsync([username]);
console.log(accounts);
if(accounts.length == 0) {return;}
let account = accounts[0];
let vp = account.voting_power + (10000 * ((new Date - new Date(account.last_vote_time + "Z")) / 1000) / 432000);
var text = "Voting Powerは " + (vp/100).toFixed(4) + " %です。";
$("#votingPower").text(text);
}
window.onload = function() {
steem.api.setOptions({url: 'https://api.steemit.com'});
saveUserName();
getAccountsAsync();
setInterval(getAccountsAsync, 5000);
};
</script>
</head>
<body>
<div>
こんにちは、
</div>
<h1 id="votingPower"></h1>
</body>
</html>