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/is-gunu-hesaplama.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions public/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,86 @@ code {
overflow-wrap: anywhere;
}

/* iş günü hesaplama: options shared by both cards, holiday lists under each result */
.isg-bar {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr);
gap: 12px 24px;
align-items: start;
padding: 16px 24px;
border-bottom: 1px solid var(--border);
}

.isg-bar .opt {
padding: 0;
}

.isg-arefe {
display: grid;
gap: 6px;
}

.isg-arefe .seg-radio span {
padding: 0 8px;
}

.isg-note {
color: var(--muted-foreground);
}

.isg-hol {
margin-top: 16px;
}

.found caption {
padding-bottom: 6px;
font-size: 14px;
font-weight: 600;
text-align: left;
}

.isg-hol td:first-child {
white-space: nowrap;
}

.isg-more {
margin-top: 8px;
color: var(--muted-foreground);
font-size: 13px;
}

.isg-more:empty {
display: none;
}

.hol-table {
max-width: 42em;
margin-top: 24px;
}

.hol-table caption {
color: var(--muted-foreground);
font-weight: 400;
}

.hol-table td,
.hol-table th[scope="row"] {
white-space: nowrap;
}

@media (max-width: 833px) {
.isg-bar {
grid-template-columns: minmax(0, 1fr);
}
}

@media (max-width: 480px) {
.isg-hol td:first-child,
.hol-table td {
white-space: normal;
}
}

.avg-list {
height: auto;
min-height: 9.5em;
Expand Down
83 changes: 82 additions & 1 deletion scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const YAS = "/tr/yas-hesaplama/";
const YUZDE = "/tr/yuzde-hesaplama/";
const ORTALAMA = "/tr/ortalama-hesaplama/";
const GUN = "/tr/gun-hesaplama/";
const ISG = "/tr/is-gunu-hesaplama/";
const DAYS = "/days-between-dates/";
const LINES = "/remove-line-breaks/";
const HEX = "/hex-to-rgb/";
Expand Down Expand Up @@ -1131,18 +1132,97 @@ for (const width of [1440, 390]) {
await setDate("start", 15, 5, 1990);
await setDate("end", 30, 7, 2026);
await page.fill("#shift-days", "90");
expect((await page.locator(`a[href="${ISG}"]`).count()) >= 2, `${label}: no link to iş günü hesaplama`);
await page.screenshot({ path: `${shots}/tr-gun-${width}.png`, fullPage: true });
await langMenu(page, label, "tr", { en: DAYS, tr: GUN }, null);
finish(errors, label);
await context.close();
}

for (const width of [1440, 390]) {
const label = `isg ${width}`;
const { context, page, errors } = await open(width, ISG, label);
await page.evaluate(() => localStorage.clear());
await page.reload({ waitUntil: "networkidle" });
const val = (id) => page.textContent(`#${id}`);
const setDate = async (p, d, m, y) => {
await page.fill(`#${p}-d`, String(d));
await page.selectOption(`#${p}-m`, String(m));
await page.fill(`#${p}-y`, String(y));
};
const pick = (name, value) => page.locator(`label:has(input[name="${name}"][value="${value}"]) span`).click();
expect((await page.inputValue("#start-y")) === String(new Date().getFullYear()), `${label}: start is not today`);
expect((await page.locator(".hol-table tbody tr").count()) === 14, `${label}: bayram table rows`);
expect((await page.locator('a[href="/tr/gun-hesaplama/"]').count()) >= 1, `${label}: no link to gün hesaplama`);

await setDate("start", 1, 1, 2026);
await setDate("end", 31, 1, 2026);
expect((await val("count-main")) === "21 iş günü" && (await val("we")) === "9 gün" && (await val("hol")) === "1 gün", `${label}: January gave ${await val("count-main")}`);
expect((await page.locator("#hol-body tr").count()) === 1 && (await val("hol-body")).includes("Yılbaşı"), `${label}: holiday list`);
await setDate("start", 2, 1, 2026);
expect((await val("count-main")) === "21 iş günü", `${label}: from 2 January gave ${await val("count-main")}`);
await page.uncheck("#include-start");
expect((await val("count-main")) === "20 iş günü" && (await val("range")).includes("hariç"), `${label}: excluded start gave ${await val("count-main")}`);
await page.check("#include-start");

await setDate("start", 1, 1, 2026);
await setDate("end", 31, 12, 2026);
expect((await val("count-main")) === "249,5 iş günü" && (await val("half")) === "3 gün", `${label}: 2026 gave ${await val("count-main")}`);
await pick("arefe", "work");
expect((await val("count-main")) === "251 iş günü", `${label}: arefe as work gave ${await val("count-main")}`);
await pick("arefe", "off");
expect((await val("count-main")) === "248 iş günü", `${label}: arefe off gave ${await val("count-main")}`);
await pick("arefe", "half");
await page.check("#saturday");
expect((await val("count-main")) === "299,5 iş günü", `${label}: saturday gave ${await val("count-main")}`);
await page.uncheck("#saturday");
await page.uncheck("#holidays");
expect((await val("count-main")) === "261 iş günü" && !(await page.isVisible("#hol-wrap")), `${label}: no holidays gave ${await val("count-main")}`);
await page.check("#holidays");

await setDate("start", 1, 12, 2035);
await setDate("end", 10, 1, 2037);
expect((await val("years-note")).includes("2036-2037"), `${label}: uncovered years not noted: ${await val("years-note")}`);
await setDate("start", 31, 1, 2026);
await setDate("end", 1, 1, 2026);
expect((await val("count-main")) === "21 iş günü" && (await val("status")).length > 10, `${label}: swap gave ${await val("count-main")}`);
await setDate("end", 31, 2, 2023);
expect((await val("status")).includes("28 gün"), `${label}: missing day not reported`);

await setDate("base", 2, 12, 2026);
await page.fill("#shift-days", "20");
expect((await val("shift-out")) === "30 Aralık 2026" && (await val("shift-sub")) === "Çarşamba, 28 takvim günü sonra", `${label}: add gave ${await val("shift-out")} ${await val("shift-sub")}`);
await setDate("base", 18, 3, 2026);
await page.fill("#shift-days", "1");
expect((await val("shift-out")) === "23 Mart 2026" && (await val("shift-status")).includes("1,5") && (await page.locator("#shift-hol-body tr").count()) === 4, `${label}: arefe shift gave ${await val("shift-out")}`);
await pick("op", "sub");
await setDate("base", 23, 3, 2026);
expect((await val("shift-out")) === "18 Mart 2026" && (await val("shift-formula")).includes("- 1 iş günü"), `${label}: sub gave ${await val("shift-out")}`);
await page.fill("#shift-days", "abc");
expect((await val("shift-out")) === "-" && (await val("shift-status")).length > 10, `${label}: bad shift not reported`);
await pick("arefe", "work");
await page.reload({ waitUntil: "networkidle" });
expect(await page.isChecked('input[name="op"][value="sub"]'), `${label}: op not remembered`);
expect(await page.isChecked('input[name="arefe"][value="work"]'), `${label}: arefe not remembered`);

await pick("op", "add");
await pick("arefe", "half");
await setDate("start", 1, 3, 2026);
await setDate("end", 31, 5, 2026);
await setDate("base", 2, 12, 2026);
await page.fill("#shift-days", "20");
await page.screenshot({ path: `${shots}/tr-isg-${width}.png`, fullPage: true });
await langMenu(page, label, "tr", { en: "/", tr: ISG }, 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()) === 19, `${label}: index does not list every tool`);
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 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 @@ -1158,6 +1238,7 @@ for (const path of OTHER) {
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/word-frequency-counter/"]').count()) === 1, `${label}: index does not link the word frequency counter`);
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`);
const lang = path === "/tr/" ? "tr" : "en";
await langMenu(page, label, lang, HOME, `${shots}/menu${path.replace(/\//g, "_")}-${width}.png`);
finish(errors, label);
Expand Down
62 changes: 60 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,65 @@ ${dateFields("base", u.base, u, { today: u.today })}
</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 };
/** Holiday rows for one result; the page script fills the body and keeps the wrapper hidden while it is empty. */
function holTable(id, title, u) {
return `<div class="found-wrap isg-hol" id="${id}-wrap" hidden><table class="found"><caption>${esc(title)}</caption><thead><tr><th scope="col">${esc(u.holDate)}</th><th scope="col">${esc(u.holName)}</th><th scope="col">${esc(u.holEffect)}</th></tr></thead><tbody id="${id}-body"></tbody></table><p class="isg-more" id="${id}-more"></p></div>`;
}

/** Business days: shared counting options on top, then the range count and the date shift, as on the gün hesaplama page. */
function isgunuTool(page) {
const u = page.ui;
const row = (id, label) => `<div class="calc-row"><dt>${esc(label)}</dt><dd id="${id}">-</dd></div>`;
const check = (id, label, hint, on) => `<label class="opt"><input type="checkbox" id="${id}"${on ? " checked" : ""}><span>${esc(label)}<small>${esc(hint)}</small></span></label>`;
return `<section class="tool pct isg" aria-label="${esc(u.toolLabel)}">
<div class="isg-bar" role="group" aria-label="${esc(u.optionsLabel)}">
${check("holidays", u.holidays, u.holidaysHint, true)}
${check("saturday", u.saturday, u.saturdayHint, false)}
<div class="isg-arefe"><span class="field-label" id="arefe-label">${esc(u.arefe)}</span><div class="seg seg-radio" role="radiogroup" aria-labelledby="arefe-label">${u.arefes.map(([v, l], i) => radio("arefe", v, l, i === 0)).join("")}</div></div>
</div>
<div class="calc pct-card" id="between">
<div class="calc-in">
<div class="pct-head"><h3>${esc(u.between.title)}</h3><p>${esc(u.between.question)}</p></div>
${dateFields("start", u.start, u, { today: u.today })}
${dateFields("end", u.end, u, { today: u.today })}
${check("include-start", u.includeStart, u.includeStartHint, true)}
</div>
<div class="calc-out">
<div class="age-main"><span>${esc(u.resultLabel)}</span><strong id="count-main">-</strong><p id="range"></p></div>
<dl>
${row("cal", u.calendar)}
${row("we", u.weekend)}
${row("hol", u.holidayRow)}
${row("half", u.halfRow)}
</dl>
<p class="formula" id="formula" aria-label="${esc(u.formula)}"></p>
<p class="status calc-status" id="status" role="status" aria-live="polite"></p>
<p class="calc-status isg-note" id="years-note"></p>
${holTable("hol", u.holTitle, u)}
</div>
</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>
${dateFields("base", u.base, u, { today: u.today })}
<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="field"><label for="shift-days">${esc(u.shiftDays)}</label><input id="shift-days" class="input" type="text" inputmode="numeric" autocomplete="off" maxlength="9" placeholder="${esc(u.shiftPh)}"></div>
</div>
<div class="calc-out">
<div class="age-main"><span>${esc(u.shift.result)}</span><strong id="shift-out">-</strong><p id="shift-sub"></p></div>
<dl>
${row("shift-cal", u.shiftCalendar)}
</dl>
<p class="formula" id="shift-formula" aria-label="${esc(u.formula)}"></p>
<p class="status calc-status" id="shift-status" role="status" aria-live="polite"></p>
<p class="calc-status isg-note" id="shift-years"></p>
${holTable("shift-hol", u.shiftHolTitle, u)}
</div>
</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 };

/** 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 @@ -995,7 +1053,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", "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", "nav.js"];
const sha = (...parts) => {
const h = createHash("sha256");
for (const p of parts) h.update(p);
Expand Down
Loading