check invalid and complete statuses

This commit is contained in:
AJ ONeal 2018-06-21 06:23:16 +00:00
parent 148cda8516
commit 79648af88c
1 changed files with 19 additions and 0 deletions

View File

@ -3,6 +3,7 @@
var meta = {}; var meta = {};
var magic; var magic;
var domainname;
function checkStatus() { function checkStatus() {
// TODO use Location or Link // TODO use Location or Link
@ -36,7 +37,24 @@ function submitCode(pair) {
, cors: true , cors: true
}).then(function (resp) { }).then(function (resp) {
return resp.json().then(function (data) { return resp.json().then(function (data) {
// TODO check for error (i.e. bad Pair Code / PIN)
// shouldn't be pending (because we get here by being ready)
// should poll over 'ready'
if ('invalid' === data.status) {
window.alert("something went wrong");
return;
}
if ('complete' === data.status) {
setTimeout(function () {
window.document.body.innerHTML += ('<img src="https://' + domainname + '/">');
// TODO once this is loaded (even error) Let's Encrypt is done,
// then it's time to redirect to the domain. Yay!
}, 1 * 1000);
return;
}
setTimeout(checkStatus, 0); setTimeout(checkStatus, 0);
document.querySelector('.js-authz').hidden = false; document.querySelector('.js-authz').hidden = false;
console.log(data); console.log(data);
/* /*
@ -45,6 +63,7 @@ function submitCode(pair) {
}); });
*/ */
document.querySelectorAll('.js-new-href').forEach(function ($el) { document.querySelectorAll('.js-new-href').forEach(function ($el) {
domainname = data.domains[0];
$el.href = 'https://' + data.domains[0] + '/'; $el.href = 'https://' + data.domains[0] + '/';
$el.innerText = '🔐 https://' + data.domains[0]; $el.innerText = '🔐 https://' + data.domains[0];
}); });