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

328 lines
10 KiB
JavaScript

var bit = 0;
var bitFac = 1;
let out = 0;
let check = false;
let checkIf = false;
let test;
let test1;
// Var. for Pi funktion
var Pi = 0;
var pricePi = 5;
var Pifac = 0;
var piTrue = false;
var piCheck = false;
var Pifact = 1;
// Var. for PC funktion
var Pc = 0;
var pricePc = 10;
var Pcfac = 0;
var PcTrue = false;
var PcCheck = false;
var Pcfact = 1;
// Var. for Server funktion
var Sv = 0;
var priceSv = 10;
var Svfac = 0;
var SvTrue = false;
var SvCheck = false;
var Svfact = 1;
function up() {
bit = bit + bitFac;
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
if (check != true) {
check = true;
setTimeout(loop, 1);
}
}
function loop() {
myVar = setInterval(load, 100);
}
function load() {
if (bit >= pricePi) {
document.getElementById("pi").style.color = "#148914";
} else {
document.getElementById("pi").style.color = "unset";
}
if (bit >= pricePc) {
document.getElementById("pc").style.color = "#148914";
} else {
document.getElementById("pc").style.color = "unset";
}
if (bit >= priceSv) {
document.getElementById("sv").style.color = "#148914";
} else {
document.getElementById("sv").style.color = "unset";
}
}
// Buy one PI funktion --------------------------------------------------------------
function undoPi() {
document.getElementById("pi").style.color = "unset";
}
function piFunk() {
if (piTrue === true && piCheck === true) {
Pifac = Pi * 1.05;
bit = bit + Pifac;
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
var Pifac2 = Pifac / 2;
out = (Pifac2.toFixed(1)) + " /sec";
document.getElementById('piBits').innerHTML = out;
setTimeout(piFunk, 2000);
}
}
function pistr() {
if (piTrue === true) {
piTrue = false;
document.getElementById('pistr').innerHTML = "Start PI";
} else {
piTrue = true;
setTimeout(piFunk, 1);
document.getElementById('pistr').innerHTML = "Stop PI";
}
}
function pi() {
if (bit >= pricePi) {
bit = bit - pricePi;
Pifact = Pifact * 1.005;
pricePi = pricePi * Pifact;
Pi = Pi + 1;
console.log(Pifact.toPrecision(3));
//console.log (pricePi.);
console.log(pricePi);
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
out = pricePi.toFixed(1);
document.getElementById('piPrice').innerHTML = out;
if (Pi >= 1) {
piTrue = true;
document.getElementById('pistr').innerHTML = "Stop PI";
if (piCheck != true) {
setTimeout(piFunk, 1);
piCheck = true;
}
}
} else {
document.getElementById("pi").style.color = "#ff0000";
setTimeout(undoPi, 1000);
}
}
// Buy one PC funktion --------------------------------------------------------------
function undoPc() {
document.getElementById("pc").style.color = "unset";
}
function pcFunk() {
if (PcTrue === true && PcCheck === true) {
Pcfac = Pc * 1.3;
bit = bit + Pcfac;
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
var Pcfac2 = Pcfac / 2;
out = (Pcfac2.toFixed(1)) + " /sec";
document.getElementById('pcBits').innerHTML = out;
setTimeout(pcFunk, 2000);
}
}
function pcstr() {
if (PcTrue === true) {
PcTrue = false;
document.getElementById('pcstr').innerHTML = "Start PC";
} else {
PcTrue = true;
setTimeout(pcFunk, 1);
document.getElementById('pcstr').innerHTML = "Stop PC";
}
}
function pc() {
if (bit >= pricePc) {
bit = bit - pricePc;
Pcfact = Pcfact * 1.005;
pricePc = pricePc * Pcfact;
Pc = Pc + 1;
console.log(Pcfact.toPrecision(3));
//console.log (pricePc.);
console.log(pricePc);
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
out = pricePc.toFixed(1);
document.getElementById('pcPrice').innerHTML = out;
if (Pc >= 1) {
PcTrue = true;
document.getElementById('pcstr').innerHTML = "Stop Pc";
if (PcCheck != true) {
setTimeout(pcFunk, 1);
PcCheck = true;
}
}
} else {
document.getElementById("pc").style.color = "#ff0000";
setTimeout(undoPc, 1000);
}
}
// Buy one Server funktion --------------------------------------------------------------
function undoSv() {
document.getElementById("sv").style.color = "unset";
}
function svFunk() {
if (SvTrue === true && SvCheck === true) {
Svfac = Sv * 1.6;
bit = bit + Svfac;
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
var Svfac2 = Svfac / 2;
out = (Svfac2.toFixed(1)) + " /sec";
document.getElementById('svBits').innerHTML = out;
setTimeout(svFunk, 2000);
}
}
function svstr() {
if (SvTrue === true) {
SvTrue = false;
document.getElementById('svstr').innerHTML = "Start Server";
} else {
SvTrue = true;
setTimeout(svFunk, 1);
document.getElementById('svstr').innerHTML = "Stop Server";
}
}
function sv() {
if (bit >= priceSv) {
bit = bit - priceSv;
Svfact = Svfact * 1.009;
priceSv = priceSv * Svfact;
Sv = Sv + 1;
console.log(Svfact.toPrecision(3));
//console.log (priceSv.);
console.log(priceSv);
out = bit.toFixed(1);
document.getElementById('output').innerHTML = out;
out = priceSv.toFixed(1);
document.getElementById('svPrice').innerHTML = out;
if (Sv >= 1) {
SvTrue = true;
document.getElementById('svstr').innerHTML = "Stop Server";
if (SvCheck != true) {
setTimeout(svFunk, 1);
SvCheck = true;
}
}
} else {
document.getElementById("sv").style.color = "#ff0000";
setTimeout(undoSv, 1000);
}
}
//--Popup shit---------------------------------------
var wrenchCheck = true;
function wrench() {
if (wrenchCheck == true) {
document.getElementById("icon-bit-main").style.display = "none";
document.getElementById("wrench").style.display = "block";
wrenchCheck = false;
var elements = document.getElementsByClassName('icon-nav1');
elements[0].style.backgroundColor = "#4C4C4C";
if (bagCheck === true || arrowCheck === true ) {
document.getElementById("bag").style.display = "none";
document.getElementById("arrow").style.display = "none";
var elements = document.getElementsByClassName('icon-nav2');
elements[0].style.backgroundColor = "#c4c4c4";
var elements = document.getElementsByClassName('icon-nav3');
elements[0].style.backgroundColor = "#c4c4c4";
bagCheck = true;
arrowCheck = true;
}
}
else{
document.getElementById("wrench").style.display = "none";
document.getElementById("icon-bit-main").style.display = "block";
wrenchCheck = true;
var elements = document.getElementsByClassName('icon-nav1');
elements[0].style.backgroundColor = "#c4c4c4";
}
}
var bagCheck = true;
function bag() {
if (bagCheck == true) {
document.getElementById("bag").style.display = "block";
document.getElementById("icon-bit-main").style.display = "none";
bagCheck = false;
var elements = document.getElementsByClassName('icon-nav2');
elements[0].style.backgroundColor = "#4C4C4C";
if (wrenchCheck === true || arrowCheck === true ) {
document.getElementById("wrench").style.display = "none";
document.getElementById("arrow").style.display = "none";
var elements = document.getElementsByClassName('icon-nav1');
elements[0].style.backgroundColor = "#c4c4c4";
var elements = document.getElementsByClassName('icon-nav3');
elements[0].style.backgroundColor = "#c4c4c4";
wrenchCheck = true;
arrowCheck = true;
}
}
else{
document.getElementById("bag").style.display = "none";
document.getElementById("icon-bit-main").style.display = "block";
bagCheck = true;
var elements = document.getElementsByClassName('icon-nav2');
elements[0].style.backgroundColor = "#c4c4c4";
}
}
var arrowCheck = true;
function arrow() {
if (arrowCheck == true) {
document.getElementById("icon-bit-main").style.display = "none";
document.getElementById("arrow").style.display = "block";
arrowCheck = false;
var elements = document.getElementsByClassName('icon-nav3');
elements[0].style.backgroundColor = "#4C4C4C";
if (wrenchCheck === true || bagCheck === true ) {
document.getElementById("wrench").style.display = "none";
document.getElementById("bag").style.display = "none";
var elements = document.getElementsByClassName('icon-nav1');
elements[0].style.backgroundColor = "#c4c4c4";
var elements = document.getElementsByClassName('icon-nav2');
elements[0].style.backgroundColor = "#c4c4c4";
wrenchCheck = true;
bagCheck = true;
}
}
else{
document.getElementById("arrow").style.display = "none";
document.getElementById("icon-bit-main").style.display = "block";
arrowCheck = true;
var elements = document.getElementsByClassName('icon-nav3');
elements[0].style.backgroundColor = "#c4c4c4";
}
}
//https://www.w3schools.com/howto/howto_js_popup_form.asp
//https://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_lightbulb