Various fixes

This commit is contained in:
MathMan05 2024-06-08 22:22:59 -05:00
parent 54f026e262
commit 8c80870d30
5 changed files with 64 additions and 36 deletions

View file

@ -529,7 +529,7 @@ const images=[];
const imageshtml=[]; const imageshtml=[];
function createunknown(fname,fsize,src){ function createunknown(fname,fsize,src){
const div=document.createElement("table"); const div=document.createElement("table");
div.classList.add("unkownfile"); div.classList.add("unknownfile");
const nametr=document.createElement("tr"); const nametr=document.createElement("tr");
div.append(nametr); div.append(nametr);
const fileicon=document.createElement("td"); const fileicon=document.createElement("td");

View file

@ -10,40 +10,41 @@ function setTheme(){
document.body.className=name+"-theme"; document.body.className=name+"-theme";
} }
setTheme(); setTheme();
{
const instancein=document.getElementById("instancein");
let timeout=0;
async function check(e){
try{
verify.innerText="Checking Instance"
instanceinfo=await setInstance(instancein.value)
localStorage.setItem("instanceinfo",JSON.stringify(instanceinfo));
verify.innerText="Instance is all good"
setTimeout(_=>{
console.log(verify.innerText)
verify.innerText="";
},3000);
}catch(e){ const instancein=document.getElementById("instancein");
console.log("catch") let timeout=0;
verify.innerText="Invalid Instance, try again" async function checkInstance(e){
} try{
} verify.innerText="Checking Instance"
if(instancein){ instanceinfo=await setInstance(instancein.value)
console.log(instancein) localStorage.setItem("instanceinfo",JSON.stringify(instanceinfo));
instancein.addEventListener("keydown",e=>{ verify.innerText="Instance is all good"
const verify=document.getElementById("verify"); if(checkInstance.alt){checkInstance.alt();}
verify.innerText="Waiting to check Instance" setTimeout(_=>{
clearTimeout(timeout); console.log(verify.innerText)
timeout=setTimeout(check,1000); verify.innerText="";
}); },3000);
}
if(localStorage.getItem("instanceinfo")){ }catch(e){
instancein.value=localStorage.getItem("instanceinfo").wellKnown console.log("catch")
}else{ verify.innerText="Invalid Instance, try again"
check("https://spacebar.chat/");
} }
} }
if(instancein){
console.log(instancein)
instancein.addEventListener("keydown",e=>{
const verify=document.getElementById("verify");
verify.innerText="Waiting to check Instance"
clearTimeout(timeout);
timeout=setTimeout(checkInstance,1000);
});
}
if(localStorage.getItem("instanceinfo")){
instancein.value=JSON.parse(localStorage.getItem("instanceinfo")).wellknown
}else{
checkInstance("https://spacebar.chat/");
}
async function login(username, password){ async function login(username, password){
const options={ const options={
method: "POST", method: "POST",

View file

@ -23,8 +23,12 @@
<input type="password" placeholder="Enter Password Again" name="psw2" required><br><br> <input type="password" placeholder="Enter Password Again" name="psw2" required><br><br>
<label for="date"><b>Date of birth:</b></label><br> <label for="date"><b>Date of birth:</b></label><br>
<input type="date" id="start" name="trip-start" name="date"/><br><br><br><br> <input type="date" id="start" name="date"/><br><br>
<p class="wrongred" id="wrong"></p>
<b id="TOSbox">I agree to the <a href="" id="TOSa">TOS</a>:</b>
<input type="checkbox" id="TOS" name="TOS"/><br>
<p class="wrongred" id="wrong"></p><br>
<button type="submit">Create account</button> <button type="submit">Create account</button>
</form> </form>
<a href="/login.html">Already have an account?</a> <a href="/login.html">Already have an account?</a>

View file

@ -9,6 +9,7 @@ async function registertry(e){
const username=elements[2].value; const username=elements[2].value;
if(elements[3].value!==elements[4].value){ if(elements[3].value!==elements[4].value){
document.getElementById("wrong").innerText="Passwords don't match"; document.getElementById("wrong").innerText="Passwords don't match";
return;
} }
const password=elements[3].value; const password=elements[3].value;
const dateofbirth=elements[5].value; const dateofbirth=elements[5].value;
@ -20,7 +21,7 @@ async function registertry(e){
email:email, email:email,
username:username, username:username,
password:password, password:password,
consent:true, consent:elements[5].checked,
}), }),
headers:{ headers:{
"content-type": "application/json" "content-type": "application/json"
@ -40,3 +41,20 @@ async function registertry(e){
//document.getElementById("wrong").innerText=h; //document.getElementById("wrong").innerText=h;
// console.log(h); // console.log(h);
} }
let TOSa=document.getElementById("TOSa");
async function tosLogic(){
const apiurl=new URL(JSON.parse(localStorage.getItem("instanceinfo")).api)
const tosPage=(await (await fetch(apiurl.toString()+"/ping")).json()).instance.tosPage;
if(tosPage){
document.getElementById("TOSbox").innerHTML="I agree to the <a href=\"\" id=\"TOSa\">TOS</a>:";
TOSa=document.getElementById("TOSa");
TOSa.href=tosPage;
}else{
document.getElementById("TOSbox").innerText="This instance has no TOS, accept TOS anyways:";
TOSa=null;
}
console.log(tosPage);
}
tosLogic();
checkInstance.alt=tosLogic;

View file

@ -8,7 +8,12 @@ body {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
#TOS{
width: fit-content !important;
}
.unkownfile{
background:var(--unknown-file-bg) ;
}
.imgfit { .imgfit {
max-width: 80vw; max-width: 80vw;
max-height: 80vh; max-height: 80vh;