From a87096dd6e40ffffb19f3026d6c2a9ae4582f84a Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 10 Nov 2015 09:29:57 -0500 Subject: [PATCH] Added auto stay duration calc for nights fields --- js/app.js | 40 ++++++++++------------------------------ js/custom/pageSetup.js | 40 ++++++++++------------------------------ 2 files changed, 20 insertions(+), 60 deletions(-) diff --git a/js/app.js b/js/app.js index 102ab2d..a531a6a 100644 --- a/js/app.js +++ b/js/app.js @@ -68,6 +68,10 @@ $(document).ready(function () { } y = currentDate.getFullYear(); requiredDate = y + '-' + m + '-' + d; + arrival = d + '-' + m + '-' + y; + arrival.toString(); + arrival = arrival.replace(/\//g, ""); + arrival = parseInt(arrival, 10); $("#departOff").val(requiredDate); } @@ -88,40 +92,16 @@ $(document).ready(function () { } y = currentDate.getFullYear(); requiredDate = y + '-' + m + '-' + d; + departure = d + '-' + m + '-' + y; + departure.toString(); + departure = departure.replace(/\//g, ""); + departure = parseInt(departure, 10); + $("#nightsOff").val(departure - arrival); + stay = 'stay_nights=' + (departure - arrival) + '&'; if ($("#departOff").val() < $('#departOff').attr("min")) { // $("#dateOff2").val(requiredDate); } }); - /* $("#arriveOff").datepicker({ - onSelect: function (date) { - $("#arriveOff").datepicker({dateFormat: 'mm/dd/yy'}).val(); - arrival = $("#arriveOff").datepicker('getDate'); - d = arrival.getDate(); - m = arrival.getMonth() + 1; - y = arrival.getFullYear(); - arrival = d + '-' + m + '-' + y; // to pass as a date value in the url - start = "arrival_date=" + y + '-' + m + '-' + d + '&'; // for date parsing to get length of stay - arrival.toString(); - arrival = arrival.replace(/\//g, ""); - arrival = parseInt(arrival, 10); - } - }); - $("#departOff").datepicker({ - onSelect: function (date) { - $("#departOff").datepicker({dateFormat: 'mm/dd/yy'}).val(); - departure = $("#departOff").datepicker('getDate'); - d = departure.getDate(); - m = departure.getMonth() + 1; - y = departure.getFullYear(); - departure = d + '-' + m + '-' + y; - end = y + '-' + m + '-' + d + '&'; - departure.toString(); - departure = departure.replace(/\//g, ""); - departure = parseInt(departure, 10); - $("#nightsOff").val(departure - arrival); - stay = 'stay_nights=' + (departure - arrival) + '&'; - } - }); */ ///// end of canvas datepicker logic ^ ////////////////////////////////////////////// /// top bar reservation form dropdown logic //////////////////////////// diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index c3302f9..f4c83b3 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -59,6 +59,10 @@ $(document).ready(function () { } y = currentDate.getFullYear(); requiredDate = y + '-' + m + '-' + d; + arrival = d + '-' + m + '-' + y; + arrival.toString(); + arrival = arrival.replace(/\//g, ""); + arrival = parseInt(arrival, 10); $("#departOff").val(requiredDate); } @@ -79,40 +83,16 @@ $(document).ready(function () { } y = currentDate.getFullYear(); requiredDate = y + '-' + m + '-' + d; + departure = d + '-' + m + '-' + y; + departure.toString(); + departure = departure.replace(/\//g, ""); + departure = parseInt(departure, 10); + $("#nightsOff").val(departure - arrival); + stay = 'stay_nights=' + (departure - arrival) + '&'; if ($("#departOff").val() < $('#departOff').attr("min")) { // $("#dateOff2").val(requiredDate); } }); - /* $("#arriveOff").datepicker({ - onSelect: function (date) { - $("#arriveOff").datepicker({dateFormat: 'mm/dd/yy'}).val(); - arrival = $("#arriveOff").datepicker('getDate'); - d = arrival.getDate(); - m = arrival.getMonth() + 1; - y = arrival.getFullYear(); - arrival = d + '-' + m + '-' + y; // to pass as a date value in the url - start = "arrival_date=" + y + '-' + m + '-' + d + '&'; // for date parsing to get length of stay - arrival.toString(); - arrival = arrival.replace(/\//g, ""); - arrival = parseInt(arrival, 10); - } - }); - $("#departOff").datepicker({ - onSelect: function (date) { - $("#departOff").datepicker({dateFormat: 'mm/dd/yy'}).val(); - departure = $("#departOff").datepicker('getDate'); - d = departure.getDate(); - m = departure.getMonth() + 1; - y = departure.getFullYear(); - departure = d + '-' + m + '-' + y; - end = y + '-' + m + '-' + d + '&'; - departure.toString(); - departure = departure.replace(/\//g, ""); - departure = parseInt(departure, 10); - $("#nightsOff").val(departure - arrival); - stay = 'stay_nights=' + (departure - arrival) + '&'; - } - }); */ ///// end of canvas datepicker logic ^ ////////////////////////////////////////////// /// top bar reservation form dropdown logic //////////////////////////// -- 2.17.1