Reputation: 476
I am new to Meteor and Node.js, there for my problem might just be a banality for those more skilled.
I am writing a script, that should return time in +30 minute in the future, in this format: 11.12.16 20:05
However, if I try to run my function, nothing seems to be happening and I get no errors in console or from server.
This is my html:
<body>
<header>DPPZ</header>
{{> price24}}
{{> price32}}
<div id="newWindow" style="display: none;">
<p id="time"></p>
</div>
</body>
<template name="price24">
<div class="container24">
<button id="container24" onclick="ticket24()">24Kč</button>
<p>(30 minut)</p>
</div>
</template>
<template name="price32">
<div class="container32">
<button id="container32" onclick="ticket32()">32Kč</button>
<p>(90 minut)</p>
</div>
</template>
Here is my JS:
function ticket24(){
document.getElementById("newWindow").style.display = "block";
var d = new Date();
var den = d.getDate();
var mesic = d.getMonth();
var rok = d.getFullYear();
var hodina = d.getUTCHours();
var minuta = d.getUTCMinutes();
switch(mesic){
case(0):
mesic = 1;
case(1):
mesic = 2;
case(2):
mesic = 3;
case(3):
mesic = 4;
case(4):
mesic = 5;
case(5):
mesic = 6;
case(6):
mesic = 7;
case(7):
mesic = 8;
case(8):
mesic = 9;
case(9):
mesic = 10;
case(10):
mesic = 11;
case(11):
mesic = 12;
}
function novaMinuta(hodiny, minuty){
switch(minuta){
case(0):
minuta = "00";
case(1):
minuta = "01";
case(2):
minuta = "02";
case(3):
minuta = "03";
case(4):
minuta = "04";
case(5):
minuta = "05";
case(6):
minuta = "06";
case(7):
minuta = "07";
case(8):
minuta = "08";
case(9):
minuta = "09";
default:
minuta = minuta;
}
if (10 <= Number(minuta) >= 29){
return Number(hodina + 1)+ ":" + Number(minuta) + 30;
}
else if (Number(minuta) == 30){
return Number(hodina + 2) + ":" + "00";
}
else if (Number(minuta) > 30){
return Number(hodina + 2) + ":" + Number(minuta) - 30;
}
}
rok = rok.toString().replace("20", "");
document.getElementById("time").innerHTML = den + "." + mesic + "." + rok +
" " + novaMinuta(hodina, minuta);
document.getElementById("newWindow").style.display = "block";
}
The document.getElementById("newWindow").style.display = "block";
works, but the rest of the code 'prints' nothing.
Upvotes: 1
Views: 43
Reputation: 1878
You forgot the break
for each case
:
switch(mesic){
case(0):
mesic = 1;
break;
case(1):
mesic = 2;
break;
...
Upvotes: 1