From 143ec6503417530f831c8d42b5eb50cd9f2e47ac Mon Sep 17 00:00:00 2001 From: Adam Hovorka Date: Wed, 13 May 2020 19:30:02 -0600 Subject: Add page word count --- main.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'main.js') diff --git a/main.js b/main.js index 9285947..18b8c97 100644 --- a/main.js +++ b/main.js @@ -26,6 +26,10 @@ const wordCount = () => { nodes.reduce((a,p) => { const n = data.pages[data.paths[p]]; return a + n.body.trim().split(/\s+/).length + n.choices.reduce((a,c) => a + c[1].trim().split(/\s+/).length, 0)}, 0); + const n = data.pages[data.paths[data.current]]; + document.querySelector("#page-word-count span").innerText = + n.body.trim().split(/\s+/).length + + n.choices.reduce((a,c) => a + c[1].trim().split(/\s+/).length, 0); }; const db = new Dexie("vanguard-editor"); -- cgit v1.2.3-70-g09d2