improve toc js

This commit is contained in:
anarsec 2023-07-07 02:07:42 +00:00
parent 89dd57f725
commit 27cbe3f4fd
No known key found for this signature in database
3 changed files with 20 additions and 3 deletions

View file

@ -234,7 +234,7 @@ To install Element Desktop, Whonix is not guaranteed to have Tor Stream Isolatio
* Open a Terminal in the new Template: **Applications menu → Template: whonix-ws-16-element: Xfce Terminal**
* Run the commands in the [Element install guide](https://element.io/download#linux) to install Element Desktop in the Template.
* Template qubes require a proxy for `wget`. Before running the command, create a configuration file at `~/.wgetrc` in the Template, with the contents:
```
```bash
use_proxy = on
http_proxy = 127.0.0.1:8082
https_proxy = 127.0.0.1:8082

View file

@ -20,11 +20,28 @@
return (c.top <= h) && (n.top - menuBarHeight >= 0);
}
function highlightTocItem(tocIndex) {
const bottomGap = 50;
tocItems[tocIndex].classList.add('is-active');
const bodyRect = document.body.getBoundingClientRect();
const elemRect = tocItems[tocIndex].getBoundingClientRect();
const menuRect = document.querySelector(".menu").getBoundingClientRect();
const menuAbsTop = menuRect.top - bodyRect.top;
const elemAbsBottom = elemRect.bottom - bodyRect.top;
const h = (window.innerHeight || document.documentElement.clientHeight);
if(elemAbsBottom > menuAbsTop + h - 48 - bottomGap){
document.querySelector(".menu").style = "position: sticky; top: " + (menuAbsTop - elemAbsBottom + h - bottomGap).toString() + "px";
}
else{
document.querySelector(".menu").style = "position: sticky; top: 48px;";
}
}
function activateIfVisible() {
let b = true;
for (let i = 0; i < tocItems.length; i++) {
if (b && isVisible(i)) {
tocItems[i].classList.add('is-active');
highlightTocItem(i);
b = false;
} else
tocItems[i].classList.remove('is-active');

View file

@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src 'self'; img-src 'self'; script-src 'self'; media-src 'self'; style-src 'self';" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src 'self'; img-src 'self'; script-src 'self'; media-src 'self'; style-src 'self' 'unsafe-inline';" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="#ffffff" name="theme-color" />
<meta content="#da532c" name="msapplication-TileColor" />