Purpose of the code shown is to add by time some reminder. the cases are for different days of the week and in that days specific times.
Strange thing some statements are working most not, but i dont see what breaks the code:
function refreshTime() {
var now = getTime();
$('#date').html(now.day + ', ' + now.date + '. ' + now.month);
$('#time').html("<span class='hour'>" + now.hour + "</span>" + "<span class='minute'>" + now.minute + "</span>" + "<span class='second'>" + now.second + "</span>");
if (now.day != "Sonntag" && now.day != "Samstag")
{
if (now.hour == "9" && now.minute >= "50")
{
var left = "60" - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
if (now.hour == '11' && now.minute >= '50')
{
var left = '60' - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
if (now.hour == '14' && now.minute >= '50')
{
var left = '60' - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
if (now.hour == "17" && now.minute >= "50")
{
var left = "60" - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
else
{
$('#gh').html("");
}
}
if (now.day == "Samstag")
{
if (now.hour == "9" && now.minute >= "50")
{
var left = "60" - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
if (now.hour == "12" && now.minute >= "50")
{
var left = "60" - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
if (now.hour == "13" && now.minute >= "50")
{
var left = "60" - now.minute;
$('#gh').html("<span class='gh_remind'>Grosshandel einstellen in " + left + " Minuten!</span>");
}
else
{
$('#gh').html("");
}
}
}
Thanks for your help!
Consider this:
Even though you (probably) expect
bto store'right'value in the end of thatifstructure, it – surprise, surprise! – will containFOOBARinstead. The reason is that if all yourifs are written like this, they’re independent of each other. The first one will assign'right'string tobvariable – but the second one, going throughelsebranch, will happily reassign it (to some foobar).If you want to create a chain of
ifs, useif - else if - elsesyntax instead:Now that will show you the
rightthing, right? )