aboutsummaryrefslogtreecommitdiff
path: root/extension/pages/confirm-contract.js
diff options
context:
space:
mode:
Diffstat (limited to 'extension/pages/confirm-contract.js')
-rw-r--r--extension/pages/confirm-contract.js90
1 files changed, 49 insertions, 41 deletions
diff --git a/extension/pages/confirm-contract.js b/extension/pages/confirm-contract.js
index 0514a4e9b..ec6985805 100644
--- a/extension/pages/confirm-contract.js
+++ b/extension/pages/confirm-contract.js
@@ -13,47 +13,55 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
*/
-/// <reference path="../lib/decl/handlebars/handlebars.d.ts" />
-"use strict";
-var url = URI(document.location.href);
-var query = URI.parseQuery(url.query());
-var $_ = function (x) { return document.getElementById(x); };
-function renderContract(contract) {
- var showAmount = document.getElementById("show-amount");
- $_('merchant-name').innerText = contract.merchant.name;
-}
-function clone(obj) {
- // This is faster than it looks ...
- return JSON.parse(JSON.stringify(obj));
-}
-Handlebars.registerHelper('prettyAmount', function (amount) {
- var v = amount.value + amount.fraction / 10e6;
- return v.toFixed(2) + " " + amount.currency;
-});
-document.addEventListener("DOMContentLoaded", function (e) {
- var offer = JSON.parse(query.offer);
- console.dir(offer);
- var source = $_("contract-template").innerHTML;
- var template = Handlebars.compile(source);
- $_("render-contract").innerHTML = template(offer.contract);
- document.getElementById("confirm-pay").addEventListener("click", function (e) {
- console.log("Query:", JSON.stringify(query));
- var d = {
- offer: JSON.parse(query.offer),
- merchantPageUrl: query.merchantPageUrl
- };
- chrome.runtime.sendMessage({ type: 'confirm-pay', detail: d }, function (resp) {
- if (!resp.success) {
- var source_1 = $_("error-template").innerHTML;
- var template_1 = Handlebars.compile(source_1);
- $_("status").innerHTML = template_1(resp);
- return;
+System.register(["../lib/web-common"], function(exports_1) {
+ /// <reference path="../lib/decl/handlebars/handlebars.d.ts" />
+ "use strict";
+ var web_common_1;
+ function prettyAmount(amount) {
+ var v = amount.value + amount.fraction / 1e6;
+ return v.toFixed(2) + " " + amount.currency;
+ }
+ function main() {
+ var url = URI(document.location.href);
+ var query = URI.parseQuery(url.query());
+ var offer = JSON.parse(query.offer);
+ console.dir(offer);
+ var contract = offer.contract;
+ var Contract = {
+ view: function (ctrl) {
+ return [
+ m("p", (_a = ["Hello, this is the wallet. The merchant \"", "\"\n wants to enter a contract over ", "\n with you."], _a.raw = ["Hello, this is the wallet. The merchant \"", "\"\n wants to enter a contract over ", "\n with you."], i18n(_a, contract.merchant.name, prettyAmount(contract.amount)))),
+ m("p", (_b = ["The contract contains the following products:"], _b.raw = ["The contract contains the following products:"], i18n(_b))),
+ m('ul', _.map(contract.products, function (p) { return m("li", p.description + ": " + prettyAmount(p.price)); })),
+ m("button", { onclick: doPayment }, (_c = ["Confirm Payment"], _c.raw = ["Confirm Payment"], i18n(_c)))
+ ];
+ var _a, _b, _c;
}
- document.location.href = URI(d.offer.exec_url)
- .absoluteTo(query.merchantPageUrl)
- .addQuery({ H_contract: d.offer.H_contract })
- .href();
- });
- });
+ };
+ m.mount(document.getElementById("contract"), Contract);
+ function doPayment() {
+ var d = {
+ offer: offer
+ };
+ chrome.runtime.sendMessage({ type: 'confirm-pay', detail: d }, function (resp) {
+ if (!resp.success) {
+ console.log("confirm-pay error", JSON.stringify(resp));
+ return;
+ }
+ var c = d.offer.contract;
+ console.log("contract", c);
+ document.location.href = web_common_1.substituteFulfillmentUrl(c.fulfillment_url, offer);
+ });
+ }
+ }
+ exports_1("main", main);
+ return {
+ setters:[
+ function (web_common_1_1) {
+ web_common_1 = web_common_1_1;
+ }],
+ execute: function() {
+ }
+ }
});
//# sourceMappingURL=confirm-contract.js.map \ No newline at end of file