From 143451e39cdf10d7587e7c1522d7d3c6d27607e7 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 25 Jun 2023 12:00:43 +0200 Subject: [PATCH] Miscellaneous utilities fixes. --- source/utilities/elements.ts | 2 +- source/utilities/globals.ts | 3 +++ source/utilities/groups.ts | 3 +-- source/utilities/logging.ts | 2 +- source/utilities/query-selectors.ts | 12 +++++++----- source/utilities/report-a-bug.ts | 20 +++++++------------- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/source/utilities/elements.ts b/source/utilities/elements.ts index c9d64ae..5028f4e 100644 --- a/source/utilities/elements.ts +++ b/source/utilities/elements.ts @@ -1,6 +1,6 @@ /** * Creates an HTML Element from a given string. Only use this when using - * `htm/preact` isn't practical. + * Preact isn't practical. */ export function createElementFromString(input: string): T { const template = document.createElement("template"); diff --git a/source/utilities/globals.ts b/source/utilities/globals.ts index 22c180c..8e780f0 100644 --- a/source/utilities/globals.ts +++ b/source/utilities/globals.ts @@ -1,3 +1,6 @@ +/** + * Initialize the `TildesReExtended` global. + */ export function initializeGlobals() { if (window.TildesReExtended === undefined) { window.TildesReExtended = { diff --git a/source/utilities/groups.ts b/source/utilities/groups.ts index 024169b..0b3fab6 100644 --- a/source/utilities/groups.ts +++ b/source/utilities/groups.ts @@ -2,8 +2,7 @@ import {log} from "./logging.js"; import {querySelectorAll} from "./query-selectors.js"; /** - * Tries to extract and save the groups. Returns the current saved groups when - * the user is not in `/groups` and the new ones when they are in `/groups`. + * Try to extract the groups when in the group listing page at `/groups`. */ export function extractGroups(): string[] | undefined { if (window.location.pathname !== "/groups") { diff --git a/source/utilities/logging.ts b/source/utilities/logging.ts index b54afb1..19199fb 100644 --- a/source/utilities/logging.ts +++ b/source/utilities/logging.ts @@ -1,5 +1,5 @@ /** - * Logs something to the console under the debug level. + * Log something to the console under the debug level. * @param thing The thing to log. * @param force If true, ignores whether or not debug logging is enabled. */ diff --git a/source/utilities/query-selectors.ts b/source/utilities/query-selectors.ts index 3e5d2db..4a30263 100644 --- a/source/utilities/query-selectors.ts +++ b/source/utilities/query-selectors.ts @@ -1,15 +1,17 @@ // These utility functions mainly exist so it's easier to work with TypeScript's // typing and so we don't have to write `document.query...` all the time. -// The first function should only ever be used when we know for certain that -// the target element is going to exist. - -/** Returns the first element found that matches the selector. */ +/** + * Get the first element found that matches the selector. Only use this when you + * know for certain that the target element exists. + */ export function querySelector(selector: string): T { return document.querySelector(selector)!; } -/** Returns all elements found from all the selectors. */ +/** + * Get all elements found from all the given selectors. + */ export function querySelectorAll( ...selectors: string[] ): T[] { diff --git a/source/utilities/report-a-bug.ts b/source/utilities/report-a-bug.ts index f48e4c4..bf489c3 100644 --- a/source/utilities/report-a-bug.ts +++ b/source/utilities/report-a-bug.ts @@ -9,12 +9,11 @@ export function createReportTemplate( location: "gitlab" | "tildes", trxVersion: string, ): string { - let introText = - "Thank you for taking the time to report a bug! Don't forget to fill in an\n appropriate title above, and make sure the information below is correct."; + let introText = "Thank you for taking the time to report a bug!"; + introText += "\n Please make sure the information below is correct."; - if (location === "tildes") { - introText = - "Thank you for taking the time to report a bug! Please make sure the\n information below is correct."; + if (location === "gitlab") { + introText += "\n Don't forget to set a title for the issue!"; } const layout = platform.layout ?? ""; @@ -43,16 +42,11 @@ export function createReportTemplate( reportTemplate += `| Device | ${manufacturer} ${product} |\n`; } - reportTemplate += `\n

The Problem

+ reportTemplate += `\n \n\n\n -

A Solution

-\n\n\n`; return reportTemplate;