telebit-relay.js/lib/extensions/admin/login/js/app.js

30 lines
971 B
JavaScript
Raw Normal View History

2018-06-15 08:45:47 +00:00
(function () {
'use strict';
var magic = (window.location.hash || '').substr(2).replace(/magic=/, '');
if (magic) {
window.fetch('https://api.' + location.hostname + '/api/telebit.cloud/magic/' + magic, {
method: 'GET'
, cors: true
}).then(function (resp) {
return resp.json().then(function (json) {
2018-06-15 09:00:16 +00:00
if (json.error) {
document.querySelector('.js-error').hidden = false;
document.querySelector('.js-magic-link').innerText = magic;
return;
}
2018-06-15 08:45:47 +00:00
document.querySelector('body').hidden = false;
2018-06-15 09:00:16 +00:00
document.querySelector('.js-magic').hidden = false;
document.querySelector('.js-token-data').innerText = JSON.stringify(json, null, 2);
document.querySelector('.js-new-href').href = json.domains[0];
document.querySelector('.js-new-href').innerText = json.domains[0];
2018-06-15 08:45:47 +00:00
});
});
} else {
document.querySelector('body').hidden = false;
2018-06-15 09:00:16 +00:00
document.querySelector('.js-error').hidden = false;
2018-06-15 08:45:47 +00:00
}
}());