1
Fork 0

Miscellaneous utilities fixes.

This commit is contained in:
Bauke 2023-06-25 12:00:43 +02:00
parent fdb9b0e711
commit 143451e39c
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
6 changed files with 20 additions and 22 deletions

View File

@ -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<T extends Element>(input: string): T {
const template = document.createElement("template");

View File

@ -1,3 +1,6 @@
/**
* Initialize the `TildesReExtended` global.
*/
export function initializeGlobals() {
if (window.TildesReExtended === undefined) {
window.TildesReExtended = {

View File

@ -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") {

View File

@ -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.
*/

View File

@ -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<T extends Element>(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<T extends Element>(
...selectors: string[]
): T[] {

View File

@ -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 ?? "<unknown>";
@ -43,16 +42,11 @@ export function createReportTemplate(
reportTemplate += `| Device | ${manufacturer} ${product} |\n`;
}
reportTemplate += `\n<h3>The Problem</h3>
reportTemplate += `\n
<!--
Please explain in sufficient detail what the problem is. When possible,
including an image or video showing the problem also helps immensely.
-->\n\n\n
<h3>A Solution</h3>
<!--
If you know of any possible solutions, feel free to include them. If the
solution is just something like "it should work" then you can safely omit
this section.
including an image or video showing the problem also helps immensely, but it's
not required.
-->\n\n\n`;
return reportTemplate;