2024-06-22 14:58:29 +01:00
|
|
|
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
|
|
|
|
|
2024-03-12 18:34:05 +00:00
|
|
|
let homeserverBox = document.getElementById("homeserverBox")
|
|
|
|
let statusBox = document.getElementById("statusBox")
|
|
|
|
let changeButton = document.getElementById("changeButton")
|
2024-06-25 21:03:50 +01:00
|
|
|
let backButton = document.getElementById("backButton")
|
2024-03-12 18:34:05 +00:00
|
|
|
|
2024-07-30 11:23:22 +01:00
|
|
|
let remote = localStorage.getItem("SETTING-homeServer")
|
2024-06-25 19:43:24 +01:00
|
|
|
if (remote == null) {
|
2024-07-30 11:23:22 +01:00
|
|
|
localStorage.setItem("SETTING-homeServer", "https://notes.hectabit.org")
|
2024-06-25 19:43:24 +01:00
|
|
|
remote = "https://notes.hectabit.org"
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
statusBox.innerText = "You are currently connected to: " + remote + ". "
|
|
|
|
});
|
|
|
|
|
2024-03-12 18:34:05 +00:00
|
|
|
function showElements(yesorno) {
|
|
|
|
if (!yesorno) {
|
|
|
|
homeserverBox.classList.add("hidden")
|
|
|
|
changeButton.classList.add("hidden")
|
Fixed the labels not being hidden in inoutdivs, made inoutdivs use a flexbox or table to avoid the use of a calc() and a transform(), updated to AES-256 GCM Native crypto from CryptoJS, added a migration page to migrate from CryptoJS, remove the Argon2 Compatibility thing, remove all backwards-compatibility measures, updated the changelog to be accurate, made NoScript cancel-able, made the inoutdiv dynamically scale, told people what a homeserver is, switched to argon2id from sha-3 and sha-512, add a PoW captcha using WASM, make a really long commit message.
If you are still reading this, I admire your dedication. I spent 8 hours and 33 minutes on this commit alone.
2024-07-20 17:12:25 +01:00
|
|
|
inputContainer.classList.add("hidden")
|
2024-03-12 18:34:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
homeserverBox.classList.remove("hidden")
|
|
|
|
changeButton.classList.remove("hidden")
|
Fixed the labels not being hidden in inoutdivs, made inoutdivs use a flexbox or table to avoid the use of a calc() and a transform(), updated to AES-256 GCM Native crypto from CryptoJS, added a migration page to migrate from CryptoJS, remove the Argon2 Compatibility thing, remove all backwards-compatibility measures, updated the changelog to be accurate, made NoScript cancel-able, made the inoutdiv dynamically scale, told people what a homeserver is, switched to argon2id from sha-3 and sha-512, add a PoW captcha using WASM, make a really long commit message.
If you are still reading this, I admire your dedication. I spent 8 hours and 33 minutes on this commit alone.
2024-07-20 17:12:25 +01:00
|
|
|
inputContainer.classList.remove("hidden")
|
2024-03-12 18:34:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-02 18:13:28 +01:00
|
|
|
changeButton.addEventListener("click", () => {
|
2024-03-12 18:34:05 +00:00
|
|
|
async function doStuff() {
|
|
|
|
let remote = homeserverBox.value
|
|
|
|
|
2024-07-02 18:13:28 +01:00
|
|
|
if (remote === "") {
|
2024-03-12 18:34:05 +00:00
|
|
|
statusBox.innerText = "A homeserver is required!"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
showElements(false)
|
|
|
|
statusBox.innerText = "Connecting to homeserver..."
|
|
|
|
|
2024-07-02 18:13:28 +01:00
|
|
|
fetch(remote + "/api/versionjson")
|
2024-03-12 18:34:05 +00:00
|
|
|
.then((response) => response)
|
|
|
|
.then((response) => {
|
|
|
|
async function doStuff() {
|
2024-07-02 18:13:28 +01:00
|
|
|
if (response.status === 200) {
|
|
|
|
let version = await response.json()
|
|
|
|
let fetchClientVersion = await (await fetch("/static/version.txt")).text()
|
|
|
|
if (parseInt(version["versionnum"]) < parseInt(fetchClientVersion)) {
|
|
|
|
localStorage.setItem("legacy", "true")
|
|
|
|
}
|
2024-07-30 15:26:47 +01:00
|
|
|
localStorage.setItem("SETTING-homeServer", remote)
|
2024-03-12 18:34:05 +00:00
|
|
|
|
2024-03-15 17:01:55 +00:00
|
|
|
if (document.referrer !== "") {
|
|
|
|
window.location.href = document.referrer;
|
|
|
|
}
|
|
|
|
else {
|
2024-06-25 19:43:24 +01:00
|
|
|
window.location.href = "/login";
|
2024-03-15 17:01:55 +00:00
|
|
|
}
|
2024-07-02 18:13:28 +01:00
|
|
|
} else if (response.status === 404) {
|
|
|
|
let legacyHomeserverCheck = await fetch(remote + "/api/version")
|
|
|
|
if (legacyHomeserverCheck.status === 200) {
|
|
|
|
let homeserverText = await legacyHomeserverCheck.text()
|
|
|
|
let homeserverFloat = homeserverText.split(" ")[2]
|
|
|
|
let homeserverNameCheck = homeserverText.split(" ")[0]
|
|
|
|
if (homeserverNameCheck !== "Burgernotes") {
|
|
|
|
statusBox.innerText = "This homeserver is not compatible with Burgernotes!"
|
|
|
|
showElements(true)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let homeserverInt = parseFloat(homeserverFloat) * 100
|
|
|
|
if (homeserverInt < 200) {
|
|
|
|
localStorage.setItem("legacy", "true")
|
2024-07-30 15:26:47 +01:00
|
|
|
localStorage.setItem("SETTING-homeServer", remote)
|
2024-07-02 18:13:28 +01:00
|
|
|
if (document.referrer !== "") {
|
|
|
|
window.location.href = document.referrer;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location.href = "/login";
|
|
|
|
}
|
|
|
|
} else if (homeserverInt > 200) {
|
|
|
|
localStorage.setItem("legacy", "false")
|
2024-07-30 15:26:47 +01:00
|
|
|
localStorage.setItem("SETTING-homeServer", remote)
|
2024-07-02 18:13:28 +01:00
|
|
|
if (document.referrer !== "") {
|
|
|
|
window.location.href = document.referrer;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location.href = "/login";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
statusBox.innerText = "This homeserver is not compatible with Burgernotes!"
|
|
|
|
showElements(true)
|
|
|
|
}
|
|
|
|
}
|
2024-03-12 18:34:05 +00:00
|
|
|
}
|
|
|
|
else {
|
2024-07-02 18:13:28 +01:00
|
|
|
statusBox.innerText = "This homeserver is not compatible with Burgernotes!"
|
2024-03-12 18:34:05 +00:00
|
|
|
showElements(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doStuff()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
doStuff()
|
|
|
|
});
|
2024-06-22 14:58:29 +01:00
|
|
|
|
2024-07-02 18:13:28 +01:00
|
|
|
backButton.addEventListener("click", () => {
|
2024-06-25 21:03:50 +01:00
|
|
|
history.back()
|
|
|
|
});
|
|
|
|
|
2024-06-25 19:43:24 +01:00
|
|
|
// @license-end
|