wallet-core/extension/content_scripts/notify.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-11-25 20:41:31 +01:00
// Script that is injected into pages in order to allow merchants pages to
// query the availability of Taler.
2015-12-03 20:07:03 +01:00
'use strict';
2015-11-25 20:41:31 +01:00
// Install our handshake handlers only once the
// document is loaded
// TODO: change the spec to do it on the body
document.addEventListener("DOMContentLoaded", function(e) {
console.log("DOM fully loaded and parsed");
2015-12-03 20:07:03 +01:00
document.body.addEventListener('taler-checkout-probe', function(e) {
let evt = new Event('taler-wallet-present');
document.body.dispatchEvent(evt);
console.log("merchant handshake done");
2015-12-03 20:07:03 +01:00
});
document.body.addEventListener('taler-wire-probe', function(e) {
let evt = new Event('taler-wallet-present');
document.body.dispatchEvent(evt);
console.log("bank handshake done");
});
document.body.addEventListener('taler-create-reserve', function(e) {
console.log("reserve creation " + JSON.stringify(e.detail));
chrome.runtime.sendMessage({action:'new-reserve-request', detail:e.detail}, function(resp) {
console.log("got response");
document.location.href = resp.url;
});
});
});
2015-11-25 20:41:31 +01:00
console.log("Taler wallet: content page loaded");