diff --git a/.env b/.env index 539364a..e91eeb8 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ JWTSECRET = "CSEN603ROCKSi<8SE!" -PORT=80 +PORT=8080 diff --git a/config/api.js b/config/api.js index dbf2232..d98ac92 100644 --- a/config/api.js +++ b/config/api.js @@ -10,11 +10,11 @@ exports.seedDB = function(cb) { mongo.clearDB(function(err) { assert.equal(null, err); mongo.seed('flights', flights, function() { - mongo.seed('bookings', bookings, function() { + // mongo.seed('bookings', bookings, function() { mongo.seed('airports', airports, function() { mongo.close(); }); - }); + // }); }); }); @@ -66,7 +66,7 @@ exports.searchFlights = function(origin, destination, departingDate, cabin, cb) '$regex': departingDate } }).toArray(function(err, flights) { - if (flights[0] == undefined) { + if (flights.length === 0) { cb(err, []); } else { if (economyOrBusiness == "economy") @@ -101,25 +101,9 @@ exports.searchFlights = function(origin, destination, departingDate, cabin, cb) exports.submitPay = function(firstName, lastName, passport, passportNumber, issueDate, expiryDate, email, phoneNumber, bookingRefNumber, flightNumber, businessOrEconomic, cb) { var selectedSeat = 0; - - // console.log(businessOrEconomic); - - - // console.log('i`m in api'); mongo.connect(function(err, db) { - - // db.collection("flights").drop(); - // db.collection("flights").remove({"flightNumber": "MYNKSH3"}); - - // var cursor =db.collection('flights').find( ); - // cursor.each(function(err, doc) { - // if (doc != null) { - // console.dir(doc); - // } - // }); // update after find free seat - var collection = db.collection('flights'); collection.find({ "flightNumber": flightNumber @@ -129,15 +113,8 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu mongo.close(); return; } - - //flights[0].seat[flights[0].nextvf,m] - // console.log(flights[0]); - - // console.log(flights[0].SeatMap[0]); - // flights[0].SeatMap[0] - // remove then insert - if (bookingRefNumber === "true") { // economy + if (businessOrEconomic === "true") { // economy //check on availableESeats of economy if (!(flights[0].availableESeats === 0)) { selectedSeat = flights[0].nextEcoSeat; @@ -155,10 +132,7 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu } // if avaliable dec availableBSeats and inc next Bseat - - } - // // console.log("selectedSeat :"+selectedSeat); flights[0].SeatMap[selectedSeat].bookingRefNumber = bookingRefNumber; @@ -166,7 +140,6 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu db.collection("flights").remove({ "flightNumber": flightNumber }, function(err, records) { - // var collection = db.collection('flights'); var document = { @@ -214,23 +187,8 @@ exports.submitPay = function(firstName, lastName, passport, passportNumber, issu cb(err, true); }); }); - - - // - - }); - - - }); - - - - - - - }); } diff --git a/public/controllers/congratsCtrl.js b/public/controllers/congratsCtrl.js index f178b5c..819fbba 100644 --- a/public/controllers/congratsCtrl.js +++ b/public/controllers/congratsCtrl.js @@ -4,4 +4,6 @@ App.controller('congratsCtrl', function($scope, $location,paymentSrv) { // $location.url('/congrats'); // }; + + } \ No newline at end of file diff --git a/public/controllers/flightsCtrl.js b/public/controllers/flightsCtrl.js index 4ed007b..1400d75 100644 --- a/public/controllers/flightsCtrl.js +++ b/public/controllers/flightsCtrl.js @@ -12,7 +12,7 @@ App.controller('flightsCtrl', function($scope, FlightsSrv, OutReturnSrv, $locati $scope.returnFlightFound = true; $scope.outgoingInfo = []; $scope.returnInfo = []; - + if (FlightsSrv.getPinging().toString() === 'true') if ($scope.roundTrip === 'true') pingAirlineR($scope.origin, $scope.dest, changeISOFormat($scope.oDate), changeISOFormat($scope.rDate)); @@ -36,9 +36,9 @@ App.controller('flightsCtrl', function($scope, FlightsSrv, OutReturnSrv, $locati var outDate = moment(oDate).toDate().getTime(); var jwt = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNWU5LU0giLCJpYXQiOjE0NjA3NzIyOTQsImV4cCI6MTQ5MjMwODI5NSwiYXVkIjoid3d3LnNlY291cnNlLmNvbSIsInN1YiI6Ik1ZTktTSCBJYmVyaWEiLCJUZWFtIjoiTVlOS1NIIn0.hZxhv8XAcu1cARgcrtfb0l_crF1-Ic1tJt9eUhIL0qQ'; $http.get(c.ip + '/api/flights/search/' + origin + '/' + dest + '/' + departDate + '/' + outDate + '/' + tclass + '?wt=' + jwt).success(function(flight) { - if (flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0) + if (flight != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0) $scope.outgoingInfo.push(flight.outgoingFlights[0]); - if (flight.returnFlights[0] != 'undefined' && flight.returnFlights[0].length != 0) + if (flight != 'undefined' && flight.returnFlights[0] != 'undefined' && flight.returnFlights[0] != 'undefined' && flight.returnFlights[0].length != 0) $scope.returnInfo.push(flight.returnFlights[0]); // console.log(flight.outgoingFlights); }); @@ -53,7 +53,7 @@ App.controller('flightsCtrl', function($scope, FlightsSrv, OutReturnSrv, $locati var departDate = moment(oDate).toDate().getTime(); jwt = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNWU5LU0giLCJpYXQiOjE0NjA3NzIyOTQsImV4cCI6MTQ5MjMwODI5NSwiYXVkIjoid3d3LnNlY291cnNlLmNvbSIsInN1YiI6Ik1ZTktTSCBJYmVyaWEiLCJUZWFtIjoiTVlOS1NIIn0.hZxhv8XAcu1cARgcrtfb0l_crF1-Ic1tJt9eUhIL0qQ'; $http.get(c.ip + '/api/flights/search/' + origin + '/' + dest + '/' + departDate + '/' + tclass + '?wt=' + jwt).success(function(flight) { - if (flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0) + if (flight != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0] != 'undefined' && flight.outgoingFlights[0].length != 0) $scope.outgoingInfo.push(flight.outgoingFlights[0]); // console.log(flight.outgoingFlights); }); diff --git a/public/controllers/paymentCtrl.js b/public/controllers/paymentCtrl.js index a68125b..6b8d3de 100644 --- a/public/controllers/paymentCtrl.js +++ b/public/controllers/paymentCtrl.js @@ -3,13 +3,15 @@ App.controller('paymentCtrl', function($scope, FlightsSrv, ConfirmSrv, OutReturn $scope.tab = "active in"; $scope.reservation = ConfirmSrv.getReservation(); $scope.totalPrice = OutReturnSrv.getSelectedPrice(); - $scope.cabin=FlightsSrv.getSelectedCabin(); + $scope.cabin = FlightsSrv.getSelectedCabin(); var roundTrip = FlightsSrv.getSelectedRoundTrip(); - var outgoingFlight= OutReturnSrv.getSelectedOutFlight(); - if(roundTrip == 'true') + var outgoingFlight = OutReturnSrv.getSelectedOutFlight(); + if (roundTrip == 'true') returnFlight = OutReturnSrv.getSelectedReturnFlight(); $scope.outCurrency = outgoingFlight.currency; + + $scope.tab1 = function() { $scope.tab = "active in"; $scope.tab2 = ""; @@ -32,10 +34,10 @@ App.controller('paymentCtrl', function($scope, FlightsSrv, ConfirmSrv, OutReturn }; var postAPay = function() { - $scope.bookingRefNumber = $scope.getBookingRef() ; - paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, outgoingFlight , $scope.cabin); - if(roundTrip =='true') - paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, returnFlight , $scope.cabin); + $scope.bookingRefNumber = $scope.getBookingRef(); + paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, outgoingFlight, $scope.cabin); + if (roundTrip == 'true') + paymentSrv.postPay($scope.reservation, $scope.bookingRefNumber, returnFlight, $scope.cabin); }; var SetCardType = function(value) { @@ -87,55 +89,94 @@ App.controller('paymentCtrl', function($scope, FlightsSrv, ConfirmSrv, OutReturn //NARIHAN $scope.getBookingRef = function() { - // var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; - // var string_length = 8; - // var randomstring = ''; - // for (var i=0; i" + enc + "
" + "Decoded String: " + dec; + var res = enc; + // "
" + "Decoded String: " + dec; + document.getElementById("ptag").innerHTML = "Booking Reference:(please copy it for further tracking):" + "
"; document.getElementById("demo").innerHTML = res; - return enc; + var copyTextareaBtn = document.querySelector('.js-textareacopybtn'); + + copyTextareaBtn.addEventListener('click', function(event) { + var copyTextarea = document.querySelector('.js-copytextarea'); + copyTextarea.select(); + + try { + var successful = document.execCommand('copy'); + var msg = successful ? 'successful' : 'unsuccessful'; + console.log('Copying text command was ' + msg); + } catch (err) { + console.log('Oops, unable to copy'); + } + }); + + + + // document.getElementById("copyButton").addEventListener("click", function() { + // copyToClipboard(enc); + // }); + + // function copyToClipboard(elem) { + // // create hidden text element, if it doesn't already exist + // var targetId = "_hiddenCopyText_"; + // var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA"; + // var origSelectionStart, origSelectionEnd; + // if (isInput) { + // // can just use the original source element for the selection and copy + // target = elem; + // origSelectionStart = elem.selectionStart; + // origSelectionEnd = elem.selectionEnd; + // } else { + // // must use a temporary form element for the selection and copy + // target = document.getElementById(targetId); + // if (!target) { + // var target = document.createElement("textarea"); + // target.style.position = "absolute"; + // target.style.left = "-9999px"; + // target.style.top = "0"; + // target.id = targetId; + // document.body.appendChild(target); + // } + // target.textContent = elem.textContent; + // } + // // select the content + // var currentFocus = document.activeElement; + // target.focus(); + // target.setSelectionRange(0, target.value.length); + + // // copy the selection + // var succeed; + // try { + // succeed = document.execCommand("copy"); + // } catch(e) { + // succeed = false; + // } + // // restore original focus + // if (currentFocus && typeof currentFocus.focus === "function") { + // currentFocus.focus(); + // } + + // if (isInput) { + // // restore prior selection + // elem.setSelectionRange(origSelectionStart, origSelectionEnd); + // } else { + // // clear temporary content + // target.textContent = ""; + // } + // return succeed; + // } - }; + return enc; + }; //End of Narihan diff --git a/public/partials/bookingRef.html b/public/partials/bookingRef.html index 3e44c61..950cc99 100644 --- a/public/partials/bookingRef.html +++ b/public/partials/bookingRef.html @@ -27,10 +27,12 @@
-
- -
+
+
+
+
+
diff --git a/public/partials/landingPage.html b/public/partials/landingPage.html index 0a3d684..6f6b4cc 100644 --- a/public/partials/landingPage.html +++ b/public/partials/landingPage.html @@ -198,7 +198,9 @@

Flights

Returning:

- + + + + +

- + diff --git a/public/partials/teamMembers.html b/public/partials/teamMembers.html index e82fe87..2eeeeca 100644 --- a/public/partials/teamMembers.html +++ b/public/partials/teamMembers.html @@ -1,24 +1,4 @@ - - + @@ -38,7 +18,7 @@ - + @@ -47,7 +27,27 @@ - + +