diff options
Diffstat (limited to 'ethereal/assets')
-rw-r--r-- | ethereal/assets/ethereum.js | 4 | ||||
-rw-r--r-- | ethereal/assets/qml/webapp.qml | 12 | ||||
-rw-r--r-- | ethereal/assets/samplecoin.html | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/ethereal/assets/ethereum.js b/ethereal/assets/ethereum.js index fefad584a..0f9f68c43 100644 --- a/ethereal/assets/ethereum.js +++ b/ethereal/assets/ethereum.js @@ -47,6 +47,10 @@ window.eth = { postData({call: "getKey"}, cb); }, + watch: function(address) { + postData({call: "watch", args: [address]}); + }, + on: function(event, cb) { if(eth._onCallbacks[event] === undefined) { diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml index 9cf154e9b..c34e0dc55 100644 --- a/ethereal/assets/qml/webapp.qml +++ b/ethereal/assets/qml/webapp.qml @@ -74,14 +74,24 @@ ApplicationWindow { var keys = eth.getKey() postData(data._seed, keys) break + case "watch": + if(data.args.length > 0) { + eth.watch(data.args[0]); + } } } function postData(seed, data) { webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed})) } + function postEvent(event, data) { + webview.experimental.postMessage(JSON.stringify({data: data, _event: event})) + } function onNewBlockCb(block) { - webview.experimental.postMessage(JSON.stringify({data: block, _event: "block:new"})) + postEvent("block:new", block) + } + function onObjectChangeCb(stateObject) { + postEvent("object:change", stateObject) } } diff --git a/ethereal/assets/samplecoin.html b/ethereal/assets/samplecoin.html index 476283f60..1b89be877 100644 --- a/ethereal/assets/samplecoin.html +++ b/ethereal/assets/samplecoin.html @@ -22,12 +22,15 @@ function tests() { } function init() { + eth.watch(jefcoinAddr); + eth.getKey(function(key) { eth.getStorage(jefcoinAddr, key, function(storage) { document.querySelector("#currentAmount").innerHTML = "Amount: " + storage; }); - eth.on("block:new", function() { + eth.on("object:change", function(stateObject) { + debug(stateObject); eth.getStorage(jefcoinAddr, key, function(storage) { document.querySelector("#currentAmount").innerHTML = "Amount: " + storage; }); |