Pen Settings

HTML

CSS

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

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

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.

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 ng-app="Pomodoro" ng-controller="PomodoroController" ng-cloak>

  <audio id='alert' src="https://www.optimalist.gg/wp-content/uploads/2020/10/346328__steaq__bright-tibetan-bell-ding-b-note-cleaner.wav" preload='auto'></audio>
  <div layout='column'>
    <md-content layout='row' class='md-padding' layout-align='end'>
      <md-button ng-click='showSettings()'>Settings</mb-button>

    </md-content>
    <div layout='row' layout-align='center'>
      <h1>{{length[session] | timer}} {{sessions[session]}}</h1>
    </div>
    <div layout='row' layout-align='center'>
      <p class='md-display-4'>{{time | timer}}</p>
    </div>
    <div layout='row' layout-align='center'>
      <md-button class='md-accent md-raised' ng-click='timer()' ng-hide='isRunning()'>start</md-button>
      <md-button ng-click='stop()' ng-show='isRunning()' class='ng-hide md-accent'>pause</md-button>
      <md-button ng-click='stop()'>stop</md-button>
    </div>
    <md-progress-linear md-mode="determinate" value='{{time/length[session]*100}}'></md-progress-linear>
  </div>
</div>

              
            
!

CSS

              
                md-content {
  border: 1px solid #e1e1e1;
}

/* md-dialog {
  width: 100%;
} */

.tab {
  margin: 25px;
}


              
            
!

JS

              
                var app = angular.module('Pomodoro', ['ngMaterial']);

app.controller('PomodoroController', function($scope, $timeout, $mdDialog, $document) {
  $scope.sessions = ['Breathing Session', 'Log ending mood or start another breathing session.'];
  $scope.session = 0;

  $scope.length = [];
  $scope.length[0] = 120; // seconds
  $scope.length[1] = 1;
  $scope.time = 0;
  var timerPromise;
  $scope.timer = function() {
    $scope.time += 1;
    if ($scope.time < $scope.length[$scope.session]) {
      timerPromise = $timeout($scope.timer, 1000);
    } else {
  playSound();
      $scope.next();
    }
  };
  $scope.stop = function() {
    $timeout.cancel(timerPromise);
  };
  $scope.isRunning = function() {
    return timerPromise.$$state.status == 0;
  };
  $scope.next = function() {
    $scope.stop();
    $scope.session = $scope.session == 0 ? 1 : 0;
    $scope.time = 0;
  }
  function playSound() {
    document.getElementById('alert').play();
  }
  var html = `

<md-dialog flex='90' flex-gt-sm='50'>
  <md-dialog-content>
    <md-tabs>
      <md-tab label='Breathing'>
        <div class='tab' layout='column' layout-align='center'>
          <p>The length of the breathing session is {{length[0] | timer}}</p>
          <md-slider step='5' ng-model='length[0]' min='5' max='1800'></md-slider>
        </div>
      </md-tab>
      <md-tab label='Start another breathing session'>
        <div class='tab'>
          <p>Start another breathing session {{length[1] | timer}}. Don't forget to log your ending mood!</p>
          <md-slider step='5' ng-model='length[1]' min='5' max='600'></md-slider>
        </div>
      </md-tab>
    </md-tabs>
  </md-dialog-content>
  <md-dialog-actions>
    <md-button ng-click='closeDialog()'>ok</md-button>
  </md-dialog-actions>
</md-dialog>
`;
  $scope.showSettings = function($event) {
    var parentEl = angular.element(document.body);
    $mdDialog.show({
      parent: parentEl,
      targetEvent: $event,
      template: html,
      locals: {
        length: $scope.length
      },
      controller: SettingsController,
      clickOutsideToClose: true
    }).then(function(answer) {
      $scope.length = answer.length;
    });

    function SettingsController($scope, $mdDialog, length) {
      $scope.length = length;
      $scope.closeDialog = function() {
        $mdDialog.hide($scope);
      }
    }
  }
});

app.filter('timer', function() {
  function pad(n) {
    return n < 10 ? "0" + n : n;
  }
  return function(seconds, time) {
    var minutes = parseInt(seconds / 60, 10)
    var seconds = parseInt(seconds % 60, 10)
    var time = pad(minutes) + ":" + pad(seconds);
    return time;
  };
});
              
            
!
999px

Console