Skip to content

Instantly share code, notes, and snippets.

View paceaux's full-sized avatar
🌐
Obsessing with languagey things

Paceaux paceaux

🌐
Obsessing with languagey things
View GitHub Profile
@paceaux
paceaux / tableOfContents.js
Created March 16, 2022 16:49
A class for generating a table of contents on a page.
class TableOfContents {
static listContainerClass = 'articleTOC__list';
static listItemClass = 'articleTOC__item';
static listLinkClass = 'articleTOC__link';
static modifierSeparator = '--';
/*
* @description Gets a list of all title elements having an ID in a given container
* @param {HTMLElement} container - An element containing title elements (h1, h2, h3)
/**
* @class Locker
* @description who doesn't like Konami?
* @example const locker = new Locker(); locker.initialize();
*
*/
// I'm not going to use Babel for a tiny static site
// eslint-disable-next-line no-unused-vars
class Locker {
/**
@paceaux
paceaux / README.md
Created October 19, 2021 14:16
Front-end Readme
@paceaux
paceaux / conjunctions.english.js
Created October 5, 2018 21:49
English conjunctions
/*
* Conjunctions
* https://www.english-grammar-revolution.com/list-of-conjunctions.html
*/
module.exports = [
{
conjunction: ['and'],
type: 'coordinating',
},
@paceaux
paceaux / classname.regex.js
Created January 5, 2021 17:07
A Regex for finding a class name in html
/*
where "title" is the full class name
/class=(.*[ "]title[ "].*)/g
*/
const className = 'title';
const regex = new RegExp(`/class=(.*[ "]${className}[ "].*)/g`);
@paceaux
paceaux / jscss.js
Last active October 29, 2020 16:25
JSCSS, The quick and easy way to do CSS in the DOM
/**
* Class for adding CSS with JavaScript that relies on the CSSOM
*/
class JSCSS {
/**
* @param {string} cssText Text for a stylesheet. Rulesets, queries, and all
*/
constructor(cssText = '') {
const sheet = JSCSS.addStyleSheet();
this.stylesheet = JSCSS.getStyleSheet(sheet.title);
@paceaux
paceaux / queryCSSProperty
Last active October 19, 2020 17:16
Get all CSS selectors containing a particular CSS property
/** queryCSSByPropertyName
* queries the CSSOM looking for CSS rulesets containing a particular CSS property.
* @param {string} queryPropName CSS property name
* @param {string} queryPropValue value of CSS property
* @returns Map with key as CSS selector, value as CSS properties.
*/
function queryCSSByProperty(queryPropName, queryPropValue) {
const styleSheets= document.styleSheets; // get all the stylesheets
const properties = new Map(); // set up the variable that'll store our result
@paceaux
paceaux / graphicEQUrl.js
Last active June 28, 2020 15:38
Graphic EQ in a url
/* Courtesy of Jake Albaugh: https://twitter.com/jake_albaugh/status/1118611365508337665 */
const bars = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
const ctx = new AudioContext();
const analyser = ctx.createAnalyser();
analyser.fftSize = 32;
const uIntArray = new Uint8Array(16);
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
ctx.createMediaStreamSource(stream).connect(analyser);
updateUrl();
@paceaux
paceaux / SearchMap.js
Last active June 5, 2020 16:32
SearchMap: A JavaScript Map with searchable keys
/** Evaluates an array, makes the key lowercasee and makes the value an object with original keyname
* @param {Array} iterable=[] an array of arrays:[[key,val],[key,val]]
* @returns Array
*/
function LowercaseIterable(iterable = []) {
if (iterable.length === 0) return [];
const newIterable = iterable.map(([key, val]) => {
const entry = [
key.toLowerCase(),
@paceaux
paceaux / this.js
Last active March 11, 2020 20:37
const these = _itshelf = itshelf = _shelf = shelf = _itself = itself =_self = self = _me = me = _that = that = _this = this;