diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2015-07-30 17:52:19 +0200 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2015-07-30 17:52:19 +0200 |
commit | 8ffc458b7acfc3179dd793b65ac6db3e5c79cd3b (patch) | |
tree | 767b09340d37369ecc10067970e90a30ff48d65b /src/frontend/merchant.js | |
parent | 9c2a5666f9f3d83aae4ed0c41b53929f64406dcc (diff) | |
download | merchant-8ffc458b7acfc3179dd793b65ac6db3e5c79cd3b.tar.gz merchant-8ffc458b7acfc3179dd793b65ac6db3e5c79cd3b.tar.bz2 merchant-8ffc458b7acfc3179dd793b65ac6db3e5c79cd3b.zip |
defining the new directory layout according to the
frontend/backend merchant architecture
Diffstat (limited to 'src/frontend/merchant.js')
-rw-r--r-- | src/frontend/merchant.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/frontend/merchant.js b/src/frontend/merchant.js new file mode 100644 index 00000000..a65b5008 --- /dev/null +++ b/src/frontend/merchant.js @@ -0,0 +1,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; + +} |