check invalid and complete statuses
This commit is contained in:
parent
148cda8516
commit
79648af88c
|
@ -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];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue