Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/og/saat-hesaplama.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,16 @@ code {
visibility: hidden;
}

/* saat hesaplama: two short columns read better than a full-width table */
.saat-table {
max-width: 22em;
}

.saat-table th[scope="row"] {
color: var(--foreground);
font-size: 14px;
}

/* word frequency counter: the table scrolls inside the output pane */
.pane-title {
font-size: 14px;
Expand Down
78 changes: 77 additions & 1 deletion scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const YUZDE = "/tr/yuzde-hesaplama/";
const ORTALAMA = "/tr/ortalama-hesaplama/";
const GUN = "/tr/gun-hesaplama/";
const ISG = "/tr/is-gunu-hesaplama/";
const SAAT = "/tr/saat-hesaplama/";
const DAYS = "/days-between-dates/";
const LINES = "/remove-line-breaks/";
const HEX = "/hex-to-rgb/";
Expand Down Expand Up @@ -1217,12 +1218,86 @@ for (const width of [1440, 390]) {
await context.close();
}

for (const width of [1280, 390]) {
const label = `saat ${width}`;
const { context, page, errors } = await open(width, SAAT, label);
await page.evaluate(() => localStorage.clear());
await page.reload({ waitUntil: "networkidle" });
const val = (id) => page.textContent(`#${id}`);
const row = (n, k) => page.locator(".avg-row:not(.avg-head)").nth(n).locator(`[data-k="${k}"]`);
const pick = (value) => page.locator(`label:has(input[name="op"][value="${value}"]) span`).click();
expect((await page.locator(`a[href="${ISG}"]`).count()) >= 1 && (await page.locator(`a[href="${GUN}"]`).count()) >= 1, `${label}: no links to the date tools`);
expect((await page.locator(".saat-table tbody tr").count()) === 12, `${label}: minute table rows`);

await page.fill("#start", "08:30");
await page.fill("#end", "17:00");
expect((await val("span-out")) === "8 saat 30 dakika" && (await val("span-dec")) === "8,5 saat" && (await val("span-break")) === "Yok", `${label}: span gave ${await val("span-out")}`);
await page.fill("#break", "60");
expect((await val("span-out")) === "7 saat 30 dakika" && (await val("span-min")) === "450 dakika" && (await val("span-dec")) === "7,5 saat", `${label}: break gave ${await val("span-out")}`);
expect((await val("span-formula")).includes("8 saat 30 dakika - 60 dakika mola = 7 saat 30 dakika"), `${label}: span formula ${await val("span-formula")}`);
await page.fill("#break", "600");
expect((await val("span-out")) === "-" && (await val("span-status")).includes("uzun olamaz"), `${label}: long break not reported`);
await page.fill("#break", "");
await page.fill("#start", "22:00");
await page.fill("#end", "0600");
expect((await val("span-out")) === "8 saat" && (await val("span-sub")).includes("ertesi gün") && (await val("span-status")).includes("ertesi güne"), `${label}: night gave ${await val("span-out")}`);
await page.fill("#start", "9:20");
await page.fill("#end", "10:00");
expect((await val("span-dec")) === "0,67 saat" && (await val("span-formula")).includes("≈"), `${label}: rounding gave ${await val("span-dec")}`);
await page.fill("#end", "25:00");
expect((await val("span-out")) === "-" && (await val("span-status")).includes("Bitiş"), `${label}: bad end not reported`);
await page.fill("#end", "8:");
expect((await val("span-status")) === "", `${label}: half typed time reported`);

await page.fill("#base", "22:00");
await page.fill("#shift-h", "3");
await page.fill("#shift-m", "30");
expect((await val("shift-out")) === "01:30" && (await val("shift-sub")) === "Ertesi gün" && (await val("shift-formula")).includes("(ertesi gün)"), `${label}: add gave ${await val("shift-out")}`);
await page.fill("#shift-m", "90");
expect((await val("shift-out")) === "02:30" && (await val("shift-dur")) === "4 saat 30 dakika", `${label}: minute overflow gave ${await val("shift-out")}`);
await pick("sub");
await page.fill("#base", "01:00");
await page.fill("#shift-h", "50");
await page.fill("#shift-m", "");
expect((await val("shift-out")) === "23:00" && (await val("shift-sub")) === "3 gün önce", `${label}: sub gave ${await val("shift-out")} ${await val("shift-sub")}`);
await page.fill("#shift-h", "x");
expect((await val("shift-out")) === "-" && (await val("shift-status")).length > 5, `${label}: bad hours not reported`);
await page.reload({ waitUntil: "networkidle" });
expect(await page.isChecked('input[name="op"][value="sub"]'), `${label}: op not remembered`);
expect((await page.inputValue("#start")) === "", `${label}: times were kept`);
await pick("add");

await row(0, "h").fill("7");
await row(0, "m").fill("45");
await row(1, "h").fill("8");
await row(1, "m").fill("30");
await page.click("#add-row");
expect((await page.locator(".avg-row:not(.avg-head)").count()) === 4, `${label}: row not added`);
await row(3, "m").fill("90");
expect((await val("sum-out")) === "17 saat 45 dakika" && (await val("sum-hm")) === "17:45" && (await val("sum-dec")) === "17,75 saat" && (await val("sum-status")).includes("60"), `${label}: sum gave ${await val("sum-out")}`);
await row(2, "h").fill("-2");
expect((await val("sum-out")) === "-" && (await val("sum-status")).includes("3."), `${label}: bad row not reported`);
await page.locator(".avg-row:not(.avg-head)").nth(2).locator(".avg-del").click();
expect((await page.locator(".avg-row:not(.avg-head)").count()) === 3 && (await val("sum-out")) === "17 saat 45 dakika", `${label}: row not removed`);

await page.fill("#start", "08:30");
await page.fill("#end", "17:00");
await page.fill("#break", "60");
await page.fill("#base", "22:00");
await page.fill("#shift-h", "3");
await page.fill("#shift-m", "30");
await page.screenshot({ path: `${shots}/tr-saat-${width}.png`, fullPage: true });
await langMenu(page, label, "tr", { en: "/", tr: SAAT }, null);
finish(errors, label);
await context.close();
}

for (const path of OTHER) {
for (const width of [1440, 390]) {
const label = `${path} ${width}`;
const { context, page, errors } = await open(width, path, label);
await page.screenshot({ path: `${shots}/page${path.replace(/\//g, "_")}-${width}.png`, fullPage: true });
if (path !== "/missing-page") expect((await page.locator(".tool-card").count()) === 20, `${label}: index does not list every tool`);
if (path !== "/missing-page") expect((await page.locator(".tool-card").count()) === 21, `${label}: index does not list every tool`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/kdv-hesaplama/"]').count()) === 1, `${label}: index does not link KDV`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/yas-hesaplama/"]').count()) === 1, `${label}: index does not link yaş hesaplama`);
if (path !== "/missing-page") expect((await page.locator(`.tool-card a[href="${path === "/tr/" ? GUN : DAYS}"]`).count()) === 1, `${label}: index does not link days between dates`);
Expand All @@ -1239,6 +1314,7 @@ for (const path of OTHER) {
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/yuzde-hesaplama/"]').count()) === 1, `${label}: index does not link yüzde hesaplama`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/ortalama-hesaplama/"]').count()) === 1, `${label}: index does not link ortalama hesaplama`);
if (path !== "/missing-page") expect((await page.locator(`.tool-card a[href="${ISG}"]`).count()) === 1, `${label}: index does not link iş günü hesaplama`);
if (path !== "/missing-page") expect((await page.locator(`.tool-card a[href="${SAAT}"]`).count()) === 1, `${label}: index does not link saat hesaplama`);
const lang = path === "/tr/" ? "tr" : "en";
await langMenu(page, label, lang, HOME, `${shots}/menu${path.replace(/\//g, "_")}-${width}.png`);
finish(errors, label);
Expand Down
67 changes: 65 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,70 @@ ${holTable("shift-hol", u.shiftHolTitle, u)}
</section>`;
}

const TOOL_BODY = { paste: pasteTool, linebreaks: lineBreaksTool, case: caseTool, color: colorTool, invisible: invisibleTool, repeater: repeaterTool, chmod: chmodTool, slug: slugTool, special: specialTool, counter: counterTool, frequency: frequencyTool, reverse: caseTool, flip: pasteTool, compare: compareTool, kdv: kdvTool, yas: yasTool, dates: datesTool, yuzde: pctTool, ortalama: avgTool, gun: gunTool, isgunu: isgunuTool };
/** One duration row for the sum card; the page script clones the first one, so the labels carry a {n} the script fills in. */
function durRow(u, n) {
const label = (tpl) => esc(tpl.replace("{n}", n));
const input = (k, tpl, ph) => `<input class="input" type="text" inputmode="numeric" autocomplete="off" spellcheck="false" maxlength="7" data-k="${k}" aria-label="${label(tpl)}" placeholder="${esc(ph[n - 1] ?? "")}">`;
return `<div class="avg-row">${input("h", u.messages.hRow, u.hPh)}${input("m", u.messages.mRow, u.mPh)}<button type="button" class="btn btn-quiet avg-del" aria-label="${label(u.messages.removeRow)}">${REMOVE}</button></div>`;
}

/** Three time calculators in one panel: the span between two times, a time moved by a duration, and a sum of durations. */
function saatTool(page) {
const u = page.ui;
const row = (id, label) => `<div class="calc-row"><dt>${esc(label)}</dt><dd id="${id}">-</dd></div>`;
const field = (id, f, mode = "decimal", max = 5) =>
`<div class="field"><label for="${id}">${esc(f.label)}</label><input id="${id}" class="input" type="text" inputmode="${mode}" autocomplete="off" spellcheck="false" maxlength="${max}" placeholder="${esc(f.ph)}"${f.hint ? ` aria-describedby="${id}-hint"` : ""}>${f.hint ? `<small id="${id}-hint">${esc(f.hint)}</small>` : ""}</div>`;
const out = (id, label, rows) => `<div class="calc-out">
<div class="age-main"><span>${esc(label)}</span><strong id="${id}-out">-</strong><p id="${id}-sub"></p></div>
<dl>
${rows.map(([r, l]) => row(`${id}-${r}`, l)).join("\n")}
</dl>
<p class="formula" id="${id}-formula" aria-label="${esc(u.formula)}"></p>
<p class="status calc-status" id="${id}-status" role="status" aria-live="polite"></p>
</div>`;
return `<section class="tool pct saat" aria-label="${esc(u.toolLabel)}">
<div class="pct-bar"><p>${esc(u.barHint)}</p></div>
<div class="calc pct-card" id="span">
<div class="calc-in">
<div class="pct-head"><h3>${esc(u.span.title)}</h3><p>${esc(u.span.question)}</p></div>
<div class="pct-fields">${field("start", u.start)}${field("end", u.end)}</div>
${field("break", u.brk, "numeric", 4)}
</div>
${out("span", u.span.result, [
["gross", u.rows.gross],
["break", u.rows.brk],
["min", u.rows.minutes],
["dec", u.rows.decimal],
])}
</div>
<div class="calc pct-card" id="shift">
<div class="calc-in">
<div class="pct-head"><h3>${esc(u.shift.title)}</h3><p>${esc(u.shift.question)}</p></div>
${field("base", u.base)}
<div class="seg seg-radio pct-dir" role="radiogroup" aria-label="${esc(u.opLabel)}">${u.ops.map(([v, l], i) => radio("op", v, l, i === 0)).join("")}</div>
<div class="pct-fields">${field("shift-h", u.hours, "numeric", 7)}${field("shift-m", u.minutes, "numeric", 7)}</div>
</div>
${out("shift", u.shift.result, [["dur", u.rows.duration]])}
</div>
<div class="calc pct-card" id="sum">
<div class="calc-in">
<div class="pct-head"><h3>${esc(u.sum.title)}</h3><p>${esc(u.sum.question)}</p></div>
<div class="avg-rows" role="group" aria-label="${esc(u.sum.title)}">
<div class="avg-row avg-head" aria-hidden="true"><span>${esc(u.hourHead)}</span><span>${esc(u.minuteHead)}</span><span></span></div>
${[1, 2, 3].map((n) => durRow(u, n)).join("\n")}
</div>
<div><button type="button" class="btn btn-outline" id="add-row">${PLUS}${esc(u.addRow)}</button></div>
</div>
${out("sum", u.sum.result, [
["hm", u.rows.hm],
["min", u.rows.minutes],
["dec", u.rows.decimal],
])}
</div>
</section>`;
}

const TOOL_BODY = { paste: pasteTool, linebreaks: lineBreaksTool, case: caseTool, color: colorTool, invisible: invisibleTool, repeater: repeaterTool, chmod: chmodTool, slug: slugTool, special: specialTool, counter: counterTool, frequency: frequencyTool, reverse: caseTool, flip: pasteTool, compare: compareTool, kdv: kdvTool, yas: yasTool, dates: datesTool, yuzde: pctTool, ortalama: avgTool, gun: gunTool, isgunu: isgunuTool, saat: saatTool };

/** Prose, a list of titled rows with sources, and a dated note; the paste and compare pages build theirs from why and shortcuts. */
function infoSection(page, sec) {
Expand Down Expand Up @@ -1053,7 +1116,7 @@ function manifest(lang) {
};
}

const SCRIPTS = ["clean.js", "plain-text.js", "diff.js", "text-compare.js", "kdv.js", "kdv-hesaplama.js", "yas.js", "yas-hesaplama.js", "date-diff.js", "days-between-dates.js", "line-breaks.js", "remove-line-breaks.js", "case.js", "case-converter.js", "color.js", "hex-to-rgb.js", "invisible.js", "invisible-character.js", "repeat.js", "text-repeater.js", "reverse.js", "reverse-text.js", "flip.js", "upside-down-text.js", "chmod.js", "chmod-calculator.js", "slug.js", "slug-generator.js", "special.js", "remove-special-characters.js", "count.js", "karakter-sayaci.js", "frequency.js", "word-frequency-counter.js", "sayi.js", "yuzde.js", "yuzde-hesaplama.js", "ortalama.js", "ortalama-hesaplama.js", "gun-hesaplama.js", "is-gunu.js", "is-gunu-hesaplama.js", "nav.js"];
const SCRIPTS = ["clean.js", "plain-text.js", "diff.js", "text-compare.js", "kdv.js", "kdv-hesaplama.js", "yas.js", "yas-hesaplama.js", "date-diff.js", "days-between-dates.js", "line-breaks.js", "remove-line-breaks.js", "case.js", "case-converter.js", "color.js", "hex-to-rgb.js", "invisible.js", "invisible-character.js", "repeat.js", "text-repeater.js", "reverse.js", "reverse-text.js", "flip.js", "upside-down-text.js", "chmod.js", "chmod-calculator.js", "slug.js", "slug-generator.js", "special.js", "remove-special-characters.js", "count.js", "karakter-sayaci.js", "frequency.js", "word-frequency-counter.js", "sayi.js", "yuzde.js", "yuzde-hesaplama.js", "ortalama.js", "ortalama-hesaplama.js", "gun-hesaplama.js", "is-gunu.js", "is-gunu-hesaplama.js", "saat.js", "saat-hesaplama.js", "nav.js"];
const sha = (...parts) => {
const h = createHash("sha256");
for (const p of parts) h.update(p);
Expand Down
Loading