diff --git a/webpage/index.js b/webpage/index.js index fdea7ca..44e73e6 100644 --- a/webpage/index.js +++ b/webpage/index.js @@ -529,7 +529,7 @@ const images=[]; const imageshtml=[]; function createunknown(fname,fsize,src){ const div=document.createElement("table"); - div.classList.add("unkownfile"); + div.classList.add("unknownfile"); const nametr=document.createElement("tr"); div.append(nametr); const fileicon=document.createElement("td"); diff --git a/webpage/login.js b/webpage/login.js index ff20893..27f048b 100644 --- a/webpage/login.js +++ b/webpage/login.js @@ -10,40 +10,41 @@ function setTheme(){ document.body.className=name+"-theme"; } 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){ - console.log("catch") - verify.innerText="Invalid Instance, try again" - } - } - if(instancein){ - console.log(instancein) - instancein.addEventListener("keydown",e=>{ - const verify=document.getElementById("verify"); - verify.innerText="Waiting to check Instance" - clearTimeout(timeout); - timeout=setTimeout(check,1000); - }); - } - if(localStorage.getItem("instanceinfo")){ - instancein.value=localStorage.getItem("instanceinfo").wellKnown - }else{ - check("https://spacebar.chat/"); +const instancein=document.getElementById("instancein"); +let timeout=0; +async function checkInstance(e){ + try{ + verify.innerText="Checking Instance" + instanceinfo=await setInstance(instancein.value) + localStorage.setItem("instanceinfo",JSON.stringify(instanceinfo)); + verify.innerText="Instance is all good" + if(checkInstance.alt){checkInstance.alt();} + setTimeout(_=>{ + console.log(verify.innerText) + verify.innerText=""; + },3000); + + }catch(e){ + console.log("catch") + verify.innerText="Invalid Instance, try again" } } +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){ const options={ method: "POST", diff --git a/webpage/register.html b/webpage/register.html index ad7b117..9a85662 100644 --- a/webpage/register.html +++ b/webpage/register.html @@ -23,8 +23,12 @@


-



-

+

+ + + I agree to the TOS: +
+


Already have an account? diff --git a/webpage/register.js b/webpage/register.js index 356dab8..f2d541e 100644 --- a/webpage/register.js +++ b/webpage/register.js @@ -9,6 +9,7 @@ async function registertry(e){ const username=elements[2].value; if(elements[3].value!==elements[4].value){ document.getElementById("wrong").innerText="Passwords don't match"; + return; } const password=elements[3].value; const dateofbirth=elements[5].value; @@ -20,7 +21,7 @@ async function registertry(e){ email:email, username:username, password:password, - consent:true, + consent:elements[5].checked, }), headers:{ "content-type": "application/json" @@ -40,3 +41,20 @@ async function registertry(e){ //document.getElementById("wrong").innerText=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 TOS:"; + 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; diff --git a/webpage/style.css b/webpage/style.css index e0f2445..a2b18ed 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -8,7 +8,12 @@ body { margin: 0; padding: 0; } - +#TOS{ + width: fit-content !important; +} +.unkownfile{ + background:var(--unknown-file-bg) ; +} .imgfit { max-width: 80vw; max-height: 80vh;