While anyone can find cheap crap on sale during Black Friday (just open up Amazon's page and count all the items from brands you've never heard of), we're compiling the best budget-friendly deals we know shouldn't steer you wrong. These are items we've tried or even tested ourselves — which is why we can say an Apple AirTag tracker for $24.98 is totally worth it, or why the latest Amazon Echo Dot smart speaker for $24.99 with a free Hue smart bulb is kind of a steal (if you don't mind living with Alexa).
Call them stocking stuffers or impulse-buys if you'd like, but nothing beats a great deal on something affordable that's actually good.
//this module finds every h2 and h3 in the article body and creates a table of contents based off them. if you only want to link h2s, set 'mainHeadsOnly' in the line below to 'true'. if you only want to link h3s, set 'subHeadsOnly' to 'true'. obviously, setting both to true will result in no table of contents at all.
//setting the 'collapsible' flag to 'true' will hide links to h3s until the user interacts with a + button next to the h2 link
//please see graham if you have any issues.
var mainHeadsOnly = false;
var subHeadsOnly = false;
var collapsible = false;
function makeId(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i {
item.classList.remove("active");
})
button.classList.add("active");
subheads.forEach(item => {
item.classList.add("active");
});
} else {
actives.forEach(item => {
item.classList.remove("active");
})
}
}
window.addEventListener('DOMContentLoaded', (event) => {
var ids = [];
var html = "";
const headers = document.querySelectorAll(".duet--article--article-body-component .duet--article--standard-heading");
const mainHeads = document.querySelectorAll(".duet--article--article-body-component h2.duet--article--standard-heading");
const subHeads = document.querySelectorAll(".duet--article--article-body-component h3.duet--article--standard-heading");
const tableOfContents = document.querySelector(".verge-table-of-contents");
const returnString = "Return to table of contents↴";
var index = 0;
for (let i = 0; i {
item.id = "m_"+ids[index];
index+=1;
});
subHeads.forEach(item => {
item.id = "s_"+ids[index];
index+=1;
});
var index = 0;
var currentHeader = 0;
headers.forEach(item => {
if(item.id) {
if(item.id[0] == "m" && subHeadsOnly == false) {
currentHeader+=1;
html+="
";
} else if(item.id[0] == "s" && mainHeadsOnly == false) {
html+="
";
}
}
});
if(subHeadsOnly == true) {
tableOfContents.classList.add('subheads-only');
}
if(collapsible == true && subHeadsOnly == false & mainHeadsOnly == false) {
tableOfContents.classList.add('expandable');
}
mainHeads.forEach(item => {
item.innerHTML = item.innerHTML+returnString;
});
subHeads.forEach(item => {
if(mainHeadsOnly == false) {
item.innerHTML = item.innerHTML+returnString;
}
});
tableOfContents.innerHTML = html;
document.querySelectorAll('.toc-link').forEach(item => {
item.tabIndex = "0";
var target = item.dataset.target
item.addEventListener('click', (e) => {
e.preventDefault();
document.querySelector(target).scrollIntoView();
item.blur();
});
item.addEventListener('keydown', e => {
if(e.code == "Enter") {
e.preventDefault();
document.querySelector(target).scrollIntoView();
item.blur();
}
});
});
document.querySelectorAll('.polygon-table-of-contents .expand').forEach(item => {
var target = item.dataset.target
var subheads = document.querySelectorAll('[data-grouping="'+target+'"]');
if (subheads.length === 0) {
item.classList.add('hidden');
}
item.addEventListener('click', (e) => {
e.preventDefault();
expand(target);
});
});
});
.duet--article--article-body-component .duet--article--standard-heading, #toc-main {
scroll-margin-top: 64px;
padding: 10px 25px;
}
.verge-table-of-contents:empty {
display: none;
}
.duet--article--article-body-component h2.duet--article--standard-heading, .duet--article--article-body-component h3.duet--article--standard-heading {
margin-right: 2rem;
position: relative;
}
.verge-table-of-contents .main-header-link, .verge-table-of-contents.subheads-only .sub-header-link {
margin: 0.25em 0 0.25em 0px;
}
.verge-table-of-contents .sub-header-link {
margin: 0.25em 0 0.25em 15px;
}
.verge-table-of-contents .sub-header-link:last-child {
margin-bottom: 15px;
}
.verge-table-of-contents.expandable .sub-header-link {
display: none;
}
.verge-table-of-contents.expandable .sub-header-link.active {
display: block;
}
.verge-table-of-contents .expand {
display: none;
margin-left: 0.5rem;
border: none;
cursor: pointer;
position: relative;
}
.verge-table-of-contents .expand svg {
margin-top: -4px;
transform-origin: center center;
}
.verge-table-of-contents.expandable .expand {
display: inline;
}
.verge-table-of-contents.expandable .expand.active:after {
content: "";
display: block;
position: absolute;
right: 0;
top: 50%;
height: 3px;
width: 18px;
background-color: #5200FF;
transform: translateY(-50%);
margin-top: 1px;
}
.verge-table-of-contents.expandable .expand.active svg {
fill: transparent;
}
.verge-table-of-contents.expandable .expand.hidden {
display: inline;
}
.verge-table-of-contents .toc-link {
display: inline;
box-shadow: var(--tw-ring-offset-shadow,0 0 #5200FF),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);
--tw-shadow: inset 0 -1px 0 0 #5200FF;
--tw-shadow-colored: inset 0 -1px 0 0 var(--tw-shadow-color);
cursor: pointer;
}
.verge-table-of-contents .toc-link:hover, .duet--article--article-body-component .duet--article--standard-heading .toc-link.toc-return:hover, .verge-table-of-contents .toc-link:focus, .duet--article--article-body-component .duet--article--standard-heading .toc-link.toc-return:focus {
--tw-shadow: inset 0 -.5em 0 0 #3cffd0;
--tw-shadow-colored: inset 0 -.5em 0 0 var(--tw-shadow-color);
}
.duet--article--article-body-component .duet--article--standard-heading .toc-link.toc-return {
margin: 0;
position: absolute;
left: calc(100% + 1rem);
top: 50%;
display: inline-block;
transform-origin: center center;
transform: translate(-50%, -50%);
--tw-shadow: inset 0 -1px 0 0 transparent;
}
.duet--article--article-body-component .duet--article--standard-heading .toc-return .hidden {
display: none;
}
.duet--article--article-body-component .duet--article--standard-heading .toc-return .arrow {
transform: scaleY(-0.85);
display: inline-block;
transform-origin: center center;
cursor: pointer;
}
No comments:
Post a Comment