Click here to Skip to main content
15,881,172 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionRe: How can I get an input value from ajax result search Pin
ZurdoDev4-Mar-20 5:12
professionalZurdoDev4-Mar-20 5:12 
AnswerRe: How can I get an input value from ajax result search Pin
vlafratta5-Mar-20 3:39
vlafratta5-Mar-20 3:39 
GeneralRe: How can I get an input value from ajax result search Pin
ZurdoDev5-Mar-20 3:50
professionalZurdoDev5-Mar-20 3:50 
GeneralRe: How can I get an input value from ajax result search Pin
vlafratta5-Mar-20 4:54
vlafratta5-Mar-20 4:54 
AnswerRe: How can I get an input value from ajax result search Pin
ZurdoDev5-Mar-20 5:10
professionalZurdoDev5-Mar-20 5:10 
GeneralRe: How can I get an input value from ajax result search Pin
vlafratta16-Mar-20 1:41
vlafratta16-Mar-20 1:41 
SuggestionRe: How can I get an input value from ajax result search Pin
Richard Deeming6-Apr-20 1:30
mveRichard Deeming6-Apr-20 1:30 
QuestionFunction showMessage not available Pin
vinnie moag28-Feb-20 15:04
vinnie moag28-Feb-20 15:04 
AnswerRe: Function showMessage not available Pin
Richard MacCutchan28-Feb-20 22:45
mveRichard MacCutchan28-Feb-20 22:45 
Questiondrawing A Random Bezier Curve 10 times then reset Pin
LarsAlaska28-Feb-20 11:21
LarsAlaska28-Feb-20 11:21 
AnswerRe: drawing A Random Bezier Curve 10 times then reset Pin
Graham Breach28-Feb-20 19:54
Graham Breach28-Feb-20 19:54 
QuestionThere is some problem in my code I could not get the bus seat layout seats. Please help me Pin
Member 1465358023-Feb-20 22:45
Member 1465358023-Feb-20 22:45 
function generateLayout(seats, zIndex) {
    var busLayoutHtmlTmpl = '';
    var maxNoOfColumns = 0;
    var missingPathWayRowNO = -1;
    var missingPathWayRowNOTmp = 0;
    var isfirtRow = 0;
    var isDriverSeat = true;
    var rowSeatValues = [];
    var columnSeatValues = [];
    _.each(seats, function (columnSeats, rowIndex) {
        if (isfirtRow == 0) {
            missingPathWayRowNOTmp = rowIndex;
            isfirtRow = 1;
        } else {
            if (parseInt(missingPathWayRowNOTmp) + 1 != rowIndex) {
                missingPathWayRowNO = parseInt(missingPathWayRowNOTmp) + 1;
            } else {
                missingPathWayRowNOTmp = parseInt(missingPathWayRowNOTmp) + 1;
                maxNoOfColumns = columnSeats.length > maxNoOfColumns ? columnSeats.length : maxNoOfColumns;
            }
        }

    });
    var v = [];
    _.each(zIndex, function (seats, t) {
        $.inArray(seats, v) === -1 && v.push(seats)
    }),
        _.each(seats, function (columnSeats, rowIndex) {
            _.each(columnSeats, function (seat, columnIndex) {
                if ($.inArray(seat.x, rowSeatValues) === -1) {
                    rowSeatValues.push(seat.y);
                }
                if ($.inArray(seat.y, columnSeatValues) === -1) {
                    columnSeatValues.push(seat.y);
                }
            });
        });
    var seatLayOutMax= new Array();
    var count = 0;
    _.each(rowSeatValues, function (row, columnIndex) {
        seatLayOutMax[row] = new Array();
        _.each(columnSeatValues, function (seat, columnIndex) {
            seatLayOutMax[row][seat] = "";
        });
    });
    _.each(seats, function (columnSeats, rowIndex) {
        _.each(columnSeats, function (seat, columnIndex) {
            seatLayOutMax[seat.x][seat.y] = seat
        });
    });
    var pathComparision = 0; var enterInRowsCount = 0;
    _.each(seatLayOutMax, function (seats, index) {
        busLayoutHtmlTmpl += '<tr>';
     
      
        _.each(seats, function (col, ind) {
            var seat = col;
            if (seat == undefined) { return; }
            pathComparision = seat.x;
            if (seat != "") {
                var l = seat.height;
                var w = seat.width;
                if (l == 1 && w == 1) {
                    busLayoutHtmlTmpl += '<td  title="Seat : ' + seat.id + 'style="width:8%; padding:2px;"><div id="div' + seat.seat_no + "_" + '</div></td>';
                } else if (l == 1 && w == 2) {
                    busLayoutHtmlTmpl += '<td  title="Seat : ' + seat.id + 'style="width:8%; padding:2px;"><div id="div' + seat.seat_no + "_" + ' </div></td>';
                } else if (l == 2 && w == 1) {
                    if (rowSeatValues.height == 1) {
                        busLayoutHtmlTmpl += '<td  title="Seat : ' + seat.id + 'style="width:8%; padding:2px;" rowspan="2"><div id="div' + seat.seat_no + "_" + '</div></td>';
                    } else {
                        busLayoutHtmlTmpl += '<td  title="Seat : ' + seat.id + 'style="width:8%; padding:2px;"><div id="div' + seat.seat_no + "_" + '</div></td>';
                    }
                }
            } else {
                busLayoutHtmlTmpl += '<td></td>';
            }
        });
      //  busLayoutHtmlTmpl = busLayoutHtmlTmpl.replace('<tr></tr>', '');
        if (seats === undefined && busLayoutHtmlTmpl != "<tr>" && !busLayoutHtmlTmpl.includes('<tr><td><div style="width: 28px; height: 24px; margin-right: 5px;"></div></td><td></td></tr>')) {
            busLayoutHtmlTmpl.replace('<tr></tr>', '');
            busLayoutHtmlTmpl += '<tr><td><div style="width: 28px; height: 24px; margin-right: 5px;"></div></td><td></td></tr>';
        } else {
            busLayoutHtmlTmpl += '</tr>';
        }
    });
   
    return busLayoutHtmlTmpl;
}
function SeatLayout() {
 $.ajax({
    url: "seats.json",
    dataType: "text",
    success: function(data) {

        var json = $.parseJSON(data);
          designCanvas(json);
    }
        });
    

}



function designCanvas(json) {
//if (json.success == false) {
       // alert(json.message);
    //    document.getElementById('btnViewSeat').click();
  //      return;
  //  }
   
    var seatSelected = [];
    var divLower = document.getElementById('tblLowerSeat');
    var divUpper = document.getElementById('tblUpperSeat');
    var lowerSeats = [];
    var upperSeats = [];
if(json.seats.z === 0){
  lowerSeats.push(json.seats);
}
if(json.seats.z === 1){
  upperSeats.push(json.seats);
}
    lowerSeats = lowerSeats.sort(function (a, b) { return b.id - a.id; });
  upperSeats = upperSeats.sort(function (a, b) { return b.id - a.id; });

    var r = [];
    lowerSeats.forEach(function (e) {
        if (r.indexOf(e.x) == -1) { r.push(e.x); }
    });
    var g = new Array(r.length);
    for (var i = 0; i < r.length; i++) {
        g[i] = new Array();
        for (var j = 0; j < lowerSeats.length; j++) {
            if (lowerSeats[j].x == r[i]) {
              g[i].push(lowerSeats[j]);
                
            }
        }
    }

    htmlLower = generateLayout(g, 0);
    divLower.innerHTML = htmlLower;
  //  if (upperSeats.height > 0) {
      //  document.getElementById('divSeatsUpper').style.display = "block";
    //    var rU = [];
    //    upperSeats.forEach(function (e) {
         //   if (rU.indexOf(e.x) == -1) { rU.push(e.x); }
     //   });
    //    var gU = new Array(rU.height);
     //   for (var i = 0; i < rU.length; i++) {
           // gU[i] = new Array();
          //  for (var j = 0; j < upperSeats.length; j++) {
              //  if (upperSeats[j].x == rU[i]) {
           //         gU[i].push(upperSeats[j]);
              //  }
      //      }
    //    }
      //  htmlUpper = generateLayout(gU, 1);
  //      divUpper.innerHTML = htmlUpper;
 //   } else {
     //   document.getElementById('divSeatsUpper').style.display = "none";
 //   }




}

   <button class="btn btn-primary" id="btnViewSeat" onclick="SeatLayout();">
                                    View Seats class="fa fa-arrow-circle-down">
                                </button>
<p id="demo"></p>
<link href="/TPT-2020/Assets/css/seatStyle.css" rel="stylesheet" />
<link href="https://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<link href="/TPT-2020/Assets/css/bootstrap.min.css" rel="stylesheet" />
     <div id="Viewseatcollapse" class="collapse busseatmng" style="display:inherit">
                <div class="col-sm-12 card">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-sm-8">
                                <div class="upperbusdivwrp" id="divSeatsUpper">
                                    <div class="row busseatstructure">
                                        <div class="col-sm-12 bg-dark pd-10 text-white text-center"><h5>Upper Deck</h5></div>
                                        <div class="col-sm-12 busseatsinner">
                                            <div class="row">
                                                <div class="col-sm-12">
                                                    <div class="row">
                                                        <div class="col-sm-1 col-1 driver"></div>
                                                        <div class="col-sm-11 col-11">
                                                            <table id="tblUpperSeat">
                                                               <tbody>
                                                                 
                                                               </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="lowerbusdivwrp">
                                    <div class="row busseatstructure">
                                        <div class="col-sm-12 bg-dark pd-10 text-white text-center"><h5>Lower Deck</h5></div>
                                        <div class="col-sm-12 busseatsinner">
                                            <div class="row">
                                                <div class="col-sm-12">
                                                    <div class="row">
                                                        <div class="col-sm-1 col-1 driver"><img src="/TPT-2020/images/stairing.png"></div>
                                                        <div class="col-sm-11 col-11">
                                                            <table id="tblLowerSeat">
                                                               <tbody>
                                                                  
                                                               </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <script type="text/javascript" src="/TPT-2020/scripts/BindData1.js"></script>
<script type="text/javascript" src="/TPT-2020/scripts/GetDynamicSeats2.js"></script>

SuggestionRe: There is some problem in my code I could not get the bus seat layout seats. Please help me Pin
Richard Deeming23-Feb-20 23:01
mveRichard Deeming23-Feb-20 23:01 
QuestionHow does this work in Javascript? Pin
Nand3210-Feb-20 23:25
Nand3210-Feb-20 23:25 
AnswerRe: How does this work in Javascript? Pin
Richard Deeming11-Feb-20 1:09
mveRichard Deeming11-Feb-20 1:09 
GeneralRe: How does this work in Javascript? Pin
Nand3211-Feb-20 1:27
Nand3211-Feb-20 1:27 
QuestionValidate if my drop location is not empty using JS(HTML DnD API) Pin
Member 147327851-Feb-20 20:04
Member 147327851-Feb-20 20:04 
SuggestionRe: Validate if my drop location is not empty using JS(HTML DnD API) Pin
Richard MacCutchan1-Feb-20 21:33
mveRichard MacCutchan1-Feb-20 21:33 
GeneralRe: Validate if my drop location is not empty using JS(HTML DnD API) Pin
Member 147327851-Feb-20 22:41
Member 147327851-Feb-20 22:41 
AnswerRe: Validate if my drop location is not empty using JS(HTML DnD API) Pin
Richard Deeming3-Feb-20 0:53
mveRichard Deeming3-Feb-20 0:53 
GeneralRe: Validate if my drop location is not empty using JS(HTML DnD API) Pin
Nathan Minier3-Feb-20 1:10
professionalNathan Minier3-Feb-20 1:10 
AnswerRe: Validate if my drop location is not empty using JS(HTML DnD API) Pin
ZurdoDev3-Feb-20 2:20
professionalZurdoDev3-Feb-20 2:20 
AnswerRe: Validate if my drop location is not empty using JS(HTML DnD API) Pin
jkirkerx5-Feb-20 12:40
professionaljkirkerx5-Feb-20 12:40 
QuestionPls help!javascript Noobie, Im getting if the average of the array is whole number, why does the method 2 doesn' work? Pin
Member 1472307521-Jan-20 16:36
Member 1472307521-Jan-20 16:36 
AnswerRe: Pls help!javascript Noobie, Im getting if the average of the array is whole number, why does the method 2 doesn' work? Pin
Richard Deeming21-Jan-20 23:52
mveRichard Deeming21-Jan-20 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.