Build a Stylish Digital Stopwatch Clock Widget in Browser Using HTML5 CSS3 and Javascript Full Project For Beginners

 

 

 

index.html

 

 

<link href="https://fonts.googleapis.com/css?family=Orbitron|Text+Me+One" rel="stylesheet">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css"/>

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

        <div class="container">

            <div class="ClockHolder">

                <div class="WeekDays">
                    <span>sat</span>
                    <span>sun</span>
                    <span>mon</span>
                    <span>tue</span>
                    <span>wed</span>
                    <span>thu</span>
                    <span>fri</span>
                </div>

                <div class="TimeHolder">

                    <div class="TimeOptions">

                        <i class="fas fa-clock" data-title="Time"></i>
                        <i class="fas fa-stopwatch" data-title="StopWatch"></i>
                        <i class="far fa-clock" data-title="CountDown"></i>

                    </div>

                    <div class="Numbers">

                        <div class="NumberHolder H1">

                            <span class="d1"></span>
                            <span class="d2"></span>
                            <span class="d3"></span>
                            <span class="d4"></span>
                            <span class="d5"></span>
                            <span class="d6"></span>
                            <span class="d7"></span>

                        </div>

                        <div class="NumberHolder H2">

                            <span class="d1"></span>
                            <span class="d2"></span>
                            <span class="d3"></span>
                            <span class="d4"></span>
                            <span class="d5"></span>
                            <span class="d6"></span>
                            <span class="d7"></span>

                        </div>

                        <span>:</span>

                        <div class="NumberHolder M1">

                            <span class="d1"></span>
                            <span class="d2"></span>
                            <span class="d3"></span>
                            <span class="d4"></span>
                            <span class="d5"></span>
                            <span class="d6"></span>
                            <span class="d7"></span>

                        </div>

                        <div class="NumberHolder M2">

                            <span class="d1"></span>
                            <span class="d2"></span>
                            <span class="d3"></span>
                            <span class="d4"></span>
                            <span class="d5"></span>
                            <span class="d6"></span>
                            <span class="d7"></span>

                        </div>

                        <span>:</span>

                        <div class="NumberHolder S1">

                            <span class="d1"></span>
                            <span class="d2"></span>
                            <span class="d3"></span>
                            <span class="d4"></span>
                            <span class="d5"></span>
                            <span class="d6"></span>
                            <span class="d7"></span>

                        </div>

                        <div class="NumberHolder S2">

                            <span class="d1"></span>
                            <span class="d2"></span>
                            <span class="d3"></span>
                            <span class="d4"></span>
                            <span class="d5"></span>
                            <span class="d6"></span>
                            <span class="d7"></span>

                        </div>


                    </div>

                    <div class="AlarmInput">
                        <input type="number" placeholder="Enter Seconds">
                    </div>

                    <div class="TimeFormat">

                        <div class="Type">
                            <span>12hr</span>
                            <span class="active">24hr</span>
                        </div>

                        <div class="Formats">
                            <span>am</span>
                            <span>pm</span>
                        </div>

                        <div class="control">

                            <span class="Start active"><i class="fas fa-play"></i>Start</span>
                            <span class="Pause"><i class="fas fa-pause"></i>Pause</span>
                            <span class="Stop active"><i class="fas fa-stop"></i>Stop</span>

                        </div>

                    </div>

                </div>

            </div>

        </div>

 

 

style.css

 

 

/* Css Reset */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* Css Code */

body{
    background-color: #7B1FA2;
    font-family: 'Text Me One', sans-serif;
}

.container{
    width: 90%;
    max-width: 1400px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    display: flex;
    justify-content: center;
}

.ClockHolder{
    width: 500px;
    background-color: #1b252a;
    padding: 30px 50px;
    border-radius: 15px;
    border: 3px solid #0277BD;
    position: relative;
}

.ClockHolder::after{
    content: " ";
    position: absolute;
    bottom: -15px;
    left: 50%;
    width: 70%;
    height: 15px;
    background-color: #0277bd;
    transform: translate(-50%,0);
    border-radius: 3px 3px 8px 8px;
}

.ClockHolder::before{

}

.WeekDays{
    display: flex;
    width: 100%;
    justify-content: space-between;
    text-transform: uppercase;
    color: #646c72;
    cursor: default;
}

.WeekDays .active{
    color: aliceblue;
    position: relative;
}

.WeekDays .active::after{
    content: "";
    position: absolute;
    bottom: -3px;
    left: 0;
    height: 2px;
    width: 100%;
    background-color: aliceblue;
}

.Numbers,
.TimeHolder{
    display: flex;
    justify-content: space-around;
    width: 100%;
    padding: 20px 0 5px;
    align-items: flex-end;
}

.NumberHolder{
    position: relative;
    width: 60px;
    height: 95px;
}

.d1 , .d2 , .d3 , .d4 , .d5 , .d6 , .d7{
    width: 8px;
    height: 40px;
    background-color: azure;
    position: absolute;
}

.d1::after , .d2::after , .d3::after , .d4::after , .d5::after , .d6::after , .d7::after{
    content: "";
    position: absolute;
    background-color: azure;
    width: 7px;
    height: 7px;
    top: -7px;
    left: 0;
    clip-path: polygon(0 0, 0% 100%, 100% 100%);
}


.d1::before , .d2::before , .d3::before , .d4::before , .d5::before , .d6::before , .d7::before{
    content: "";
    position: absolute;
    background-color: azure;
    width: 7px;
    height: 7px;
    bottom: -7px;
    left: 0;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}
.d7{
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%) rotate(90deg);
}

.d7::before{
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.d7::after{
    clip-path: polygon(0 100%, 100% 100%, 50% 0);
}

@keyframes From01{
    from{
        top: 0;
        left: 0;
    }
    to{
        top: 0;
        left: calc( 100% - 7px );
        transform: rotate(180deg);
    }
}
@keyframes From02{
    from{
        bottom: 0;
        left: 0;
    }
    to{
        bottom: 0;
        left: calc(100% - 7px);
        transform: rotate(180deg);
    }
}
@keyframes From05{
    from{
        top: -22px;
        left: 7px;
        transform: rotate(90deg) translate(-50%,-50%);
    }
    to{
        top: 0;
        left: calc(100% - 7px);
        transform: rotate(180deg);
    }
}
@keyframes From06{
    from{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
    to{
        bottom: 0;
        left: calc(100% - 7px);
        transform: rotate(180deg) translate(0,0);
    }
}
.TimeOptions{
    display: flex;
    flex-direction: column;
    color: aliceblue;
}

.Numbers>span{
    font-size: 100px;
    color: aliceblue;
}

.NumberHolder{
    margin: 0 7px;    
}

.Formats span{
    display: none;
    color: aliceblue;
    font-size: 2em;
    cursor: default;
}

.Formats .active{
    display: block;
}

.Type{
    display: flex;
    flex-direction: column;
    color: #98afaf;
}

.Type span{
    position: relative;
    margin: 2px 0;
    cursor: pointer;
}

.Type span::before{
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #98afaf;
    transition: all .4s ease;
}

.Type span:hover::before{
    width: 100%;
}

.TimeFormat{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 110px;
}

.Type .active{
    color: aquamarine;    
}

.Type .active::after{
    content: "\f053";
    font-weight: 900;
    font-family: "Font Awesome 5 Free";
    position: absolute;
    top: 50%;
    right: -20px;
    transform: translate(-50%,-50%);
}

.Type .active::before{
    width: 100%;
}

.TimeOptions i{
    margin: 10px 3px;
    position: relative;
    cursor: pointer;
}

.TimeOptions i::after {
    display: block;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    background: #fff;
    color: #646464;
    content: attr(data-title);
    font-size: 12px;
    padding: 3px 11px;
    top: -45%;
    left: 50%;
    white-space: nowrap;
    transform: translate(-50%,-50%) scale3d(.2,.2,1);
    transition: all .35s ease-in-out;
    line-height: initial;
    border-radius: 100px;
    z-index: 20;
}

.control{
    display: none;
    color: #F0FFFF;
    position: relative;
    margin-left: 10px
}

.control span{
    position: relative;
    cursor: pointer;
    text-align: center;
    display: none;
    margin-bottom: 20px;
}

.control .Pause{
    display: none;
}
.control span.active{
    display: block;
}

.control span i{
    margin-bottom: 5px;
}

.TimeOptions i:hover::after {
    opacity: 1;
    transform: translate(-50%,-50%) scale3d(1,1,1);
}

.StopWatch .Type,.StopWatch .Formats,.Alarm .Type,.Alarm .Formats{
    display: none;
}

.StopWatch .control,.Alarm .control{
    display: block;
}

.ClockHolder::before{
    content: "";
    position: absolute;
    width: 110%;
    height: 10px;
    background-color: #00000077;
    bottom: -25px;
    left: -5%;
    border-radius: 100%;
    filter: blur(5px);
}

.AlarmInput{
    display: none;
}

.AlarmInput input{
    height: 100px;
    font-size: 100px;
    max-width: 400px;
    font-family: 'Orbitron', sans-serif;
    background-color: #1b252a;
    border: none;
    padding: 5px 20px;
    color: azure;
    letter-spacing: 5px;
    position: relative;
}

.AlarmInput input:focus{
    border: 1px solid #fff;
}

.Alarm .AlarmInput{
    display: block;
}
.Alarm .AlarmInput.DisNone{
    display: none;
}

.AlarmInput input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-size: 30px;
}
.AlarmInput input::-moz-placeholder { /* Firefox 19+ */
    font-size: 30px;
}
.AlarmInput input:-ms-input-placeholder { /* IE 10+ */
    font-size: 30px;
}
.AlarmInput input:-moz-placeholder { /* Firefox 18- */
    font-size: 30px;
}

.show1 .d1{
    animation: From01 .35s ease 1 forwards;
}
.show1 .d2{
    animation: From02 .35s ease 1 forwards;
}
.show1 .d3{
    top: 0;
    left: calc( 100% - 7px );
    transform: rotate(180deg);
}
.show1 .d4{
    bottom: 0;
    left: calc(100% - 7px);
    transform: rotate(180deg);
}

.show1 .d5{
    animation: From05 .35s ease 1 forwards;
}
.show1 .d6{
    animation: From06 .35s ease 1 forwards;
}
.show1 .d7{
    opacity: 0;
}

.show2 .d1{
    top: 0;
    left: calc( 100% - 7px );
    transform: rotate(180deg);
}
.show2 .d2{
    animation: From12 .35s ease 1 forwards;
}
.show2 .d3{
    top: 0;
    left: calc( 100% - 7px );
    transform: rotate(180deg);
}
.show2 .d4{
    animation: From16 .35s ease 1 forwards;
}
.show2 .d5{
    animation: From15 .35s ease 1 forwards;
}
.show2 .d6{
    animation: From16 .35s ease 1 forwards;
}
.show2 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From12{
    from{
        bottom: 0;
        left: calc(100% - 7px);
        transform: rotate(180deg);
    }
    to{
        bottom: 0;
        left: 0;
    }
}
@keyframes From15{
    from{
        top: 0;
        left: calc(100% - 7px);
        transform: rotate(180deg);
    }
    to{
        top: -22px;
        left: 7px;
        transform: rotate(90deg) translate(-50%,-50%);
    }
}
@keyframes From16{
    from{
        bottom: 0;
        left: calc(100% - 7px);
        transform: rotate(180deg) translate(0,0);
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}
.show3 .d1{
    top: 0;
    left: calc( 100% - 7px );
    transform: rotate(180deg);
}
.show3 .d2{
    animation: From22 .35s ease 1 forwards;
}
.show3 .d3{
    top: 0;
    right: 0;
    transform: rotate(180deg);
}
.show3 .d4{
    animation: From24 .35s ease 1 forwards;
}

.show3 .d5{
    top: -22px;
    left: 7px;
    transform: rotate(90deg) translate(-50%,-50%);
}
.show3 .d6{
    animation: From24 .35s ease 1 forwards;
}
.show3 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From22{
    from{
        bottom: 0;
        left: 0;
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}
@keyframes From24{
    from{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
    to{
        bottom: 0;
        right: 0;
        transform: rotate(180deg) translate(0,0);
    }
}
.show4 .d1{
    animation: From31 .35s ease 1 forwards;
}
.show4 .d2{
    top: 0;
    right: 0;
    transform: rotate(180deg);
}
.show4 .d3{
    top: 0;
    right: 0;
    transform: rotate(180deg);
}
.show4 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show4 .d5{
    animation: From31 .35s ease 1 forwards;
}
.show4 .d6{
    animation: From36 .35s ease 1 forwards;
}
.show4 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From31{
    from{
        top: -22px;
        left: 7px;
        transform: rotate(90deg) translate(-50%,-50%);
    }
    to{
        top: 0;
        left: 0;
    }
}
@keyframes From32{
    from{
        bottom: 0;
        left: 0;
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}
@keyframes From36{
    from{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
    to{
        bottom: 0;
        right: 0;
        transform: rotate(180deg) translate(0,0);
    }
}
.show5 .d1{
    top: 0;
    left: 0;
}
.show5 .d2{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}
.show5 .d3{
    animation: From43 .35s ease 1 forwards;
}
.show5 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show5 .d5{
    animation: From43 .35s ease 1 forwards;
}
.show5 .d6{
    animation: From46 .35s ease 1 forwards;
}
.show5 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From43{
    from{
        top: 0;
        right: 0;
        transform: rotate(180deg) translate(0,0);
    }
    to{
        top: -22px;
        left: 7px;
        transform: rotate(90deg) translate(-50%,-50%);
    }
}
@keyframes From42{
    from{
        bottom: 0;
        left: 0;
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}
@keyframes From46{
    from{
        bottom: 0;
        right: 0;
        transform: rotate(180deg) translate(0,0);
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}
.show6 .d1{
    top: 0;
    left: 0;
}
.show6 .d2{
    animation: From52 .35s ease 1 forwards;
}
.show6 .d3{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}
.show6 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show6 .d5{
    top: -22px;
    left: 7px;
    transform: rotate(90deg) translate(-50%,-50%);
}
.show6 .d6{
    bottom: -22px;
    left: 7px;
    transform: rotate(-90deg) translate(-50%,50%);
}
.show6 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From52{
    from{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
    to{
        bottom: 0;
        left: 0;
    }
}
.show7 .d1{
    animation: From61 .35s ease 1 forwards;
}
.show7 .d2{
    animation: From62 .35s ease 1 forwards;
}
.show7 .d3{
    animation: From63 .35s ease 1 forwards;
}
.show7 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show7 .d5{
    top: -22px;
    left: 7px;
    transform: rotate(90deg) translate(-50%,-50%);
}
.show7 .d6{
    animation: From66 .35s ease 1 forwards;
}
.show7 .d7{
    opacity: 0;
    transition: opacity .35s ease;
}

@keyframes From61{
    from{
        top: 0;
        left: 0;
    }
    to{
        top: 0;
        right: 0;
        transform: rotate(180deg);
    }
}
@keyframes From63{
    from{
        top: -22px;
        left: 7px;
        transform: rotate(90deg) translate(-50%,-50%);
    }
    to{
        top: 0;
        right: 0;
        transform: rotate(180deg);
    }
}
@keyframes From62{
    from{
        bottom: 0;
        left: 0;
    }
    to{
        bottom: 0;
        right: 0;
        transform: rotate(180deg);
    }
}

@keyframes From66{
    from{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
    to{
        bottom: 0;
        right: 0;
        transform: rotate(180deg);
    }
}
.show8 .d1{
    animation: From71 .35s ease 1 forwards;
}
.show8 .d2{
    animation: From72 .35s ease 1 forwards;
}
.show8 .d3{
    top: 0;
    right: 0;
    transform: rotate(180deg);
}
.show8 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show8 .d5{
    top: -22px;
    left: 7px;
    transform: rotate(90deg) translate(-50%,-50%);
}
.show8 .d6{
    animation: From76 .35s ease 1 forwards;
}
.show8 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From71{
    from{
        top: -22px;
        left: 7px;
        transform: rotate(90deg) translate(-50%,-50%);
    }
    to{
        top: 0;
        left: 0;
    }
}
@keyframes From72{
    from{
        bottom: 0;
        right: 0;
        transform: rotate(180deg);
    }
    to{
        bottom: 0;
        left: 0;
    }
}

@keyframes From76{
    from{
        bottom: 0;
        right: 0;
        transform: rotate(180deg);
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}

.show9 .d1{
    top: 0;
    left: 0;
}
.show9 .d2{
    animation: From82 .35s ease 1 forwards;
}
.show9 .d3{
    top: 0;
    right: 0;
    transform: rotate(180deg);
}
.show9 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show9 .d5{
    top: -22px;
    left: 7px;
    transform: rotate(90deg) translate(-50%,-50%);
}
.show9 .d6{
    bottom: -22px;
    left: 7px;
    transform: rotate(-90deg) translate(-50%,50%);
}
.show9 .d7{
    opacity: 1;
    transition: opacity .35s ease;
}

@keyframes From82{
    from{
        bottom: 0;
        left: 0;
    }
    to{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
}

.show0 .d1{
    top: 0;
    left: 0;
}
.show0 .d2{
    animation: From92 .35s ease 1 forwards;
}
.show0 .d3{
    top: 0;
    right: 0;
    transform: rotate(180deg);
}
.show0 .d4{
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.show0 .d5{
    top: -22px;
    left: 7px;
    transform: rotate(90deg) translate(-50%,-50%);
}
.show0 .d6{
    bottom: -22px;
    left: 7px;
    transform: rotate(-90deg) translate(-50%,50%);
}
.show0 .d7{
    opacity: 0;
    transition: opacity .35s ease;
}

@keyframes From92{
    from{
        bottom: -22px;
        left: 7px;
        transform: rotate(-90deg) translate(-50%,50%);
    }
    to{
        bottom: 0;
        left: 0;
    }
}

.BgAnimation{
    animation: Colors .35s ease infinite alternate;
}


@keyframes Colors{
    0%{
        background-color: #7B1FA2;
    }
    100%{
        background-color: red;
    }
}

 

See also  Javascript Event Handling of Buttons Using onclick Attribute & AddEventListner Method Full Example For Beginners

 

script.js

 

 

var Format = 1,
            TimeHolder = 0,
            StopChecker = 0;

        function resetTimer(){
            $('.S1').removeClass().addClass('NumberHolder S1 show0' );
            $('.S2').removeClass().addClass('NumberHolder S2 show0' );

            $('.M1').removeClass().addClass('NumberHolder M1 show0' );
            $('.M2').removeClass().addClass('NumberHolder M2 show0' );

            $('.H1').removeClass().addClass('NumberHolder H1 show0' );
            $('.H2').removeClass().addClass('NumberHolder H2 show0' );
        }

        function SetDay(DD) {
            $(".WeekDays span:nth-child(" + ((DD + 2) % 7) + ")").addClass('active');
        };

        function Run24hr(S1,S2,M1,M2,H1,H2){

            $('.S1').removeClass().addClass('NumberHolder S1 show' + S1 );
            $('.S2').removeClass().addClass('NumberHolder S2 show' + S2 );

            $('.M1').removeClass().addClass('NumberHolder M1 show' + M1 );
            $('.M2').removeClass().addClass('NumberHolder M2 show' + M2 );

            $('.H1').removeClass().addClass('NumberHolder H1 show' + H1 );
            $('.H2').removeClass().addClass('NumberHolder H2 show' + H2 );
        };

        function Run12hr(S1,S2,M1,M2,HH){

            if(HH>12){
                HH = HH -12;
                $(".Formats span:nth-child(2)").addClass('active');
            } else{
                $(".Formats span:nth-child(1)").addClass('active');
            };
            var H1 = Math.floor(HH/10),
                H2 = HH%10;

            $('.S1').removeClass().addClass('NumberHolder S1 show' + S1 );
            $('.S2').removeClass().addClass('NumberHolder S2 show' + S2 );

            $('.M1').removeClass().addClass('NumberHolder M1 show' + M1 );
            $('.M2').removeClass().addClass('NumberHolder M2 show' + M2 );

            if(H1===0){
                $('.H1').fadeOut(0);
            }else{
                $('.H1').fadeIn().removeClass().addClass('NumberHolder H1 show' + H1 );
            }
            $('.H2').removeClass().addClass('NumberHolder H2 show' + H2 );
        };

        function Stopwatch(TimeHolder){

            var HH = Math.floor( TimeHolder/3600),
                MM = Math.floor( (TimeHolder - (HH*3600)) / 60 ),
                SS = Math.floor( TimeHolder - HH*3600 - MM*60 );

            var S1 = Math.floor(SS/10),
                S2 = SS%10,
                M1 = Math.floor(MM/10),
                M2 = MM%10,
                H1 = Math.floor(HH/10),
                H2 = HH%10;

            Run24hr(S1,S2,M1,M2,H1,H2);
        };

        function update_time(){

            var dt = new Date(),
                HH = dt.getHours(),
                MM = dt.getMinutes(),
                SS = dt.getSeconds(),
                DD = dt.getDay();
            SetDay(DD);

            var S1 = Math.floor(SS/10),
                S2 = SS%10,
                M1 = Math.floor(MM/10),
                M2 = MM%10,
                H1 = Math.floor(HH/10),
                H2 = HH%10;

            if(Format===1){
                Run24hr(S1,S2,M1,M2,H1,H2);
            } else if (Format===2){
                Run12hr(S1,S2,M1,M2,HH);
            } else if (Format===3 && StopChecker === 0){
                TimeHolder++;
                Stopwatch(TimeHolder);
            } else if (Format===4 && StopChecker === 0){
                TimeHolder--;
                if(TimeHolder===0){
                    AlarmOut();
                } else {
                    Stopwatch(TimeHolder);
                }
            };



            setTimeout(update_time,1000);

        };


        $('.Type span').on('click',function(){
            $('.Type .active').removeClass('active');
            $(this).addClass('active');
            var T = $(this).html();
            if(T==='24hr'){
                Format = 1;
                $('.H1').fadeIn();
                $('.Formats span').removeClass('active');

            } else {
                Format = 2;
            }
        });

        $('.fa-stopwatch').on('click',function(){
            $('body').removeClass('BgAnimation');
            $('.H1').fadeIn();
            if( !($('.TimeHolder').hasClass('StopWatch')) )
            {
                Format = 3;
                resetTimer();
                StopChecker = 1;
                $('.TimeHolder').removeClass().addClass('TimeHolder StopWatch');
                $('.Numbers').fadeIn(0);
                $('.Pause').removeClass('active');
                $('.Start').addClass('active');
                TimeHolder = 0;
            }
        });

        $('.Start').on('click',function(){
            $('body').removeClass('BgAnimation');
            if(Format===3){
                StopChecker = 0;
                $(this).removeClass('active');
                $('.Pause').addClass('active');
            } else if(Format===4){
                TimeHolder = $('.AlarmInput input').val();
                if(TimeHolder>0){
                    StopChecker = 0;
                    resetTimer();
                    $(this).removeClass('active');
                    $('.Pause').addClass('active');
                    $('.AlarmInput').addClass('DisNone');
                    $('.Numbers').fadeIn(0);
                }
            }
        });

        $('.Pause').on('click',function(){
            StopChecker = 1;
            $(this).removeClass('active');
            $('.Start').addClass('active');
        });

        $('.Stop').on('click',function(){
            $('body').removeClass('BgAnimation');
            if(Format===3){
                StopChecker = 1;
                TimeHolder = 0;
                resetTimer();
                $('.Pause').removeClass('active');
                $('.Start').addClass('active');
            } else if(Format===4){
                resetTimer();
                StopChecker = 1;
                $('.AlarmInput').removeClass('DisNone');
                $('.Numbers').fadeOut(0);
                $('.AlarmInput input').val("");
                $('.Pause').removeClass('active');
                $('.Start').addClass('active');
            }
        });

        $('.fas.fa-clock').on('click',function(){
            $('body').removeClass('BgAnimation');

            if( ( $('.Type .active').html() ) === '12hr' ){
                Format=2;
            } else {
                Format=1;
            }

            StopChecker = 0;
            $('.TimeHolder').removeClass().addClass('TimeHolder');
            $('.Numbers').fadeIn(0);
        });


        $('.far.fa-clock').on('click',function(){
            $('body').removeClass('BgAnimation');
            $('.H1').fadeIn();
            if( !($('.TimeHolder').hasClass('Alarm')) )
            {
                $('.TimeHolder').removeClass().addClass('TimeHolder Alarm');
                Format = 4;
                resetTimer();
                StopChecker = 1;
                $('.AlarmInput').removeClass('DisNone');
                $('.TimeHolder').addClass('Alarm');
                $('.Numbers').fadeOut(0);
                $('.Pause').removeClass('active');
                $('.Start').addClass('active');
            }
        });

        // Alarm Out
        function AlarmOut(){
            $('body').addClass('BgAnimation');
            resetTimer();
            StopChecker = 1;
        }


        update_time();

Leave a Reply