Last active
August 29, 2015 14:15
-
-
Save acrogenesis/60368b9c504ba15ed72a to your computer and use it in GitHub Desktop.
Returns timestamp
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
<html> | |
<head> | |
<title>Timestamp</title> | |
</head> | |
<script> | |
var myTimer; | |
function getTime(){ | |
var xmlhttp; | |
var span; | |
if (window.XMLHttpRequest) | |
{// code for IE7+, Firefox, Chrome, Opera, Safari | |
xmlhttp=new XMLHttpRequest(); | |
} | |
else | |
{// code for IE6, IE5 | |
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
xmlhttp.onreadystatechange=function() | |
{ | |
if (xmlhttp.readyState==4 && xmlhttp.status==200) | |
{ | |
p = document.createElement("p"); | |
p.innerText = xmlhttp.responseText | |
document.getElementById("timestamps").appendChild(p); | |
} | |
} | |
xmlhttp.open("GET","http://localhost:4567/",true); | |
xmlhttp.send(); | |
} | |
function startGetTime(){ | |
getTime(); | |
myTimer = setInterval(function(){ getTime(); }, 20000); | |
} | |
function stopGetTime(){ | |
clearInterval(myTimer); | |
} | |
</script> | |
<body> | |
<button name="button" onclick="startGetTime();">Start</button> | |
<button name="button" onclick="stopGetTime();">Stop</button> | |
<div id="timestamps"> | |
</div> | |
</body> | |
</html> |
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
require 'sinatra' | |
get '/' do | |
response['Access-Control-Allow-Origin'] = '*' | |
Time.now.to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment