Cybrkyd's Git Repositories

IndexedDB-notes - commit: 67b2711

commit 67b271105e3b6e4ea8739a5ca27bf9d0bcb2b14cc2a3a411324992c441e9ade5
author cybrkyd <git@cybrkyd.com> 2026-05-25 18:17:59 +0100
committer cybrkyd <git@cybrkyd.com> 2026-05-25 18:17:59 +0100

Commit Message

Word count and character count display

📊 Diffstat

idb-notes.html 29
1 files changed, 28 insertions(+), 1 deletions(-)

Diff

diff --git a/idb-notes.html b/idb-notes.html
index 5dc0079..ee06633 100644
--- a/idb-notes.html
+++ b/idb-notes.html
@@ -57,7 +57,15 @@ textarea {
font-family: inherit;
}
.link-btn:hover {
- color: darkblue;
+ color: #0a6b75;
+ }
+ #countContainer {
+ margin-top: 10px;
+ font-size: 0.8rem;
+ color: #555;
+ display: flex;
+ justify-content: center;
+ gap: 10px;
}
.saved-column {
@@ -185,6 +193,10 @@ textarea {
<div id="docStatus"></div>
<textarea id="editor" placeholder="Write something..."></textarea>
<br>
+ <div id="countContainer">
+ <div id="wordCount">0 words</div> |
+ <div id="charCount">0 characters</div>
+ </div>
<button class="link-btn" id="saveBtn">Save Doc</button>
<button class="link-btn" id="newBtn">New Doc</button>
<button class="link-btn" id="exportBtn">Export as TXT</button>
@@ -419,6 +431,21 @@ toggleBtn.addEventListener('click', function() {
toggleBtn.textContent = savedColumn.classList.contains('collapsed') ? '+' : '−';
});
+ const textarea = document.getElementById('editor');
+ const charCount = document.getElementById('charCount');
+ const wordCount = document.getElementById('wordCount');
+
+ function updateCounts(text) {
+ const characters = text.length;
+ const words = text.trim().split(/\s+/).filter(Boolean).length;
+ charCount.textContent = `${characters} character${characters !== 1 ? 's' : ''}`;
+ wordCount.textContent = `${words} word${words !== 1 ? 's' : ''}`;
+ }
+
+ textarea.addEventListener('input', () => {
+ updateCounts(textarea.value);
+ });
+
updateStatus();
</script>
</body>