go-totp/static/main.js

23 lines
736 B
JavaScript
Raw Normal View History

2020-09-15 07:48:54 +00:00
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function update() {
var d = new Date()
console.log(d.getMilliseconds())
}
function send() {
var secret = document.getElementsByClassName("secretBox")[0].value;
var xhr = new XMLHttpRequest();
xhr.open("POST", "/calculate", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
secret: secret,
}));
xhr.onload = function() {
document.getElementsByClassName("totp-response-code")[0].innerHTML = JSON.parse(this.responseText)["code"];
document.getElementsByClassName("totp-response-time")[0].innerHTML = JSON.parse(this.responseText)["time"];
}
}