ardon-income/calculate.js

71 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-09-09 03:30:59 +00:00
"use strict";
//Licensed under the Apache License 2.0. See license file for information.
function calculate() {
2017-09-09 04:15:16 +00:00
var blocks = 0
2017-09-09 03:30:59 +00:00
var tenblocks = 0
2017-09-09 04:15:16 +00:00
var twentyfifth = 0
var embassies = 0
var capital = 0
var percent = 0
2017-09-09 03:30:59 +00:00
var numReg = /^\d+$/;
//Get input
var blocks = document.getElementById("blocks").value;
var one = document.getElementById("one").value;
var gov = document.getElementById("gov").value;
2017-09-16 04:05:42 +00:00
var design = document.getElementById("design").value;
2017-09-09 04:15:16 +00:00
var embassies = document.getElementById("embassies").value;
var capital = document.getElementById("capital").value;
var infra = document.getElementById("infra").value;
2017-09-16 03:40:20 +00:00
var town = document.getElementById("town").value;
var city = document.getElementById("city").value;
var metro = document.getElementById("metro").value;
2017-09-09 03:30:59 +00:00
2017-09-09 04:15:16 +00:00
if (blocks.match(numReg))
2017-09-09 03:30:59 +00:00
{
//Do nothing.
}
else
{
//Tells them to enter only numbers.
alert("Please enter only numbers in this field.");
}
var emeralds = +blocks / 1000
console.log(emeralds)
2017-09-16 04:05:42 +00:00
var infra = +infra / 1000 * 0.005
console.log(infra)
var one = +one / 1000 * 0.01
console.log(one)
var design = +design / 1000 * 0.015
console.log(design)
var gov = +gov / 1000 * 0.02
console.log(gov)
var embassies = +embassies * 0.01
2017-09-09 04:15:16 +00:00
console.log(embassies)
var capital = +capital * 0.025
2017-09-09 04:15:16 +00:00
console.log(capital)
2017-09-16 03:40:20 +00:00
var town = +town * 0.005
console.log(town)
var city = +city * 0.01
console.log(city)
var metro = +metro * 0.01
console.log(metro)
2017-09-16 03:43:31 +00:00
var percent = +one + +design + +gov + +embassies + +capital + +infra + +town + +city + +metro
2017-09-16 04:05:42 +00:00
//var percent = +percent / 100
2017-09-09 04:15:16 +00:00
console.log(percent)
2017-09-16 04:05:42 +00:00
var total = +emeralds * +percent + +emeralds
2017-09-09 04:15:16 +00:00
var total = total.toFixed(4);
console.log(total)
var date = Date();
console.log(date)
2017-09-09 03:30:59 +00:00
//Show result
alert("Your secret message is " + total);
document.getElementById("Answer").innerHTML = "Your secret message is " + total;
}