Skip to content

Instantly share code, notes, and snippets.

@aflores
Created November 4, 2014 00:04
Show Gist options
  • Save aflores/4453336b3f352da0aa8b to your computer and use it in GitHub Desktop.
Save aflores/4453336b3f352da0aa8b to your computer and use it in GitHub Desktop.
javascript clock
----
In ASP.NET CODE
HttpCookie cookie = Request.Cookies["OldCookieName"];
cookie.Values["CompanyID"] = Convert.ToString(CompanyId);
Response.SetCookie(cookie); //SetCookie is used for update the cookies.
Response.Cookie.Add(cookie); //This is used for Add cookies.
----
In the page where you want to show the clock
<div id='clock-container' style='text-align:center;width:350px;border:solid 1px #333;padding:5px;margin:10px'>
<a id="toggle-clock" href="#">Toggle Clock</a>
<div id='clock-span' style='display:none;padding:10px;background-color:#cfc;'>asdlfkjalksdjf</div>
</div>
<script>
function refreshClock() {
$('#clock-span').text(new Date());
setTimeout(function() {
refreshClock();
},1000);
}
$(function(){
$('#toggle-clock').on('click',function() {
refreshClock();
$('#clock-span').toggle();
})
});
</script>
----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment