aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-15 06:24:14 +0800
committerobscuren <geffobscura@gmail.com>2014-08-15 06:24:14 +0800
commitaadc5be3ff9e3818e41d83910b9730e5f1af042e (patch)
tree3dc980f34391257eb2a0c1be3a042e99f39489f3 /ethereal/assets
parent1fd69e956949671806b23b7ec1feec4f6c416a81 (diff)
downloadgo-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.tar
go-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.tar.gz
go-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.tar.bz2
go-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.tar.lz
go-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.tar.xz
go-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.tar.zst
go-tangerine-aadc5be3ff9e3818e41d83910b9730e5f1af042e.zip
Implemented new watch
* Old watch methods have been removed * Implemented new callback handlers for onWatchCb * added new Filter JS object
Diffstat (limited to 'ethereal/assets')
-rw-r--r--ethereal/assets/ext/ethereum.js32
-rw-r--r--ethereal/assets/ext/test.html30
-rw-r--r--ethereal/assets/qml/webapp.qml18
3 files changed, 74 insertions, 6 deletions
diff --git a/ethereal/assets/ext/ethereum.js b/ethereal/assets/ext/ethereum.js
index 5b8fb54f3..5891fb9f9 100644
--- a/ethereal/assets/ext/ethereum.js
+++ b/ethereal/assets/ext/ethereum.js
@@ -137,6 +137,7 @@ window.eth = {
postData({call: "getSecretToAddress", args: [sec]}, cb);
},
+ /*
watch: function(address, storageAddrOrCb, cb) {
var ev;
if(cb === undefined) {
@@ -166,6 +167,16 @@ window.eth = {
postData({call: "disconnect", args: [address, storageAddrOrCb]});
},
+ */
+
+ watch: function(options) {
+ var filter = new Filter(options);
+ filter.number = newWatchNum().toString()
+
+ postData({call: "watch", args: [options, filter.number]})
+
+ return filter;
+ },
set: function(props) {
postData({call: "set", args: props});
@@ -208,11 +219,28 @@ window.eth = {
}
}
},
-
-
}
+
window.eth._callbacks = {}
window.eth._onCallbacks = {}
+
+var Filter = function(options) {
+ this.options = options;
+};
+
+Filter.prototype.changed = function(callback) {
+ eth.on("watched:"+this.number, callback)
+}
+
+Filter.prototype.getMessages = function(cb) {
+ return eth.getMessages(this.options, cb)
+}
+
+var watchNum = 0;
+function newWatchNum() {
+ return watchNum++;
+}
+
function postData(data, cb) {
data._seed = Math.floor(Math.random() * 1000000)
if(cb) {
diff --git a/ethereal/assets/ext/test.html b/ethereal/assets/ext/test.html
new file mode 100644
index 000000000..b605e8dbd
--- /dev/null
+++ b/ethereal/assets/ext/test.html
@@ -0,0 +1,30 @@
+<!doctype>
+<html>
+<head>
+<title>Tests</title>
+</head>
+
+<body>
+<button onclick="test();">Test me</button>
+
+<script type="text/javascript">
+function test() {
+ var filter = eth.watch({
+ latest: -1,
+ from: "e6716f9544a56c530d868e4bfbacb172315bdead",
+ });
+
+ filter.changed(function(messages) {
+ console.log("messages", messages)
+ })
+
+ filter.getMessages(function(messages) {
+ console.log("getMessages", messages)
+ });
+
+}
+</script>
+
+</body>
+
+</html>
diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml
index 48b410787..b0f50c8f9 100644
--- a/ethereal/assets/qml/webapp.qml
+++ b/ethereal/assets/qml/webapp.qml
@@ -220,11 +220,16 @@ ApplicationWindow {
postData(data._seed, key)
break
+ /*
case "watch":
- require(1)
- eth.watch(data.args[0], data.args[1]);
+ require(1)
+ eth.watch(data.args[0], data.args[1]);
- break
+ break
+ */
+ case "watch":
+ require(2)
+ eth.watch(data.args[0], data.args[1])
case "disconnect":
require(1)
@@ -247,7 +252,7 @@ ApplicationWindow {
break
case "debug":
- console.log(data.args[0]);
+ console.log(data.args[0]);
break;
}
} catch(e) {
@@ -269,6 +274,11 @@ ApplicationWindow {
webview.experimental.postMessage(JSON.stringify({data: data, _event: event}))
}
+ function onWatchedCb(data, id) {
+ var messages = JSON.parse(data)
+ postEvent("watched:"+id, messages)
+ }
+
function onNewBlockCb(block) {
postEvent("block:new", block)
}