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 --- index.html | 1 + main.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/index.html b/index.html index 8bf6371..d3f9e0f 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,7 @@
Total Word Count:
Path Word Count:
+
Page Word Count:
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-54-g00ecf