diff options
| author | Adam Soltys <[email protected]> | 2012-11-06 20:38:48 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-06 20:38:48 -0800 |
| commit | 08f341f692688f077e9080bded2b14fdd5979c1e (patch) | |
| tree | cf962ed8dd97f96102b1678184076b53a39ad527 | |
| parent | d407b638bc07ea0c7b05374c64e6d4b48770df86 (diff) | |
| download | coinos-server-08f341f692688f077e9080bded2b14fdd5979c1e.tar.gz coinos-server-08f341f692688f077e9080bded2b14fdd5979c1e.zip | |
Read parameters from client account
| -rw-r--r-- | client.json | 1 | ||||
| -rw-r--r-- | clients.js | 22 | ||||
| -rw-r--r-- | js/bitcoin_pos.js | 41 |
3 files changed, 50 insertions, 14 deletions
diff --git a/client.json b/client.json new file mode 100644 index 00000000..eb7d41cf --- /dev/null +++ b/client.json @@ -0,0 +1 @@ +{"title": "Daily Catch", "address": "1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr", "logo": "http://vanbtc.ca/pos/img/dailycatch.jpg", "commission": "3"} diff --git a/clients.js b/clients.js new file mode 100644 index 00000000..f75b5d52 --- /dev/null +++ b/clients.js @@ -0,0 +1,22 @@ +var http = require('http'); +var mysql = require('mysql'); +var url = require('url'); + +http.createServer(function (req, res) { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + var client = url.parse(req.url, true).query.client; + + var connection = mysql.createConnection({ + host : 'localhost', + user : 'root', + password : 'MPJzfq97', + database: 'vanbtc' + }); + + connection.connect(); + connection.query("SELECT * FROM users WHERE login = ?", [client], function(err, rows) { + res.write(JSON.stringify(rows)); + connection.end(); + res.end(); + }); +}).listen(8000); diff --git a/js/bitcoin_pos.js b/js/bitcoin_pos.js index 67acd288..5d8f551b 100644 --- a/js/bitcoin_pos.js +++ b/js/bitcoin_pos.js @@ -1,28 +1,26 @@ $(function() { var websocket = null; + var client = getParameterByName('client'); var title = getParameterByName('title'); var address = getParameterByName('address'); var commission = getParameterByName('commission'); var logo = getParameterByName('logo'); var exchange = 0; - if (address == "") - address = '1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr' - - if (commission == "") - commission = 3; - - if (logo != "") - $('#logo').attr('src', logo).show(); - - - $('#title').html(title); - $('#address').html(address); - $('#received').hide(); - + setupPage(); setupQR(); setupSocket(); + if (client != "") { + $.getJSON('client.json', { name: client }, function(data) { + title = data.title; + address = data.address; + commission = data.commission; + logo = data.logo; + setupPage(); + }); + } + $('#amount').keyup(updateTotal); $('#amount').focus(); $('#amount').focus(function() { @@ -76,6 +74,21 @@ $(function() { setTimeout(fetchExchangeRate, 900000); } + function setupPage() { + if (address == "") + address = '1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr' + + if (commission == "") + commission = 3; + + if (logo != "") + $('#logo').attr('src', logo).show(); + else + $('#title').html(title); + + $('#address').html(address); + $('#received').hide(); + } function setupSocket() { setTimeout(setupSocket, 10000); |
