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

/* yüzde hesaplama: one card per question, stacked in a single panel */
.pct-bar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px 12px;
padding: 12px 24px;
border-bottom: 1px solid var(--border);
font-size: 14px;
}

.pct-bar p {
flex: 1 1 16em;
color: var(--muted-foreground);
}

.pct-bar label {
font-weight: 600;
}

.pct-bar select {
width: auto;
height: 36px;
padding: 0 8px;
}

.pct-card + .pct-card {
border-top: 1px solid var(--border);
}

.pct-card:last-child .calc-out {
border-bottom-right-radius: var(--radius);
}

.pct-head h3 {
font-size: 16px;
font-weight: 600;
letter-spacing: -0.01em;
}

.pct-head p {
margin-top: 4px;
color: var(--muted-foreground);
font-size: 14px;
}

.pct-fields {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 12px;
}

.pct-dir {
max-width: 16em;
}

.pct .age-main strong {
overflow-wrap: anywhere;
}

/* word frequency counter: the table scrolls inside the output pane */
.pane-title {
font-size: 14px;
Expand Down
64 changes: 63 additions & 1 deletion scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const TOOL = { en: "/paste-without-formatting/", tr: "/tr/duz-metin-olarak-yapis
const COMPARE = { en: "/text-compare/", tr: "/tr/metin-karsilastirma/" };
const KDV = "/tr/kdv-hesaplama/";
const YAS = "/tr/yas-hesaplama/";
const YUZDE = "/tr/yuzde-hesaplama/";
const DAYS = "/days-between-dates/";
const LINES = "/remove-line-breaks/";
const HEX = "/hex-to-rgb/";
Expand Down Expand Up @@ -973,12 +974,72 @@ for (const width of [1280, 390]) {
await context.close();
}

for (const width of [1440, 390]) {
const label = `yuzde ${width}`;
const { context, page, errors } = await open(width, YUZDE, label);
await page.evaluate(() => localStorage.clear());
await page.reload({ waitUntil: "networkidle" });
const val = (id) => page.textContent(`#${id}`);
const pick = (name, value) => page.locator(`label:has(input[name="${name}"][value="${value}"]) span`).click();

await page.fill("#oran-a", "200");
await page.fill("#oran-b", "%15");
expect((await val("oran-out")) === "30" && (await val("oran-formula")).includes("200 × 15 ÷ 100 = 30"), `${label}: oran gave ${await val("oran-out")}`);
await page.fill("#kaci-a", "1");
await page.fill("#kaci-b", "3");
expect((await val("kaci-out")) === "%33,33" && (await val("kaci-formula")).includes("≈"), `${label}: kaci gave ${await val("kaci-out")}`);
await page.fill("#kaci-b", "0");
expect((await val("kaci-out")) === "-" && (await val("kaci-status")).includes("sıfıra"), `${label}: zero not reported`);
await page.fill("#degisim-a", "100");
await page.fill("#degisim-b", "80");
expect((await val("degisim-out")) === "%20" && (await val("degisim-sub")) === "Azalış" && (await val("degisim-diff")) === "-20", `${label}: degisim gave ${await val("degisim-out")}`);
await page.fill("#fiyat-a", "1.200");
await page.fill("#fiyat-b", "15");
expect((await val("fiyat-out")) === "1.020" && (await val("fiyat-amount")) === "180", `${label}: indirim gave ${await val("fiyat-out")}`);
await pick("fiyat-dir", "zam");
expect((await val("fiyat-out")) === "1.380" && (await val("fiyat-label")) === "Zamlı fiyat", `${label}: zam gave ${await val("fiyat-out")}`);
await pick("once-dir", "zam");
await page.fill("#once-a", "1.200");
await page.fill("#once-b", "20");
expect((await val("once-out")) === "1.000" && (await val("once-amount")) === "200", `${label}: once gave ${await val("once-out")}`);
await page.fill("#oran-a", "12,345");
await page.fill("#oran-b", "10");
expect((await val("oran-out")) === "1,23", `${label}: decimal comma gave ${await val("oran-out")}`);
await page.selectOption("#digits", "4");
expect((await val("oran-out")) === "1,2345", `${label}: digits gave ${await val("oran-out")}`);
await page.fill("#oran-a", "abc");
expect((await val("oran-out")) === "-" && (await val("oran-status")).length > 10, `${label}: bad number not reported`);

await page.reload({ waitUntil: "networkidle" });
expect((await page.inputValue("#digits")) === "4", `${label}: digits not remembered`);
expect(await page.isChecked('input[name="fiyat-dir"][value="zam"]'), `${label}: zam not remembered`);
expect((await page.inputValue("#oran-a")) === "", `${label}: number was kept`);

await page.selectOption("#digits", "2");
await pick("fiyat-dir", "indirim");
await pick("once-dir", "indirim");
await page.fill("#oran-a", "200");
await page.fill("#oran-b", "15");
await page.fill("#kaci-a", "30");
await page.fill("#kaci-b", "200");
await page.fill("#degisim-a", "80");
await page.fill("#degisim-b", "100");
await page.fill("#fiyat-a", "1.200");
await page.fill("#fiyat-b", "15");
await page.fill("#once-a", "1.020");
await page.fill("#once-b", "15");
await page.screenshot({ path: `${shots}/tr-yuzde-${width}.png`, fullPage: true });
await langMenu(page, label, "tr", { en: "/", tr: YUZDE }, 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()) === 17, `${label}: index does not list every tool`);
if (path !== "/missing-page") expect((await page.locator(".tool-card").count()) === 18, `${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="/days-between-dates/"]').count()) === 1, `${label}: index does not link days between dates`);
Expand All @@ -992,6 +1053,7 @@ for (const path of OTHER) {
if (path !== "/missing-page") expect((await page.locator(`.tool-card a[href="${SPECIAL[path === "/tr/" ? "tr" : "en"]}"]`).count()) === 1, `${label}: index does not link the special character remover`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/karakter-sayaci/"]').count()) === 1, `${label}: index does not link the counter`);
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`);
const lang = path === "/tr/" ? "tr" : "en";
await langMenu(page, label, lang, HOME, `${shots}/menu${path.replace(/\//g, "_")}-${width}.png`);
finish(errors, label);
Expand Down
37 changes: 35 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,40 @@ ${row("weekend", u.weekend)}
</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 };
/** Five small calculators stacked in one panel: searchers phrase the same percentage question many ways, and each card answers one. */
function pctTool(page) {
const u = page.ui;
const field = (card, key) => {
const f = card[key];
return `<div class="field"><label for="${card.id}-${key}">${esc(f.label)}</label><input id="${card.id}-${key}" class="input" type="text" inputmode="${f.signed ? "text" : "decimal"}" autocomplete="off" spellcheck="false" placeholder="${esc(f.ph)}"></div>`;
};
const cards = u.cards
.map((c) => {
const dir = c.dir ? `<div class="seg seg-radio pct-dir" role="radiogroup" aria-label="${esc(u.dirLabel)}">${u.dirs.map(([v, l], i) => radio(`${c.id}-dir`, v, l, i === 0)).join("")}</div>` : "";
const rows = (c.rows ?? []).map((r) => `<div class="calc-row"><dt id="${c.id}-${r}-label">${esc(u.rowLabels[r])}</dt><dd id="${c.id}-${r}">-</dd></div>`).join("");
return `<div class="calc pct-card" id="${c.id}" data-mode="${c.id}">
<div class="calc-in">
<div class="pct-head"><h3>${esc(c.title)}</h3><p>${esc(c.question)}</p></div>
${dir}
<div class="pct-fields">${field(c, "a")}${field(c, "b")}</div>
</div>
<div class="calc-out">
<div class="age-main"><span id="${c.id}-label">${esc(c.result)}</span><strong id="${c.id}-out">-</strong><p id="${c.id}-sub"></p></div>
${rows ? `<dl>${rows}</dl>` : ""}
<p class="formula" id="${c.id}-formula" aria-label="${esc(u.formula)}"></p>
<p class="status calc-status" id="${c.id}-status" role="status" aria-live="polite"></p>
</div>
</div>`;
})
.join("\n");
const digits = [0, 1, 2, 3, 4].map((n) => `<option value="${n}"${n === 2 ? " selected" : ""}>${n}</option>`).join("");
return `<section class="tool pct" aria-label="${esc(u.toolLabel)}">
<div class="pct-bar"><p>${esc(u.barHint)}</p><label for="digits">${esc(u.digits)}</label><select id="digits" class="input">${digits}</select></div>
${cards}
</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 };

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