Skip to content

Commit

Permalink
Disable faucet buttons when sending or no longer available.
Browse files Browse the repository at this point in the history
  • Loading branch information
caedesvvv committed Jan 25, 2015
1 parent 6c5f6a8 commit 29770f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/html/tools/faucet.html
Expand Up @@ -4,10 +4,10 @@
<h3>Testnet faucet</h3>
<div>Thanks to <a href="http://faucet.xeno-genesis.com/">Haskoin</a> and <a href="https://helloblock.io/">Helloblock</a> for providing this service.</div>
<div class="columns large-6">
<a ng-click="pokeHelloblockFaucet()" class="button">{{'Get from helloblock'|_}}</a>
<a ng-disabled="faucetRunning.helloblock" ng-click="pokeHelloblockFaucet()" class="button">{{'Get from helloblock'|_}}</a>
</div>
<div class="columns large-6">
<a ng-disabled="faucetDisabled" ng-click="pokeHaskoinFaucet()" class="button">{{'Get coins haskoin'|_}}</a>
<a ng-disabled="faucetRunning.haskoin" ng-click="pokeHaskoinFaucet()" class="button">{{'Get from haskoin'|_}}</a>
</div>
</div>
<div>You can also get coins at the <a href="http://kuttler.eu/bitcoin/btc/faucet/">kuttler's faucet</a> and <a href="http://tpfaucet.appspot.com/">tpfaucet</a></div>
Expand Down
6 changes: 6 additions & 0 deletions src/js/frontend/controllers/faucet.js
Expand Up @@ -6,20 +6,26 @@ define(['./module', 'darkwallet'], function (controllers, DarkWallet) {

var day = 60*60*24*1000;

$scope.faucetRunning = {haskoin: false, helloblock: false};

$scope.pokeHelloblockFaucet = function() {
var walletAddress = $wallet.generateAddress();
walletAddress.label = 'helloblock';
$scope.faucetRunning.helloblock = true;
$http({method: 'POST', url: "https://testnet.helloblock.io/v1/faucet/withdrawal", data: "toAddress="+walletAddress.address+"&value=1000000", headers:{'Content-Type': 'application/x-www-form-urlencoded'}})
.success(function(data) {
notify.success(_("Coins requested!"));
$scope.faucetRunning.helloblock = false;
})
.error(function() {
notify.warning(_("Error fetching coins"));
$scope.faucetRunning.helloblock = false;
});

};

$scope.pokeHaskoinFaucet = function() {
$scope.faucetRunning.haskoin = true;
if (identity.settings.faucetTimestamp && (identity.settings.faucetTimestamp > Date.now() - day)) {
notify.warning(_("You can only use the haskoin faucet one time a day!"));
return;
Expand Down

0 comments on commit 29770f2

Please sign in to comment.