50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
|
(function () {
|
||
|
"use strict";
|
||
|
|
||
|
// AJQuery
|
||
|
function $(sel, el) {
|
||
|
if (!el) {
|
||
|
el = document;
|
||
|
}
|
||
|
return el.querySelector(sel);
|
||
|
}
|
||
|
function $$(sel, el) {
|
||
|
if (!el) {
|
||
|
el = document;
|
||
|
}
|
||
|
return el.querySelectorAll(sel);
|
||
|
}
|
||
|
|
||
|
function displayToken(token) {
|
||
|
$$(".js-token").forEach(function (el) {
|
||
|
el.innerText = token;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
Pocket.onToken(function (token) {
|
||
|
// TODO Pocket v1.0 will make this obsolete
|
||
|
localStorage.setItem("pocket-token", token);
|
||
|
displayToken();
|
||
|
});
|
||
|
displayToken(localStorage.getItem("pocket-token"));
|
||
|
|
||
|
// requires div with class 'pocket'
|
||
|
$("form.js-signin").addEventListener("submit", function (ev) {
|
||
|
ev.preventDefault();
|
||
|
ev.stopPropagation();
|
||
|
|
||
|
var email = $("[name=email]").value;
|
||
|
Pocket.openSignin(ev, { email: email });
|
||
|
});
|
||
|
|
||
|
$("form.js-healthcheck").addEventListener("submit", function (ev) {
|
||
|
ev.preventDefault();
|
||
|
ev.stopPropagation();
|
||
|
|
||
|
window.fetch("/api/public/status").then(async function (resp) {
|
||
|
var res = await resp.json();
|
||
|
$(".js-server-health").innerText = JSON.stringify(res, null, 2);
|
||
|
});
|
||
|
});
|
||
|
})();
|