Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">
  <div class="alarm_container">
    <div class="alarm_container_sm">
      <input type="text" name="" id="text_input" value ="?:?:?" readonly>
    </div>
    <div class="setAlarmContainer">
      Place Time for Alarm in Here<input type="text" name="" id="set_alarm_input">(ex.03:05:24 - 23:59:59)
      <div class="buttonContainer">
        <a href="#" class="alarm_function set">Set Alarm</a>
        <a href="#" class="alarm_function clear">Clear Alarm</a>
      </div>
    </div>
  </div>
</div>

<audio src="https://freesound.org/data/previews/250/250629_4486188-lq.mp3" class="alarm_sound"></audio>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Orbitron&display=swap');

*{
  margin:0;
  padding: 0;
  font-family:Lato;
  font-weight: 500;
  font-size:1.1em;
}

li{
  list-style:none;
}

a{
  text-decoration:none;
  color:black;
}
a:hover{
    text-decoration: none;
}

input[type="text"], 
input[type="email"] , 
input[type="tel"] ,
select,
textarea{
    padding: .5em 3em .5em .4em;
    font-size: 1.2em;
    font-family: sans-serif;
    font-weight: 300;
}

input[type="submit"] {
    /* all: unset; */
    -webkit-appearance: none;
    border: none;
    border-radius: unset;
    cursor: pointer;
    font-size: 1em;
}

.wrapper{
  min-height:100vh;
  background: cadetblue;
  display:flex;
  align-items:center;
  justify-content:center;
}

.alarm_container{
  padding: 1em 8em;
  position:relative;
}

.alarm_container_sm {
    background: black;
    padding: 0.4em;
    border-radius: 5px;
    transform: translate(-10px, 12px);
    box-shadow: 1px -20px 0px 6px rgb(0,0,0,.75);
  transition:all 1.5s ease;
}



.alarm_container_sm input[type="text"] {
    padding: 1em .3em 1em .4em;
    font-size: 5.5em;
    border-radius: 5px;
    font-weight: 100;
    width: 52vw;
    background: floralwhite;
    height: 20vh;
    text-align: center;
    font-family: Orbitron;
}

.setAlarmContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1em;
}

.buttonContainer {
    display: flex;
    width: 40vw;
    justify-content: space-between;
    align-items:self-start
}


.alarm_function {
    margin-top:.3em;
    padding: 1em 1em;
    border: 3px solid black;
    font-family: Orbitron;
}

.alarm_function.set{
  background: #4CAF50;
  text-align:center;
}

.alarm_function.clear{
  background: #f44336;
}


              
            
!

JS

              
                // Defining Variables
var timeContainer = document.getElementsByClassName('alarm_container_sm')[0],
    timeInput = document.getElementById('text_input'),
    setAlarmInput = document.getElementById('set_alarm_input'),
    requiredField = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/,
    timeValues = [],
    alarm_function_buttons = Array.from(document.querySelectorAll('.alarm_function')),
    masterTl = new TimelineMax(),
    alarm_sound = document.getElementsByClassName('alarm_sound')[0],
    set_Alarm = document.getElementsByClassName('set')[0];

gsap.registerPlugin(CustomEase, CustomWiggle);
CustomWiggle.create("funWiggle", {wiggles:50, type:"uniform"});


//Defining Functions and Methods
function getSeconds(){
  var timeInSeconds = new Date().getSeconds();
  var timeInMinutes = new Date().getMinutes();
  var timeInHours = new Date().getHours();
  if (timeInHours < 10) {
    timeInput.value = `0${timeInHours}:${timeInMinutes}:${timeInSeconds}`;
  } else if (timeInMinutes < 10) {
    timeInput.value = `${timeInHours}:0${timeInMinutes}:${timeInSeconds}`;
  } else if ( timeInSeconds < 10) {
    timeInput.value = `${timeInHours}:${timeInMinutes}:0${timeInSeconds}`;
  } else {
    timeInput.value = `${timeInHours}:${timeInMinutes}:${timeInSeconds}`;
  }
}

function setAlarm(value){
  timeValues.push(value);
  setInterval(function(){checkTimes(timeValues)},1000);
}

function checkTimes(values){
  values.map(timeValue => timeValue === timeInput.value ? turnOnAlarm() : -1 );
}

function turnOnAlarm(){
  timeInput.style.backgroundColor = "#f44336";
  timeContainer.style.boxShadow = "1px -20px 30px 6px #f44336";
  CustomWiggle.create("funWiggle", {wiggles:20, type:"uniform"});
  gsap.to(timeContainer, {duration: 9, rotation:20, ease:"funWiggle" , clearProps: 'all' }); 
  alarm_sound.play();
  setTimeout(function(){
    clearAlarm();
  } , 10000)
}

function clearAlarm(){
  timeValues = [];
  timeInput.style.backgroundColor = "floralwhite";
  set_Alarm.innerHTML = "Set Alarm";
}

function checkFields(value){
  if (!(requiredField.test(value)))
    return;
  return value
}

//Initialization Methods
setAlarmInput.onchange = function(e){
  checkFields(e.target.value);
};

alarm_function_buttons.map(alarm_button =>
  alarm_button.onclick =  function(e){
    e.preventDefault();
    var button_clicked = e.target;
    console.log(button_clicked);
    if (button_clicked.classList.contains('set')) {
      setAlarm(setAlarmInput.value);
      button_clicked.innerHTML = `Alarm is set <br>${setAlarmInput.value}`;
      setAlarmInput.value = "";
      
    }else{
      clearAlarm();
    }
  }
);



setInterval(function(){
  getSeconds();
}, 1000);
              
            
!
999px

Console