From 9e481804a72ce78792826e215cf3660819bbb18a Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 1 May 2014 22:59:16 +0200 Subject: [PATCH] Added a 'set' method to change window settings for external applications --- ethereal/assets/ethereum.js | 4 ++++ ethereal/assets/qml/webapp.qml | 6 ++++++ ethereal/assets/samplecoin/samplecoin.html | 2 ++ 3 files changed, 12 insertions(+) diff --git a/ethereal/assets/ethereum.js b/ethereal/assets/ethereum.js index fd5091bd1..e5dae9248 100644 --- a/ethereal/assets/ethereum.js +++ b/ethereal/assets/ethereum.js @@ -71,6 +71,10 @@ window.eth = { postData({call: "disconnect", args: [address, storageAddrOrCb]}); }, + set: function(props) { + postData({call: "set", args: props}); + }, + on: function(event, cb) { if(eth._onCallbacks[event] === undefined) { eth._onCallbacks[event] = []; diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml index c0df0b66e..1c1ac852d 100644 --- a/ethereal/assets/qml/webapp.qml +++ b/ethereal/assets/qml/webapp.qml @@ -91,6 +91,12 @@ ApplicationWindow { require(1) postData(data._seed, null) break; + case "set": + for(var key in data.args) { + if(webview.hasOwnProperty(key)) { + window[key] = data.args[key]; + } + } } } catch(e) { console.log(data.call + ": " + e) diff --git a/ethereal/assets/samplecoin/samplecoin.html b/ethereal/assets/samplecoin/samplecoin.html index 1f4d1e3e1..ba60cf951 100644 --- a/ethereal/assets/samplecoin/samplecoin.html +++ b/ethereal/assets/samplecoin/samplecoin.html @@ -21,6 +21,8 @@ function createTransaction() { } function init() { + eth.set({width: 500, title: "Hello world"}) + eth.getKey(function(key) { eth.getStorageAt(jefcoinAddr, key, function(storage) { document.querySelector("#current-amount").innerHTML = storage;