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
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Small tools Halit Sever uses himself, at tools.halit.org. They run in your brows
- [**Chmod calculator**](https://tools.halit.org/chmod-calculator/) - Linux file permissions between checkboxes, octal (755, 4755) and symbolic (rwxr-xr-x) form, with setuid, setgid and the sticky bit, the chmod command in numeric and symbolic form, and symbolic changes such as g+w or a+X applied the way GNU chmod does. Reads a pasted `ls -l` line. English only.
- [**Slug generator**](https://tools.halit.org/slug-generator/) - turns titles into URL slugs: lowercase, a hyphen, underscore or dot between words, accented and Turkish letters (ç, ğ, ı, İ, ö, ş, ü) made plain or kept, German umlauts as ae, oe and ue on request, optional English stop word removal and a maximum length that keeps whole words. One slug per line for a list of titles. English only.
- [**Remove special characters**](https://tools.halit.org/remove-special-characters/) - removes punctuation, symbols, emoji and invisible characters from text and turns accented letters into plain ones (é to e, ß to ss, Turkish ı and İ to i and I), with a keep list for characters such as @ or the hyphen, an option to put a space where a character was, collapsed spaces, lowercase and an a to z only mode. Turkish version: [Türkçe karakter temizleme](https://tools.halit.org/tr/turkce-karakter-temizleme/), which also repairs garbled Turkish such as ü and ı (UTF-8 read as Windows-1252 or 1254).
- [**Kelime ve karakter sayacı**](https://tools.halit.org/tr/karakter-sayaci/) - word and character counter: words, characters with and without spaces, letters, sentences and paragraphs as you type, a reading time at a speed you set, a character limit and a count for the selected part. Words follow Unicode word boundaries (UAX #29), so apostrophes such as İstanbul'da keep a word whole; characters are grapheme clusters, so an emoji counts once. Turkish only.
- **Stays on your device** - every tool is plain JavaScript in the page. A Content Security Policy blocks connections to any server except the Cloudflare Web Analytics page-view beacon, so pasted text cannot be sent anywhere.
- **English and Turkish** - each page has a Turkish twin written in Turkish, paired with `hreflang`.

Expand Down
Binary file added public/og/karakter-sayaci.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,31 @@ code {
display: none;
}

/* word and character counter: the text gets the wider column */
.counter {
grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.counter .pane textarea {
min-height: 440px;
}

.counter-fields {
display: grid;
gap: 16px;
margin-top: 20px;
}

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

.counter .pane textarea {
min-height: 220px;
}
}

.field[hidden] {
display: none;
}
Expand Down
55 changes: 54 additions & 1 deletion scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,64 @@ for (const lang of ["en", "tr"]) {
}
}

const COUNTER = "/tr/karakter-sayaci/";
for (const width of [1280, 390]) {
const label = `tr counter ${width}`;
const { context, page, errors } = await open(width, COUNTER, label);
await page.evaluate(() => localStorage.clear());
await page.reload({ waitUntil: "networkidle" });
const read = () => page.evaluate(() => Object.fromEntries(["words", "characters", "noSpaces", "letters", "sentences", "paragraphs", "reading"].map((id) => [id, document.getElementById(id).textContent])));
await page.fill("#src", "Merhaba dünya. Bugün hava çok güzel!\n\nİstanbul'da 3 gün kaldım.");
let r = await read();
expect(r.words === "10" && r.characters === "63" && r.noSpaces === "53" && r.letters === "48" && r.sentences === "3" && r.paragraphs === "2" && r.reading === "3 sn", `${label}: counts ${JSON.stringify(r)}`);
await page.fill("#src", "e-posta 2026-12-01 Işık’ın 👨‍👩‍👧 🇹🇷 - 1.000");
r = await read();
expect(r.words === "4" && r.characters === "38" && r.letters === "12", `${label}: edge counts ${JSON.stringify(r)}`);
await page.fill("#src", "kelime ".repeat(1000));
r = await read();
expect(r.words === "1.000" && r.reading === "5 dk", `${label}: long text ${JSON.stringify(r)}`);
await page.fill("#wpm", "250");
expect((await read()).reading === "4 dk", `${label}: wpm ${JSON.stringify(await read())}`);
await page.fill("#wpm", "10");
expect((await read()).reading === "5 dk" && (await page.textContent("#wpm-hint")).includes("50 ile 1.000"), `${label}: wpm range`);
await page.fill("#wpm", "250");
await page.fill("#limit", "7000");
expect((await page.textContent("#limit-hint")) === "0 karakter kaldı.", `${label}: limit ${await page.textContent("#limit-hint")}`);
await page.fill("#limit", "6990");
expect((await page.textContent("#limit-hint")) === "Sınır 10 karakter aşıldı.", `${label}: over ${await page.textContent("#limit-hint")}`);
await page.reload({ waitUntil: "networkidle" });
expect((await page.inputValue("#wpm")) === "250" && (await page.inputValue("#limit")) === "6990", `${label}: settings not remembered`);
await page.fill("#src", "Bir iki üç dört beş");
await page.focus("#src");
await page.evaluate(() => document.getElementById("src").setSelectionRange(0, 7));
await page.waitForTimeout(100);
expect((await page.textContent("#status")) === "Seçili kısım: 2 kelime, 7 karakter", `${label}: selection ${await page.textContent("#status")}`);
await page.click("#clear");
r = await read();
expect(r.words === "0" && r.characters === "0" && r.reading === "0 sn", `${label}: clear ${JSON.stringify(r)}`);
await page.evaluate(() => navigator.clipboard.writeText("Panodan gelen metin."));
await page.click("#paste");
await page.waitForTimeout(150);
expect((await read()).words === "3", `${label}: paste ${JSON.stringify(await read())}`);
const big = "Uzun bir metin, çok uzun. ".repeat(4000);
await page.fill("#src", big);
await page.waitForTimeout(600);
expect((await read()).words === "20.000", `${label}: big text ${JSON.stringify(await read())}`);
await page.fill("#wpm", "");
await page.fill("#limit", "");
await page.fill("#src", "Yazarken kelime, karakter ve cümle sayısı güncellenir. İstanbul'da 3 gün kaldım!\n\nOkuma süresi dakikada 200 kelimeye göre hesaplanır.");
await page.screenshot({ path: `${shots}/tr-counter-${width}.png`, fullPage: true });
await langMenu(page, label, "tr", { en: "/", tr: COUNTER }, 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()) === 15, `${label}: index does not list every tool`);
if (path !== "/missing-page") expect((await page.locator(".tool-card").count()) === 16, `${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 @@ -886,6 +938,7 @@ for (const path of OTHER) {
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/chmod-calculator/"]').count()) === 1, `${label}: index does not link the chmod calculator`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/slug-generator/"]').count()) === 1, `${label}: index does not link the slug generator`);
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`);
const lang = path === "/tr/" ? "tr" : "en";
await langMenu(page, label, lang, HOME, `${shots}/menu${path.replace(/\//g, "_")}-${width}.png`);
finish(errors, label);
Expand Down
35 changes: 33 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { pages, TOOLS, SITE } from "./content.mjs";
import { FLAGS } from "./flags.mjs";
import { BLANKS, MAX_COPIES, describe } from "../src/invisible.js";
import { MAX_COUNT, DEFAULTS } from "../src/repeat.js";
import { DEFAULT_WPM, MIN_WPM, MAX_WPM } from "../src/count.js";

const ORIGIN = "https://tools.halit.org";
const REPO = "https://github.com/halitsever/tools";
Expand Down Expand Up @@ -492,6 +493,36 @@ ${textPanes(u)}
</section>`;
}

/** Text on the left, counts on the right; the speed and limit fields sit under the counts they change. */
function counterTool(page) {
const u = page.ui;
const row = (id, label, cls = "") => `<div class="calc-row${cls}"><dt>${esc(label)}</dt><dd id="${id}">0</dd></div>`;
return `<section class="tool" aria-label="${esc(u.toolLabel)}">
<div class="calc counter">
<div class="pane">
<div class="pane-head"><label for="src">${esc(u.input)}</label><div class="pane-actions"><button type="button" class="btn btn-outline" id="paste">${esc(u.paste)}</button><button type="button" class="btn btn-quiet" id="clear">${esc(u.clear)}</button></div></div>
<textarea id="src" spellcheck="false" autocomplete="off" placeholder="${esc(u.placeholder)}"></textarea>
</div>
<div class="calc-out">
<dl>
${row("words", u.words, " total")}
${row("characters", u.characters, " total")}
${row("noSpaces", u.noSpaces)}
${row("letters", u.letters)}
${row("sentences", u.sentences)}
${row("paragraphs", u.paragraphs)}
${row("reading", u.reading)}
</dl>
<div class="counter-fields">
<div class="field"><label for="wpm">${esc(u.wpm)}</label><input id="wpm" class="input" type="number" inputmode="numeric" min="${MIN_WPM}" max="${MAX_WPM}" step="1" placeholder="${DEFAULT_WPM}" aria-describedby="wpm-hint"><small id="wpm-hint">${esc(u.wpmHint)}</small></div>
<div class="field"><label for="limit">${esc(u.limit)}</label><input id="limit" class="input" type="number" inputmode="numeric" min="1" step="1" placeholder="${esc(u.limitPh)}" aria-describedby="limit-hint"><small id="limit-hint">${esc(u.limitHint)}</small></div>
</div>
<p class="status calc-status" id="status" role="status" aria-live="polite"></p>
</div>
</div>
</section>`;
}

const SWAP = `<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M2.5 5.5h10M10 3l2.5 2.5L10 8M13.5 10.5h-10M6 8l-2.5 2.5L6 13"/></svg>`;
const OPEN = `<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M9 2.5H4.5a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V6M9 2.5 12.5 6M9 2.5V6h3.5"/></svg>`;
const MINUS = `<svg class="sign" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true" focusable="false"><path d="M3 6h6"/></svg>`;
Expand Down Expand Up @@ -639,7 +670,7 @@ ${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, reverse: caseTool, flip: pasteTool, compare: compareTool, kdv: kdvTool, yas: yasTool, dates: datesTool };
const TOOL_BODY = { paste: pasteTool, linebreaks: lineBreaksTool, case: caseTool, color: colorTool, invisible: invisibleTool, repeater: repeaterTool, chmod: chmodTool, slug: slugTool, special: specialTool, counter: counterTool, reverse: caseTool, flip: pasteTool, compare: compareTool, kdv: kdvTool, yas: yasTool, dates: datesTool };

/** 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 @@ -795,7 +826,7 @@ await mkdir(OUT, { recursive: true });
await cp(new URL("../public/", import.meta.url), OUT, { recursive: true });
await rm(new URL("signature.svg", OUT));
await writeFile(new URL("site.css", OUT), minifyCss((await read("../tokens.css")) + "\n" + (await read("../public/site.css"))));
for (const f of ["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", "nav.js"]) await cp(new URL(`../src/${f}`, import.meta.url), new URL(f, OUT));
for (const f of ["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", "nav.js"]) await cp(new URL(`../src/${f}`, import.meta.url), new URL(f, OUT));

const built = [];
for (const page of pages.list) {
Expand Down
Loading