Skip to content

Instantly share code, notes, and snippets.

@deanhume
Created February 9, 2012 10:22
Show Gist options
  • Save deanhume/1779089 to your computer and use it in GitHub Desktop.
Save deanhume/1779089 to your computer and use it in GitHub Desktop.
Blog TinyCon
<input type="hidden" id="blogCount" name="blogCount" value="<%= TempData["TotalPageCount"] %>" />
<script type="text/javascript">
// Check if user can handle localStorage first.
if (typeof (localStorage) != 'undefined') {
GetCount();
}
function GetCount() {
// Get the last value
var blogCount = localStorage.getItem('blogCount');
// If null, then set it
if (blogCount == null) {
localStorage.setItem("blogCount", document.getElementById('blogCount').value); //saves to the database, "key", "value"
} else {
// If not null then check the last count and compare
var result = document.getElementById('blogCount').value - blogCount;
// If different, then show the favicon bubble
if (result > 0) {
if (result != document.getElementById('blogCount').value) {
window.Tinycon.setBubble(result);
// Re-add to localStorage
localStorage.setItem("blogCount", document.getElementById('blogCount').value); //saves to the database, "key", "value"
}
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment