Advertisement
metalx1000

Get Shift Fire Fighting ENFD

Apr 1st, 2016 (edited)
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <script>
  5.       var shift = getShift();
  6.  
  7.       document.addEventListener("DOMContentLoaded", function(event) {
  8.         document.getElementById("shift").innerHTML = "Today is a " + shift;
  9.       });
  10.  
  11.       function getShift(){
  12.         var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
  13.         var ashift = new Date(2015,8,15);
  14.         var bshift = new Date(2015,8,16);
  15.         var cshift = new Date(2015,8,17);
  16.         var today = new Date();
  17.         today.setHours(0,0,0,0);
  18.  
  19.         ashift = Math.round(Math.abs((ashift.getTime() - today.getTime())/(oneDay)));
  20.         bshift = Math.round(Math.abs((bshift.getTime() - today.getTime())/(oneDay)));
  21.         cshift = Math.round(Math.abs((cshift.getTime() - today.getTime())/(oneDay)));
  22.         //diffDays % 2;
  23.         if(ashift % 3 === 0){
  24.           return "A shift";
  25.           }else if(bshift % 3 === 0){
  26.           return "B shift";
  27.           }else if(cshift % 3 === 0){
  28.           return "C shift";
  29.           }else{
  30.           return "unkown shift";
  31.         }
  32.  
  33.       }
  34.     </script>
  35.   </head>
  36.   <body>
  37.     <h1 id="shift"></h1>
  38.   </body>
  39. </html>
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement