This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("slugify()", () => { | |
it("Must remove url encodings.", () => { | |
const result = slugify("New%20York, NY"); | |
expect(result).toBe("new-york-ny"); | |
}); | |
it("Must replace non-alphanumerics with dashes.", () => { | |
const result = slugify("a@b"); | |
expect(result).toBe("a-b"); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7B var style %3D document.createElement(%27style%27), styleContent %3D document.createTextNode(%27* %7B outline: 1px solid gray !important%3B font-family: system !important%3B %7D body, span %7B background-color: turquoise !important%3B color: white !important%3B %7D a, a:visited, a:active %7B color: yellow !important%3B background-color: white !important%3B %7D a:hover %7B color: White !important%3B background-color: white !important%3B font-family: system !important%3B %7D input, img %7B border: 1px solid red !important%3B %7D input%5Btype%3Dbutton%5D %7B background-color: gray !important%3B font-family: system !important%3B %7D code, blockquote, pre, div, h1, h2, h3, h4, h5, h6 %7B background-color: red !important%3B color: yellow !important%3B %7D input %7B background-color: yellow !important%3B font-family: system !important%3B font-size: 200%25 !important%3B %7D %27)%3B style.appendChild(styleContent )%3B var caput %3D document.getElementsByTagName(%27head%27)%3B caput%5B0%5D.appe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Recursively an ancestor element with a matching attribute. | |
**/ | |
const findAncestor = (el, label) => { | |
while ((el = el.parentElement) && !el.getAttribute(label)); | |
return el.getAttribute(label); | |
} | |
/** | |
* Retrieve the attribute or its ancestor attribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the value deep within a path of object. | |
* If at any point in the path the key does not exist. We return undefined. | |
* If we have a default value and the path does not exist return that default value. | |
* | |
* This allows you to avoid constantly checking for properties along the way like | |
* `this.state.wave && this.state.wave.data && this.state.wave.data.companyName` | |
* | |
* @example get(this, "state.wave.data.companyName") // can return undefined | |
* @example get(this, "state.companyOptions", []); // always returns an array. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* We collect this data from the performance entries instead of directly from GPT because the targeting | |
* can can change between requests. Pulling data from googletag after a refresh will only give you the | |
* cuurent state of GPT. | |
*/ | |
(() => { | |
function getUrlParams(search) { | |
let hashes = search.split('&').filter(item => { | |
return /^enc_prev_ius|^iu_parts|^prev_iu_szs|^prev_scp|^cust_params|^correlator/.test(item); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns an array of ad requests. Requires modern browsers. | |
* [{ | |
* correlator: '1978064853149162', | |
* pageTargeting: { | |
* key1: 'val1', | |
* key2: 'val2', | |
* }, | |
* slots: [{ | |
* sizes: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the label IDs from all currently loaded GPT slots. | |
* | |
* @return {Array)} The collected label ids. | |
*/ | |
function getLabelIds() { | |
// declare our output array. | |
var labels = []; | |
// for looping over the slots | |
function getlabels(slot) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(d, u) { | |
const i = u.length | |
let s; | |
while (i--) { | |
s = d.createElement('script'); | |
s.async = true; | |
s.src = u[i]; | |
d.head.appendChild(s); | |
} | |
}(document, [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks for an elements existence within a RAF within a promise. | |
* | |
* @param {string} selector - The element you wish to find. Defaults to 'body'. | |
* @param {string} target - The parent element to search within. Defaults to document. | |
* @return {Promise} Resolves when the element exists. | |
*/ | |
function elementReady(selector, target) { | |
var options = { | |
target: target || document, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var tab = [].slice.call(document.styleSheets).map(function(e) { | |
return { | |
size: e.cssRules.length / 1e3 + " kb", | |
url: e.href || "Block" | |
} | |
}); | |
console.group("CSS Data"); | |
console.table(tab); | |
console.groupEnd("CSS Data"); |
NewerOlder