You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.4 KiB

"use strict";
//Licensed under the Apache License 2.0. See license file for information.
function calculate() {
var blocks = 0
var tenblocks = 0
var twentyfifth = 0
var embassies = 0
var capital = 0
var percent = 0
var numReg = /^\d+$/;
//Get input
var blocks = document.getElementById("blocks").value;
var tenblocks = document.getElementById("tenblocks").value;
var twentyfifth = document.getElementById("twentyfifth").value;
var embassies = document.getElementById("embassies").value;
var capital = document.getElementById("capital").value;
if (blocks.match(numReg))
{
//Do nothing.
}
else
{
//Tells them to enter only numbers.
alert("Please enter only numbers in this field.");
}
var emeralds = +blocks / 1000
console.log(emeralds)
var tenblocks = +tenblocks / 1000 * 0.001
console.log(tenblocks)
var twentyfifth = +twentyfifth / 1000 * 0.0025
console.log(twentyfifth)
var embassies = +embassies * 0.0025
console.log(embassies)
var capital = +capital * 0.01
console.log(capital)
var percent = +tenblocks + +twentyfifth + +embassies + +capital
console.log(percent)
var total = +emeralds * +percent +emeralds
var total = total.toFixed(4);
console.log(total)
var date = Date();
console.log(date)
//Show result
alert("Your secret message is " + total);
document.getElementById("Answer").innerHTML = "Your secret message is " + total;
}