Permalink
Browse files

Readme and instructions

  • Loading branch information...
1 parent 46528f9 commit b70ff57241ddc2525ed79f017fcfd1cf19430b7e @benbrown benbrown committed Nov 28, 2012
Showing with 526 additions and 3 deletions.
  1. +20 −2 aware.js
  2. +395 −0 demo.html
  3. +1 −1 index.html
  4. +110 −0 readme.md
  5. BIN shkmark_example.png
View
@@ -42,7 +42,7 @@
return str+'s';
}
}
-
+
function relativeTimestamp(ms) {
var seconds = Math.floor(ms / 1000);
@@ -110,10 +110,12 @@
var settings = {
dateAttribute: 'data-pubDate',
- permalinkClass: '.permalink',
bufferTime: 60*60*1000 // by default, leave things new if they are an hour old or less
}
+
+ var reader = {};
+
$.extend(settings,options);
@@ -126,17 +128,27 @@
if (!lastVisit) {
setLastVisit(now);
$('body').addClass('first-visit');
+ reader.lastVisit = now;
+ reader.firstVisit = true;
+ reader.secondsSinceLastVisit = 0;
+ window.reader = reader;
+
return;
} else {
lastVisit = new Date(lastVisit);
+ reader.lastVisit = lastVisit;
}
if (lastVisit.getDOY() < now.getDOY()) {
$('body').addClass('first-visit-of-day');
$('body').addClass('repeat-visitor');
+ reader.firstVisitOfDay = true;
+ reader.repeatVisitor = true;
+
} else {
if (!$('body').hasClass('first-visit')) {
$('body').addClass('repeat-visitor');
+ reader.repeatVisitor = true;
}
}
@@ -156,6 +168,12 @@
});
+
+ reader.secondsSinceLastVisit = Math.floor((now-lastVisit)/1000);
+ reader.timeSinceLastVisit = relativeTimestamp(now-lastVisit);
+
+ window.reader = reader;
+
setLastVisit(now);
}
Oops, something went wrong.

0 comments on commit b70ff57

Please sign in to comment.