SHARE
TWEET

TimeConverter

a guest Jun 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function attachEventsListeners() {
  2.     let daysInput = document.getElementById('days');
  3.     let hoursInput = document.getElementById('hours');
  4.     let minutesInput = document.getElementById('minutes');
  5.     let secondsInput = document.getElementById('seconds');
  6.  
  7.     let daysBtn = document.getElementById('daysBtn');
  8.     let hoursBtn = document.getElementById('hoursBtn');
  9.     let minutesBtn = document.getElementById('minutesBtn');
  10.     let secondsBtn = document.getElementById('secondsBtn');
  11.  
  12.     daysBtn.addEventListener('click', function() {
  13.         let days = daysInput.value;
  14.         hoursInput.value = days * 24;
  15.         minutesInput.value = days * 1440;
  16.         secondsInput.value = days * 86400;
  17.     });
  18.  
  19.     hoursBtn.addEventListener('click', function() {
  20.         let hours = hoursInput.value;
  21.         daysInput.value = hours / 24;
  22.         minutesInput.value = hours * 60;
  23.         secondsInput.value = hours * 60 * 60;
  24.     });
  25.  
  26.     minutesBtn.addEventListener('click', function() {
  27.         let minutes = minutesInput.value;
  28.         hoursInput.value = minutes / 60;
  29.         daysInput.value = minutes / 60 / 24;
  30.         secondsInput.value = minutes * 60;
  31.     });
  32.  
  33.     secondsBtn.addEventListener('click', function() {
  34.         let seconds = secondsInput.value;
  35.         hoursInput.value = seconds / 60 / 60;
  36.         minutesInput.value = seconds / 60;
  37.         daysInput.value = seconds / 60 / 60 / 24;
  38.     });
  39. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top