You are on page 1of 2

var x = '<div class="row" style="width: 280px;">'+

'<ul style="list-style:none; text-align: center; margin-left:1em;">'+


'<li class="bet_amount_box bold multiplier_header_background
bet_amount_options_margin" style="border: none;width: 74%;padding:4px
5px;">INCREASE BET BY % </li>'+
'<li class="bet_amount_box bold bet_amount_options" style="border:
none;width: 20%;">'+
'<input id="incremento"class="bold bet_amount_value_input
common_background_border" type="text" name="stake" id="double_your_btc_stake"
value="0" style="height: 20px;margin: 0;width: 100%!important;border: none!
important;padding: 1px 0;">'+
'</li>'+
'</ul>'+
'<ul style="list-style:none;text-align: center;margin-left:1em;margin-
bottom: 65px;">'+
'<li class="bet_amount_box bold bet_amount_options
bet_amount_options_margin" style="color: #483704;background: #ecb108;border:
none;width: 80px;">'+
'<a href="javascript:void(0);" id="hi_incremento" style="display:
block;color: inherit;">BET HI</a>'+
'</li>'+
'<li class="bet_amount_box bold bet_amount_options
bet_amount_options_margin" style="color: #483704;background: #ecb108;border:
none;width: 80px;">'+
'<a href="javascript:void(0);" id="lo_incremento" style="display:
block;color: inherit;">BET LO</a>'+
'</li>'+
'<li class="bet_amount_box bold bet_amount_options
bet_amount_options_margin" style="color: #ffffff;background: #FF5722;border:
none;width: 88px;">'+
'<a href="javascript:void(0);" id="reset_incremento"
style="display: block;color: inherit;">RESET</a>'+
'</li>'+
'</ul>'+
'<div id="mensaje_incremento" style="display:none;margin-left: 2px;width:
250px;clear: both;font-size: 13px;background: #E53935;padding: 4px 0;font-weight:
700;color: #EEEEEE;border-radius: 2px;">'+
'<span style="width: 100%;">El numero tiene que estar entre 1 y
100</span>'+
'</div>'+
'</div>';
var fibonacci = document.createElement('div');
fibonacci.setAttribute("id","fibonacci");
fibonacci.innerHTML = x;
var padre = document.querySelector("#double_your_btc_stake").parentNode;
padre.appendChild(fibonacci);
var elementCount = document.querySelector('#count');
var inputStake = document.querySelector("#double_your_btc_stake");
var inputIncremento = document.querySelector("#incremento");
var elementHiInc = document.querySelector("#hi_incremento");
var elementLoInc = document.querySelector("#lo_incremento");
var elementResetInc = document.querySelector("#reset_incremento");
var elementMensajeInc = document.querySelector("#mensaje_incremento");
var botonHi = document.querySelector("#double_your_btc_bet_hi_button");
var botonLo = document.querySelector("#double_your_btc_bet_lo_button");
var ant;
var cont = 1;

elementHiInc.addEventListener("click",function(){
if(verificarPorcentaje()){
agregarIncremento();
console.log("Click en HI");
botonHi.click();
}
});
elementLoInc.addEventListener("click",function(){
if(verificarPorcentaje()){
agregarIncremento();
console.log("Click en LO");
botonLo.click();
}
});
elementResetInc.addEventListener("click", function(){
console.log("Click en RESET");
inputStake.value = "0.00000001";
ant = undefined;
cont = 1;
});
function incrementar(num,incremento){
if(ant == undefined){
ant = num;
}
let ap = ant + (ant*(incremento/100));
console.log("ant", ant);
console.log("incremento", incremento);
console.log("ap", ap);
ant = ap;
return ap;
}
function agregarIncremento(){
const factor = 100000000;
var num = parseFloat(inputStake.value)*factor;
var incremento = parseFloat(inputIncremento.value);
var fibo = cont == 1 ? 1 : incrementar(num,incremento);
var newStake = new Number(fibo/factor).toFixed(8);
cont++;

inputStake.value = newStake;
}
function verificarPorcentaje(){
let inc = parseInt(inputIncremento.value);
if(inc < 1 || inc > 100 || isNaN(inc) == true){
elementMensajeInc.style.display = 'block';
inputIncremento.value = '0';
return 0;
}else{
elementMensajeInc.style.display = 'none';
return 1;
}
}

You might also like