Compare commits

..

No commits in common. "4604f8642960d8e497da5f6a9fffaed20b714101" and "26951b4f0f5cf2a9d5a67b14ea1cc621af3a36c5" have entirely different histories.

View File

@ -1,7 +1,7 @@
<script>
import isURL from "validator/lib/isURL";
import isUUID from "validator/lib/isUUID";
import { apikey, lang, stationinfo, api_endpoint, page } from "./store.js";
import { apikey, lang, stationinfo, api_endpoint } from "./store.js";
import axios from "axios";
import background from "./kaya_kids_background.jpg";
import { _, locale } from "svelte-i18n";
@ -10,10 +10,9 @@
$: error = false;
$: errormessage = "";
$: isTokenValid =
token === "rst" ||
(token?.length === 44 &&
token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]));
token?.length === 44 &&
token.split(".")[0].length === 7 &&
isUUID(token.split(".")[1]);
$: isEndpointValid = isURL(api_endpoint_input);
</script>
@ -68,30 +67,22 @@
class="flex flex-col pt-3 md:pt-8"
onsubmit="event.preventDefault();"
on:submit={() => {
if (token === "rst") {
apikey.set("");
api_endpoint.set("");
page.set("");
token = "";
api_endpoint_input = "";
} else {
axios
.request({
method: "GET",
url: $api_endpoint + "api/stations/me",
headers: { Authorization: "Bearer " + token },
})
.then(function (response) {
error = false;
errormessage = "";
apikey.set(token);
stationinfo.set(JSON.stringify(response.data));
})
.catch(function (e) {
error = true;
errormessage = e.response.data.short;
});
}
axios
.request({
method: "GET",
url: $api_endpoint + "api/stations/me",
headers: { Authorization: "Bearer " + token },
})
.then(function (response) {
error = false;
errormessage = "";
apikey.set(token);
stationinfo.set(JSON.stringify(response.data));
})
.catch(function (e) {
error = true;
errormessage = e.response.data.short;
});
}}
>
<div class="flex flex-col pt-4">
@ -127,18 +118,10 @@
class="flex flex-col pt-3 md:pt-8"
onsubmit="event.preventDefault();"
on:submit={() => {
if (api_endpoint_input === "rst") {
apikey.set("");
api_endpoint.set("");
page.set("");
token = "";
api_endpoint_input = "";
} else {
if (api_endpoint_input.substr(-1) !== "/") {
api_endpoint_input = api_endpoint_input + "/";
}
api_endpoint.set(api_endpoint_input);
if (api_endpoint_input.substr(-1) !== "/") {
api_endpoint_input = api_endpoint_input + "/";
}
api_endpoint.set(api_endpoint_input);
}}
>
<div class="flex flex-col pt-4">