Skip to content

Instantly share code, notes, and snippets.

@rashad612
Forked from alaahaytham/gist:3027851
Created July 1, 2012 10:35
Show Gist options
  • Save rashad612/3027859 to your computer and use it in GitHub Desktop.
Save rashad612/3027859 to your computer and use it in GitHub Desktop.
function getUnreadItems() {
$.ajax({
url : "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=" + account + "&count=1",
dataType : "jsonp",
success: function(results) {
var id = results['0'].id;
var text = results['0'].text;
var initialValue = results['0'].id;
var avatar = results['0'].user.profile_image_url;
$('#avatar img').attr("src", avatar);
$('#tweet').text(text);
localStorge['id'] = localStorge['id'] || null;
if (localStorage['id'] !== initialValue) {
localStorage['id'] = id;
var n = window.webkitNotifications.createNotification('', 'New Tweet', localStorage['text']);
n.show();
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment