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 magic;
var domainname;
function checkStatus() {
// TODO use Location or Link
@ -36,7 +37,24 @@ function submitCode(pair) {
, cors: true
}).then(function (resp) {
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);
document.querySelector('.js-authz').hidden = false;
console.log(data);
/*
@ -45,6 +63,7 @@ function submitCode(pair) {
});
*/
document.querySelectorAll('.js-new-href').forEach(function ($el) {
domainname = data.domains[0];
$el.href = 'https://' + data.domains[0] + '/';
$el.innerText = '🔐 https://' + data.domains[0];
});