Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
8aaec1d9
Commit
8aaec1d9
authored
Nov 13, 2014
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved example
parent
b1428555
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
index.html
example/index.html
+22
-18
No files found.
example/index.html
View file @
8aaec1d9
...
@@ -4,34 +4,38 @@
...
@@ -4,34 +4,38 @@
<head>
<head>
<script
type=
"text/javascript"
src=
"js/es6-promise/promise.min.js"
></script>
<script
type=
"text/javascript"
src=
"js/es6-promise/promise.min.js"
></script>
<script
type=
"text/javascript"
src=
"../dist/ethereum.js"
></script>
<script
type=
"text/javascript"
src=
"../dist/ethereum.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
if
(
window
.
Promise
===
undefined
)
{
window
.
Promise
=
ES6Promise
.
Promise
;
}
var
web3
=
require
(
'web3'
);
var
web3
=
require
(
'web3'
);
web3
.
setProvider
(
new
web3
.
providers
.
AutoProvider
());
web3
.
setProvider
(
new
web3
.
providers
.
AutoProvider
());
function
testSnippet
()
{
function
watchBalance
()
{
web3
.
eth
.
watch
({
altered
:
web3
.
eth
.
coinbase
}).
changed
(
function
()
{
var
coinbase
=
web3
.
eth
.
coinbase
;
web3
.
eth
.
balanceAt
(
web3
.
eth
.
coinbase
).
then
(
function
(
balance
)
{
var
originalBalance
=
0
;
console
.
log
(
parseInt
(
balance
,
16
));
console
.
log
(
typeof
balance
);
web3
.
eth
.
balanceAt
(
coinbase
).
then
(
function
(
balance
)
{
document
.
getElementById
(
"result"
).
innerText
=
+
balance
;
originalBalance
=
web3
.
toDecimal
(
balance
);
document
.
getElementById
(
'original'
).
innerText
=
'original balance: '
+
originalBalance
+
' watching...'
;
});
web3
.
eth
.
watch
({
altered
:
coinbase
}).
changed
(
function
()
{
web3
.
eth
.
balanceAt
(
coinbase
).
then
(
function
(
balance
)
{
var
currentBalance
=
web3
.
toDecimal
(
balance
);
document
.
getElementById
(
"current"
).
innerText
=
'current: '
+
currentBalance
;
document
.
getElementById
(
"diff"
).
innerText
=
'diff: '
+
(
currentBalance
-
originalBalance
);
});
});
});
});
}
}
</script>
</head>
</script>
</head>
<body>
<body>
<h1>
std::name_reg
</h1>
<h1>
balance
</h1>
<input
type=
"text"
id=
"name"
></input>
<button
type=
"button"
onClick=
"watchBalance();"
>
watch balance
</button>
<button
type=
"button"
onClick=
"testSnippet();"
>
test snippet
</button>
<div></div>
<div></div>
result:
<div
id=
"original"
></div>
<div
id=
"result"
></div>
<div
id=
"current"
></div>
<div
id=
"diff"
></div>
</body>
</body>
</html>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment