~callum/beavers-dam

d9fc6c78214a9dc0c1370efd02267c798f626406 — Callum Brown 1 year, 8 months ago 3951439
hard coded min word count
1 files changed, 4 insertions(+), 2 deletions(-)

M content/content.js
M content/content.js => content/content.js +4 -2
@@ 1,3 1,5 @@
const MINWORDS = 3;

const save = (text) => {
	chrome.storage.local.get(
		{ entries: [] }


@@ 54,7 56,7 @@ const dam = () => {
	let saveAndContinue = document.createElement("button");
	saveAndContinue.textContent = `Save & Continue to ${location.hostname}`;
	saveAndContinue.addEventListener("click", () => {
		if (textarea.value.length > 0) {
		if (textarea.value.trim().split(" ").length >= MINWORDS) {
			save(textarea.value);
			dam.remove();
			// Check if this host has been set to be undammed in popup.js


@@ 64,7 66,7 @@ const dam = () => {
				}
			}).then(() => chrome.storage.local.set({ undam: null }));
		} else {
			window.alert("Please write in your journal.");
			window.alert(`Please write at least ${MINWORDS} words.`);
		}
	});
	dam.append(saveAndContinue)