diff options
Diffstat (limited to 'cmd/mist/assets/ext/eth.js/qt.js')
-rw-r--r-- | cmd/mist/assets/ext/eth.js/qt.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/mist/assets/ext/eth.js/qt.js b/cmd/mist/assets/ext/eth.js/qt.js new file mode 100644 index 000000000..644c37737 --- /dev/null +++ b/cmd/mist/assets/ext/eth.js/qt.js @@ -0,0 +1,27 @@ +(function() { + var QtProvider = function() { + this.handlers = []; + + var self = this; + navigator.qt.onmessage = function (message) { + self.handlers.forEach(function (handler) { + handler.call(self, JSON.parse(message.data)); + }); + } + }; + + QtProvider.prototype.send = function(payload) { + navigator.qt.postMessage(JSON.stringify(payload)); + }; + + Object.defineProperty(QtProvider.prototype, "onmessage", { + set: function(handler) { + this.handlers.push(handler); + }, + }); + + if(typeof(web3) !== "undefined" && web3.providers !== undefined) { + web3.providers.QtProvider = QtProvider; + } +})(); + |