Fixed setting providers to the right object

This commit is contained in:
obscuren 2014-10-21 00:37:58 +02:00
parent 76b20be2ea
commit 8a7d1a69b3
3 changed files with 9 additions and 4 deletions

View File

@ -3,12 +3,15 @@
<head> <head>
<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="qt.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function registerName() { function registerName() {
var name = document.querySelector("#name").value; var name = document.querySelector("#name").value;
name = eth.fromAscii(name); name = web3.fromAscii(name);
eth.transact({to: "NameReg", gas: "10000", gasPrice: eth.gasPrice, data: [eth.fromAscii("register"), name]}).then(function(tx) { var eth = web3.eth;
eth.transact({to: "NameReg", gas: "10000", gasPrice: eth.gasPrice, data: [web3.fromAscii("register"), name]}).then(function(tx) {
document.querySelector("#result").innerHTML = "Registered name. Please wait for the next block to come through."; document.querySelector("#result").innerHTML = "Registered name. Please wait for the next block to come through.";
}, function(err) { }, function(err) {
console.log(err); console.log(err);

4
qt.js
View File

@ -3,6 +3,7 @@
QtProvider.prototype.send = function(payload) { QtProvider.prototype.send = function(payload) {
navigator.qt.postData(JSON.stringify(payload)); navigator.qt.postData(JSON.stringify(payload));
}; };
Object.defineProperty(QtProvider.prototype, "onmessage", { Object.defineProperty(QtProvider.prototype, "onmessage", {
set: function(handler) { set: function(handler) {
navigator.qt.onmessage = handler; navigator.qt.onmessage = handler;
@ -10,6 +11,7 @@
}); });
if(typeof(web3) !== "undefined" && web3.providers !== undefined) { if(typeof(web3) !== "undefined" && web3.providers !== undefined) {
web3.QtProvider = QtProvider; web3.providers.QtProvider = QtProvider;
} }
})(); })();

View File

@ -46,6 +46,6 @@
}); });
if(typeof(web3) !== "undefined" && web3.providers !== undefined) { if(typeof(web3) !== "undefined" && web3.providers !== undefined) {
web3.WebSocketProvider = WebSocketProvider; web3.providers.WebSocketProvider = WebSocketProvider;
} }
})(); })();