add a max duration to key, change a method from get to post

This commit is contained in:
daniel-j
2020-03-04 15:16:07 +01:00
parent e30dc08861
commit 9bde12b2be
2 changed files with 15 additions and 11 deletions

View File

@@ -34,17 +34,17 @@ var downloadlink = document.getElementById('downloadlink')
var key = null
var pollTimer = null
function xhr(url, cb) {
function xhr(method, url, cb) {
var x = new XMLHttpRequest()
x.onload = function () {
cb(x)
}
x.open('GET', url, true)
x.open(method, url, true)
x.send(null)
}
function pollFile () {
xhr('/status/' + key, function (x) {
xhr('GET', '/status/' + key, function (x) {
var data
try {
data = JSON.parse(x.responseText)
@@ -67,7 +67,7 @@ function generateKey () {
keyOutput.textContent = '- - - -'
if (pollTimer) clearInterval(pollTimer)
downloads.style.display = 'none'
xhr('/generate', function (x) {
xhr('POST', '/generate', function (x) {
keyOutput.textContent = x.responseText
if (x.responseText !== 'error') {
key = x.responseText