Skip to content

Commit

Permalink
Fine tune visuals in document-blocked page
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 31, 2024
1 parent fd3624f commit 34771d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/css/document-blocked.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ a {
position: relative;
z-index: 10;
}
#theURL > p > span:first-of-type {
display: block;
max-height: 6lh;
overflow-y: auto;
}
:root.mobile #theURL > p > span:first-of-type {
max-height: 3lh;
}
#theURL #toggleParse {
background-color: transparent;
top: 100%;
Expand Down Expand Up @@ -132,9 +140,11 @@ body[dir="rtl"] #toggleParse {

#urlskip a {
display: block;
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
overflow-y: auto;
word-break: break-all;
}
:root.mobile #urlskip a {
max-height: 3lh;
}

#actionContainer {
Expand Down
24 changes: 22 additions & 2 deletions src/js/document-blocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,25 @@ let details = {};

/******************************************************************************/

dom.text('#theURL > p > span:first-of-type', details.url);
const urlToFragment = raw => {
try {
const fragment = new DocumentFragment();
const url = new URL(raw);
const hn = url.hostname;
const i = raw.indexOf(hn);
const b = document.createElement('b');
b.append(hn);
fragment.append(raw.slice(0,i), b, raw.slice(i+hn.length));
return fragment;
} catch(_) {
}
return raw;
};

/******************************************************************************/

dom.clear('#theURL > p > span:first-of-type');
qs$('#theURL > p > span:first-of-type').append(urlToFragment(details.url));
dom.text('#why', details.fs);

if ( typeof details.to === 'string' && details.to.length !== 0 ) {
Expand All @@ -85,7 +103,9 @@ if ( typeof details.to === 'string' && details.to.length !== 0 ) {
let pos = text.indexOf(linkPlaceholder);
if ( pos !== -1 ) {
const link = document.createElement('a');
link.href = link.textContent = details.to;
link.href = details.to;
dom.cl.add(link, 'code');
link.append(urlToFragment(details.to));
fragment.append(
text.slice(0, pos),
link,
Expand Down

0 comments on commit 34771d0

Please sign in to comment.