css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
      integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
      crossorigin="anonymous">
    
    <!-- jQuery first (with ajax here), then Popper.js, then Bootstrap JS -->
    <script
      src="https://code.jquery.com/jquery-3.3.1.min.js"
      integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
      crossorigin="anonymous">
    </script>

    <!-- Optional JavaScript, needed for scrollspy -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
      integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
      crossorigin="anonymous"></script>

    <!-- bootstrap JS -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    
<script
			  src="https://code.jquery.com/jquery-3.3.1.min.js"
			  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
			  crossorigin="anonymous"></script>

    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" 
    rel="stylesheet" 
    integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">


    <!-- Font awesome icons -->
    <script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" defer></script>
    
    <!--  jQuery countdown  -->

    <script src="C:\Users\adam\Desktop\pomodoro clock\jquery.countdown-2.1.0/jquery.countdown.min.js"></script>
    
    <!--  google fonts  -->
    <link href="https://fonts.googleapis.com/css?family=Dancing+Script" rel="stylesheet"> 
    <link href="https://fonts.googleapis.com/css?family=Source+Serif+Pro" rel="stylesheet"> 
    
    <!-- my css file -->
    <link rel="stylesheet" href="style.css">
    
    <!-- my script file -->
    <script src="script.js"></script>
   
    <title>Pomodoro clock</title>
  </head>
  <body>
      <style>
    body { background-color: #333333; }
  </style>
    
    <div class="container-fluid">

        
      
       <div class="row" id="input-area">
       
        <div class="col-sm-5">
            <h1 class="text-center" id="play-text">Play Time</h1>
            <div class="row">
                


                <div class="col-sm-12" id="play-time">
                    
                    <div class="row">
                        <button class="btn btn-primary">+</button>
                    </div>
                    
                    
                    <h2 id="play-time-value">5</h2>
                    <div class="row">
                        <button class="btn btn-primary">-</button>
                    </div>
                </div>


            
            </div>
        </div>
        
        <div class="col-sm-2">
        </div>

        <div class="col-sm-5">
            <h1 class="text-center" id="work-text">Work Time</h1>
            <div class="row">
                
                <div class="col-sm-12" id="work-time">
                    
                    <div class="row">
                        <button class="btn btn-primary">+</button>
                    </div>
                    
                    
                    <h2 id="work-time-value">25</h2>
                    <div class="row">
                        <button class="btn btn-primary">-</button>
                    </div>
                </div>
            
            </div>
        </div>
           
       </div>
    
        <div class="row" id="control-button-area">
            
               <div class="col-sm-12">
                <button class="btn btn-success" id="control-button">Go!</button>
                   
               </div>
        </div>
                
                
        <div class="row" id="notifcation-area">
            
            <div class="col-sm-12">
                
                <h1 id='current-session'>Session</h1>
                
            </div>
            
        </div>
                
                
        <div class="row" id="display-area">

            <div class="col-sm-12">




                <h2 id="session-time">25</h2>

                
                
                


<!--
                <div class="progress position-relative">
                    <div class="progress-bar" role="progressbar" style="width: 60%" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"></div>
                    <small class="justify-content-center d-flex position-absolute w-100"><p id="progress-text">what</p></small>
                </div>
-->
                <div id="clock"></div>
            </div>
            
            
            
        </div>
        

    </div>
    
  </body>
</html>
            
          
!
            
              body {
    background: #333333;
}

.container-fluid {
    background: #333333;
    color: white;
}

h1 {
    font-size: 1.5em;
}

h2 {
    font-size: 1.5em;
    margin-top: 2%;
    margin-bottom: 3%;
}

#input-area, #display-area {
    
    /* margin-top: 8%; */
    padding-top: 8%;
    text-align: center;
    
    max-width: 375px;
    
    margin-left: auto;
    margin-right: auto;
/*    border: solid;*/
}

#display-area {
    padding-top: 2%;
}


#play-text {
    font-family: 'Dancing Script', cursive;
}

#work-text {
    font-family: 'Source Serif Pro', serif;
}

/* labels for play and work */
.text-center {
    margin-bottom: 10%;
}



#play-time {
/*    display: inline;*/
/*    border: solid;*/
}

#work-time {
/*    display: inline;*/
/*    border: solid;*/
}

.btn {
    
    width: 80%;

    margin: auto;
}

/**
 * Progress bars with centered text
 */

.progress {
/*    position: relative;*/
    color: white;
    
    
    background: blue;
    
/*    max-width: 100%;*/
    
/*    the only thing that seems to change anything */
    min-height: 200px;
}

#control-button-area {
    
    margin: 2%;
    width: 90%;
    text-align: center;
    max-width: 375px;
/*    max-width: 375px;*/
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 0;
}

#control-button {
    width: 100%;
}

#notifcation-area {
    text-align: center;
}

#current-session {
    padding-top: 5%;
    padding-bottom: 0%;
    font-size: 2em;
}

#display-area {
    margin-top: 0%;
/*    border: solid green;*/
    min-height: 200px;
}

#session-time {
    padding-top: 0%;
    padding-bottom: 0%;
    font-size: 4em;
}


            
          
!
            
              $( document ).ready(function() {

    // tests the script is being loaded
    // alert('test');

    // $.noConflict();
    // jQuery(document).ready(function($){
    //    alert('jQuery is working');
    // });

    var playTime = 5;
    var workTime = 25;
    var currentSession = 'work';
    var countDown = false;
    var secondsRemaining;
    var workHasRun = false;
    var playHasRun = false;
    var intervalHandle;
    
    
    
    
    $('#session-time').text(workTime);
    
    function decrementTime() {
        secondsRemaining--;
    }
    
    
    function remainingTime() {
        var min = Math.floor(secondsRemaining / 60);
        var sec = secondsRemaining - (min * 60);
        // add a leading zero (as a string value) if seconds less than 10
        if (sec < 10) {
            sec = "0" + sec;
        }
        
        let message = min + ":" + sec;
        $('#session-time').text(message);
        
        if( secondsRemaining <= 0 ) {
            clearInterval( intervalHandle );
            $('#session-time').text('0:00');
            
            if( currentSession == 'work' ) {
                currentSession = 'play';
                console.log(currentSession)
                playHasRun = false;
                workHasRun = false;
                runCountdown();
                
            } else if( currentSession == 'play' ) {
                console.log('should be setting PLAY HERE')
                playHasRun = false;
                workHasRun = false;
                currentSession = 'work';
                console.log(currentSession)
                runCountdown();
            }
        }
    }
    
    // controls the buttons behaviour when running and stopped
    $('#control-button').click(function() {
        if( countDown == false ) {
            countDown = true;
            console.log('call countdown method and disable buttons')
            runCountdown();
            $('.btn-primary').prop('disabled', true);
        } else {
            clearInterval(intervalHandle);
            countDown = false;
            console.log('enable buttons')
            $('.btn-primary').prop('disabled', false);
        }
        
        var btnClss = $('#control-button').attr("class");
        
        if (btnClss == "btn btn-success") {
            $('#control-button').addClass("btn-warning").removeClass("btn-success");
            $('#control-button').text("Pause");
            
            console.log( $('#control-button').attr("class") )
        } else {
            $('#control-button').addClass("btn-success").removeClass("btn-warning");
            $('#control-button').text("Go!");
        }
    });
    
    function runCountdown() {
        
        if( workHasRun || playHasRun ) {
            decrementTime();
            intervalHandle = setInterval(tick, 1000);

        } else {
            
            if( currentSession == 'work' ) {
                $('#current-session').text('werk werk werk');
                
                secondsRemaining = workTime * 60;
                console.log('getting to work here?')
                workHasRun = true;
            } else if( currentSession == 'play' ) {
                $('#current-session').text('playful joy');
                
                console.log('getting to play here?')
                secondsRemaining = playTime * 60;
                playHasRun = true;
            }
            decrementTime();
            remainingTime();
            
            intervalHandle = setInterval(tick, 1000);

            
        }

    }
    
    
    
    function tick() {
        
        decrementTime();
        remainingTime();
    }
    
    
    
    if( currentSession == 'work' ) {
        $('#current-session').text('werk werk werk');
    } 
    
    if( currentSession == 'play' ) {
        $('#current-session').text('playful joy');
    } 
    
    function displayTime(variable) {
        console.log(variable);
        
        if( variable == playTime ) {
            $('#play-time-value').text( playTime );
        }
        
        if( variable == workTime ) {
            $('#work-time-value').text( workTime );
            
            if( !workHasRun ) {
                $('#session-time').text( workTime );
                
            }
        }
    }
    
    
    
    $('#play-time').find('.btn').click(function() {
        playHasRun = false;
//        console.log('testicles', $(this).text());
        let value = $(this).text();
        
        if( value == '-' ) {
            console.log('a minus sign')
            
            if( playTime > 0 ) {
                playTime--;
            }
            displayTime( playTime );
        }
        
        if( value == '+' ) {
            console.log('a plus sign')
            playTime++;
            displayTime( playTime );
        }
    });
    
    $('#work-time').find('.btn').click(function() {
        workHasRun = false;
        console.log('testicles', $(this).text());
        
        let value = $(this).text();
        
        if( value == '-' ) {
            console.log('a minus sign')
            
            if( workTime > 0 ) {
                workTime--;
            }
            displayTime( workTime );
        }
        
        if( value == '+' ) {
            console.log('a plus sign')
            workTime++;
            displayTime( workTime );
        }
    });
    
    
    
    
    
    
    
    
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console