From c6e4b92638a1d9b0a6616cda9eb78a755247b1fe Mon Sep 17 00:00:00 2001 From: "Nipun Atul Mistry;Mistry.Nipun@mayo.edu;16223021" Date: Mon, 15 Nov 2021 17:03:38 -0600 Subject: [PATCH] Added a new button, 'Changes Only' that users can use to toggle the display of just the lines with changes. Helpful when dealing with large files --- deps/diff.js | 20 ++++++++++++++++++++ diff2HtmlCompare.py | 12 ++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/deps/diff.js b/deps/diff.js index b4141d9..1c27490 100644 --- a/deps/diff.js +++ b/deps/diff.js @@ -6,6 +6,7 @@ $( document ).ready(function() { var $showoriginal = $('.menuoption#showoriginal'), $showmodified = $('.menuoption#showmodified'), + $showchangesonly = $('.menuoption#showchangesonly'), $codeprintmargin = $('.menuoption#codeprintmargin'), $highlight = $('.menuoption#highlight'), $dosyntaxhighlight = $('.menuoption#dosyntaxhighlight'); @@ -46,6 +47,25 @@ $( document ).ready(function() { } }); + $showchangesonly.state = true + $showchangesonly.on("click", function(){ + switch ($showchangesonly.state) { + case true: + $('.lineno_leftnodiff').hide() + $('.lineno_rightnodiff').hide() + $('.left_nodiff').hide() + $('.right_nodiff').hide() + $showchangesonly.state = false + break; + case false: + $('.lineno_leftnodiff').show() + $('.lineno_rightnodiff').show() + $('.left_nodiff').show() + $('.right_nodiff').show() + $showchangesonly.state = true + break; + } + }); $codeprintmargin.state = true $codeprintmargin.on("click", function(){ diff --git a/diff2HtmlCompare.py b/diff2HtmlCompare.py index 644ce93..4249197 100644 --- a/diff2HtmlCompare.py +++ b/diff2HtmlCompare.py @@ -75,6 +75,10 @@ +
+ + +
@@ -163,7 +167,7 @@ def getDiffLineNos(self): elif not isinstance(left_no, int) and isinstance(right_no, int): no = ' ' else: - no = '' + str(left_no) + "" + no = '' + str(left_no) + "" else: if change: if isinstance(left_no, int) and isinstance(right_no, int): @@ -175,7 +179,7 @@ def getDiffLineNos(self): no = '' + \ str(right_no) + "" else: - no = '' + str(right_no) + "" + no = '' + str(right_no) + "" retlinenos.append(no) @@ -204,9 +208,11 @@ def _wrap_code(self, source): else: if left_no <= len(source): i, t = source[left_no - 1] + t = '' + t + "" else: i = 1 t = left_line + t = '' + t + "" else: if change: if isinstance(left_no, int) and isinstance(right_no, int) and right_no <= len(source): @@ -223,9 +229,11 @@ def _wrap_code(self, source): else: if right_no <= len(source): i, t = source[right_no - 1] + t = '' + t + "" else: i = 1 t = right_line + t = '' + t + "" yield i, t except: # print "WARNING! failed to enumerate diffs fully!"