Permalink
Browse files

fancier demo

  • Loading branch information...
substack committed Jul 4, 2011
1 parent e2b99dc commit 6826d21cad7336df7a7c92b73984931132d09e8f
Showing with 31 additions and 6 deletions.
  1. +1 −2 browser.js
  2. +12 −0 example/progress/index.html
  3. +18 −4 example/progress/main.js
View
@@ -2,7 +2,6 @@ var $ = require('jquery-browserify');
module.exports = function () {
var div = $('<div>').css({
- float : 'right',
'margin-right' : '5px',
height : '40px',
width : '200px'
@@ -12,7 +11,7 @@ module.exports = function () {
.text('0%')
.css({
position : 'absolute',
- width : '150px',
+ width : '190px',
'font-weight' : 'bold',
'z-index' : 10,
'text-align' : 'center',
@@ -1,8 +1,20 @@
<html>
<head>
<script type="text/javascript" src="/browserify.js"></script>
+ <style type="text/css">
+ #msg {
+ height: 1em;
+ margin-bottom: 0.5em;
+ font-weight: bold;
+ font-family: monospace;
+ }
+ </style>
</head>
<body>
+ <div id="msg">
+ Computing...
+ <span id="done">_</span>
+ </div>
<div id="p"></div>
</body>
</html>
View
@@ -5,8 +5,22 @@ $(window).ready(function () {
var p = progressify();
p.appendTo($('#p'));
- var iv = setInterval(function () {
- var dx = Math.floor(Math.random() * 3);
- p.percent(p.percent() + dx);
- }, 100);
+ var iv0 = setInterval(function () {
+ p.percent(p.percent() + 1);
+
+ if (p.percent() === 100) {
+ clearInterval(iv0);
+ clearInterval(iv1);
+ $('#done').text('done');
+ }
+ }, 50);
+
+ var iv1 = setInterval(function () {
+ if ($('#done').text() === ' ') {
+ $('#done').text('_');
+ }
+ else {
+ $('#done').text(' ');
+ }
+ }, 500);
});

0 comments on commit 6826d21

Please sign in to comment.