This commit is contained in:
Marek Kotewicz 2014-11-03 17:46:56 +01:00
parent b0e11826e5
commit 0cdef3376d

View File

@ -2,22 +2,27 @@
<html> <html>
<head> <head>
<script type="text/javascript" src="es6-promise-2.0.0.js"></script>
<script type="text/javascript" src="main.js"></script> <script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="websocket.js"></script> <script type="text/javascript" src="websocket.js"></script>
<script type="text/javascript" src="qt.js"></script> <script type="text/javascript" src="qt.js"></script>
<script type="text/javascript" src="httprpc.js"></script> <script type="text/javascript" src="httprpc.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function registerName() { if (window.Promise === undefined) {
var name = document.querySelector("#name").value; window.Promise = ES6Promise.Promise;
name = web3.fromAscii(name); }
var eth = web3.eth; //web3.setProvider(new web3.providers.QtProvider());
eth.transact({to: "NameReg", gas: "10000", gasPrice: eth.gasPrice, data: [web3.fromAscii("register"), name]}).then(function(tx) { web3.setProvider(new web3.providers.HttpRpcProvider("http://localhost:8080"));
document.querySelector("#result").innerHTML = "Registered name. Please wait for the next block to come through.";
}, function(err) { function testSnippet() {
console.log(err); web3.eth.watch({altered: web3.eth.coinbase}).changed(function() {
web3.eth.balanceAt(web3.eth.coinbase).then(function (balance) {
document.getElementById("result").innerText = web3.toDecimal(balance);
});
}); });
} }
</script> </script>
</head> </head>
@ -25,8 +30,10 @@ function registerName() {
<h1>std::name_reg</h1> <h1>std::name_reg</h1>
<input type="text" id="name"></input> <input type="text" id="name"></input>
<input type="submit" onClick="registerName();"></input> <button type="button" onClick="testSnippet();">test snippet</button>
<div id="result"></div>
<div></div>
result: <div id="result"></div>
</body> </body>