Fossil SCM

For the --webpage output, use javascript to resize all side-by-side diff columns so that they completely fill the available screen width.

drh 2021-08-25 18:00 trunk
Commit 571dd613ac47cf75cbc3c23fbbbb47588ae883fe9b67b7c3bec5e48b45c0b559
1 file changed +25
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -168,10 +168,11 @@
168168
*/
169169
static const char zWebpageHdr[] =
170170
@ <!DOCTYPE html>
171171
@ <html>
172172
@ <head>
173
+@ <meta charset="UTF-8">
173174
@ <style>
174175
@ table.sbsdiffcols {
175176
@ width: 90%;
176177
@ border-spacing: 0;
177178
@ font-size: xx-small;
@@ -220,10 +221,34 @@
220221
@ </style>
221222
@ </head>
222223
@ <body>
223224
;
224225
const char zWebpageEnd[] =
226
+@ <script>
227
+@ (function(){
228
+@ var lastWidth = 0;
229
+@ function checkWidth(){
230
+@ if( document.body.clientWidth!=lastWidth ){
231
+@ lastWidth = document.body.clientWidth;
232
+@ var w = lastWidth*0.5 - 100;
233
+@ var allCols = document.getElementsByClassName('difftxtcol');
234
+@ for(let i=0; i<allCols.length; i++){
235
+@ allCols[i].style.width = w + "px";
236
+@ allCols[i].style.maxWidth = w + "px";
237
+@ }
238
+@ var allDiffs = document.getElementsByClassName('sbsdiffcols');
239
+@ w = lastWidth;
240
+@ for(let i=0; i<allDiffs.length; i++){
241
+@ allDiffs[i].style.width = w + "px";
242
+@ allDiffs[i].style.maxWidth = w + "px";
243
+@ }
244
+@ }
245
+@ setTimeout(checkWidth, 100)
246
+@ }
247
+@ checkWidth();
248
+@ }());
249
+@ </script>
225250
@ </body>
226251
@ </html>
227252
;
228253
229254
/*
230255
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -168,10 +168,11 @@
168 */
169 static const char zWebpageHdr[] =
170 @ <!DOCTYPE html>
171 @ <html>
172 @ <head>
 
173 @ <style>
174 @ table.sbsdiffcols {
175 @ width: 90%;
176 @ border-spacing: 0;
177 @ font-size: xx-small;
@@ -220,10 +221,34 @@
220 @ </style>
221 @ </head>
222 @ <body>
223 ;
224 const char zWebpageEnd[] =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225 @ </body>
226 @ </html>
227 ;
228
229 /*
230
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -168,10 +168,11 @@
168 */
169 static const char zWebpageHdr[] =
170 @ <!DOCTYPE html>
171 @ <html>
172 @ <head>
173 @ <meta charset="UTF-8">
174 @ <style>
175 @ table.sbsdiffcols {
176 @ width: 90%;
177 @ border-spacing: 0;
178 @ font-size: xx-small;
@@ -220,10 +221,34 @@
221 @ </style>
222 @ </head>
223 @ <body>
224 ;
225 const char zWebpageEnd[] =
226 @ <script>
227 @ (function(){
228 @ var lastWidth = 0;
229 @ function checkWidth(){
230 @ if( document.body.clientWidth!=lastWidth ){
231 @ lastWidth = document.body.clientWidth;
232 @ var w = lastWidth*0.5 - 100;
233 @ var allCols = document.getElementsByClassName('difftxtcol');
234 @ for(let i=0; i<allCols.length; i++){
235 @ allCols[i].style.width = w + "px";
236 @ allCols[i].style.maxWidth = w + "px";
237 @ }
238 @ var allDiffs = document.getElementsByClassName('sbsdiffcols');
239 @ w = lastWidth;
240 @ for(let i=0; i<allDiffs.length; i++){
241 @ allDiffs[i].style.width = w + "px";
242 @ allDiffs[i].style.maxWidth = w + "px";
243 @ }
244 @ }
245 @ setTimeout(checkWidth, 100)
246 @ }
247 @ checkWidth();
248 @ }());
249 @ </script>
250 @ </body>
251 @ </html>
252 ;
253
254 /*
255

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button