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 sanitizeHTML(html, whitelistedTagNames = []) { | |
/* List of event attributes to remove */ | |
const eventAttributes = [ | |
'onabort', | |
'onblur', | |
'onclick', | |
'ondblclick', | |
'onerror', | |
'onfocus', | |
'onkeydown', |
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
async function getLocationSuggestions({ query, apiKey, boundaryCountry = 'US', layers = 'locality' }) { | |
const autocompleteData = await fetch(`https://api.geocode.earth/v1/autocomplete?api_key=${apiKey}&text=${encodeURIComponent(query)}&boundary.country=${boundaryCountry}&layers=locality`, { | |
"body": null, | |
"method": "GET", | |
"credentials": "omit" | |
}) | |
.then(async res => res.json()); | |
const autocompleteSuggestions = autocompleteData | |
.features |
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
/** | |
* Receives a form element and validates the | |
* fields with a required tag. | |
* | |
* @param {HTMLElement} formEl - The HTMLElement of the for to be validated | |
* @param {Function} callback - The form submission handler to run if validation passes. | |
* @param {String} invalidClass - OPTIONAL. A class appended to fields that are invalid. | |
* @returns {null} - Nothing is returned. The function calls the callback if validation passes. | |
*/ |
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
const puppeteer = require("puppeteer"); | |
let browser; | |
module.exports = async function (context, req) { | |
var startTime = Date.now(); | |
if(!browser){ | |
browser = await puppeteer.launch({headless: true}); | |
} |
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
const formatPhoneNumber = (num, format = 'default') => { | |
/* Filter only numbers from the input */ | |
const cleaned = ('' + num).replace(/\D/g, ''); | |
/* Check if the input is of correct */ | |
const match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/); | |
if (match) { | |
/* Remove the matched extension code. Change this to format for any country code.*/ | |
const intlCode = (match[1] ? '' : ''); |
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
const viewportLessThan = (px = 969) => window.innerWidth < px; |