Skip to content

Instantly share code, notes, and snippets.

Kevin Weber kevinweber

Block or report user

Report or block kevinweber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kevinweber
kevinweber / README.md
Created May 17, 2017 — forked from toodooleedoo/README.md
#AEM #Sightly #SSJS Server Side JavaScript Use-API Breadcrumbs
View README.md

###Description Retrieve a Page Object from all pages which are in the Site root then build a breadcrumb component and display the current pages title in a submenu.

###Use case Display a bar under eg a menu which displays the current pages title and functional breadcrumb components o the right.

##Requirements

  • Responsive and which works on all mobile devices and desktop.
  • Current pages title on the left
  • Breadcrumbs on the right
@kevinweber
kevinweber / enforcer.js
Last active Oct 20, 2017
Enforcer.js: Address validation
View enforcer.js
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
*
@kevinweber
kevinweber / e.164.phoneNumber.js
Last active Sep 27, 2018
Convert string to match E.164 phone number pattern (e.g. +1234567890)
View e.164.phoneNumber.js
/**
* 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 '';
}
@kevinweber
kevinweber / createNestedObject.js
Last active Feb 24, 2017
Convert dot-notated string or path of object into an object using recursion. This is similar to Lodash's _.zipObject but it doesn't set any values.
View createNestedObject.js
/**
* Convert an array into an object where each object gets nested like this:
['string1', 'string2', 'string3']
becomes
{
string1: {
string2: {
@kevinweber
kevinweber / HTML-CSS-JS-editor.js
Last active Aug 13, 2018
Bookmarks / Search Input Queries
View HTML-CSS-JS-editor.js
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>
View buttongroup.xml
<alignment jcr:primaryType="nt:unstructured"
name="./alignChildren"
fieldLabel="Alignment of components"
required="{Boolean}true"
selectionMode="single"
sling:resourceType="granite/ui/components/coral/foundation/form/buttongroup">
<items jcr:primaryType="nt:unstructured">
<default jcr:primaryType="nt:unstructured"
name="./default"
@kevinweber
kevinweber / _cq_dialog.xml
Last active Sep 19, 2018
AEM: Sling Resource Merging & Includes (dialog, inheriting properties)
View _cq_dialog.xml
<?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">
@kevinweber
kevinweber / $.js
Last active Dec 19, 2016
MiniJQuery using documentSelectorAll - you don't need jQuery!
View $.js
// 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:
@kevinweber
kevinweber / ifTargetPageExists.js
Last active Dec 9, 2016
Helper: Check target URL using XMLHttpRequest before we execute a callback accordingly. No Ajax/Promise needed.
View ifTargetPageExists.js
/**
* 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();
@kevinweber
kevinweber / encodeSvg.js
Created Oct 31, 2016
Helper: Convert React component (SVG element) to base64 encoded URL. Useful for adding a background image.
View encodeSvg.js
import ReactDOMServer from 'react-dom/server';
export function encodeSvg(reactElement) {
return 'data:image/svg+xml,' + escape(ReactDOMServer.renderToStaticMarkup((reactElement)));
}
You can’t perform that action at this time.