summaryrefslogtreecommitdiff
path: root/demo/bank/index.html
blob: 7746e1e4e79310105ee6afb80c822790d40de2db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Taler's "demo" bank</title>
  <link rel="stylesheet" type="text/css" href="style.css">
    <script>
        /*
        @licstart  The following is the entire license notice for the
        JavaScript code in this page.

        Copyright (C) 2015 GNUnet e.V.

        The JavaScript code in this page is free software: you can
        redistribute it and/or modify it under the terms of the GNU
        Lesser General Public License (GNU LGPL) as published by the Free Software
        Foundation, either version 2.1 of the License, or (at your option)
        any later version.  The code is distributed WITHOUT ANY WARRANTY;
        without even the implied warranty of MERCHANTABILITY or FITNESS
        FOR A PARTICULAR PURPOSE.  See the GNU LGPL for more details.

        As additional permission under GNU LGPL version 2.1 section 7, you
        may distribute non-source (e.g., minimized or compacted) forms of
        that code without the copy of the GNU LGPL normally required by
        section 4, provided you include this license notice and a URL
        through which recipients can access the Corresponding Source.

        @licend  The above is the entire license notice
        for the JavaScript code in this page.
        */
    </script>
</head>
<body id="css-zen-garden" onload="signal_me()">
    <div class="explanation" id="zen-explanation" role="article">
      <h1>Welcome to the KUDOS bank!</h1>
      <p>Through this page, you can wire funds to our demonstrator mint
         in order to create your reserves from where withdraw your coins.
	 Once the reserve is created, the withdrawing of coins will be
	 entirely handled by the wallet, with no intervention required
	 to the user.
      </p>
      <p>
      Enter the deisired amount, and click 'Select mint'. Your wallet
      will make you choose a mint and will automatically submit all the
      needed data into the bank's system. At the end of the withdrawal,
      the wallet will show you the 'All coins withdrawn' nice message.
      </p>

      <p>Still missing a wallet? <a href="http://demo.taler.net/extension">Install one!</a>
      </p>
    </div>
      <form id="reserve-form" name="tform" action="/fake_wire_transfer.php" method="POST">
          <input type="text" id="reserve-pk-input" name="reserve_pk" hidden></input>
          Amount to withdraw: 
          <select id="reserve-amn-id" name="kudos_amount">
            <option value="1 KUDOS">1 KUDOS</option>
            <option value="2 KUDOS">2 KUDOS</option>
            <option value="3.01 KUDOS">3.01 KUDOS</option>
            <option value="5 KUDOS">5 KUDOS</option>
            <option value="10 KUDOS">10 KUDOS</option>
            <option value="10.50 KUDOS">10.50 KUDOS</option>
            <option value="1000.3 KUDOS">1000.3 KUDOS</option>
          </select>
          <input type="text" name="mint_rcv" id="kudos-mint" hidden></input>
          <input id="select-mint"
	         type="button"
		 value="Select mint"
		 onclick="wire_funds()"
		 disabled></input>
      </form>
    </div>
  <script type="text/javascript">
  
  document.body.addEventListener("taler-wallet-present",
                                 has_taler_wallet_cb,
				 false);

  document.body.addEventListener("taler-unload",
                                 no_taler_wallet_cb,
				 false);

  document.body.addEventListener("taler-load",
                                 signal_me,
				 false);

  function wire_funds(){
    var wallet_param = {
    form_id : 'reserve-form',
    input_amount : 'reserve-amn-id', 
    input_pub : 'reserve-pk-input',
    mint_rcv : 'kudos-mint'
    //'base_url' : window.location.host not anymore: must be given by the mint
    };
    var trigger = new CustomEvent("taler-create-reserve", {detail: wallet_param});
    document.body.dispatchEvent(trigger);
  };

  /* The mint signals itself to the wallet */
  function signal_me(){
    var eve = new Event('taler-checkout-probe');
    document.body.dispatchEvent(eve);
  };

  function has_taler_wallet_cb(){
    var button = document.getElementById("select-mint");
    button.removeAttribute("disabled");
  }

  function no_taler_wallet_cb(){
    var button = document.getElementById("select-mint");
    button.setAttribute("disabled", "true");
  }

  </script>
</body>
</html>