SHARE
TWEET

Untitled

a guest Jun 25th, 2019 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. btna = [
  2.     {
  3.       "id":"#btn123",
  4.       "formId" : "#wpcf7-f4849-p4850-o1",
  5.       'openTime' : "June 23, 2019 14:00:00",
  6.       'closeTime' : "June 23, 2019 14:00:00",
  7.     },
  8.     {
  9.       "id":"#btn1234",
  10.       "formId" : "#wpcf7-f4940-p4850-o2",
  11.       'openTime' : "June 23, 2019 14:00:00",
  12.       'closeTime' : "June 25, 2019 14:00:00",
  13.     },
  14.     {
  15.       "id":"#btn12345",
  16.       "formId" : "#wpcf7-f4941-p4850-o3",
  17.       'openTime' : "June 23, 2019 14:00:00",
  18.       'closeTime' : "June 28, 2019 14:00:00",
  19.     }
  20.   ]
  21.   $(document).ready(function(){
  22.     let openTime
  23.     let closeTime
  24.     let button
  25.     let itemForm
  26.     let now = Date.now();
  27.     btna.map(function(item){
  28.       openTime = (new Date(item.openTime)).getTime()
  29.             closeTime = (new Date(item.closeTime)).getTime()
  30.       button = $( item.id )
  31.       itemForm = $( item.formId )
  32.       if (closeTime > now && openTime < now ) {
  33.         // Button in correct time period
  34.         button.addClass("active")
  35.  
  36.         itemForm.hide()
  37.         button.click(function(){
  38.            $( item.formId ).toggle(250)
  39.         })
  40.       }else{
  41.         // Button is'nt in its time period
  42.         button.addClass("ex1")
  43.         itemForm.hide()
  44.       }
  45.     })
  46.   })
  47.      
  48. let openTime= new Date("June 23, 2019 14:00:00");
  49.     let closeTime= new Date("June 26, 2019 14:00:00");
  50.     btna = [
  51.         {
  52.             "id":"#btn123",
  53.             "formId" : "#wpcf7-f4849-p4850-o1",
  54.             'openTime' : openTime,
  55.             'closeTime' : closeTime,
  56.         },
  57.         {
  58.             "id":"#btn1234",
  59.             "formId" : "#wpcf7-f4940-p4850-o2",
  60.             'openTime' : openTime.setDate(openTime.getDate() + 7),
  61.             'closeTime' : closeTime.setDate(openTime.getDate() + 7),
  62.         },
  63.         {
  64.             "id":"#btn12345",
  65.             "formId" : "#wpcf7-f4941-p4850-o3",
  66.             'openTime' : openTime.setDate(openTime.getDate() + 7),
  67.             'closeTime' : closTime.setDate(openTime.getDate() + 7),
  68.         }
  69.     ]
  70.  
  71.     $(document).ready(function(){
  72.         let button
  73.         let itemForm
  74.         let now = Date.now();
  75.         btna.map(function(item){
  76.             openTime = (new Date(item.openTime)).getTime()
  77.             closeTime = (new Date(item.closeTime)).getTime()
  78.             button = $( item.id )
  79.             itemForm = $( item.formId )
  80.             if (openTime < now && closeTime > now) {
  81.                 // Button in correct time period
  82.                 button.addClass("active")
  83.  
  84.                 itemForm.hide()
  85.                 button.click(function(){
  86.                      $( item.formId ).toggle(250)
  87.                 })
  88.             }else{
  89.                 // Button is'nt in its time period
  90.                 button.addClass("hide")
  91.                 itemForm.hide()
  92.             }
  93.         })
  94.     })
  95.      
  96. let openTime += 7
  97.     let closeTime += 7
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top