fixing intial widget setup, today's date wasn't working
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 14 Aug 2018 17:26:20 +0000 (13:26 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 14 Aug 2018 17:26:20 +0000 (13:26 -0400)
js/app.js
js/custom/pageSetup.js
style.css

index d7ecbef..c338a90 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -27,7 +27,7 @@ $(document).ready(function () {
             $("#res-tab-open").attr("id", "res-tab");
         }
     });
-    var start,  extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd,  m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&',
+    var extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd,  m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&',
         crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&',
         adults,
         kids,
@@ -42,6 +42,21 @@ $(document).ready(function () {
     function getNights(depart, arrive){
         return Math.floor((depart - arrive) / (1000*60*60*24));
     }
+    var today = new Date();
+    var dd = today.getDate();
+    var mm = today.getMonth()+1; //January is 0!
+    var yyyy = today.getFullYear();
+
+    if(dd<10) {
+        dd = '0'+dd
+    } 
+
+    if(mm<10) {
+        mm = '0'+mm
+    } 
+
+    today = yyyy + '-' + mm + '-' + dd;
+    let start = `arrival_date=${today}&`;
     $(document).on('change', '#arriveOff', function () {
         const _ = $(this);
         // offset weird timezone issues by replacing - with /
@@ -51,7 +66,7 @@ $(document).ready(function () {
         let year    = arrivalDate.getUTCFullYear();   
         let formattedDate = `${year}-${month}-${day}`;
         _.val(formattedDate);
-        start = `arrival_date=${formattedDate}&`;
+        
 
         // weird date incrementer is the only way in vanilla js to roll over to next month instead of going to 8-32-2018 for example
         let minDate  = ((new Date(arrivalDate).valueOf() + + 1000*3600*24) > 9) ? (new Date(arrivalDate).valueOf() + + 1000*3600*24) : `0${(new Date(arrivalDate).valueOf() + + 1000*3600*24)}`;    
@@ -70,9 +85,6 @@ $(document).ready(function () {
         }
         
 
-        
-        
-    
         // currentDate = $("#arriveOff").val();
         // currentDate = new Date(currentDate);
         // console.log(currentDate);
index 995005b..26cb735 100644 (file)
@@ -18,7 +18,7 @@ $(document).ready(function () {
             $("#res-tab-open").attr("id", "res-tab");
         }
     });
-    var start,  extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd,  m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&',
+    var extraDay,currentDate, currentDate2, requiredDate,minDays, departure, stay, d, dd,  m, y, bayView = 'vD4ZpIFk4%2b7FyPsaBnkCqP1cBHWnJili9k5D83MqJq4%3d&',
         crookedRiver = 'ZhWXD46i2%2fq319vcR%2fcw69rZvA2bz%2fttOOxO9t1%2fBJ0%3d&',
         adults,
         kids,
@@ -33,6 +33,21 @@ $(document).ready(function () {
     function getNights(depart, arrive){
         return Math.floor((depart - arrive) / (1000*60*60*24));
     }
+    var today = new Date();
+    var dd = today.getDate();
+    var mm = today.getMonth()+1; //January is 0!
+    var yyyy = today.getFullYear();
+
+    if(dd<10) {
+        dd = '0'+dd
+    } 
+
+    if(mm<10) {
+        mm = '0'+mm
+    } 
+
+    today = yyyy + '-' + mm + '-' + dd;
+    let start = `arrival_date=${today}&`;
     $(document).on('change', '#arriveOff', function () {
         const _ = $(this);
         // offset weird timezone issues by replacing - with /
@@ -42,7 +57,7 @@ $(document).ready(function () {
         let year    = arrivalDate.getUTCFullYear();   
         let formattedDate = `${year}-${month}-${day}`;
         _.val(formattedDate);
-        start = `arrival_date=${formattedDate}&`;
+        
 
         // weird date incrementer is the only way in vanilla js to roll over to next month instead of going to 8-32-2018 for example
         let minDate  = ((new Date(arrivalDate).valueOf() + + 1000*3600*24) > 9) ? (new Date(arrivalDate).valueOf() + + 1000*3600*24) : `0${(new Date(arrivalDate).valueOf() + + 1000*3600*24)}`;    
@@ -61,9 +76,6 @@ $(document).ready(function () {
         }
         
 
-        
-        
-    
         // currentDate = $("#arriveOff").val();
         // currentDate = new Date(currentDate);
         // console.log(currentDate);
index f346625..caf98bc 100644 (file)
--- a/style.css
+++ b/style.css
@@ -3,5 +3,5 @@ Theme Name: Staffords
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
 Description: A theme for Staffords
-Version: 1.0.50
+Version: 1.0.51
 */