function winners() {
updating = true;
if (mm == "Best of 3") {
var wygrany = (s1 == "2")? 'left' : 'right';
return true;
}
if (mm == "Best of 5") {
var wygrany = (s1 == "3")? 'left' : 'right';
return true;
}
if (mm == "Best of 7") {
var wygrany = (s1 == "4")? 'left' : 'right';
return true;
}
return false; }
This is the code that should be deciding if my var wygrany = 'left' or 'right'.
function runUpdate() {
if (timeOld == timeNew) return;
if (winners == true) {
updating = true;
setTimeout(function(){
$('.team.center .name').set('$', '-flipInY +fadeOut');
if(wygrany == "left") {
$('.team.right').set('$', '+animated +fadeOutDown');
$('.team.left').set('$', '+winner_show');
$('#ww').set('$', '-hidden +fadeIn');
$('.bg_winner').set('$', '-hidden +fadeIn');
} else {
$('.team.left').set('$', '+animated +fadeOutUp');
$('.team.right').set('$', '+winner_show');
$('#ww').set('$', '-hidden +fadeIn');
$('.bg_winner').set('$', '-hidden +fadeIn');
}
updating = false;
}, 1000);
}
This is the part responsible for display. Although code is not working, my function winners always returns 'true' and then script stops. It is probably syntax error but i can't find it.
trueifmmis equal toBest of 3,Best of 5orBest of 7. It will returnfalsefor other use cases. Are these the only use cases you have? Were you intending for your variablewygranyto affect the return?if (winner() == true)instead ofif (winner == true)mmbut he's trying access a variable that's not defined globally in it's own scope. Which is numero uno problem.if (winner() == true)orif (winner == true)would work. Though there are slight differences.