Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit a49e852f7697bfde871c5751d623d9d2cc85da43 1 parent 994cd08
@brettle authored
Showing with 55 additions and 8 deletions.
  1. BIN  audio/HowsItGoing.wav
  2. +10 −3 index.html
  3. +45 −5 js/script.js
View
BIN  audio/HowsItGoing.wav
Binary file not shown
View
13 index.html
@@ -35,9 +35,16 @@
<header>
</header>
- <div role="main">
-
- </div>
+ <div role="main">
+ <p>This application estimates the percentage of time you are paying attention to your task by randomly asking you
+ whether you are on task or distracted. It will automatically adapt the expected interval between prompts based
+ on your past performance.</p>
+ <p>You're current efficiency is:</p>
+ <div>
+ <span id="efficiency"></span>% based on <span id="samples"></span> samples.
+ </div>
+ <audio id="audioPrompt" preload=auto src="audio/HowsItGoing.wav"></audio>
+ </div>
<footer>
</footer>
View
50 js/script.js
@@ -1,8 +1,48 @@
-/* Author:
-
-*/
-
-
+/* Author: Dean Brettle
+ * Copyright 2011
+ * Licensed under the terms of the AGPL3.
+ */
+as = {
+ interval: 60000,
+ factor: 1.2,
+ efficiency: 0.0,
+ history: [],
+ focusedCount: 0,
+ start: function() {
+ window.setTimeout(as.playAudio, 10000 + as.interval * Math.random());
+ },
+ playAudio: function() {
+ var audioPrompt;
+ if (!audioPrompt) {
+ audioPrompt = $("#audioPrompt")[0];
+ audioPrompt.addEventListener("ended", as.prompt);
+ }
+ audioPrompt.currentTime = 0.0;
+ audioPrompt.play();
+ },
+ prompt: function() {
+ var focused = window.confirm("How's it going?");
+ if (focused) {
+ as.interval = as.interval * as.factor;
+ }
+ else {
+ as.interval = as.interval / as.factor;
+ }
+ as.history.push(focused);
+ as.focusedCount += focused;
+ as.efficiency = 1.0*as.focusedCount/as.history.length;
+ as.displayStats();
+ as.start();
+ },
+ displayStats: function() {
+ $("#efficiency").html(Math.round(as.efficiency*100));
+ $("#samples").html(as.history.length);
+ }
+};
+$(function() {
+ as.displayStats();
+ as.start();
+});
Please sign in to comment.
Something went wrong with that request. Please try again.