Created
February 18, 2013 16:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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