"use strict";
var red_id = document.getElementsByClassName("btn btn-danger btn-lg btn-block betButton")[0];
var green_id = document.getElementsByClassName("btn btn-success btn-lg btn-block betButton")[0];
var black_id = document.getElementsByClassName("btn btn-inverse btn-lg btn-block betButton")[0];
document.getElementById('betAmount').value = 'NaN';
red_id.id = 'red';
green_id.id = 'green';
black_id.id = 'black';
setInterval(automated, 40000);
function automated() {
var roll_history = $('#past')[0].childNodes[9].textContent;
var roll_hisLast = $('#past')[0].childNodes[8].textContent;
var red_button = document.getElementById('red');
var black_button = document.getElementById('black');
var base_bet = 1;
function thisRoll(roll_history) {
var this_roll;
if (roll_history === 0) {
this_roll = 'green';
} else if ((roll_history >= 1) && (roll_history <= 7)) {
this_roll = 'red';
} else if ((roll_history >= 8) && (roll_history <= 14)) {
this_roll = 'black';
}
return this_roll;
}
var thisRoll = thisRoll(roll_history);
console.log(thisRoll);
function LastRoll(roll_hisLast) {
var last_roll;
if (roll_hisLast === 0) {
last_roll = 'green';
} else if ((roll_hisLast >= 1) && (roll_hisLast <= 7)) {
last_roll = 'red';
} else if ((roll_hisLast >= 8) && (roll_hisLast <= 14)) {
last_roll = 'black';
}
return last_roll;
}
var lastRoll = LastRoll(roll_hisLast);
console.log(LastRoll);
function compare(thisRoll, lastRoll) {
var win_lose;
if (thisRoll !== lastRoll) {
win_lose = 'lose';
} else {
win_lose = 'win';
}
return win_lose;
}
var winLose = compare(thisRoll, lastRoll);
console.log(winLose);
var input_last = document.getElementById('betAmount').value;
function betInputLast(input_last) {
var last;
last = input_last;
return last;
}
var lastXX = betInputLast(input_last);
console.log(lastXX);
function betInputLastX(lastXX) {
var fix_X;
if (isNaN(lastXX)) {
fix_X = base_bet;
}
return fix_X;
}
var lastX = betInputLastX(X);
console.log(lastX);
function betInput(winLose) {
var x;
if (winLose === 'win') {
x = base_bet;
} else if (winLose === 'lose') {
x = lastX * 2;
}
return x;
}
var X = betInput(winLose);
console.log(X);
var bet_input = document.getElementById('betAmount').value = X;
function bet(thisRoll, X) {
var log;
if (thisRoll === 'red') {
red_button.click();
log = 'Betting ' + X + ' on red';
} else if (thisRoll === 'black') {
black_button.click();
log = 'Betiing ' + X + ' on black';
}
return log;
}
var Log = bet(thisRoll, X);
console.log(Log);
}
<div class="roulette"><div class="well text-center" style="margin-bottom:10px;margin-top:25px; padding: 20px;">
<div class="progress text-center" style="height:50px;margin-bottom:10px;">
<span id="banner">Rolling in 24.93...</span>
<div class="progress-bar progress-bar-danger" id="counter" style="width: 83.1432%; overflow: hidden;"></div>
</div>
<div id="case" style="margin-bottom: 15px; background-position: -208px 0px;">
<div id="pointer"></div>
</div>
<div id="past">
<div data-rollid="696912" class="ball ball-0">0</div>
<div data-rollid="696913" class="ball ball-8">9</div>
<div data-rollid="696914" class="ball ball-1">5</div>
<div data-rollid="696915" class="ball ball-1">3</div>
<div data-rollid="696916" class="ball ball-1">6</div>
<div data-rollid="696917" class="ball ball-8">14</div>
<div data-rollid="696918" class="ball ball-1">3</div>
<div data-rollid="696919" class="ball ball-8">11</div>
<div data-rollid="696920" class="ball ball-8">10</div>
<div data-rollid="696921" class="ball ball-0">0</div>
</div>
<div style="margin: 20px 0px;">
</div>
<div class="form-group">
<div class="input-btn bet-buttons">
<span class="balance">
<span>Balance: </span>
<span id="dongers_r"></span>
<span id="balance_r" class="">15020</span> <i style="cursor:pointer; margin-left: 5px;" class="fa fa-refresh noselect" id="getbal_r"></i>
</span>
<input type="text" class="form-control input-lg" placeholder="Bet amount..." id="betAmount">
<button type="button" class="btn btn-danger betshort" data-action="clear">Clear</button>
<button type="button" class="btn btn-default betshort" data-action="10">+10</button>
<button type="button" class="btn btn-default betshort" data-action="100">+100</button>
<button type="button" class="btn btn-default betshort" data-action="1000">+1000</button>
<button type="button" class="btn btn-default betshort" data-action="half">1/2</button>
<button type="button" class="btn btn-default betshort" data-action="double">x2</button>
<button type="button" class="btn btn-primary betshort" data-action="max">Max</button>
</div>
</div>
</div>
<div class="row text-center">
<div class="col-xs-4 betBlock" style="padding-right:0px">
<div class="panel panel-default bet-panel" id="panel11-7-b">
<div class="panel-heading">
<button class="btn btn-danger btn-lg btn-block betButton" data-lower="1" data-upper="7"><span> 1 to 7</span><span></span></button>
</div>
</div>
<div class="panel panel-default bet-panel" id="panel1-7-m">
<div class="panel-body" style="padding:0px">
<div class="my-row">
<div class="text-center"><span class="mytotal">0</span></div>
</div>
</div>
</div>
<div class="panel panel-default bet-panel" id="panel1-7-t">
<div class="panel-body" style="padding:0px">
<div class="total-row">
<div class="text-center">Total bet: <span class="total">24485</span></div>
</div>
</div>
</div>
</div>
<div class="col-xs-4 betBlock">
<div class="panel panel-default bet-panel" id="panel0-0-b">
<div class="panel-heading">
<button class="btn btn-success btn-lg btn-block betButton" data-lower="0" data-upper="0">0</button>
</div>
</div>
<div class="panel panel-default bet-panel" id="panel0-0-m">
<div class="panel-body" style="padding:0px">
<div class="my-row">
<div class="text-center"><span class="mytotal">0</span></div>
</div>
</div>
</div>
<div class="panel panel-default bet-panel" id="panel0-0-t">
<div class="panel-body" style="padding:0px">
<div class="total-row">
<div class="text-center">Total bet: <span class="total">13780</span></div>
</div>
</div>
</div>
</div>
<div class="col-xs-4 betBlock" style="padding-left:0px">
<div class="panel panel-default bet-panel" id="panel8-14-b">
<div class="panel-heading">
<button class="btn btn-inverse btn-lg btn-block betButton" data-lower="8" data-upper="14"><span> 8 to 14</span><span></span></button>
</div>
</div>
<div class="panel panel-default bet-panel" id="panel8-14-m">
<div class="panel-body" style="padding:0px">
<div class="my-row">
<div class="text-center"><span class="mytotal">0</span></div>
</div>
</div>
</div>
<div class="panel panel-default bet-panel" id="panel8-14-t">
<div class="panel-body" style="padding:0px">
<div class="total-row">
<div class="text-center">Total bet: <span class="total">6572</span></div>
</div>
</div>
</div>
</div>
</div></div>
The function that dosen't work is function betInput(winLose) that have to multiply with 2 if winLose = 'lose' it happens first time but after that the output is only 2, were it should be multiplyed with 2.
I know this is peace of cake but i can't seem to figure it out.
Uncaught TypeError.betAmountbetInputLastXtofunction betInputLastX(lastXX) { var fix_X; if (isNaN(lastXX)) { fix_X = base_bet; } else { fix_X = lastXX; } return fix_X; } var lastX = betInputLastX(X); console.log(lastX);it will work?