From 4f49b16079b27d7ce633619e4cddfdf2bffbc952 Mon Sep 17 00:00:00 2001 From: cashmere Date: Fri, 4 Sep 2026 09:05:24 +0200 Subject: initial commit --- src/diff.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/diff.js (limited to 'src/diff.js') diff --git a/src/diff.js b/src/diff.js new file mode 100644 index 0000000..b0d09da --- /dev/null +++ b/src/diff.js @@ -0,0 +1,73 @@ +/* Refinements to the display of unified and side-by-side diffs. +** +** In all cases, the table columns tagged with "difftxt" are expanded, +** where possible, to fill the width of the screen. +** +** For a side-by-side diff, if either column is two wide to fit on the +** display, scrollbars are added. The scrollbars are linked, so that +** both sides scroll together. Left and right arrows also scroll. +*/ +window.addEventListener('load',function(){ + var SCROLL_LEN = 25; + function initDiff(diff){ + var txtCols = diff.querySelectorAll('td.difftxt'); + var txtPres = diff.querySelectorAll('td.difftxt pre'); + var width = 0; + if(txtPres.length>=2){ + width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth); + } + var i; + for(i=0; i