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 /
Created May 17, 2017 — forked from toodooleedoo/
#AEM #Sightly #SSJS Server Side JavaScript Use-API Breadcrumbs

###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.


  • Responsive and which works on all mobile devices and desktop.
  • Current pages title on the left
  • Breadcrumbs on the right
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 / 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 / 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']
string1: {
string2: {
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"
fieldLabel="Alignment of components"
<items jcr:primaryType="nt:unstructured">
<default jcr:primaryType="nt:unstructured"
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=""
<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 / $.js
Last active Dec 19, 2016
MiniJQuery using documentSelectorAll - you don't need jQuery!
View $.js
// Use this:
var $ = function (domSelector) {
// Or this:
const $ = (domSelector) => [];
// And then use $ like this:
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 / 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.