/** * Before calling this method we should have to pass seats array in sorted order. * * In buslayout response seats Object has lower (zindex=0) and upper (zindex =1) we have to call this function upper seats array and lower seats array different calls. */ generateLayout: function(seats, zIndex){ var busLayoutHtmlTmpl = '';// This variable is used for seat layout template var maxNoOfColumns =0; // maximun no of columns out of all available rows; /* * finding path way logic start from here */ var missingPathWayRowNO =-1; var missingPathWayRowNOTmp=0 var isfirtRow=true; var isDriverSeat=true; var rowSeatValues= []; var columnSeatValues= []; _.each(seats,function(columnSeats,rowIndex){ if(isfirtRow) { missingPathWayRowNOTmp=rowIndex; isfirtRow=false; }else { if(parseInt(missingPathWayRowNOTmp)+1!=rowIndex) { missingPathWayRowNO=parseInt(missingPathWayRowNOTmp)+1; }else { missingPathWayRowNOTmp=parseInt(missingPathWayRowNOTmp)+1; } } maxNoOfColumns = columnSeats.length >maxNoOfColumns?columnSeats.length:maxNoOfColumns; }); /* * finding path way logic end from here */ /* * Loop for unique rows and culumn and keeping in array for display we are using this array */ _.each(seats,function(columnSeats,rowIndex){ _.each(columnSeats,function(seat,columnIndex){ if($.inArray(seat.row, rowSeatValues) === -1){ rowSeatValues.push(seat.row); } if($.inArray(seat.column,columnSeatValues) === -1){ columnSeatValues.push(seat.column); } }); }); /* * To display seat layout in the form of matrix for that creating empty matrix with the help of unique rows and columns */ var seatLayOutMax=new Array(); var count = 0; _.each(rowSeatValues,function(row,columnIndex){ seatLayOutMax[row] = new Array() ; _.each(columnSeatValues,function(seat,columnIndex){ seatLayOutMax[row][seat]=""; }); }); /* * Asigning seat object to matrix */ _.each(rowSeats,function(columnSeats,rowIndex){ _.each(columnSeats,function(seat,columnIndex){ seatLayOutMax[seat.row][seat.column] = seat }); }); /* * seat display html logic */ var pathComparision = 0; _.each(seatLayOutMax,function(row,index){ busLayoutHtmlTmpl += '