From ebc0ca1b0208a5f0eed840d26aaea81216628cc2 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 15:55:26 -0500 Subject: [PATCH 01/16] remove some logs --- index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.js b/index.js index 1ab22b7..a27f368 100755 --- a/index.js +++ b/index.js @@ -14,9 +14,7 @@ fetch("https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/instan for(const instance of json){ console.log(instance); if(!instancenames.has(instance.name)){ - console.log("pushed"); instances.push(instance); - console.log(instances) }else{ const ofinst=instancenames.get(instance.name) for(const key of Object.keys(instance)){ From 0e5cafd112d067c7beb6d44c9434f5eed9c270fa Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 16:21:09 -0500 Subject: [PATCH 02/16] style updates --- webpage/style.css | 50 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/webpage/style.css b/webpage/style.css index 03cac58..9ab7b19 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -1,6 +1,3 @@ -html{ - height:100%; -} body { font-family: "acumin-pro", "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 400; @@ -706,7 +703,7 @@ textarea:focus-visible, } .servertd { - background-color: var(--channel-name-bg); + background-color: var(--server-bg); height: .55in; width:100%; display: flex; @@ -796,7 +793,7 @@ textarea:focus-visible, button { transition: background .1s ease-in-out; - background-color: var(--button-bg); + background-color: var(--message-bg-hover); color: var(--primary-text); border-color:var(--timestamp-color); font-weight: bold; @@ -821,11 +818,11 @@ button:disabled:hover{ color: var(--primary-text); } button:hover { - background-color: var(--button-hover); + background-color: var(--primary-bg); } input::file-selector-button { transition: background .1s ease-in-out; - background-color: var(--button-bg); + background-color: var(--message-bg-hover); border-color:var(--timestamp-color); color: var(--primary-text); font-weight: bold; @@ -844,7 +841,7 @@ input[type="file"] { } select{ transition: background .1s ease-in-out; - background-color: var(--button-bg); + background-color: var(--message-bg-hover); color: var(--primary-text); font-weight: bold; text-align: left; @@ -995,7 +992,7 @@ span { user-select: none; } -.filename a{ +.filename { color: var(--filename); } @@ -1288,9 +1285,6 @@ span { padding: .05in; box-sizing: border-box; } -.flexspace:has(.Buttons){ - padding:0; -} .titlediv{ height:100%; display: flex; @@ -1303,7 +1297,7 @@ span { border-bottom: solid .03in var(--message-bg-hover); background: var(--primary-bg); padding: .06in .2in; - background: var(--channel-name-bg); + background: var(--server-bg); box-sizing: border-box; } .exitsettings{ @@ -1403,6 +1397,7 @@ span { overflow: hidden; cursor: pointer; flex-shrink: 0; + position: relative; } .discovery-guild .flex { @@ -1825,7 +1820,7 @@ form div{ } .banner{ position:absolute; - z-index:0; + z-index: 0; top:0; left:0; width:100%; @@ -1956,3 +1951,30 @@ form div{ .clickable:hover{ text-decoration:underline; } + +#titleDiv{ + box-sizing: border-box; + display:flex; + flex-direction: row; + align-items: center; + width: 100%; + padding: .03in .15in; + background: var(--profile-bg); + border-bottom: solid var(--black); + position: absolute; +} +#TitleButtons{ + color:var(--primary-text); + margin-left: .03in; + padding: .05in; + border-radius:.075in; + border:solid .03in var(--black); + box-shadow: 0 0 .07in var(--shadow); + transition: box-shadow .3s; +} +#TitleButtons:hover{ + box-shadow: 0 0 .01in var(--shadow); +} +#pageTitle{ + margin-right:.1in; +} From 04e3ac9955a3533d4b935adfa5b1f94bd53f058e Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 20:05:22 -0500 Subject: [PATCH 03/16] update to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 11de622..48a8706 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,5 @@ dist #Data file for tomoato testAccount.json CC +uptime.json +.directory From f2480130c14d455953ffb8a85fc85037e4b3eafa Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 20:56:52 -0500 Subject: [PATCH 04/16] added a home screen to jank client --- .dist/home.js | 62 ++++++++++++++++++++ .dist/login.js | 2 +- index.js | 16 ++++-- stats.js | 142 ++++++++++++++++++++++++++++++++++++++++++++++ webpage/home.html | 48 ++++++++++++++++ webpage/home.ts | 64 +++++++++++++++++++++ webpage/login.ts | 2 +- webpage/style.css | 81 ++++++++++++++++++++++++-- 8 files changed, 407 insertions(+), 10 deletions(-) create mode 100644 .dist/home.js create mode 100644 stats.js create mode 100644 webpage/home.html create mode 100644 webpage/home.ts diff --git a/.dist/home.js b/.dist/home.js new file mode 100644 index 0000000..ffb50ee --- /dev/null +++ b/.dist/home.js @@ -0,0 +1,62 @@ +import { mobile } from "./login.js"; +console.log(mobile); +const serverbox = document.getElementById("instancebox"); +fetch("/instances.json").then(_ => _.json()).then((json) => { + console.warn(json); + for (const instance of json) { + if (instance.display === false) { + continue; + } + const div = document.createElement("div"); + div.classList.add("flexltr", "instance"); + if (instance.image) { + const img = document.createElement("img"); + img.src = instance.image; + div.append(img); + } + const statbox = document.createElement("div"); + statbox.classList.add("flexttb"); + { + const textbox = document.createElement("div"); + textbox.classList.add("flexttb", "instatancetextbox"); + const title = document.createElement("h2"); + title.innerText = instance.name; + if (instance.online !== undefined) { + const status = document.createElement("span"); + status.innerText = instance.online ? "Online" : "Offline"; + status.classList.add("instanceStatus"); + title.append(status); + } + textbox.append(title); + if (instance.description || instance.descriptionLong) { + const p = document.createElement("p"); + if (instance.descriptionLong) { + p.innerText = instance.descriptionLong; + } + else { + p.innerText = instance.description; + } + textbox.append(p); + } + statbox.append(textbox); + } + { + const stats = document.createElement("div"); + stats.classList.add("flexltr"); + const span = document.createElement("span"); + span.innerText = `Uptime: All time: ${Math.floor(instance.uptime.alltime * 100)}% This week: ${Math.floor(instance.uptime.weektime * 100)}% Today: ${Math.floor(instance.uptime.daytime * 100)}%`; + stats.append(span); + statbox.append(stats); + } + div.append(statbox); + div.onclick = _ => { + if (instance.online) { + window.location.href = "/register.html?instance=" + encodeURI(instance.name); + } + else { + alert("Instance is offline, can't connect"); + } + }; + serverbox.append(div); + } +}); diff --git a/.dist/login.js b/.dist/login.js index b4f0817..46aa5b3 100644 --- a/.dist/login.js +++ b/.dist/login.js @@ -419,7 +419,6 @@ if (datalist) { console.warn(json); if (instancein && instancein.value === "") { instancein.value = json[0].name; - setTimeout(checkInstance, 10); } for (const instance of json) { if (instance.display === false) { @@ -447,5 +446,6 @@ if (datalist) { } datalist.append(option); } + checkInstance(""); }); } diff --git a/index.js b/index.js index a27f368..9ac4858 100755 --- a/index.js +++ b/index.js @@ -4,7 +4,8 @@ const compression = require('compression') const express = require('express'); const fs = require('fs'); const app = express(); -const instances=require("./webpage/instances.json") +const instances=require("./webpage/instances.json"); +const stats=require("./stats.js"); const instancenames=new Map(); for(const instance of instances){ instancenames.set(instance.name,instance); @@ -12,7 +13,6 @@ for(const instance of instances){ app.use(compression()) fetch("https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/instances/instances.json").then(_=>_.json()).then(json=>{ for(const instance of json){ - console.log(instance); if(!instancenames.has(instance.name)){ instances.push(instance); }else{ @@ -24,6 +24,7 @@ fetch("https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/instan } } } + stats.observe(instances) }) app.use("/getupdates",(req, res) => { @@ -145,6 +146,10 @@ async function inviteres(req,res){ app.use('/services/oembed', (req, res) => { inviteres(req, res); }) +app.use("/uptime",(req,res)=>{ + const uptime=stats.uptime[req.query.name]; + res.send(uptime); +}) app.use('/', async (req, res) => { const scheme = req.secure ? 'https' : 'http'; const host=`${scheme}://${req.get("Host")}`; @@ -156,13 +161,14 @@ app.use('/', async (req, res) => { }else{ console.log(req); } - + if(req.path==="/"){ + res.sendFile(`./webpage/home.html`, {root: __dirname}); + } if(debugging&&req.path.startsWith("/service.js")){ res.send("dud"); return; } if(req.path.startsWith("/instances.json")){ - console.log("grabbed") res.send(JSON.stringify(instances)); return; } @@ -189,3 +195,5 @@ app.use('/', async (req, res) => { const PORT = process.env.PORT || +process.argv[1] || 8080; app.listen(PORT, () => {}); console.log("this ran :P"); + +exports.getapiurls=getapiurls; diff --git a/stats.js b/stats.js new file mode 100644 index 0000000..385ca5e --- /dev/null +++ b/stats.js @@ -0,0 +1,142 @@ +const index = require('./index.js'); +const fs=require("fs"); +let uptimeObject={}; +if(fs.existsSync("./uptime.json")){ + try{ + uptimeObject=JSON.parse(fs.readFileSync('./uptime.json', 'utf8')); + }catch{ + uptimeObject={}; + } +} + +async function observe(instances){ + const active=new Set(); + async function resolveinstance(instance){ + calcStats(instance); + let api; + if(instance.urls){ + api=instance.urls.api; + }else if(instance.url){ + const urls=await index.getapiurls(instance.url); + if(urls){ + api=urls.api; + } + } + if(!api||api===""){ + + setSatus(instance,false); + console.warn(instance.name+" does not resolve api URL"); + setTimeout(_=>{resolveinstance(instance)},1000*60*30,); + return + } + active.add(instance.name); + api+=api.endsWith("/")?"":"/" + function check(){ + fetch(api+"ping").then(_=>{ + setSatus(instance,_.ok); + }) + } + setTimeout( + _=>{ + check(); + setInterval(_=>{ + check(); + },1000*60*30) + },Math.random()*1000*60*10 + ) + } + const promlist=[]; + for(const instance of instances){ + promlist.push(resolveinstance(instance)); + } + await Promise.allSettled(promlist); + for(const key of Object.keys(uptimeObject)){ + if(!active.has(key)){ + setSatus(key,false); + } + } +} +function calcStats(instance){ + let obj=uptimeObject[instance.name]; + if(!obj) return; + const day=Date.now()-1000*60*60*24; + const week=Date.now()-1000*60*60*24*7; + let alltime=-1; + let totalTimePassed=0; + let laststamp=0; + let daytime=-1; + let weektime=-1; + let online=false; + for(const thing of obj){ + const stamp=thing.time; + if(alltime===-1){ + laststamp=stamp; + alltime=0; + } + const timepassed=stamp-laststamp; + totalTimePassed+=timepassed; + alltime+=online*timepassed; + if(stamp>week){ + if(weektime===-1){ + weektime=online*(stamp-week); + }else{ + weektime+=online*timepassed; + } + if(stamp>day){ + if(daytime===-1){ + daytime=online*(stamp-day); + }else{ + daytime+=online*timepassed; + } + } + } + online=thing.online; + } + instance.online=online; + const timepassed=Date.now()-laststamp; + totalTimePassed+=timepassed; + daytime+=online*timepassed; + weektime+=online*timepassed; + alltime+=online*timepassed; + alltime/=totalTimePassed; + if(timepassed>1000*60*60*24){ + daytime/=1000*60*60*24; + if(timepassed>1000*60*60*24*7){ + weektime/=1000*60*60*24*7; + }else{ + weektime=alltime; + } + }else{ + weektime=alltime + daytime=alltime; + } + instance.uptime={daytime,weektime,alltime} +} +/** + * @param {string} name + * @param {boolean} status + */ +function setSatus(instance,status){ + const name=instance.name; + let obj=uptimeObject[name]; + let needSetting=false; + if(!obj){ + obj=[]; + uptimeObject[name]=obj; + needSetting=true; + }else{ + if(obj[obj.length-1].online!==status){ + needSetting=true; + } + } + if(needSetting){ + obj.push({time:Date.now(),online:status}); + updatejson(); + } + calcStats(instance); +} +function updatejson(){ + fs.writeFile('./uptime.json',JSON.stringify(uptimeObject),_=>{}); +} +exports.observe=observe; +exports.uptime=uptimeObject; diff --git a/webpage/home.html b/webpage/home.html new file mode 100644 index 0000000..a6ffaab --- /dev/null +++ b/webpage/home.html @@ -0,0 +1,48 @@ + + + + + + Jank Client + + + + + + + + + +
+ +

Jank Client

+

Spacebar Guild

+

Github

+
+
+ +

Welcome to Jank Client

+
+

Jank Client is a spacebar compatible client seeking to be as good as it can be with many features including:

+
    +
  • Direct Messaging
  • +
  • Reactions support
  • +
  • Invites
  • +
  • Account switching
  • +
  • User settings
  • +
+
+
+

Spacebar compatible Instances:

+
+
+
+
+

Contribute to Jank Client

+

We always appreciate some help, wether that be in the form of bug reports, or code, or even just pointing out some typos.


+

Github

+
+
+ + + diff --git a/webpage/home.ts b/webpage/home.ts new file mode 100644 index 0000000..73aaeec --- /dev/null +++ b/webpage/home.ts @@ -0,0 +1,64 @@ +import {mobile} from "./login.js"; +console.log(mobile); +const serverbox=document.getElementById("instancebox") as HTMLDivElement; + +fetch("/instances.json").then(_=>_.json()).then((json:{name:string,description?:string,descriptionLong?:string,image?:string,url?:string,display?:boolean,online?:boolean, + uptime:{alltime:number,daytime:number,weektime:number}, + urls:{wellknown:string,api:string,cdn:string,gateway:string,login?:string}}[])=>{ + console.warn(json); + for(const instance of json){ + if(instance.display===false){ + continue; + } + const div=document.createElement("div"); + div.classList.add("flexltr","instance"); + if(instance.image){ + const img=document.createElement("img"); + img.src=instance.image; + div.append(img); + } + const statbox=document.createElement("div"); + statbox.classList.add("flexttb"); + + { + const textbox=document.createElement("div"); + textbox.classList.add("flexttb","instatancetextbox"); + const title=document.createElement("h2"); + title.innerText=instance.name; + if(instance.online!==undefined){ + const status=document.createElement("span"); + status.innerText=instance.online?"Online":"Offline"; + status.classList.add("instanceStatus"); + title.append(status); + } + textbox.append(title); + if(instance.description||instance.descriptionLong){ + const p=document.createElement("p"); + if(instance.descriptionLong){ + p.innerText=instance.descriptionLong; + }else{ + p.innerText=instance.description; + } + textbox.append(p); + } + statbox.append(textbox) + } + { + const stats=document.createElement("div"); + stats.classList.add("flexltr"); + const span=document.createElement("span"); + span.innerText=`Uptime: All time: ${Math.floor(instance.uptime.alltime*100)}% This week: ${Math.floor(instance.uptime.weektime*100)}% Today: ${Math.floor(instance.uptime.daytime*100)}%` + stats.append(span); + statbox.append(stats); + } + div.append(statbox); + div.onclick=_=>{ + if(instance.online){ + window.location.href="/register.html?instance="+encodeURI(instance.name); + }else{ + alert("Instance is offline, can't connect"); + } + } + serverbox.append(div); + } + }) diff --git a/webpage/login.ts b/webpage/login.ts index d9e50ae..b3aff49 100644 --- a/webpage/login.ts +++ b/webpage/login.ts @@ -409,7 +409,6 @@ if(datalist){ console.warn(json); if(instancein&&instancein.value===""){ instancein.value=json[0].name; - setTimeout(checkInstance,10); } for(const instance of json){ if(instance.display===false){ @@ -434,5 +433,6 @@ if(datalist){ } datalist.append(option); } + checkInstance(""); }) } diff --git a/webpage/style.css b/webpage/style.css index 9ab7b19..390b8f5 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -1257,6 +1257,7 @@ span { /* padding-bottom: .1in; */ align-items: flex-start; width: 100%; + height: 100%; } .settingbuttons{ padding-top:.075in; @@ -1958,12 +1959,12 @@ form div{ flex-direction: row; align-items: center; width: 100%; - padding: .03in .15in; + padding: .03in .1in; background: var(--profile-bg); border-bottom: solid var(--black); - position: absolute; + justify-content: center; } -#TitleButtons{ +.TitleButtons{ color:var(--primary-text); margin-left: .03in; padding: .05in; @@ -1971,10 +1972,82 @@ form div{ border:solid .03in var(--black); box-shadow: 0 0 .07in var(--shadow); transition: box-shadow .3s; + display: block; + width: fit-content; } -#TitleButtons:hover{ +.TitleButtons:hover{ box-shadow: 0 0 .01in var(--shadow); } #pageTitle{ margin-right:.1in; } +.pagehead{ + background: var(--channel-hover); + height:1in; + display: flex; + align-items: center; + border-bottom: solid var(--black); + justify-content: center; + font-size: .25in; + flex-shrink: 0; +} +.pagebox{ + padding: .06in; + background: var(--channel-hover); + margin: .1in; + min-height:2in; + border-radius:.1in; + box-sizing: border-box; + border: solid .04in black; + border-left: solid .05in darkblue; + box-shadow: .03in .04in .1in var(--black); + flex-shrink: 0; +} +#instancebox{ + display:flex; + flex-direction: row; + flex-wrap: wrap; + width: fit-content; +} +.instance{ + img{ + width:.6in; + height:.6in; + margin-right:.1in; + border-radius:.2in; + border:solid .03in var(--black); + } + h2{ + font-size:.25in; + } + flex-grow:0; + width:4.8in; + height: 1.6in; + background:var(--button-bg); + border-radius:.1in; + padding:.06in; + margin:.05in; + border:solid .04in var(--black); + box-shadow:0 0 .1in var(--shadow); + display: flex; + justify-content: center; + cursor:pointer; + user-select:none; +} +.instatancetextbox{ + background:var(--message-bg-hover); + border-radius:.1in; + padding:0.03in .05in; + border:solid .03in var(--black); + height: 1.2in; + display:flex; + justify-content: center; + width:3.9in; + margin-bottom:.1in; +} +.instanceStatus{ + font-size:.125in; + font-weight:100; + margin-left:.05in; +} + From 14fe4308af06ed08dbcb93b70854d46f0cb258f1 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 20:58:50 -0500 Subject: [PATCH 05/16] fix bug with home.ts --- .dist/home.js | 2 +- webpage/home.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.dist/home.js b/.dist/home.js index ffb50ee..b54844f 100644 --- a/.dist/home.js +++ b/.dist/home.js @@ -40,7 +40,7 @@ fetch("/instances.json").then(_ => _.json()).then((json) => { } statbox.append(textbox); } - { + if (instance.uptime) { const stats = document.createElement("div"); stats.classList.add("flexltr"); const span = document.createElement("span"); diff --git a/webpage/home.ts b/webpage/home.ts index 73aaeec..2dfbffd 100644 --- a/webpage/home.ts +++ b/webpage/home.ts @@ -43,7 +43,7 @@ fetch("/instances.json").then(_=>_.json()).then((json:{name:string,description?: } statbox.append(textbox) } - { + if(instance.uptime){ const stats=document.createElement("div"); stats.classList.add("flexltr"); const span=document.createElement("span"); From 0f4e5afaebc8ae29edc5777549aa747486bbbdf2 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 21:20:03 -0500 Subject: [PATCH 06/16] fix CSS bug --- webpage/style.css | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webpage/style.css b/webpage/style.css index 390b8f5..18dc7df 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -535,7 +535,7 @@ hr { flex-direction: column; flex-shrink: 1; min-height: 0; - height: 100%; + height: 100vh; /* width: 100%; */ position: relative; } @@ -1247,6 +1247,7 @@ span { flex-shrink: 1; flex-grow: 1; align-items: stretch; + align-content: stretch; } .flexttb{ display: flex; @@ -1338,13 +1339,15 @@ span { .channelflex{ flex-shrink:0; - flex-grow:0; + flex-grow: 1; width:2.5in; display: flex; justify-content: space-evenly; align-content: stretch; flex-direction: column; overflow: hidden; + /* height: 100%; */ + height: 100vh; } .messageflex{ display:flex; From 1cdc6726b442f23fc4f6dbcc5e9f34c0e90e0571 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 21:21:17 -0500 Subject: [PATCH 07/16] add missing return --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 9ac4858..4d31198 100755 --- a/index.js +++ b/index.js @@ -163,6 +163,7 @@ app.use('/', async (req, res) => { } if(req.path==="/"){ res.sendFile(`./webpage/home.html`, {root: __dirname}); + return; } if(debugging&&req.path.startsWith("/service.js")){ res.send("dud"); From 02af5baaadd48627a0d634742e716ae8e143ee87 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 21:31:41 -0500 Subject: [PATCH 08/16] fix undefined bug --- index.js | 2 ++ stats.js | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 4d31198..b5ddf81 100755 --- a/index.js +++ b/index.js @@ -147,7 +147,9 @@ app.use('/services/oembed', (req, res) => { inviteres(req, res); }) app.use("/uptime",(req,res)=>{ + console.log(req.query.name) const uptime=stats.uptime[req.query.name]; + console.log(req.query.name,uptime,stats.uptime) res.send(uptime); }) app.use('/', async (req, res) => { diff --git a/stats.js b/stats.js index 385ca5e..64ed3d2 100644 --- a/stats.js +++ b/stats.js @@ -4,11 +4,15 @@ let uptimeObject={}; if(fs.existsSync("./uptime.json")){ try{ uptimeObject=JSON.parse(fs.readFileSync('./uptime.json', 'utf8')); + }catch{ uptimeObject={}; } } - +if(uptimeObject["undefined"]){ + delete uptimeObject["undefined"]; + updatejson(); +} async function observe(instances){ const active=new Set(); async function resolveinstance(instance){ @@ -113,11 +117,15 @@ function calcStats(instance){ instance.uptime={daytime,weektime,alltime} } /** - * @param {string} name + * @param {string|Object} instance * @param {boolean} status */ function setSatus(instance,status){ - const name=instance.name; + let name=instance.name; + if(typeof instance==="string" ){ + name=instance; + } + let obj=uptimeObject[name]; let needSetting=false; if(!obj){ @@ -133,7 +141,9 @@ function setSatus(instance,status){ obj.push({time:Date.now(),online:status}); updatejson(); } - calcStats(instance); + if(typeof instance!=="string" ){ + calcStats(instance); + } } function updatejson(){ fs.writeFile('./uptime.json',JSON.stringify(uptimeObject),_=>{}); From fab7cc3d3898d7cd809737563301f5d657bd6594 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 21:34:25 -0500 Subject: [PATCH 09/16] fix bug for uptime greater than 100% --- stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stats.js b/stats.js index 64ed3d2..f9ee3b2 100644 --- a/stats.js +++ b/stats.js @@ -99,8 +99,8 @@ function calcStats(instance){ instance.online=online; const timepassed=Date.now()-laststamp; totalTimePassed+=timepassed; - daytime+=online*timepassed; - weektime+=online*timepassed; + daytime+=online*Math.min(timepassed,1000*60*60*24); + weektime+=online*Math.min(timepassed,1000*60*60*24*7); alltime+=online*timepassed; alltime/=totalTimePassed; if(timepassed>1000*60*60*24){ From 86f8a9842124d6797720535e16b4fde36d2ce90c Mon Sep 17 00:00:00 2001 From: MathMan05 <73901602+MathMan05@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:39:13 -0500 Subject: [PATCH 10/16] Update InstanceInfo.md --- InstanceInfo.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/InstanceInfo.md b/InstanceInfo.md index 3e9b4b1..45e16f4 100644 --- a/InstanceInfo.md +++ b/InstanceInfo.md @@ -31,6 +31,7 @@ anything with a `?` in-front of its `:` are optional, though you must either inc Some of these values may not be used right now, though they will likely be used in the future, so feel free to fill out what you like, though the more you fill out the more information we can give the users about your instance in the future. language should be [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1_codes). Country should be [ISO 8166-2 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). +You can also add yourself to [this](https://github.com/spacebarchat/spacebarchat/tree/master/instances) list, and you should, though there are some disadvantages to only being in that list # Questions ## Do I have to do this to let Jank Client connect to my server? No, you may choose to not do this, this just makes it easier for people using Jank Client to find and use your instance as it's in the dropdown menu for instances, though the user may enter any instance they please. @@ -38,3 +39,5 @@ No, you may choose to not do this, this just makes it easier for people using Ja If it's spacebar compatable, yes it may be entered, though if there are too many incompatablities, it may not be included, or may need a warning of sorts. ## I'm hosting my own instance of spacebar and would like to change the defualt instance on my instance of Jank Client to my own instance. Just change the first entry in the list to your own, and it should connect without issue. +## Why would I put my instance in this list over the official spacebar list? +While putting your instance in the other list will get it to show up on jank client, this list does have more settings, and will show up earlier in the results, though either list will work to get in the dropdown menu From fc53c8e5f3ebaa55180a024792284d836bcdc836 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 21:41:55 -0500 Subject: [PATCH 11/16] remove offline servers from dropdown --- .dist/login.js | 2 +- webpage/login.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.dist/login.js b/.dist/login.js index 46aa5b3..4d25bdb 100644 --- a/.dist/login.js +++ b/.dist/login.js @@ -421,7 +421,7 @@ if (datalist) { instancein.value = json[0].name; } for (const instance of json) { - if (instance.display === false) { + if (instance.display === false || !instance.online) { continue; } const option = document.createElement("option"); diff --git a/webpage/login.ts b/webpage/login.ts index b3aff49..6a8b3c9 100644 --- a/webpage/login.ts +++ b/webpage/login.ts @@ -405,13 +405,13 @@ export {mobile, getBulkUsers,getBulkInfo,setTheme,Specialuser,getapiurls,adduser const datalist=document.getElementById("instances"); console.warn(datalist); if(datalist){ - fetch("/instances.json").then(_=>_.json()).then((json:{name:string,description?:string,src?:string,url?:string,display?:boolean,urls:{wellknown:string,api:string,cdn:string,gateway:string,login?:string}}[])=>{ + fetch("/instances.json").then(_=>_.json()).then((json:{name:string,online:boolean,description?:string,src?:string,url?:string,display?:boolean,urls:{wellknown:string,api:string,cdn:string,gateway:string,login?:string}}[])=>{ console.warn(json); if(instancein&&instancein.value===""){ instancein.value=json[0].name; } for(const instance of json){ - if(instance.display===false){ + if(instance.display===false||!instance.online){ continue; } const option=document.createElement("option"); From ea03b4234d37531e303a8c9074bc37586a99a534 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 21:48:25 -0500 Subject: [PATCH 12/16] disable offline instances --- .dist/login.js | 3 ++- webpage/login.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.dist/login.js b/.dist/login.js index 4d25bdb..5ff4e0b 100644 --- a/.dist/login.js +++ b/.dist/login.js @@ -421,10 +421,11 @@ if (datalist) { instancein.value = json[0].name; } for (const instance of json) { - if (instance.display === false || !instance.online) { + if (instance.display === false) { continue; } const option = document.createElement("option"); + option.disabled = !instance.online; option.value = instance.name; if (instance.url) { stringURLMap.set(option.value, instance.url); diff --git a/webpage/login.ts b/webpage/login.ts index 6a8b3c9..1d4772e 100644 --- a/webpage/login.ts +++ b/webpage/login.ts @@ -411,10 +411,11 @@ if(datalist){ instancein.value=json[0].name; } for(const instance of json){ - if(instance.display===false||!instance.online){ + if(instance.display===false){ continue; } const option=document.createElement("option"); + option.disabled=!instance.online; option.value=instance.name; if(instance.url){ stringURLMap.set(option.value,instance.url); From d6a5525da1c8f33c9aeed68046af3e57110d0029 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 22:05:09 -0500 Subject: [PATCH 13/16] fix another CSS bug --- webpage/style.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webpage/style.css b/webpage/style.css index 18dc7df..66902dd 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -1258,7 +1258,7 @@ span { /* padding-bottom: .1in; */ align-items: flex-start; width: 100%; - height: 100%; + /* height: 100%; */ } .settingbuttons{ padding-top:.075in; @@ -1463,6 +1463,7 @@ span { width: 100%; flex-direction: column; max-height:100in; + justify-content: flex-end; } #connection-container, #app-list-container { From aeb7915d28251c09410ac04638b378aff8dd8f42 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 22:08:35 -0500 Subject: [PATCH 14/16] fix CSS bug from recent commit --- webpage/style.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webpage/style.css b/webpage/style.css index 66902dd..0657c31 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -1297,9 +1297,8 @@ span { font-weight:900; font-size:.25in; border-bottom: solid .03in var(--message-bg-hover); - background: var(--primary-bg); padding: .06in .2in; - background: var(--server-bg); + background: var(--channel-name-bg); box-sizing: border-box; } .exitsettings{ From f05de33f8dfece8c5f6a5754910102ebc51cd345 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 22:39:13 -0500 Subject: [PATCH 15/16] fix dumb typo and fix CSS --- stats.js | 8 ++++---- webpage/style.css | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stats.js b/stats.js index f9ee3b2..7c82cc9 100644 --- a/stats.js +++ b/stats.js @@ -28,7 +28,7 @@ async function observe(instances){ } if(!api||api===""){ - setSatus(instance,false); + setStatus(instance,false); console.warn(instance.name+" does not resolve api URL"); setTimeout(_=>{resolveinstance(instance)},1000*60*30,); return @@ -37,7 +37,7 @@ async function observe(instances){ api+=api.endsWith("/")?"":"/" function check(){ fetch(api+"ping").then(_=>{ - setSatus(instance,_.ok); + setStatus(instance,_.ok); }) } setTimeout( @@ -56,7 +56,7 @@ async function observe(instances){ await Promise.allSettled(promlist); for(const key of Object.keys(uptimeObject)){ if(!active.has(key)){ - setSatus(key,false); + setStatus(key,false); } } } @@ -120,7 +120,7 @@ function calcStats(instance){ * @param {string|Object} instance * @param {boolean} status */ -function setSatus(instance,status){ +function setStatus(instance,status){ let name=instance.name; if(typeof instance==="string" ){ name=instance; diff --git a/webpage/style.css b/webpage/style.css index 0657c31..8580fe6 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -2015,10 +2015,10 @@ form div{ .instance{ img{ width:.6in; - height:.6in; - margin-right:.1in; - border-radius:.2in; - border:solid .03in var(--black); + height:.6in; + margin-right:.1in; + border-radius:.2in; + border:solid .03in var(--black); } h2{ font-size:.25in; From df9e7d55aac296ac562476bfbde263b731ac3e06 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 29 Aug 2024 22:52:54 -0500 Subject: [PATCH 16/16] prevent flashing on the webpages --- webpage/home.html | 2 +- webpage/invite.html | 2 +- webpage/login.html | 2 +- webpage/register.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webpage/home.html b/webpage/home.html index a6ffaab..968b747 100644 --- a/webpage/home.html +++ b/webpage/home.html @@ -12,7 +12,7 @@ - +

Jank Client

diff --git a/webpage/invite.html b/webpage/invite.html index 41c21bb..39f2bc0 100644 --- a/webpage/invite.html +++ b/webpage/invite.html @@ -1,4 +1,4 @@ - + diff --git a/webpage/login.html b/webpage/login.html index 9b0dd0a..63094ac 100644 --- a/webpage/login.html +++ b/webpage/login.html @@ -1,4 +1,4 @@ - + diff --git a/webpage/register.html b/webpage/register.html index f35ef56..b688038 100644 --- a/webpage/register.html +++ b/webpage/register.html @@ -1,4 +1,4 @@ - +