From b260c88345d044ef33545afc1dc77a01a173ebe9 Mon Sep 17 00:00:00 2001 From: sophie Date: Sat, 27 Jul 2024 17:19:19 +0300 Subject: [PATCH] format everything --- website/scripts/blog.tsx | 18 +++++++++--------- website/scripts/blog_page.tsx | 4 ++-- website/scripts/particles.ts | 25 +++++++++++++++---------- website/scripts/status_cafe.ts | 4 ++-- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/website/scripts/blog.tsx b/website/scripts/blog.tsx index 1c6f2b3..669a854 100644 --- a/website/scripts/blog.tsx +++ b/website/scripts/blog.tsx @@ -1,4 +1,4 @@ -import Nano, { Component, Fragment, Suspense } from "nano-jsx" +import Nano, { Component } from "nano-jsx" import { BlogPage } from "./blog_page"; import { Giscus } from "./giscus"; import { useState } from "nano-jsx/esm/hooks/useState.js"; @@ -54,7 +54,7 @@ class Main extends Component { } render(blogPosts: Metadata[]) { - + const pageOpen = useState(undefined, "pageOpen"); const md = new URLSearchParams(location.search).get("md"); let pageOpenValueRender = pageOpen[0]; @@ -72,13 +72,13 @@ class Main extends Component { } return <> -

blog & comments

- {() => { - if (blogPosts) return this.list(blogPosts) - else return

Loading...

- }} - - +

blog & comments

+ {() => { + if (blogPosts) return this.list(blogPosts) + else return

Loading...

+ }} + + } } diff --git a/website/scripts/blog_page.tsx b/website/scripts/blog_page.tsx index 8bd08e7..bc826fa 100644 --- a/website/scripts/blog_page.tsx +++ b/website/scripts/blog_page.tsx @@ -24,13 +24,13 @@ export class BlogPage extends Component { render(blogPost: string) { const pageOpen = useState(undefined, "pageOpen"); - history.replaceState({}, "", location.pathname+"?md=" + this.metadata.filename); + history.replaceState({}, "", location.pathname + "?md=" + this.metadata.filename); return <>

blog & comments

{ pageOpen[1](undefined); - history.replaceState({}, "", location.pathname+"?md="); + history.replaceState({}, "", location.pathname + "?md="); this.updateParent(); }}>return back? diff --git a/website/scripts/particles.ts b/website/scripts/particles.ts index d31b091..b45e0c3 100644 --- a/website/scripts/particles.ts +++ b/website/scripts/particles.ts @@ -29,10 +29,15 @@ class Particle { this.x = x; this.y = y; this.id = Math.random(); - this.angle = 2*Math.PI*this.id; - this.color = "hsl(" + 360 * Math.random() + ',' + - (25 + 70 * Math.random()) + '%,' + - (85 + 10 * Math.random()) + '%)'; + this.angle = 2 * Math.PI * this.id; + this.color = + "hsl(" + + 360 * Math.random() + + "," + + (25 + 70 * Math.random()) + + "%," + + (85 + 10 * Math.random()) + + "%)"; this.style = Math.random() < 0.5 ? "-" : Math.random() > 0.5 ? "+" : "*"; } @@ -40,18 +45,18 @@ class Particle { this.y += 2; this.x -= getRandomArbitrary(-1, 1); - var width2=renderSurfaceContext.measureText("+").width; + var width2 = renderSurfaceContext.measureText("+").width; renderSurfaceContext.save(); renderSurfaceContext.fillStyle = this.color; - renderSurfaceContext.font = Math.floor(this.id*60)+"px Arial"; + renderSurfaceContext.font = Math.floor(this.id * 60) + "px Arial"; renderSurfaceContext.translate(this.x, this.y); - renderSurfaceContext.rotate(2*Math.PI*this.id); - renderSurfaceContext.fillText(this.style, -width2/2,4); + renderSurfaceContext.rotate(2 * Math.PI * this.id); + renderSurfaceContext.fillText(this.style, -width2 / 2, 4); renderSurfaceContext.restore(); - + if (renderSurface.height < this.y) { - particles = particles.filter(z=>z.id !== this.id) + particles = particles.filter((z) => z.id !== this.id); } } } diff --git a/website/scripts/status_cafe.ts b/website/scripts/status_cafe.ts index 905fa76..77f5a90 100644 --- a/website/scripts/status_cafe.ts +++ b/website/scripts/status_cafe.ts @@ -33,7 +33,7 @@ interface LatestStatus { const parser = new DOMParser(); const doc = parser.parseFromString(await req.text(), "text/xml"); const latestEntryRaw = doc.querySelector("feed > entry"); - if (!latestEntryRaw) throw new Error("Missing latest entry!");; + if (!latestEntryRaw) throw new Error("Missing latest entry!"); const latestEntry: LatestStatus = { username: doc.querySelector("feed > author > name")?.textContent!, @@ -46,7 +46,7 @@ interface LatestStatus { .slice(0, -Math.min(latestEntry.status.length, 53)) .trim(); const statusElement = document.getElementById("status"); - if(!statusElement) throw new Error("Missing status element!"); + if (!statusElement) throw new Error("Missing status element!"); const h2 = document.createElement("h2"); const a = document.createElement("a"); const p = document.createElement("p");