mirror of
https://github.com/Findus23/lw1.at.git
synced 2024-09-18 14:33:44 +02:00
stricter typescript
This commit is contained in:
parent
b4a6d1f374
commit
80eeee92e7
8 changed files with 46 additions and 19 deletions
|
@ -1,11 +1,13 @@
|
|||
import {matomo} from "./matomo";
|
||||
|
||||
export function initFeedback() {
|
||||
const feedbackButton = document.getElementById("readmore")
|
||||
const feedbackDiv = document.getElementById("sentReadmore")
|
||||
const feedbackDiv = document.getElementById("sentReadmore")!
|
||||
if (feedbackButton) {
|
||||
feedbackButton.addEventListener("click", ev => {
|
||||
const id = feedbackButton.dataset.id
|
||||
if (typeof window._paq != "undefined") {
|
||||
window._paq.push(['trackEvent', 'Feedback', 'readmore', id]);
|
||||
feedbackButton.addEventListener("click", () => {
|
||||
const id = feedbackButton.dataset["id"]
|
||||
if (matomo) {
|
||||
matomo.trackEvent('Feedback', 'readmore', id);
|
||||
} else {
|
||||
console.info("Feedback not sent as Matomo isn't loaded");
|
||||
}
|
||||
|
|
|
@ -8,10 +8,13 @@ const height = width / 2;
|
|||
|
||||
function drawBlurhash(canvasEl: HTMLCanvasElement) {
|
||||
const hash = canvasEl.getAttribute("data-blurhash")
|
||||
if (!hash) {
|
||||
return
|
||||
}
|
||||
|
||||
const pixels = decode(hash, width, height);
|
||||
|
||||
const ctx = canvasEl.getContext("2d");
|
||||
const ctx = canvasEl.getContext("2d")!;
|
||||
const imageData = new ImageData(pixels, width, height);
|
||||
// ctx.scale(10, 10);
|
||||
ctx.putImageData(imageData, 0, 0);
|
||||
|
@ -20,7 +23,7 @@ function drawBlurhash(canvasEl: HTMLCanvasElement) {
|
|||
}
|
||||
|
||||
|
||||
const canvasList = Array.from(document.querySelectorAll("canvas[data-blurhash]"))
|
||||
const canvasList: HTMLCanvasElement[] = Array.from(document.querySelectorAll("canvas[data-blurhash]"))
|
||||
canvasList.slice(0, 5)
|
||||
.forEach(drawBlurhash)
|
||||
|
||||
|
|
|
@ -5,17 +5,19 @@ import {BrowserFeatures} from "matomo-lite-tracker/src/browserfeatures"
|
|||
import {enableLinkTracking} from "matomo-lite-tracker/src/linktracking"
|
||||
import {isDoNotTrackEnabled} from "matomo-lite-tracker/src/util"
|
||||
|
||||
export let matomo: MatomoLiteTracker | undefined
|
||||
|
||||
export function initMatomo(): void {
|
||||
if (isDebug|| isDoNotTrackEnabled()) {
|
||||
if (isDebug || isDoNotTrackEnabled()) {
|
||||
return
|
||||
}
|
||||
const matomo = new MatomoLiteTracker("https://matomo.lw1.at", 14)
|
||||
matomo.performanceMetric = new PerformanceMetric()
|
||||
const m = new MatomoLiteTracker("https://matomo.lw1.at", 14)
|
||||
m.performanceMetric = new PerformanceMetric()
|
||||
|
||||
matomo.browserFeatures = new BrowserFeatures()
|
||||
m.browserFeatures = new BrowserFeatures()
|
||||
|
||||
enableLinkTracking(matomo, [])
|
||||
matomo.trackPageview()
|
||||
enableLinkTracking(m, [])
|
||||
m.trackPageview()
|
||||
matomo = m
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export function defaultLanguage(): string {
|
||||
import type {Language} from "./types";
|
||||
|
||||
export function defaultLanguage(): Language {
|
||||
const lang = navigator.language.toLowerCase()
|
||||
if (lang.includes("de")) {
|
||||
return "de"
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
export function initSearch() {
|
||||
const searchWrapper = document.getElementById("search") as HTMLInputElement
|
||||
const cards = document.querySelectorAll(".card")
|
||||
const cards: NodeListOf<HTMLDivElement> = document.querySelectorAll(".card")
|
||||
if (searchWrapper) {
|
||||
searchWrapper.addEventListener("input", ev => {
|
||||
searchWrapper.addEventListener("input", () => {
|
||||
const query = searchWrapper.value.toLowerCase()
|
||||
cards.forEach((card: HTMLDivElement) => {
|
||||
const title = card.dataset.title
|
||||
const title = card.dataset["title"]
|
||||
if (!title) {
|
||||
return
|
||||
}
|
||||
card.style.display = title.includes(query) ? "block" : "none"
|
||||
})
|
||||
})
|
||||
|
|
1
assets/types.ts
Normal file
1
assets/types.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export type Language = "de" | "en"
|
|
@ -1,2 +1,2 @@
|
|||
export const isDebug = document.body.dataset.debug == "True"
|
||||
export const isDebug = document.body.dataset["debug"] == "True"
|
||||
|
||||
|
|
|
@ -1,8 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node"
|
||||
"moduleResolution": "Node",
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowUnusedLabels": false,
|
||||
"allowUnreachableCode": false,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"importsNotUsedAsValues": "error"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue