Skip to content

Instantly share code, notes, and snippets.

@seb-thomas
Created February 18, 2013 16:29
Show Gist options
  • Save seb-thomas/4978601 to your computer and use it in GitHub Desktop.
Save seb-thomas/4978601 to your computer and use it in GitHub Desktop.
Some js to help us see if a page has been updated while we've been staring at it like zombied smack addicts.
var YOUR_API_KEY = ''
var dateUpdated = "";
function changeTitle() {
var favi = jQuery('[rel="shortcut icon"]');
var titleDate = jQuery('p.author a').last().attr('title');
var reDate = /(\d+)\/(\d+)\/(\d+)/;
//Swap year and day, convert to Date obj
titleDate = (titleDate).replace(reDate, "$3/$2/$1");
titleDate = new Date(Date.parse(titleDate))
jQuery.get(
location.pathname + '.json',
{key: YOUR_API_KEY},
function(data){
dateUpdated = data.issue.updated_on;
dateUpdated = new Date(Date.parse(dateUpdated));
if (dateUpdated.getTime() > titleDate.getTime()) {
setTimeout(changeTitle, 3000);
favi.attr('href', 'http://cdn.dustball.com/time_add.png');
}
}
);
}
changeTitle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment