code

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.3 kB
2
Indexable
Never
    if (sessionStorage.getItem("fromId") == null || sessionStorage.getItem("toId") == null ||
        sessionStorage.getItem("from") == null || sessionStorage.getItem("to") == null ||
        sessionStorage.getItem("date") == null || sessionStorage.getItem("routeId") == null ||
        sessionStorage.getItem("price") == null || sessionStorage.getItem("places") == null ||
        sessionStorage.getItem("leaveTime") == null) {
        window.location.href = "/routes";
    }

    let price = parseFloat(sessionStorage.getItem("price"));
    $("span.price-normal").text(price + " лв.");
//    let places = parseInt(sessionStorage.getItem("places"));
    let places = 96;
    let freePlaces = places;

    let incompleteCells = [];
    let middleRow = 2;
    let rows = Math.ceil(places / 6);

//    if (((places - 16) % 6) == 0) {
//        rows++;
//        let middleRow1 = Math.floor(rows / 2);
//        let middleRow2 = Math.ceil(rows / 2);
//        incompleteCells.push((middleRow1 * 5) - 1);
//        incompleteCells.push((middleRow2 * 5) - 1);
//        incompleteCells.push((middleRow1 * 5) - 2);
//        incompleteCells.push((middleRow2 * 5) - 2);
//    }
//    else {
//        let middleRow = rows / 2;
//        incompleteCells.push((middleRow * 5) - 1);
//        incompleteCells.push((middleRow * 5) - 2);
//    }

    let row;
    for (let place = 1; place <= (places - 6); place++) {
        if (place % 7 == 0) {
            row = $("<tr />");
            $("table#seats").append(row);
        }

        let td = $("<td />");
//        if (!(cell == 0 || (cell % 5 == 2) || (incompleteCells.includes(cell)))) {
        if (place % 5 != 0 && place % 6 != 0) {
            $(td).html("<span class='seat-cell seat-cell-free' data-id='" + place + "' data-type='lseat' title='" + place + "'></span>");
        }

        $(row).append(td);
//        if (cell % 5 == 4) {
//            $("table#seats").append(row);
//        }
    }

//    row = $("<tr />");
//    for (; place <= places; place++) {
//        let td = $("<td />");
//        $(td).html("<span class='seat-cell seat-cell-free' data-id='" + place + "' data-type='lseat' title='" + place + "'></span>");
//        $(row).append(td);
//    }
//    $("table#seats").append(row);