mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 11:31:46 +00:00
refactor: auto format
This commit is contained in:
parent
04f905a841
commit
100d37e552
@ -36,7 +36,5 @@ export function getLuminance(rgb: Color): number {
|
||||
|
||||
// Convert an rgb color object to a hex color string
|
||||
export function rgbToHex(color: Color): string {
|
||||
return [color.r, color.g, color.b]
|
||||
.map((e) => e.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
return [color.r, color.g, color.b].map((e) => e.toString(16).padStart(2, '0')).join('');
|
||||
}
|
||||
|
@ -5,10 +5,9 @@ export async function redirectAPI({ form, fdata }: { form?: HTMLFormElement; fda
|
||||
else if (!fdata) throw new Error('No formdata provided!');
|
||||
|
||||
// Get endpoint, prefer form, then formdata or empty
|
||||
const endpoint = (form?.dataset.endpoint ?? fdata.get('endpoint')) ?? '';
|
||||
const endpoint = form?.dataset.endpoint ?? fdata.get('endpoint') ?? '';
|
||||
// Append endpoint to formdata
|
||||
if (!fdata?.has('endpoint'))
|
||||
fdata.append('endpoint', endpoint);
|
||||
if (!fdata?.has('endpoint')) fdata.append('endpoint', endpoint);
|
||||
|
||||
// Send request to be redirected to given endpoint
|
||||
const response = await fetch('/api/redirect', {
|
||||
|
@ -46,9 +46,6 @@ export function createGridArray(matrix: Matrix): MatrixCell[][] {
|
||||
const { factor } = scale;
|
||||
|
||||
return Array.from({ length: height / factor }, (_, y) =>
|
||||
Array.from(
|
||||
{ length: width / factor },
|
||||
(_, x) => ({ x, y, color: '000000' }) as MatrixCell
|
||||
)
|
||||
Array.from({ length: width / factor }, (_, x) => ({ x, y, color: '000000' }) as MatrixCell)
|
||||
) as MatrixCell[][];
|
||||
}
|
||||
|
@ -227,7 +227,9 @@
|
||||
matrix = initializeMatrix();
|
||||
matrix.scale = {
|
||||
factor: 4,
|
||||
// 0.1875 (made up padding) * 192 (height when it was made up) * 4 (scaling when it was made up)
|
||||
// 0.1875 (made up padding) *
|
||||
// 192 (height when it was made up) *
|
||||
// 4 (scaling when it was made up)
|
||||
padding: 144 / matrix.width
|
||||
};
|
||||
matrix.grid = createGridArray(matrix);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { APIResponse } from "$lib/interfaces";
|
||||
import { json, type RequestHandler } from "@sveltejs/kit";
|
||||
import type { APIResponse } from '$lib/interfaces';
|
||||
import { json, type RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
// Get endpoint on main API from searchparams
|
||||
@ -11,7 +11,7 @@ export const GET: RequestHandler = async ({ url }) => {
|
||||
// Get subreddit page data
|
||||
const response = await fetch(`https://www.reddit.com/r/${subreddit}/`, {
|
||||
headers: new Headers({
|
||||
"User-Agent": "MatrixRedditMemes/0.0.1"
|
||||
'User-Agent': 'MatrixRedditMemes/0.0.1'
|
||||
})
|
||||
});
|
||||
// Read data as string
|
||||
@ -19,9 +19,9 @@ export const GET: RequestHandler = async ({ url }) => {
|
||||
|
||||
// Get all sources of posts
|
||||
const regex = /<img[^>]+role="presentation"[^>]+src="(.*?)"[^>]*>/g;
|
||||
let results = [], match;
|
||||
while ((match = regex.exec(text)) !== null)
|
||||
results.push(match[1]);
|
||||
let results = [],
|
||||
match;
|
||||
while ((match = regex.exec(text)) !== null) results.push(match[1]);
|
||||
|
||||
// Return source data
|
||||
return json({ success: true, results } as APIResponse);
|
||||
|
@ -10,11 +10,13 @@
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler",
|
||||
"plugins": [{
|
||||
"plugins": [
|
||||
{
|
||||
"name": "typescript-svelte-plugin",
|
||||
"assumeIsSvelteProject": false,
|
||||
"enabled": true
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||
//
|
||||
|
@ -6,5 +6,5 @@ export default defineConfig({
|
||||
test: {
|
||||
include: ['src/**/*.{test,spec}.{js,ts}'],
|
||||
exclude: ['src/playwright']
|
||||
},
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user