Fossil SCM
Merged two near-identical lists of CSS selectors in the /chat JS into one. As far as I can tell, they _are_ supposed to be identical, since they're both concerned with calculating the "framing" elements of the chat area, being everything other than the list of messages. It looks like they slipped out of that ideal in the way duplicated code does.
Commit
1cf4a7d72862e2d7081173d2b221f6efb83fe01ca572ebe3baebf518aefd0343
Parent
aca0be165988de5…
1 file changed
+11
-13
+11
-13
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -65,10 +65,19 @@ | ||
| 65 | 65 | /* This can inadvertently influence our flexbox layouts, so move |
| 66 | 66 | it out of the way. */ |
| 67 | 67 | D.append(document.body,dbg); |
| 68 | 68 | } |
| 69 | 69 | })(); |
| 70 | + const GetFramingElements = function() { | |
| 71 | + return document.querySelectorAll([ | |
| 72 | + "body > header", | |
| 73 | + "body > nav.mainmenu", | |
| 74 | + "body > footer", | |
| 75 | + "h1.page-title", | |
| 76 | + "#debugMsg" | |
| 77 | + ].join(',')); | |
| 78 | + }; | |
| 70 | 79 | const ForceResizeKludge = (function(){ |
| 71 | 80 | /* Workaround for Safari mayhem regarding use of vh CSS units.... |
| 72 | 81 | We tried to use vh units to set the content area size for the |
| 73 | 82 | chat layout, but Safari chokes on that, so we calculate that |
| 74 | 83 | height here: 85% when in "normal" mode and 95% in chat-only |
| @@ -76,16 +85,11 @@ | ||
| 76 | 85 | causing the input area to move off-screen. |
| 77 | 86 | |
| 78 | 87 | While we're here, we also use this to cap the max-height |
| 79 | 88 | of the input field so that pasting huge text does not scroll |
| 80 | 89 | the upper area of the input widget off-screen. */ |
| 81 | - const elemsToCount = [ | |
| 82 | - document.querySelector('body > header'), | |
| 83 | - document.querySelector('body > nav.mainmenu'), | |
| 84 | - document.querySelector('body > #hbdrop'), | |
| 85 | - document.querySelector('body > footer') | |
| 86 | - ]; | |
| 90 | + const elemsToCount = GetFramingElements(); | |
| 87 | 91 | const contentArea = E1('div.content'); |
| 88 | 92 | const bcl = document.body.classList; |
| 89 | 93 | const resized = function f(){ |
| 90 | 94 | if(f.$disabled) return; |
| 91 | 95 | const wh = window.innerHeight, |
| @@ -324,17 +328,11 @@ | ||
| 324 | 328 | user. |
| 325 | 329 | */ |
| 326 | 330 | chatOnlyMode: function f(yes){ |
| 327 | 331 | if(undefined === f.elemsToToggle){ |
| 328 | 332 | f.elemsToToggle = []; |
| 329 | - document.querySelectorAll( | |
| 330 | - ["body > header", | |
| 331 | - "body > nav.mainmenu", | |
| 332 | - "body > footer", | |
| 333 | - "#debugMsg" | |
| 334 | - ].join(',') | |
| 335 | - ).forEach((e)=>f.elemsToToggle.push(e)); | |
| 333 | + GetFramingElements().forEach((e)=>f.elemsToToggle.push(e)); | |
| 336 | 334 | } |
| 337 | 335 | if(!arguments.length) yes = true; |
| 338 | 336 | if(yes === this.isChatOnlyMode()) return this; |
| 339 | 337 | if(yes){ |
| 340 | 338 | D.addClass(f.elemsToToggle, 'hidden'); |
| 341 | 339 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -65,10 +65,19 @@ | |
| 65 | /* This can inadvertently influence our flexbox layouts, so move |
| 66 | it out of the way. */ |
| 67 | D.append(document.body,dbg); |
| 68 | } |
| 69 | })(); |
| 70 | const ForceResizeKludge = (function(){ |
| 71 | /* Workaround for Safari mayhem regarding use of vh CSS units.... |
| 72 | We tried to use vh units to set the content area size for the |
| 73 | chat layout, but Safari chokes on that, so we calculate that |
| 74 | height here: 85% when in "normal" mode and 95% in chat-only |
| @@ -76,16 +85,11 @@ | |
| 76 | causing the input area to move off-screen. |
| 77 | |
| 78 | While we're here, we also use this to cap the max-height |
| 79 | of the input field so that pasting huge text does not scroll |
| 80 | the upper area of the input widget off-screen. */ |
| 81 | const elemsToCount = [ |
| 82 | document.querySelector('body > header'), |
| 83 | document.querySelector('body > nav.mainmenu'), |
| 84 | document.querySelector('body > #hbdrop'), |
| 85 | document.querySelector('body > footer') |
| 86 | ]; |
| 87 | const contentArea = E1('div.content'); |
| 88 | const bcl = document.body.classList; |
| 89 | const resized = function f(){ |
| 90 | if(f.$disabled) return; |
| 91 | const wh = window.innerHeight, |
| @@ -324,17 +328,11 @@ | |
| 324 | user. |
| 325 | */ |
| 326 | chatOnlyMode: function f(yes){ |
| 327 | if(undefined === f.elemsToToggle){ |
| 328 | f.elemsToToggle = []; |
| 329 | document.querySelectorAll( |
| 330 | ["body > header", |
| 331 | "body > nav.mainmenu", |
| 332 | "body > footer", |
| 333 | "#debugMsg" |
| 334 | ].join(',') |
| 335 | ).forEach((e)=>f.elemsToToggle.push(e)); |
| 336 | } |
| 337 | if(!arguments.length) yes = true; |
| 338 | if(yes === this.isChatOnlyMode()) return this; |
| 339 | if(yes){ |
| 340 | D.addClass(f.elemsToToggle, 'hidden'); |
| 341 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -65,10 +65,19 @@ | |
| 65 | /* This can inadvertently influence our flexbox layouts, so move |
| 66 | it out of the way. */ |
| 67 | D.append(document.body,dbg); |
| 68 | } |
| 69 | })(); |
| 70 | const GetFramingElements = function() { |
| 71 | return document.querySelectorAll([ |
| 72 | "body > header", |
| 73 | "body > nav.mainmenu", |
| 74 | "body > footer", |
| 75 | "h1.page-title", |
| 76 | "#debugMsg" |
| 77 | ].join(',')); |
| 78 | }; |
| 79 | const ForceResizeKludge = (function(){ |
| 80 | /* Workaround for Safari mayhem regarding use of vh CSS units.... |
| 81 | We tried to use vh units to set the content area size for the |
| 82 | chat layout, but Safari chokes on that, so we calculate that |
| 83 | height here: 85% when in "normal" mode and 95% in chat-only |
| @@ -76,16 +85,11 @@ | |
| 85 | causing the input area to move off-screen. |
| 86 | |
| 87 | While we're here, we also use this to cap the max-height |
| 88 | of the input field so that pasting huge text does not scroll |
| 89 | the upper area of the input widget off-screen. */ |
| 90 | const elemsToCount = GetFramingElements(); |
| 91 | const contentArea = E1('div.content'); |
| 92 | const bcl = document.body.classList; |
| 93 | const resized = function f(){ |
| 94 | if(f.$disabled) return; |
| 95 | const wh = window.innerHeight, |
| @@ -324,17 +328,11 @@ | |
| 328 | user. |
| 329 | */ |
| 330 | chatOnlyMode: function f(yes){ |
| 331 | if(undefined === f.elemsToToggle){ |
| 332 | f.elemsToToggle = []; |
| 333 | GetFramingElements().forEach((e)=>f.elemsToToggle.push(e)); |
| 334 | } |
| 335 | if(!arguments.length) yes = true; |
| 336 | if(yes === this.isChatOnlyMode()) return this; |
| 337 | if(yes){ |
| 338 | D.addClass(f.elemsToToggle, 'hidden'); |
| 339 |