Commit c81a2aab authored by BuildTools's avatar BuildTools
Browse files

fixed under and over selection bug

parent 9ec64c00
......@@ -34,6 +34,8 @@
</table>
<h2>Alte Einträge Löschen</h2>
<button>Löschen</button>
<button>Löschen</button><br><br>
<a href="/index.php"><h3>Zurück zur Anmeldeseite</h3></a>
</body>
......@@ -78,6 +78,7 @@ function drawTableUsage(ctx, tablenr, openTime, closeTime, reservations) {
var offsetY = 30 + (tablenr - 1) * graphHeight;
var sections = (closeTime[0] - openTime[0]) * 2 + (closeTime[1] - openTime[1]) / 30;
reservationData["sections"] = sections;
if (ctx.canvas.width < sections * 25 + 30) {
ctx.canvas.width = sections * 25 + 30;
}
......@@ -141,7 +142,7 @@ function initCanvasClickListener() {
return;
}
var section = getSectionFromLocation(x, 10, 25);
if (tablenr == -1) {
if (section < 1 || section > reservationData["sections"]) {
return;
}
......@@ -163,13 +164,24 @@ function initCanvasClickListener() {
});
}
function getTableFromLocation(y, offset, graphHeight) {
var tablenr = (y + offset) / graphHeight;
if (Math.abs(tablenr - Math.round(tablenr)) < 0.25) {
return Math.round(tablenr);
}
return -1;
}
function getSectionFromLocation(x, offset, sectionWidth) {
return Math.ceil((x - offset) / sectionWidth);
}
function selectStart(tablenr, section, openTime, closeTime) {
select.table = tablenr;
select.startH = parseInt(openTime[0]) + Math.floor((section - 1)/2);
select.startM = parseInt(openTime[1]) + ((section - 1) % 2) * 30;
if (typeof reservationData.reservations["T" + select.table] !== "undefined") {
console.log("T" + select.table);
for (var i = 0; i < reservationData.reservations["T" + select.table].length; i++) {
var res = reservationData.reservations["T" + select.table][i];
var start = res.start.split(":");
......@@ -214,18 +226,6 @@ function selectEnd(tablenr, section, openTime, closeTime) {
}
}
function getTableFromLocation(y, offset, graphHeight) {
var tablenr = (y + offset) / graphHeight;
if (Math.abs(tablenr - Math.round(tablenr)) < 0.25) {
return Math.round(tablenr);
}
return -1;
}
function getSectionFromLocation(x, offset, sectionWidth) {
return Math.ceil((x - offset) / sectionWidth);
}
function validateReservation() {
if (document.getElementById("Vname").value == "") {
alert("Vorname muss ausgefüllt sein!");
......
......@@ -13,6 +13,10 @@ button {
width: 40%;
}
select {
margin-top: 5px;
}
#datetime {
width: 50%;
margin-left: 0px;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment