Created
October 7, 2011 16:34
-
-
Save pushmatrix/1270734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Test</title> | |
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/master/lib/es5-shim.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/master/lib/batman.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/master/lib/batman.solo.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/master/lib/coffee-script.js"></script> | |
</head> | |
<body> | |
<div id="container"> | |
<div data-foreach-caller="Caller.all.sortedBy.createdAt" data-mixin="animation"> | |
<span data-bind="caller.number"></span>--- on hold for <span data-bind="caller.holdTime"></span> seconds | |
</div> | |
</div> | |
<script type="text/coffeescript"> | |
class MyApp extends Batman.App | |
@global yes | |
class Caller extends Batman.Model | |
@persist Batman.LocalStorage | |
@global yes | |
@encode 'number', 'createdAt' | |
constructor: (number, createdAt) -> | |
super() | |
@set 'number', number | |
@set 'createdAt', new Date().getTime() | |
@accessor 'holdTime', -> | |
Math.round((new Date() - @get('createdAt')) * 0.001) | |
setInterval(=> | |
@get('all').forEach (caller) -> | |
caller.set 'holdTime' | |
, 1000) | |
MyApp.run() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment