aboutsummaryrefslogtreecommitdiffstats
path: root/apps/kit/src/lib
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-09-24 09:36:46 +0200
committerivarlovlie <git@ivarlovlie.no>2022-09-24 09:36:46 +0200
commit551b32a9ebba360d437003b73831f117172be06e (patch)
tree2875c6610f53c095e48a3aa8c6d307d66de54216 /apps/kit/src/lib
parent391fc9e9dee01c9bc4f36792ac1e99edeab49b58 (diff)
downloadgreatoffice-551b32a9ebba360d437003b73831f117172be06e.tar.xz
greatoffice-551b32a9ebba360d437003b73831f117172be06e.zip
feat: Add capitalise
Diffstat (limited to 'apps/kit/src/lib')
-rw-r--r--apps/kit/src/lib/helpers.ts22
1 files changed, 13 insertions, 9 deletions
diff --git a/apps/kit/src/lib/helpers.ts b/apps/kit/src/lib/helpers.ts
index f0f60cd..c2a811e 100644
--- a/apps/kit/src/lib/helpers.ts
+++ b/apps/kit/src/lib/helpers.ts
@@ -1,8 +1,8 @@
-import {browser} from "$app/environment";
-import type {TimeEntryDto} from "$lib/models/TimeEntryDto";
-import type {UnwrappedEntryDateTime} from "$lib/models/UnwrappedEntryDateTime";
-import {logInfo} from "$lib/logger";
-import {Temporal} from "temporal-polyfill";
+import { browser } from "$app/environment";
+import type { TimeEntryDto } from "$lib/models/TimeEntryDto";
+import type { UnwrappedEntryDateTime } from "$lib/models/UnwrappedEntryDateTime";
+import { logInfo } from "$lib/logger";
+import { Temporal } from "temporal-polyfill";
export const EMAIL_REGEX = new RegExp(/^([a-z0-9]+(?:([._\-])[a-z0-9]+)*@(?:[a-z0-9]+(?:(-)[a-z0-9]+)?\.)+[a-z0-9](?:[a-z0-9]*[a-z0-9])?)$/i);
export const URL_REGEX = new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-.][a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/gm);
@@ -99,7 +99,7 @@ export function merge_obj_arr<T>(a: Array<T>, b: Array<T>, props: Array<string>)
if (a[start] === b[start]) {
//pushing the merged objects into array
- merge.push({...a[start], ...b[start]});
+ merge.push({ ...a[start], ...b[start] });
}
//incrementing start value
start = start + 1;
@@ -124,6 +124,10 @@ export function set_favicon(url: string) {
}
}
+export function capitalise(value: string): string {
+ return value.charAt(0).toUpperCase() + value.slice(1);
+}
+
export function set_emoji_favicon(emoji: string) {
// Create a canvas element
const canvas = document.createElement("canvas");
@@ -155,7 +159,7 @@ export function seconds_to_hour_minute(seconds: number) {
const hours = Math.floor(seconds / (60 * 60));
seconds -= hours * (60 * 60);
const minutes = Math.floor(seconds / 60);
- return {hours, minutes};
+ return { hours, minutes };
}
export function get_query_string(params: any = {}): string {
@@ -260,7 +264,7 @@ export function create_element(name: string, properties?: object, children?: Arr
}
export function get_element_position(element: HTMLElement | any) {
- if (!element) return {x: 0, y: 0};
+ if (!element) return { x: 0, y: 0 };
let x = 0;
let y = 0;
while (true) {
@@ -271,7 +275,7 @@ export function get_element_position(element: HTMLElement | any) {
}
element = element.offsetParent;
}
- return {x, y};
+ return { x, y };
}
export function restrict_input_to_numbers(element: HTMLElement, specials: Array<string> = [], mergeSpecialsWithDefaults: boolean = false): void {