~kota/lists

d1ed673a25691dc230f920f892c2131337ae039a — Dakota Walsh 1 year, 1 month ago 9be1672
show update button only with changes
2 files changed, 12 insertions(+), 7 deletions(-)

M ui/base.tmpl
M ui/pages/list.tmpl
M ui/base.tmpl => ui/base.tmpl +8 -6
@@ 86,14 86,16 @@
	{{template "main" .}}
</body>
<script nonce="{{.CSPNonce}}">
const growers = document.querySelectorAll(".grow-wrap");
const updater = document.querySelector("#update");
updater.style.display = "none";

growers.forEach((grower) => {
	const textarea = grower.querySelector("textarea");
const grower = document.querySelector(".grow-wrap");
const textarea = grower.querySelector("textarea");
grower.dataset.replicatedValue = textarea.value;

textarea.addEventListener("input", () => {
	grower.dataset.replicatedValue = textarea.value;
	textarea.addEventListener("input", () => {
		grower.dataset.replicatedValue = textarea.value;
	});
	updater.style.display = "unset";
});
</script>
</html>

M ui/pages/list.tmpl => ui/pages/list.tmpl +4 -1
@@ 8,7 8,10 @@
					autocomplete="off"
					rows=12>{{ .Body }}</textarea>
			</div>
			<button class="input" type="submit">Update {{ .Name }}</button>
			<button
				id="update"
				class="input"
				type="submit">Update {{ .Name }}</button>
		</form>
	</main>
{{end}}