andrewb icon

Test Counter

andrewb | PRO | 06/17/15 03:23:49 PM UTC | 0 ⭐ | 1049 👁️ | Never ⏰ | []
HTML 5 |

0 B

|

None

|

0 👍

/

0 👎

<!DOCTYPE html>
<html>
<head>
<title>test on iphone</title>
<script>
 
var Test = (function() {
    function Test() {
        this.counter = 0;
        this.value = 1;
    }
 
  Test.prototype.Add = function() {
    this.counter += this.value;
  };
 
  Test.prototype.Flip = function() {
    this.value *= -1;
  };
 
  Test.prototype.Go = function(scope) {
    var body = document.getElementsByTagName("h1")[0];
    body.innerHTML = scope.counter;
    scope.Add();
    if (scope.counter == 10)
      scope.Flip();
    else if (scope.counter==0)
      scope.Flip();
    setTimeout(scope.Go, 1000, scope);
  };
 
  return Test;
})();
 
</script>
<style type="text/css">
h1 { text-align: center; font-size: 72pt; }
</style>
</head>
<body>
<h1>hello. world!</h1>
<script>
var t = new Test();
t.Go(t);
</script>
</body>
</html>

Comments