-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.html
More file actions
187 lines (144 loc) · 5.81 KB
/
test.html
File metadata and controls
187 lines (144 loc) · 5.81 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
<html>
<head>
<script src="../dist/etherid.js"></script>
</head>
<script>
window.onload = function() {
/* first of all set up the web3 object. THis should work in Mist as well */
if(typeof web3 === 'undefined')
{
Web3 = require('web3');
web3 = new Web3();
}
if( web3.currentProvider == null )
web3.setProvider( new web3.providers.HttpProvider( ) );
/* Get the EtherID API object */
EID = require( "etherid" )
EID.getNumberOfDomains( web3, function( error, result ) {
document.getElementById( "n_domains" ).innerHTML = result
})
EID.watch( web3, function( error, result ) {
EID.getNumberOfDomains( web3, function( error, result ) {
document.getElementById( "n_domains" ).innerHTML = result
})
})
document.getElementById( "version" ).innerHTML = EID.version
// document.getElementById( "n_domains" ).innerHTML = EID.getNumberOfDomains( web3 )
domain = EID.getDomain( web3, "test", function( error, domain ) {
if( !error ) {
document.getElementById( "expires" ).innerHTML = domain.expires
document.getElementById( "owner" ).innerHTML = web3.toHex( domain.owner )
document.getElementById( "price" ).innerHTML = domain.price
document.getElementById( "transfer" ).innerHTML = web3.toHex( domain.transfer )
document.getElementById( "next" ).innerHTML = web3.toHex( domain.next_domain )
document.getElementById( "root_id" ).innerHTML = web3.toHex( domain.root_id )
}
});
E = EID.getIdEnum( web3, "test" )
id = EID.getNextId( web3, E)
list = []
while( id )
{
list.push( "'" + id.nameStr + "'" )
id = EID.getNextId( web3, E) //synchronious call!!!
}
document.getElementById( "id_list" ).innerHTML = list.join( ", ")
EID.getId( web3, "test", "test_number", function( error, id ) {
if( !error )
document.getElementById( "test_int" ).innerHTML = id.valueInt
});
EID.getId( web3, "test", "test_text", function( error, id ) {
if( !error ) document.getElementById( "test_text" ).innerHTML = id.valueStr
});
EID.getId( web3, "test", "test_ipfs", function( error, id ) {
if( !error ) document.getElementById( "test_ipfs" ).innerHTML = id.valueHash
});
E = EID.getDomainEnum( web3 )
}
function onListDomainsStart()
{
DomainEnumerator = EID.getDomainEnum( web3 )
stop_listing = false;
ListDomainStep( web3 );
}
function onListDomainsStop()
{
stop_listing = true;
}
function ListDomainStep()
{
d = EID.getNextDomain( web3, DomainEnumerator )
if( !d ) return;
document.getElementById( "list_domains" ).innerHTML = "domain #:" + DomainEnumerator.n + " " + d.domainStr
if( !stop_listing ) setTimeout( ListDomainStep, 10 )
}
function onProlong()
{
document.getElementById( "prolong_status" ).innerHTML = "Reading domain..."
domain = EID.getDomain( web3, "test", function( error, domain ) {
if( !error ) {
document.getElementById( "prolong_status" ).innerHTML = "Channging..."
EID.changeDomain( web3, domain.owner, "test", 2000000, 0, 0, function( error, domain ) {
if( !error ) {
document.getElementById( "prolong_status" ).innerHTML = "Transaction completed"
}
else
{
document.getElementById( "prolong_status" ).innerHTML = error
}
});
}
else { document.getElementById( "prolong_status" ).innerHTML = error }
});
}
function onChangeId()
{
document.getElementById( "change_id_status" ).innerHTML = "Reading domain..."
domain = EID.getDomain( web3, "test", function( error, domain ) {
if( !error ) {
document.getElementById( "change_id_status" ).innerHTML = "Channging..."
EID.changeId( web3, domain.owner, "test", "time", new Date().getTime(), function( error, domain ) {
if( !error ) {
document.getElementById( "change_id_status" ).innerHTML = "Transaction completed"
}
else
{
document.getElementById( "change_id_status" ).innerHTML = error
}
});
}
else { document.getElementById( "change_id_status" ).innerHTML = error }
});
}
</script>
<body>
<h1>Test Page</h1>
<p>EtherID API version: <span id="version" ></span></p>
<p>Total number of domains:: <span id="n_domains" ></span> (The number refreshes automatically!)</p>
<p>Domain 'test' parameters:
<br>Expiration Block: <span id="expires" ></span>
<br>Owner: <span id="owner" ></span>
<br>Price: <span id="price" ></span>
<br>Transfer: <span id="transfer" ></span>
<br>Next Domain: <span id="next" ></span>
<br>First ID: <span id="root_id" ></span>
</p>
<h2>Id's</h2>
<p>
List of all ID names: <span id="id_list" >
</p>
<p>
<br>test_int: <span id="test_int" ></span>
<br>test_text: <span id="test_text" ></span>
<br>ipfs (HASH): <span id="test_ipfs" ></span>
</p>
<h2>List all the domains</h2>
<p>
<button onClick="onListDomainsStart()">Start</button>
<button onClick="onListDomainsStop()">Stop</button>
<span id="list_domains" > </p>
<h2>Change Domain</h2>
<p><button onCLick="onProlong()">Prolong domain 'test'</button> <span id="prolong_status" ></span></p>
<p><button onCLick="onChangeId()">Change ID 'test/time'</button> <span id="change_id_status" ></span></p>
</body>
</html>