For some reason the javascript code isn’t working here. I checked it and javascript code is being executed but it isn’t working. The code is at https://codepen.io/EthanID/pen/vXjpqL?editors=0010
Here is the HTML code:
var cementCount = 10000; //DON'T CHANGE THIS CHEATERS var liveCount = 0; var clickCount = 0; var reset = 0; var lay = 0; var layCost = 15; var mix = 0; var mixCost = 5000; var roll = 0; var rollCost = 10000; var belt = 0; var beltCost = 250000; var form = 0; var formCost = 500; var mold = 0; var moldCost = 1200; var set = 0; var setCost = 3500; document.getElementById("selector").addEventListener("click", addCement); //document.getElementById("reset").addEventListener("click", reset); document.getElementById("update").addEventListener("click", update); document.getElementById("lay").addEventListener("click", buyLay); document.getElementById("mix").addEventListener("click", buyMix); document.getElementById("roll").addEventListener("click", buyRoll); document.getElementById("belt").addEventListener("click", buyBelt); document.getElementById("tiny").addEventListener("click", buyTiny); document.getElementById("med").addEventListener("click", buyMed); document.getElementById("big").addEventListener("click", buyBig); document.getElementById("form").addEventListener("click", buyForm); document.getElementById("mold").addEventListener("click", buyMold); document.getElementById("set").addEventListener("click", buySet); function addCement() { cementCount = cementCount + 1 + ((form * 10) + (mold * 30) + (set * 100)); liveCount = liveCount + 1 + ((form * 10) + (mold * 30) + (set * 100)); clickCount = clickCount + 1; } function buyLay() { if (cementCount > (layCost - 1)) { cementCount = cementCount - layCost; lay = lay + 1; } } function buyMix() { if (cementCount > (mixCost - 1)) { cementCount = cementCount - 5000; mix = mix + 1; } } function buyRoll() { if (cementCount > (rollCost - 1)) { cementCount = cementCount - 10000; roll = roll + 1; } } function buyBelt() { if (cementCount > (beltCost - 1)) { cementCount = cementCount - 250000; belt = belt + 1; } } function buyTiny() { if (cementCount > 499999) { var invest = Math.floor((Math.random() * 4) + 1); if (invest > 1) { var returnType = Math.floor((Math.random() * 4) + 1); var returnAmount = Math.floor((Math.random() * 5) + 1); if (returnType == 1) { lay = lay + returnAmount; var returnFinal = " Cement Layers"; } else if (returnType == 2) { mix = mix + returnAmount; var returnFinal = " Cement Mixers"; } else if (returnType == 3) { roll = roll + returnAmount; var returnFinal = " Steamrollers"; } else if (returnType == 4) { belt = belt + returnAmount; var returnFinal = " Conveyer Belts"; } document.getElementById("tinyCount").innerHTML = "<p style='color:green'>This investment has returned " + returnAmount + " " + returnFinal + "</p>"; } else if (invest == 1) { var lossType = Math.floor((Math.random() * 2) + 1); var lossAmount = Math.floor((Math.random() * 5) + 1); if (lossType == 1) { roll = roll - lossAmount; var returnFinal = " Cement Rollers"; var lossAmountSpecial = lossAmount; } else if (lossType == 2) { cementCount = cementCount - (lossAmount * 25000); var returnFinal = " Cementz"; var lossAmountSpecial = lossAmount * 25000; } document.getElementById("tinyCount").innerHTML = "<p style='color:red'>This investment has lost " + lossAmountSpecial + " " + returnFinal + "</p>"; } } } function buyMed() { if (cementCount > 999999) { var invest = Math.floor((Math.random() * 4) + 1); if (invest > 1) { var returnType = Math.floor((Math.random() * 4) + 1); var returnAmount = Math.floor((Math.random() * 15) + 1); if (returnType == 1) { lay = lay + returnAmount; var returnFinal = " Cement Layers"; } else if (returnType == 2) { mix = mix + returnAmount; var returnFinal = " Cement Mixers"; } else if (returnType == 3) { roll = roll + returnAmount; var returnFinal = " Steamrollers"; } else if (returnType == 4) { belt = belt + returnAmount; var returnFinal = " Conveyer Belts"; } document.getElementById("medCount").innerHTML = "<p style='color:green'>This investment has returned " + returnAmount + " " + returnFinal + "</p>"; } else if (invest == 1) { var lossType = Math.floor((Math.random() * 2) + 1); var lossAmount = Math.floor((Math.random() * 10) + 1); if (lossType == 1) { roll = roll - lossAmount; var returnFinal = " Cement Rollers"; var lossAmountSpecial = lossAmount; } else if (lossType == 2) { cementCount = cementCount - (lossAmount * 25000); var returnFinal = " Cementz"; var lossAmountSpecial = lossAmount * 25000; } document.getElementById("medCount").innerHTML = "<p style='color:red'>This investment has lost " + lossAmountSpecial + " " + returnFinal + "</p>"; } } } function buyBig() { if (cementCount > 4999999) { var invest = Math.floor((Math.random() * 4) + 1); if (invest > 1) { var returnType = Math.floor((Math.random() * 4) + 1); var returnAmount = Math.floor((Math.random() * 35) + 1); if (returnType == 1) { lay = lay + returnAmount; var returnFinal = " Cement Layers"; } else if (returnType == 2) { mix = mix + returnAmount; var returnFinal = " Cement Mixers"; } else if (returnType == 3) { roll = roll + returnAmount; var returnFinal = " Steamrollers"; } else if (returnType == 4) { belt = belt + returnAmount; var returnFinal = " Conveyer Belts"; } document.getElementById("bigCount").innerHTML = "<p style='color:green'>This investment has returned " + returnAmount + " " + returnFinal + "</p>"; } else if (invest == 1) { var lossType = Math.floor((Math.random() * 2) + 1); var lossAmount = Math.floor((Math.random() * 15) + 1); if (lossType == 1) { roll = roll - lossAmount; var returnFinal = " Cement Rollers"; var lossAmountSpecial = lossAmount; } else if (lossType == 2) { cementCount = cementCount - (lossAmount * 25000); var returnFinal = " Cementz"; var lossAmountSpecial = lossAmount * 25000; } document.getElementById("bigCount").innerHTML = "<p style='color:red'>This investment has lost " + lossAmountSpecial + " " + returnFinal + "</p>"; } } } function buyForm() { if (cementCount > (formCost - 1)) { cementCount = cementCount - 500; form = form + 1; } } function buyMold() { if (cementCount > (moldCost - 1)) { cementCount = cementCount - 1200; mold = mold + 1; } } function buySet() { if (cementCount > (setCost - 1)) { cementCount = cementCount - 3500; set = set + 1; } } setInterval(updateLay, 1000); setInterval(updateMix, 18); //Standard: 20 setInterval(updateRoll, 8); //Standard: 10 setInterval(updateBelt, 0.3); //Standard 0.4 setInterval(updateAll, 10); setInterval(updateStock, 10000); function updateLay() { cementCount = cementCount + (1 * lay); liveCount = liveCount + (1 * lay); } function updateMix() { cementCount = cementCount + (1 * mix); liveCount = liveCount + (1 * mix); } function updateRoll() { cementCount = cementCount + (1 * roll); liveCount = liveCount + (1 * roll); } function updateBelt() { cementCount = cementCount + (1 * belt); liveCount = liveCount + (1 * belt); } function updateAll() { document.getElementById("counter").innerHTML = cementCount + " Cementz<br>" + ((lay * 1) + (mix * 50) + (roll * 100) + (belt * 2500)); document.getElementById("layCount").innerHTML = "You Have " + lay + " Cement Layers"; document.getElementById("lay").innerHTML = "Buy Cement Layer [" + layCost + " Cementz]"; layCost = Math.floor(100 * (lay * 0.15 + 1)); document.getElementById("mixCount").innerHTML = "You Have " + mix + " Cement Mixers"; document.getElementById("mix").innerHTML = "Buy Cement Mixer [" + mixCost + " Cementz]"; mixCost = Math.floor(5000 * (mix * 0.15 + 1)); document.getElementById("rollCount").innerHTML = "You Have " + roll + " Steamrollers"; document.getElementById("roll").innerHTML = "Buy Steamroller [" + rollCost + " Cementz]"; rollCost = Math.floor(10000 * (roll * 0.15 + 1)); document.getElementById("beltCount").innerHTML = "You Have " + belt + " Conveyer Belts"; document.getElementById("belt").innerHTML = "Buy Conveyer Belt [" + beltCost + " Cementz]"; beltCost = Math.floor(250000 * (belt * 0.15 + 1)); document.getElementById("formCount").innerHTML = "You Have " + form + " Cement Forms"; document.getElementById("form").innerHTML = "Buy Cement Form [" + formCost + " Cementz]"; formCost = Math.floor(500 * (form * 0.15 + 1)); document.getElementById("moldCount").innerHTML = "You Have " + mold + " Cement Molds"; document.getElementById("mold").innerHTML = "Buy Cement Mold [" + moldCost + " Cementz]"; moldCost = Math.floor(1200 * (mold * 0.15 + 1)); document.getElementById("setCount").innerHTML = "You Have " + set + " Cement Sets"; document.getElementById("set").innerHTML = "Buy Cement Sets [" + setCost + " Cementz]"; setCost = Math.floor(3500 * (set * 0.15 + 1)); achievement(); } function achievement() { if (liveCount > 999999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 1000000 cement bricks!'>The Colin Award</div>"; } else if (liveCount > 499999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 500000 cement bricks!'>Lets start investing!</div>"; } else if (liveCount > 199999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 200000 cement bricks!'>Your Cement Brick Design Is Envied By Ryan & Gavin</div>"; } else if (liveCount > 99999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 100000 cement bricks!'>Your Cement Brick Design Is Envied By Austin</div>"; } else if (liveCount > 49999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 50000 cement bricks!'>5 * 10000!</div>"; } else if (liveCount > 19999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 20000 cement bricks!'>Let's Get A Warehouse!</div>"; } else if (liveCount > 14999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 15000 cement bricks!'>Better Then Brikz</div>"; } else if (liveCount > 9999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 10000 cement bricks!'>Let's Get An Office</div>"; } else if (liveCount > 8999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 9000 cement bricks!'>Over 9000!</div>"; } else if (liveCount > 4999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 5000 cement bricks!'>Small Business</div>"; } else if (liveCount > 999) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 1000 cement bricks!'>1000 Is Pretty Nice</div>"; } else if (liveCount > 499) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 500 cement bricks!'>Moving Out Of The Garage</div>"; } else if (liveCount > 99) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 100 cement bricks!'>One Hundred Is Pro</div>"; } else if (liveCount > 49) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You have 50 cement bricks!'>Noob Cementer</div>"; } else if (liveCount > 0) { document.getElementById("box").innerHTML = "Achievement Get: <div title='You made your first cement brick!'>Let's Do This</div>"; } } function updateStock() { var stockTinyType = Math.floor((Math.random() * 4) + 1); var stockTinyAmount = Math.floor((Math.random() * 5) + 1); var stockMedType = Math.floor((Math.random() * 4) + 1); var stockMedAmount = Math.floor((Math.random() * 10) + 1); var stockBigType = Math.floor((Math.random() * 4) + 1); var stockBigAmount = Math.floor((Math.random() * 25) + 1); var string = ""; var string2 = ""; var string3 = ""; if (stockTinyType == 1) { string = "<b style='color:red'>^SML -" + stockTinyAmount + "</b>st2st3"; } else if (stockTinyType > 1) { string = "<b style='color:green'>^SML " + stockTinyAmount + "</b>st2st3"; } if (stockMedType == 1) { string2 = "<b style='color:red'>^MED -" + stockMedAmount + "</b>"; } else if (stockMedType > 1) { string2 = "<b style='color:green'>^MED " + stockMedAmount + "</b>"; } if (stockBigType == 1) { string3 = "<b style='color:red'>^BIG -" + stockTinyAmount + "</b>"; } else if (stockBigType > 1) { string3 = "<b style='color:green'>^BIG " + stockTinyAmount + "</b>"; } var output = string.replace("st2", string2); output = output.replace("st3", string3); document.getElementById("stock").innerHTML = output; } document.getElementById("beltCount").addEventListener("click", ee); function ee() { if (cementCount == 2) { cementCount = cementCount + 1000000000000; liveCount = liveCount + 1000000000000; } } //(C) Ethan Coe 2016
#counter, #lay, #layCount, #mix, #mixCount, #roll, #rollCount, #belt, #beltCount, #tiny, #tinyCount, #med, #medCount, #form, #formCount, #mold, #moldCount, #big, #bigCount, #stock, #set, #setCount { text-align: center } #shop { width: 300px; border: 10px solid #696969; padding: 5px; margin: 25px; margin: auto; background-color: #aeaeae; opacity: 0.9; } #selector { border: 10px solid #696969; padding: 5px; margin: 25px; } #counter, #box { text-align: center; width: 350px; border: 10px solid #696969; padding: 5px; margin: 25px; color: white; position: fixed; top: 2%; right: 2%; position: fixed; } #counter { left: 0; } #box { right: 0; display: block; margin-left: auto; margin-right: auto; } #selector { display: block; margin-left: auto; margin-right: auto } body { background-image: url("http://www.michaelmolloy.co.uk/construction-photography/photographs/intro/large/construction-site.jpg"); background-color: #cccccc; } body { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } .change:hover { color: white; transition: 0.4s; } .change, #selector { cursor: pointer; } /*(C) Ethan Coe 2016*/
<img src="http://www.masonrydepotny.com/wp-content/uploads/2013/05/cocncrete-brick.jpg" alt="Image Missing" height="70" width="70" id="selector"> <div id="shop"> <p></p> <p id="lay" class="change">Buy Cement Layer [100 Cementz]</p> <p id="layCount">You Have 0 Cement Layers</p> <p id="mix" class="change">Buy Cement Mixer [5000 Cementz]</p> <p id="mixCount">You Have 0 Cement Mixers</p> <p id="roll" class="change">Buy Steamroller [10000]</p> <p id="rollCount">You Have 0 Steamrollers</p> <p id="belt" class="change">Buy Conveyer Belt [250000]</p> <p id="beltCount">You Have 0 Conveyer Belts</p> <hr> <p id="tiny" class="change">Buy Small Stock Investment [500000]</p> <p id="tinyCount">This Investment Hasn't Been Performed Yet</p> <p id="med" class="change">Buy Medium Stock Investment [1000000]</p> <p id="medCount">This Investment Hasn't Been Performed Yet</p> <p id="big" class="change">Buy Large Stock Investment [5000000]</p> <p id="bigCount">This Investment Hasn't Been Performed Yet</p> <P id="stock">Generating Stock Market</p> <hr> <p id="form" class="change">Buy Cement Form [500]</p> <p id="formCount">You have 0 Cement Forms</p> <p id="mold" class="change">Buy Cement Mold [1200]</p> <p id="moldCount">You have 0 Cement Molds</p> <p id="set" class="change">Buy Cement Set [3500]</p> <p id="setCount">You have 0 Cement Sets</p> </div> <div id="counter">0 Cementz <br>0 Cementz per Second <br>0 Cementz per Click</div> <p id="box">Welcome to Cementz</p> <!-(C) Ethan Coe 2016->
Advertisement
Answer
just remove this line:
document.getElementById("update").addEventListener("click", update);
Or create the update element