This file contains 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
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | |
var dataAttributes = document.querySelector('elementIdentifier').dataset; |
This file contains 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
import ReactDOMServer from 'react-dom/server'; | |
export function encodeSvg(reactElement) { | |
return 'data:image/svg+xml,' + escape(ReactDOMServer.renderToStaticMarkup((reactElement))); | |
} |
This file contains 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
/** | |
* Ensure that target page exists before we actually do something. | |
* | |
* @param {string} targetUrl - Absolute target URL to be tested | |
* @param {function} [successCallback] - Function to be executed on success | |
* @param {function} [failCallback] - Function to be executed on fail | |
*/ | |
function checkTargetFirst(targetUrl, successCallback, failCallback) { | |
var reader = new XMLHttpRequest(); |
This file contains 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
// Use this: | |
var $ = function (domSelector) { | |
return Array.prototype.slice.call(document.querySelectorAll(domSelector)); | |
} | |
// Or this: | |
const $ = (domSelector) => [].slice.call(document.querySelectorAll(domSelector)); | |
// And then use $ like this: |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" | |
xmlns:jcr="http://www.jcp.org/jcr/1.0" | |
xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | |
jcr:primaryType="nt:unstructured"> | |
<content jcr:primaryType="nt:unstructured"> | |
<items jcr:primaryType="nt:unstructured"> | |
<basic jcr:primaryType="nt:unstructured"> | |
<items jcr:primaryType="nt:unstructured"> | |
<column jcr:primaryType="nt:unstructured"> |
This file contains 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
data:text/html,<body oninput="i.srcdoc=h.value+'<style>'+c.value+'</style><script>'+j.value+'</script>'"><style>textarea,iframe{width:100%;height:50%}body{margin:0}textarea{width:33.33%;font-size:18}</style><textarea placeholder=HTML id=h></textarea><textarea placeholder=CSS id=c></textarea><textarea placeholder=JS id=j></textarea><iframe id=i> |
This file contains 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
/** | |
* Convert an array into an object where each object gets nested like this: | |
['string1', 'string2', 'string3'] | |
becomes | |
{ | |
string1: { | |
string2: { |
This file contains 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
/** | |
* Convert string to match E.164 phone number pattern (e.g. +1234567890), | |
* otherwise return empty string. | |
*/ | |
function enforcePhoneNumberPattern(string) { | |
let newString = string.match(/[0-9]{0,14}/g); | |
if (newString === null) { | |
return ''; | |
} |
This file contains 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
import { | |
debounce as T_DEBOUNCE, | |
} from 'utils/methods'; | |
/** | |
* T-ENFORCER provides methods to validate strings. | |
* This is developed with input fields in mind, but it shouldn't be limited to them. | |
* | |
* Author: Kevin Weber | |
* |