Merge pull request #349 from hydroflame/fix-donate-invalid-input

Fix donate invalid input
This commit is contained in:
danielyxie 2018-07-06 17:07:44 -05:00 committed by GitHub
commit f33bc59768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -306,13 +306,16 @@ function displayFactionContent(factionName) {
var donateDivWrapper = createElement("div", {class:"faction-work-div-wrapper"}); var donateDivWrapper = createElement("div", {class:"faction-work-div-wrapper"});
donateDiv.appendChild(donateDivWrapper); donateDiv.appendChild(donateDivWrapper);
var donateRepGain = createElement("p", { var donateRepGain = createElement("p", {
innerText:"This donation will result in 0 reputation gain" innerText:"This donation will result in 0.000 reputation gain"
}); });
var donateAmountInput = createElement("input", { var donateAmountInput = createElement("input", {
placeholder:"Donation amount", placeholder:"Donation amount",
inputListener:()=>{ inputListener:()=>{
var amt = parseFloat(donateAmountInput.value); let amt = 0;
if (isNaN(amt) || amt < 0) { if(donateAmountInput.value !== "") {
amt = parseFloat(donateAmountInput.value);
}
if (isNaN(amt)) {
donateRepGain.innerText = "Invalid donate amount entered!"; donateRepGain.innerText = "Invalid donate amount entered!";
} else { } else {
var repGain = amt / 1e6 * Player.faction_rep_mult; var repGain = amt / 1e6 * Player.faction_rep_mult;