From d2f1cb3234cbeca88903efcfd0d7d406fbece53c Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Tue, 26 Jan 2016 17:21:17 +0100
Subject: fix #4153 and #0004154

---
 extension/pages/confirm-create-reserve.tsx | 40 ++++++++++++++----------------
 1 file changed, 18 insertions(+), 22 deletions(-)

(limited to 'extension/pages/confirm-create-reserve.tsx')

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
-- 
cgit v1.2.3

