mirror of
https://github.com/miky-kr5/CEIDEC-Pong-Web.git
synced 2023-01-29 18:47:06 +00:00
Changed more site UI stuff.
This commit is contained in:
@@ -10,7 +10,7 @@ function canIPlayTheGame() {
|
|||||||
if (result.logs[0].args.player === myAccount) {
|
if (result.logs[0].args.player === myAccount) {
|
||||||
$('#can_play').text(myAccount + ' can play the game!');
|
$('#can_play').text(myAccount + ' can play the game!');
|
||||||
getTimesPlayed();
|
getTimesPlayed();
|
||||||
loadBalance();
|
loadBalance(false);
|
||||||
playTheGame();
|
playTheGame();
|
||||||
} else {
|
} else {
|
||||||
alert("Whoops! An error ocurred.\nThanks for your money, though :P");
|
alert("Whoops! An error ocurred.\nThanks for your money, though :P");
|
||||||
@@ -20,13 +20,15 @@ function canIPlayTheGame() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadBalance() {
|
function loadBalance(sad) {
|
||||||
myWeb3.eth.getCoinbase(function(err, account) {
|
myWeb3.eth.getCoinbase(function(err, account) {
|
||||||
if (err === null) {
|
if (err === null) {
|
||||||
myAccount = account;
|
myAccount = account;
|
||||||
myWeb3.eth.getBalance(account, function(err, balance) {
|
myWeb3.eth.getBalance(account, function(err, balance) {
|
||||||
if (err === null) {
|
if (err === null) {
|
||||||
$('#balance').text(myWeb3.fromWei(balance, "ether") + " ETH");
|
$('#balance').text(myWeb3.fromWei(balance, "ether") + " ETH");
|
||||||
|
if (sad)
|
||||||
|
$('#can_play').text(myAccount + " can't play the game... so sad!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -63,9 +65,8 @@ function initWeb3() {
|
|||||||
pong.setProvider(myWeb3Provider);
|
pong.setProvider(myWeb3Provider);
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
loadBalance();
|
loadBalance(true);
|
||||||
getTimesPlayed();
|
getTimesPlayed();
|
||||||
$('#can_play').text(myAccount + " can't play the game... so sad!");
|
|
||||||
|
|
||||||
// Register call and listen for events.
|
// Register call and listen for events.
|
||||||
ethCallback = canIPlayTheGame;
|
ethCallback = canIPlayTheGame;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function canIPlayTheGame() {
|
|||||||
if (result.logs[0].args.player === myAccount) {
|
if (result.logs[0].args.player === myAccount) {
|
||||||
$('#can_play').text(myAccount + ' can play the game!');
|
$('#can_play').text(myAccount + ' can play the game!');
|
||||||
getTimesPlayed();
|
getTimesPlayed();
|
||||||
loadBalance();
|
loadBalance(false);
|
||||||
playTheGame();
|
playTheGame();
|
||||||
} else {
|
} else {
|
||||||
alert("Whoops! An error ocurred.\nThanks for your money, though :P");
|
alert("Whoops! An error ocurred.\nThanks for your money, though :P");
|
||||||
@@ -20,13 +20,15 @@ function canIPlayTheGame() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadBalance() {
|
function loadBalance(sad) {
|
||||||
myWeb3.eth.getCoinbase(function(err, account) {
|
myWeb3.eth.getCoinbase(function(err, account) {
|
||||||
if (err === null) {
|
if (err === null) {
|
||||||
myAccount = account;
|
myAccount = account;
|
||||||
myWeb3.eth.getBalance(account, function(err, balance) {
|
myWeb3.eth.getBalance(account, function(err, balance) {
|
||||||
if (err === null) {
|
if (err === null) {
|
||||||
$('#balance').text(myWeb3.fromWei(balance, "ether") + " ETH");
|
$('#balance').text(myWeb3.fromWei(balance, "ether") + " ETH");
|
||||||
|
if (sad)
|
||||||
|
$('#can_play').text(myAccount + " can't play the game... so sad!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -63,9 +65,8 @@ function initWeb3() {
|
|||||||
pong.setProvider(myWeb3Provider);
|
pong.setProvider(myWeb3Provider);
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
loadBalance();
|
loadBalance(true);
|
||||||
getTimesPlayed();
|
getTimesPlayed();
|
||||||
$('#can_play').text(myAccount + " can't play the game... so sad!");
|
|
||||||
|
|
||||||
// Register call and listen for events.
|
// Register call and listen for events.
|
||||||
ethCallback = canIPlayTheGame;
|
ethCallback = canIPlayTheGame;
|
||||||
|
|||||||
Reference in New Issue
Block a user