-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathendorseCredit.html
114 lines (102 loc) · 4.46 KB
/
endorseCredit.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
<html lang="en">
<head>
<title>Endorse Credit</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="web3.js"></script>
<script type="text/javascript" src="bignumber.js"></script>
<script type="text/javascript" src="cc.js"></script>
<script type="text/javascript" >
window.onload = function () {
document.getElementById('me').innerHTML = "alias: " + myAlias + "<br/> account: " + coinbase;
document.getElementById('reputation').innerHTML = myReputation/baseUnits +" UoT";
var credits = communityCurrency.Credit({'_MoneyLender' : coinbase}, {fromBlock: 1800000, toBlock: 'latest'}, function(error, result) {
var row = "";
credits.watch(function(error, result){
row += Date(result.args.__cDealine) + " " + result.args._borrowerAddress + " <span class=\"badge\">" + result.args._endorsedUoT/baseUnits + " UoT</span><br/>";
document.getElementById('listCredit').innerHTML = row;
});
});
var creditsExp = communityCurrency.CreditExp({'_MoneyLender' : coinbase}, {fromBlock: 1800000, toBlock: 'latest'}, function(error, result) {
var row = "";
creditsExp.watch(function(error, result){
row += Date(result.args._timeStampCX) + " " + result.args._exBorrowerAddress + " <span class=\"badge\">" + result.args._oldUoT/baseUnits + " UoT</span> success <span class=\"badge\">" + result.args._success + "<span><br/>";
document.getElementById('listCreditEx').innerHTML = row;
});
});
}
function showCost () {
var borrower = document.getElementById('borrower').value;
var amount = document.getElementById('amount').value * baseUnits;
var days = document.getElementById('days').value;
var creditCost = days * amount;
document.getElementById('reputationCost').innerHTML = creditCost/baseUnits +" UoT";
}
function endorseCredit () {
var borrower = document.getElementById('borrower').value;
var amount = document.getElementById('amount').value * baseUnits;
var days = document.getElementById('days').value;
communityCurrency.credit(borrower, amount, days);
location.reload();
}
</script>
<style>
.navbar {
margin-bottom: 0;
border-radius: 0;
}
</style>
</head>
<body>
<div class="container bg-3 text-center">
<div class=container">
<script type="text/javascript" src="navbar.js"></script>
</div>
<div class="row">
<div class="col-sm-6">
<small><p id="me"></p></small>
<h3><span class="glyphicon glyphicon-ok"></span> Endorse Credit</h3>
<div class="alert alert-warning">
<small>This page only available to Commoners</small>
</div>
<form role="form">
<div class="form-group">
<label for="reputation">Available Trust:</label>
<output class="form-control" id="reputation">UoT</output>
</div>
<div class="form-group">
<label for="borrower">Borrower account:</label>
<input type="text" class="form-control" id="borrower" placeholder="Enter borrower account">
</div>
<div class="form-group">
<label for="amount">Amount:</label>
<input type="text" class="form-control" id="amount" placeholder="Enter amount">
</div>
<div class="form-group">
<label for="days">Days:</label>
<input type="text" class="form-control" id="days" placeholder="Days">
</div>
<div class="form-group">
<label for="reputationCost">Cost in UoT of this Credit:</label>
<output class="form-control" id="reputationCost">UoT</output>
</div>
</form>
<div>
<button type="submit" class="btn btn-default" onClick="showCost();"><span class="glyphicon glyphicon-question-sign"></span> Calculate Reputation Cost</button>
</div>
<div>
<button type="submit" class="btn btn-default" onClick="endorseCredit();"><span class="glyphicon glyphicon-ok"></span> Endorse Credit</button>
</div>
<h3><span class="glyphicon glyphicon-thumbs-up"></span> Endorsed Credits</h3>
<h4><span class="glyphicon glyphicon-ok"></span> Endorsed Credits</h4>
<div id="listCredit"></div>
<h4><span class="glyphicon glyphicon-remove"></span> Expired Credits</h4>
<div id="listCreditEx"></div>
</div>
</div>
</div><br>
</body>
</html>