go-totp/static/main.js
2020-09-15 09:48:54 +02:00

23 lines
736 B
JavaScript

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"];
}
}