From 1efb001a63823ddeba5cff87ffa9434576dbc34e Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 19 Nov 2022 14:44:51 +0100 Subject: [PATCH] Make checkbox work --- changedetectionio/static/js/diff-render.js | 8 +++++++- changedetectionio/templates/diff.html | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/changedetectionio/static/js/diff-render.js b/changedetectionio/static/js/diff-render.js index 716bccf78..2e48170cf 100644 --- a/changedetectionio/static/js/diff-render.js +++ b/changedetectionio/static/js/diff-render.js @@ -5,7 +5,9 @@ var result = document.getElementById('result'); function changed() { // https://github.com/kpdecker/jsdiff/issues/389 // I would love to use `{ignoreWhitespace: true}` here but it breaks the formatting - var diff = Diff[window.diffType](a.textContent, b.textContent); + options = {ignoreWhitespace: document.getElementById('ignoreWhitespace').checked}; + + var diff = Diff[window.diffType](a.textContent, b.textContent, options); var fragment = document.createDocumentFragment(); for (var i = 0; i < diff.length; i++) { @@ -82,6 +84,10 @@ for (var i = 0; i < radio.length; i++) { } } +document.getElementById('ignoreWhitespace').onchange = function (e) { + changed(); +} + var inputs = document.getElementsByClassName('change'); inputs.current = 0; diff --git a/changedetectionio/templates/diff.html b/changedetectionio/templates/diff.html index 392d0d576..f60979e3b 100644 --- a/changedetectionio/templates/diff.html +++ b/changedetectionio/templates/diff.html @@ -37,6 +37,11 @@ Removed text Inserted Text + + + +
@@ -103,7 +108,7 @@