aboutsummaryrefslogtreecommitdiff
path: root/extension/pages
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-01-26 17:21:17 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-01-26 17:24:42 +0100
commitd2f1cb3234cbeca88903efcfd0d7d406fbece53c (patch)
tree6c1ab8ea8d3f1a0634aa21c83b6d39c7eac519da /extension/pages
parent5f996fedbc7542e1ba757a5a5856e43931ad7939 (diff)
fix #4153 and #0004154
Diffstat (limited to 'extension/pages')
-rw-r--r--extension/pages/confirm-contract.html23
-rw-r--r--extension/pages/confirm-contract.js90
-rw-r--r--extension/pages/confirm-contract.tsx79
-rw-r--r--extension/pages/confirm-create-reserve.html4
-rw-r--r--extension/pages/confirm-create-reserve.js46
-rw-r--r--extension/pages/confirm-create-reserve.tsx40
6 files changed, 141 insertions, 141 deletions
diff --git a/extension/pages/confirm-contract.html b/extension/pages/confirm-contract.html
index d851af350..2a2166888 100644
--- a/extension/pages/confirm-contract.html
+++ b/extension/pages/confirm-contract.html
@@ -4,17 +4,14 @@
<head>
<title>Taler Wallet: Confirm Reserve Creation</title>
<script src="../lib/vendor/URI.js"></script>
- <script src="../lib/vendor/handlebars-v4.0.5.js"></script>
- <script src="../lib/commonHelpers.js"></script>
- <script src="confirm-contract.js"></script>
+ <script src="../lib/vendor/mithril.js"></script>
+ <script src="../lib/i18n.js"></script>
+ <script src="../lib/vendor/lodash.core.min.js"></script>
+ <script src="../lib/vendor/system-csp-production.src.js"></script>
+ <script src="../lib/module-trampoline.js"></script>
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
<script id="contract-template" type="text/x-handlebars-template">
- Hello, this is the wallet. The merchant "{{merchant.name}}"
- wants to enter a contract over {{prettyAmount amount}}
- with you.
-
- <p />
Your contract includes these products:
<ul>
@@ -41,15 +38,7 @@
</aside>
<section id="main">
-
- <article id="contract">
- <div id="render-contract"></div>
- <button id="confirm-pay">Confirm Payment</button>
- <div id="confirm-warning"></div>
- </article>
-
- <article id="status"></article>
-
+ <article id="contract"></article>
</section>
</body>
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
diff --git a/extension/pages/confirm-contract.tsx b/extension/pages/confirm-contract.tsx
index d1a64a6ba..fc5dfdece 100644
--- a/extension/pages/confirm-contract.tsx
+++ b/extension/pages/confirm-contract.tsx
@@ -17,55 +17,56 @@
/// <reference path="../lib/decl/handlebars/handlebars.d.ts" />
"use strict";
-let url = URI(document.location.href);
-let query: any = URI.parseQuery(url.query());
+import {substituteFulfillmentUrl} from "../lib/web-common";
-let $_ = (x) => document.getElementById(x);
+declare var m: any;
-function renderContract(contract) {
- let showAmount = document.getElementById("show-amount");
- $_('merchant-name').innerText = contract.merchant.name;
+function prettyAmount(amount) {
+ let v = amount.value + amount.fraction / 1e6;
+ return `${v.toFixed(2)} ${amount.currency}`;
}
-function clone(obj) {
- // This is faster than it looks ...
- return JSON.parse(JSON.stringify(obj));
-}
-
-
-Handlebars.registerHelper('prettyAmount', function(amount) {
- let v = amount.value + amount.fraction / 10e6;
- return v.toFixed(2) + " " + amount.currency;
-});
-
-document.addEventListener("DOMContentLoaded", (e) => {
+export function main() {
+ let url = URI(document.location.href);
+ let query: any = URI.parseQuery(url.query());
let offer = JSON.parse(query.offer);
console.dir(offer);
-
- let source = $_("contract-template").innerHTML;
- let template = Handlebars.compile(source);
- $_("render-contract").innerHTML = template(offer.contract);
-
- document.getElementById("confirm-pay").addEventListener("click", (e) => {
- console.log("Query:", JSON.stringify(query));
+ let contract = offer.contract;
+
+ var Contract = {
+ view(ctrl) {
+ return [
+ m("p",
+ i18n`Hello, this is the wallet. The merchant "${contract.merchant.name}"
+ wants to enter a contract over ${prettyAmount(contract.amount)}
+ with you.`),
+ m("p",
+ i18n`The contract contains the following products:`),
+ m('ul',
+ _.map(contract.products,
+ (p: any) => m("li",
+ `${p.description}: ${prettyAmount(p.price)}`))),
+ m("button", {onclick: doPayment}, i18n`Confirm Payment`)
+ ];
+ }
+ };
+
+ m.mount(document.getElementById("contract"), Contract);
+
+
+ function doPayment() {
let d = {
- offer: JSON.parse(query.offer),
- merchantPageUrl: query.merchantPageUrl
+ offer
};
- chrome.runtime.sendMessage({type:'confirm-pay', detail: d}, (resp) => {
+ chrome.runtime.sendMessage({type: 'confirm-pay', detail: d}, (resp) => {
if (!resp.success) {
- let source = $_("error-template").innerHTML;
- let template = Handlebars.compile(source);
- $_("status").innerHTML = template(resp);
+ console.log("confirm-pay error", JSON.stringify(resp));
return;
}
- document.location.href = URI(d.offer.exec_url)
- .absoluteTo(query.merchantPageUrl)
- .addQuery({H_contract: d.offer.H_contract})
- .href();
+ let c = d.offer.contract;
+ console.log("contract", c);
+ document.location.href = substituteFulfillmentUrl(c.fulfillment_url, offer);
});
- });
-});
-
-
+ }
+}
diff --git a/extension/pages/confirm-create-reserve.html b/extension/pages/confirm-create-reserve.html
index 812ae9434..b78f96712 100644
--- a/extension/pages/confirm-create-reserve.html
+++ b/extension/pages/confirm-create-reserve.html
@@ -4,8 +4,8 @@
<head>
<title>Taler Wallet: Select Taler Provider</title>
<script src="../lib/vendor/URI.js"></script>
- <script src="../lib/polyfill-react.js"></script>
- <script src="confirm-create-reserve.js"></script>
+ <script src="../lib/vendor/system-csp-production.src.js"></script>
+ <script src="../lib/module-trampoline.js"></script>
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
</head>
diff --git a/extension/pages/confirm-create-reserve.js b/extension/pages/confirm-create-reserve.js
index 193f496a6..ca9ef4099 100644
--- a/extension/pages/confirm-create-reserve.js
+++ b/extension/pages/confirm-create-reserve.js
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2015 GNUnet e.V.
+ (C) 2015-2016 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -13,27 +13,26 @@
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/>
*/
-"use strict";
-var ConfirmCreateReserve;
-(function (ConfirmCreateReserve) {
- var url = URI(document.location.href);
- var query = URI.parseQuery(url.query());
- function updateAmount() {
- var showAmount = document.getElementById("show-amount");
- console.log("Query is " + JSON.stringify(query));
- var s = query.amount_str;
- if (!s) {
- document.body.innerHTML = "Oops, something went wrong.";
- return;
+System.register([], function(exports_1) {
+ "use strict";
+ function main() {
+ function updateAmount() {
+ var showAmount = document.getElementById("show-amount");
+ console.log("Query is " + JSON.stringify(query));
+ var s = query.amount_str;
+ if (!s) {
+ document.body.innerHTML = "Oops, something went wrong.";
+ return;
+ }
+ showAmount.textContent = s;
}
- showAmount.textContent = s;
- }
- document.addEventListener("DOMContentLoaded", function (e) {
+ var url = URI(document.location.href);
+ var query = URI.parseQuery(url.query());
updateAmount();
document.getElementById("confirm").addEventListener("click", function (e) {
var d = Object.assign({}, query);
d.mint = document.getElementById('mint-url').value;
- chrome.runtime.sendMessage({ type: 'confirm-reserve', detail: d }, function (resp) {
+ var cb = function (resp) {
if (resp.success === true) {
document.location.href = resp.backlink;
}
@@ -41,8 +40,15 @@ var ConfirmCreateReserve;
document.body.innerHTML =
"Oops, something went wrong. It looks like the bank could not\n transfer funds to the mint. Please go back to your bank's website\n to check what happened.";
}
- });
+ };
+ chrome.runtime.sendMessage({ type: 'confirm-reserve', detail: d }, cb);
});
- });
-})(ConfirmCreateReserve || (ConfirmCreateReserve = {}));
+ }
+ exports_1("main", main);
+ return {
+ setters:[],
+ execute: function() {
+ }
+ }
+});
//# sourceMappingURL=confirm-create-reserve.js.map \ No newline at end of file
diff --git a/extension/pages/confirm-create-reserve.tsx b/extension/pages/confirm-create-reserve.tsx
index 38776ee6b..88af96466 100644
--- a/extension/pages/confirm-create-reserve.tsx
+++ b/extension/pages/confirm-create-reserve.tsx
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2015 GNUnet e.V.
+ (C) 2015-2016 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -16,11 +16,8 @@
"use strict";
-namespace ConfirmCreateReserve {
-
- let url = URI(document.location.href);
- let query: any = URI.parseQuery(url.query());
+export function main() {
function updateAmount() {
let showAmount = document.getElementById("show-amount");
console.log("Query is " + JSON.stringify(query));
@@ -32,26 +29,25 @@ namespace ConfirmCreateReserve {
showAmount.textContent = s;
}
+ let url = URI(document.location.href);
+ let query: any = URI.parseQuery(url.query());
+
+ updateAmount();
- document.addEventListener("DOMContentLoaded", (e) => {
- updateAmount();
+ document.getElementById("confirm").addEventListener("click", (e) => {
+ let d = Object.assign({}, query);
+ d.mint = (document.getElementById('mint-url') as HTMLInputElement).value;
- document.getElementById("confirm").addEventListener("click", (e) => {
- let d = Object.assign({}, query);
- d.mint = (document.getElementById('mint-url') as HTMLInputElement).value;
- chrome.runtime.sendMessage({type:'confirm-reserve', detail: d},
- (resp) => {
- if (resp.success === true) {
- document.location.href = resp.backlink;
- } else {
- document.body.innerHTML =
- `Oops, something went wrong. It looks like the bank could not
+ const cb = (resp) => {
+ if (resp.success === true) {
+ document.location.href = resp.backlink;
+ } else {
+ document.body.innerHTML =
+ `Oops, something went wrong. It looks like the bank could not
transfer funds to the mint. Please go back to your bank's website
to check what happened.`;
- }
- });
-
- });
+ }
+ };
+ chrome.runtime.sendMessage({type: 'confirm-reserve', detail: d}, cb);
});
-
} \ No newline at end of file