Permalink
Browse files

Adding reset method

  • Loading branch information...
1 parent 56b2e35 commit dc64b304829b4f0e181049deab767fdcb37702fb Rob Flaherty committed Jul 27, 2015
Showing with 14 additions and 5 deletions.
  1. +11 −2 screentime.js
  2. +3 −3 test/index.html
View
@@ -164,7 +164,7 @@
});
if (!$.isEmptyObject(data)) {
- options.callback.call(this, data);
+ options.callback.call(this, data, log);
}
}
@@ -187,10 +187,19 @@
}
function stopTimers() {
-
clearInterval(looker);
clearInterval(reporter);
+ }
+ $.screentime.reset = function() {
+ stopTimers();
+
+ $.each(cache, function(key, val) {
+ log[key] = 0;
+ counter[key] = 0;
+ });
+
+ startTimers();
}
function init() {
View
@@ -24,8 +24,7 @@
<div id="middle" style="background: #ddd; height: 300px">#middle</div>
<div id="bottom" style="background: #ccc; height: 1000px">#bottom</div>
<div id="end" style="background: #bbb; height: 1000px">#end</div>
-
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../screentime.js"></script>
<script>
$.screentime({
@@ -46,8 +45,9 @@
],
reportInterval: 3,
googleAnalytics: false,
- callback: function(data) {
+ callback: function(data, log) {
console.log(data);
+ console.log(log);
}
});
</script>

0 comments on commit dc64b30

Please sign in to comment.