aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mist/assets
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-22 07:24:20 +0800
committerobscuren <geffobscura@gmail.com>2015-01-22 07:24:20 +0800
commit465b0a79d8fa2550e6104d0d86e357b123f74a39 (patch)
treec048ce8180f3bfad6115b24992a24a8c271dee5a /cmd/mist/assets
parent87f50659db7a4bf194769b05f541d2ccf02f4fc8 (diff)
downloadgo-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.tar
go-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.tar.gz
go-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.tar.bz2
go-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.tar.lz
go-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.tar.xz
go-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.tar.zst
go-tangerine-465b0a79d8fa2550e6104d0d86e357b123f74a39.zip
Updated browser & pass view to callback function
Diffstat (limited to 'cmd/mist/assets')
-rw-r--r--cmd/mist/assets/qml/browser.qml471
1 files changed, 242 insertions, 229 deletions
diff --git a/cmd/mist/assets/qml/browser.qml b/cmd/mist/assets/qml/browser.qml
index a89c3c97d..c8f291e22 100644
--- a/cmd/mist/assets/qml/browser.qml
+++ b/cmd/mist/assets/qml/browser.qml
@@ -9,9 +9,9 @@ import Ethereum 1.0
Rectangle {
id: window
- objectName: "browserView"
- anchors.fill: parent
- color: "#00000000"
+ objectName: "browserView"
+ anchors.fill: parent
+ color: "#00000000"
property var title: "Browser"
property var iconSource: "../browser.png"
@@ -139,311 +139,324 @@ Rectangle {
}
}
- // Border
- Rectangle {
- id: divider
- anchors {
- left: parent.left
- right: parent.right
- top: navBar.bottom
- }
- z: -1
- height: 1
- color: "#CCCCCC"
- }
+ // Border
+ Rectangle {
+ id: divider
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: navBar.bottom
+ }
+ z: -1
+ height: 1
+ color: "#CCCCCC"
+ }
- WebView {
- objectName: "webView"
- id: webview
+ ScrollView {
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
top: divider.bottom
}
+ WebView {
+ objectName: "webView"
+ id: webview
+ anchors.fill: parent
- function injectJs(js) {
- webview.experimental.navigatorQtObjectEnabled = true;
- webview.experimental.evaluateJavaScript(js)
- webview.experimental.javascriptEnabled = true;
- }
+ function injectJs(js) {
+ webview.experimental.navigatorQtObjectEnabled = true;
+ webview.experimental.evaluateJavaScript(js)
+ webview.experimental.javascriptEnabled = true;
+ }
- function sendMessage(data) {
- webview.experimental.postMessage(JSON.stringify(data))
- }
+ function sendMessage(data) {
+ webview.experimental.postMessage(JSON.stringify(data))
+ }
+ Component.onCompleted: {
+ for (var i in experimental.preferences) {
+ console.log(i)
+ }
+ }
- experimental.preferences.javascriptEnabled: true
- experimental.preferences.webGLEnabled: true
- experimental.itemSelector: MouseArea {
- // To avoid conflicting with ListView.model when inside Initiator context.
- property QtObject selectorModel: model
- anchors.fill: parent
- onClicked: selectorModel.reject()
-
- Menu {
- visible: true
- id: itemSelector
-
- Instantiator {
- model: selectorModel.items
- delegate: MenuItem {
- text: model.text
- onTriggered: {
- selectorModel.accept(index)
+ experimental.preferences.javascriptEnabled: true
+ experimental.preferences.webAudioEnabled: true
+ experimental.preferences.pluginsEnabled: true
+ experimental.preferences.navigatorQtObjectEnabled: true
+ experimental.preferences.developerExtrasEnabled: true
+ experimental.preferences.webGLEnabled: true
+ experimental.preferences.notificationsEnabled: true
+ experimental.preferences.localStorageEnabled: true
+ experimental.userAgent:"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Mist/0.1 Safari/537.36"
+
+ experimental.itemSelector: MouseArea {
+ // To avoid conflicting with ListView.model when inside Initiator context.
+ property QtObject selectorModel: model
+ anchors.fill: parent
+ onClicked: selectorModel.reject()
+
+ Menu {
+ visible: true
+ id: itemSelector
+
+ Instantiator {
+ model: selectorModel.items
+ delegate: MenuItem {
+ text: model.text
+ onTriggered: {
+ selectorModel.accept(index)
+ }
}
+ onObjectAdded: itemSelector.insertItem(index, object)
+ onObjectRemoved: itemSelector.removeItem(object)
}
- onObjectAdded: itemSelector.insertItem(index, object)
- onObjectRemoved: itemSelector.removeItem(object)
}
- }
- Component.onCompleted: {
- itemSelector.popup()
+ Component.onCompleted: {
+ itemSelector.popup()
+ }
}
- }
- experimental.preferences.webAudioEnabled: true
- experimental.preferences.navigatorQtObjectEnabled: true
- experimental.preferences.developerExtrasEnabled: true
- experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/lib/web3.js", "../ext/ethereum.js/lib/qt.js", "../ext/setup.js"]
- experimental.onMessageReceived: {
- console.log("[onMessageReceived]: ", message.data)
- // TODO move to messaging.js
- var data = JSON.parse(message.data)
+ experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/lib/web3.js", "../ext/ethereum.js/lib/qt.js", "../ext/setup.js"]
+ experimental.onMessageReceived: {
+ console.log("[onMessageReceived]: ", message.data)
+ // TODO move to messaging.js
+ var data = JSON.parse(message.data)
- try {
- switch(data.call) {
- case "eth_compile":
- postData(data._id, eth.compile(data.args[0]))
- break
+ try {
+ switch(data.call) {
+ case "eth_compile":
+ postData(data._id, eth.compile(data.args[0]))
+ break
- case "eth_coinbase":
- postData(data._id, eth.coinBase())
+ case "eth_coinbase":
+ postData(data._id, eth.coinBase())
- case "eth_account":
- postData(data._id, eth.key().address);
+ case "eth_account":
+ postData(data._id, eth.key().address);
- case "eth_istening":
- postData(data._id, eth.isListening())
+ case "eth_istening":
+ postData(data._id, eth.isListening())
- break
+ break
- case "eth_mining":
- postData(data._id, eth.isMining())
+ case "eth_mining":
+ postData(data._id, eth.isMining())
- break
+ break
- case "eth_peerCount":
- postData(data._id, eth.peerCount())
+ case "eth_peerCount":
+ postData(data._id, eth.peerCount())
- break
+ break
- case "eth_countAt":
- require(1)
- postData(data._id, eth.txCountAt(data.args[0]))
+ case "eth_countAt":
+ require(1)
+ postData(data._id, eth.txCountAt(data.args[0]))
- break
+ break
- case "eth_codeAt":
- require(1)
- var code = eth.codeAt(data.args[0])
- postData(data._id, code);
+ case "eth_codeAt":
+ require(1)
+ var code = eth.codeAt(data.args[0])
+ postData(data._id, code);
- break
+ break
- case "eth_blockByNumber":
- require(1)
- var block = eth.blockByNumber(data.args[0])
- postData(data._id, block)
- break
+ case "eth_blockByNumber":
+ require(1)
+ var block = eth.blockByNumber(data.args[0])
+ postData(data._id, block)
+ break
- case "eth_blockByHash":
- require(1)
- var block = eth.blockByHash(data.args[0])
- postData(data._id, block)
- break
+ case "eth_blockByHash":
+ require(1)
+ var block = eth.blockByHash(data.args[0])
+ postData(data._id, block)
+ break
- require(2)
- var block = eth.blockByHash(data.args[0])
- postData(data._id, block.transactions[data.args[1]])
- break
+ require(2)
+ var block = eth.blockByHash(data.args[0])
+ postData(data._id, block.transactions[data.args[1]])
+ break
- case "eth_transactionByHash":
- case "eth_transactionByNumber":
- require(2)
+ case "eth_transactionByHash":
+ case "eth_transactionByNumber":
+ require(2)
- var block;
- if (data.call === "transactionByHash")
- block = eth.blockByHash(data.args[0])
- else
- block = eth.blockByNumber(data.args[0])
+ var block;
+ if (data.call === "transactionByHash")
+ block = eth.blockByHash(data.args[0])
+ else
+ block = eth.blockByNumber(data.args[0])
- var tx = block.transactions.get(data.args[1])
+ var tx = block.transactions.get(data.args[1])
- postData(data._id, tx)
- break
+ postData(data._id, tx)
+ break
- case "eth_uncleByHash":
- case "eth_uncleByNumber":
- require(2)
+ case "eth_uncleByHash":
+ case "eth_uncleByNumber":
+ require(2)
- var block;
- if (data.call === "uncleByHash")
- block = eth.blockByHash(data.args[0])
- else
- block = eth.blockByNumber(data.args[0])
+ var block;
+ if (data.call === "uncleByHash")
+ block = eth.blockByHash(data.args[0])
+ else
+ block = eth.blockByNumber(data.args[0])
- var uncle = block.uncles.get(data.args[1])
+ var uncle = block.uncles.get(data.args[1])
- postData(data._id, uncle)
+ postData(data._id, uncle)
- break
+ break
- case "transact":
- require(5)
+ case "transact":
+ require(5)
- var tx = eth.transact(data.args)
- postData(data._id, tx)
+ var tx = eth.transact(data.args)
+ postData(data._id, tx)
- break
+ break
- case "eth_stateAt":
- require(2);
+ case "eth_stateAt":
+ require(2);
- var storage = eth.storageAt(data.args[0], data.args[1]);
- postData(data._id, storage)
+ var storage = eth.storageAt(data.args[0], data.args[1]);
+ postData(data._id, storage)
- break
+ break
- case "eth_call":
- require(1);
- var ret = eth.call(data.args)
- postData(data._id, ret)
- break
+ case "eth_call":
+ require(1);
+ var ret = eth.call(data.args)
+ postData(data._id, ret)
+ break
- case "eth_balanceAt":
- require(1);
+ case "eth_balanceAt":
+ require(1);
- postData(data._id, eth.balanceAt(data.args[0]));
- break
+ postData(data._id, eth.balanceAt(data.args[0]));
+ break
- case "eth_watch":
- require(2)
- eth.watch(data.args[0], data.args[1])
+ case "eth_watch":
+ require(2)
+ eth.watch(data.args[0], data.args[1])
- case "eth_disconnect":
- require(1)
- postData(data._id, null)
- break;
+ case "eth_disconnect":
+ require(1)
+ postData(data._id, null)
+ break;
- case "eth_newFilterString":
- require(1)
- var id = eth.newFilterString(data.args[0])
- postData(data._id, id);
- break;
+ case "eth_newFilterString":
+ require(1)
+ var id = eth.newFilterString(data.args[0])
+ postData(data._id, id);
+ break;
- case "eth_newFilter":
- require(1)
- var id = eth.newFilter(data.args[0])
+ case "eth_newFilter":
+ require(1)
+ var id = eth.newFilter(data.args[0])
- postData(data._id, id);
- break;
+ postData(data._id, id);
+ break;
- case "eth_filterLogs":
- require(1);
+ case "eth_filterLogs":
+ require(1);
- var messages = eth.messages(data.args[0]);
- var m = JSON.parse(JSON.parse(JSON.stringify(messages)))
- postData(data._id, m);
+ var messages = eth.messages(data.args[0]);
+ var m = JSON.parse(JSON.parse(JSON.stringify(messages)))
+ postData(data._id, m);
- break;
+ break;
- case "eth_deleteFilter":
- require(1);
- eth.uninstallFilter(data.args[0])
- break;
+ case "eth_deleteFilter":
+ require(1);
+ eth.uninstallFilter(data.args[0])
+ break;
- case "shh_newFilter":
- require(1);
- var id = shh.watch(data.args[0], window);
- postData(data._id, id);
- break;
+ case "shh_newFilter":
+ require(1);
+ var id = shh.watch(data.args[0], window);
+ postData(data._id, id);
+ break;
- case "shh_newIdentity":
- var id = shh.newIdentity()
- postData(data._id, id)
+ case "shh_newIdentity":
+ var id = shh.newIdentity()
+ postData(data._id, id)
- break
+ break
- case "shh_post":
- require(1);
+ case "shh_post":
+ require(1);
- var params = data.args[0];
- var fields = ["payload", "to", "from"];
- for(var i = 0; i < fields.length; i++) {
- params[fields[i]] = params[fields[i]] || "";
- }
- if(typeof params.payload !== "object") { params.payload = [params.payload]; } //params.payload = params.payload.join(""); }
- params.topics = params.topics || [];
- params.priority = params.priority || 1000;
- params.ttl = params.ttl || 100;
+ var params = data.args[0];
+ var fields = ["payload", "to", "from"];
+ for(var i = 0; i < fields.length; i++) {
+ params[fields[i]] = params[fields[i]] || "";
+ }
+ if(typeof params.payload !== "object") { params.payload = [params.payload]; } //params.payload = params.payload.join(""); }
+ params.topics = params.topics || [];
+ params.priority = params.priority || 1000;
+ params.ttl = params.ttl || 100;
- shh.post(params.payload, params.to, params.from, params.topics, params.priority, params.ttl);
+ shh.post(params.payload, params.to, params.from, params.topics, params.priority, params.ttl);
- break;
+ break;
- case "shh_getMessages":
- require(1);
+ case "shh_getMessages":
+ require(1);
- var m = shh.messages(data.args[0]);
- var messages = JSON.parse(JSON.parse(JSON.stringify(m)));
- postData(data._id, messages);
+ var m = shh.messages(data.args[0]);
+ var messages = JSON.parse(JSON.parse(JSON.stringify(m)));
+ postData(data._id, messages);
- break;
+ break;
- case "ssh_newGroup":
- postData(data._id, "");
- break;
- }
- } catch(e) {
- console.log(data.call + ": " + e)
+ case "ssh_newGroup":
+ postData(data._id, "");
+ break;
+ }
+ } catch(e) {
+ console.log(data.call + ": " + e)
- postData(data._id, null);
+ postData(data._id, null);
+ }
}
- }
- function post(seed, data) {
- postData(data._id, data)
- }
+ function post(seed, data) {
+ postData(data._id, data)
+ }
- function require(args, num) {
- if(args.length < num) {
- throw("required argument count of "+num+" got "+args.length);
+ function require(args, num) {
+ if(args.length < num) {
+ throw("required argument count of "+num+" got "+args.length);
+ }
+ }
+ function postData(seed, data) {
+ webview.experimental.postMessage(JSON.stringify({data: data, _id: seed}))
+ }
+ function postEvent(event, id, data) {
+ webview.experimental.postMessage(JSON.stringify({data: data, _id: id, _event: event}))
}
- }
- function postData(seed, data) {
- webview.experimental.postMessage(JSON.stringify({data: data, _id: seed}))
- }
- function postEvent(event, id, data) {
- webview.experimental.postMessage(JSON.stringify({data: data, _id: id, _event: event}))
- }
- function onWatchedCb(data, id) {
- var messages = JSON.parse(data)
- postEvent("watched:"+id, messages)
- }
+ function onWatchedCb(data, id) {
+ var messages = JSON.parse(data)
+ postEvent("watched:"+id, messages)
+ }
- function onNewBlockCb(block) {
- postEvent("block:new", block)
- }
- function onObjectChangeCb(stateObject) {
- postEvent("object:"+stateObject.address(), stateObject)
- }
- function onStorageChangeCb(storageObject) {
- var ev = ["storage", storageObject.stateAddress, storageObject.address].join(":");
- postEvent(ev, [storageObject.address, storageObject.value])
+ function onNewBlockCb(block) {
+ postEvent("block:new", block)
+ }
+ function onObjectChangeCb(stateObject) {
+ postEvent("object:"+stateObject.address(), stateObject)
+ }
+ function onStorageChangeCb(storageObject) {
+ var ev = ["storage", storageObject.stateAddress, storageObject.address].join(":");
+ postEvent(ev, [storageObject.address, storageObject.value])
+ }
}
}