summaryrefslogtreecommitdiff
path: root/src/frontend/merchant.js
blob: a65b5008aea424a2ccc77b5d017b091296dad617 (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
/*

  This file is part of TALER
  Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)

  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
  Foundation; either version 3, or (at your option) any later version.

  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

  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/>


*/

/* Set up a listener to be called whenever a Wallet gets installed
so that the user is led towards the demo's steps progressively
*/

function MERCHfirstStep(){

 // NOTE: NO 'let' declarations liked by FF here.
 var resDiv = document.createElement("div");
 var resTitle = document.createElement("h3");
 var resPar = document.createElement("p");

 resTitle.innerHTML = "How To Create A Reserve";
 resPar.innerHTML = "Click on 'Create Reserve' on the Wallet's menu, and fill in the followong form"

 resTitle.setAttribute('class', 'preamble');
 resDiv.appendChild(resTitle);
 resDiv.appendChild(resPar);
 var root = document.getElementById('root');
 root.appendChild(resDiv);

 // get the form
 var getform = new XMLHttpRequest();

 getform.onload = function (){
 var parser = new DOMParser();
 var formDom = parser.parseFromString(getform.responseText, "text/html");
 var form = formDom.getElementById('reserve-form');
 
 resDiv.appendChild(form);
 
 };


 getform.open("GET", "create-reserve-form.html", true);
 getform.send();
 
}

document.body.addEventListener("taler-wallet-installed", MERCHfirstStep, false, false);


/*
notify the extension about the submission. That way it will be possible to retrieve
the mint's URL and/or other info. from the filled form. Actually, the extension will
accomplish the POST too.

*/
function MERCHtrigSubmission(){

// set 'action' attribute to mint's url
// var mint = document.getElementById("mint-url");

// var form = document.getElementById("reserve-form");
// form.setAttribute("action", "http://" + mint.value + "/admin/incoming/add");

var subEvent = new Event("submit-reserve");
document.body.dispatchEvent(subEvent);

// always return false so that the post is actually done by the extension
return false;

}