Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <link href="//cdn.jsdelivr.net/picnicss/4.1.1/picnic.min.css" rel="stylesheet">
  <script src="//rawgit.com/magnumjs/mag.js/master/dist/mag.0.20.6.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <h1>Hello Mag.JS!</h1>
  <a target="_top" href="https://github.com/magnumjs/mag.js">GitHub</a>
  <hr/>
  <div id="countdown">
    <h1></h1>
  </div>
  <script src="//rawgit.com/magnumjs/mag.js/master/src/mag.addons.0.2.js"></script>
</body>
</html>
 
.hide {
  display: none;
}
a {
  display: block;
}
a:after {
  content: " \bb";
}
 
/* MagJS - Example - birthday countdown */
// From: https://www.bignerdranch.com/blog/how-to-use-facebooks-react-library-to-build-UIs/
var ExampleApplication = mag.create('countdown', {
  view: function(state, props) {
    var elapsed = Math.round(props.elapsed / 100);
    var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0');
    var message = 'Hooray! Another year in ' + seconds + ' seconds.';
    state.h1 = message
  }
});
var bday = new Date("October 10, 2015 08:12:00");
setInterval(function() {
  ExampleApplication({
    elapsed: bday.getTime() - new Date().getTime()
  })
}, 100);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers