function randomColor() { return `#${Math.random() .toString(16) .substr(-6)}` }
const nextId = () => { const currentId = parseInt(window.localStorage.getItem("customReportCounter"), 10) || 1; window.localStorage.setItem("customReportCounter", currentId + 1); return currentId.toString(); }
/** * The hexadecimal version of the embed color, with a leading hash * @type {?string} * @readonly */ get hexColor() { return this.color ? `#${this.color.toString(16).padStart(6, '0')}` : null; }
function guidFor(str) { const hash = fnv1a(str).toString(); let slug = slugify(sanitize(str)); // Max the slug at 100 char slug = slug.substring(0, 100 - hash.length - 1); return `${slug}_${hash}`; }
export function convertToPennies(value) { if (value === 0) { return 0; } let dollarValue = parseFloat(value); dollarValue = roundNumber(dollarValue, 2); // round to 2 decimal places. const dollarValueContainsDecimal = (dollarValue.toString().indexOf('.') !== -1); return (dollarValueContainsDecimal) ? parseInt(dollarValue.toString().replace('.', ''), 10) : parseInt(dollarValue, 10) * 100; }
/** * Helper function to create a random guid * @returns {string} GUID */ const get_guid = function () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }
export function getPageViewParams( urlPath: string ): PageViewParams { const params = { last_pageview_path_with_count: `${ mostRecentUrlPath }(${ pathCounter.toString() })`, this_pageview_path_with_count: `${ urlPath }(${ pathCounter + 1 })`, }; // Record this path. mostRecentUrlPath = urlPath; pathCounter++; return params; }
function hashCode(str) { var hash = 0, i, chr; if(str.length === 0){ return hash; } for(i = 0; i < str.length; i++){ chr = str.charCodeAt(i); hash = (hash << 5) - hash + chr; } hash = Math.abs(hash) >> 0; return hash.toString(16).substring(0, 5); }
/** * The hexadecimal version of the role color, with a leading hashtag * @type {string} * @readonly */ get hexColor() { return `#${this.color.toString(16).padStart(6, '0')}`; }
const nextId = () => { const currentId = parseInt(window.localStorage.getItem("dashboardIdCounter"), 10) || 1; window.localStorage.setItem("dashboardIdCounter", currentId + 1); return currentId.toString(); }
const nextId = () => { const currentId = parseInt(window.localStorage.getItem("dashboardIdCounter"), 10) || 1; window.localStorage.setItem("dashboardIdCounter", currentId + 1); return currentId.toString(); }
function randomColor() { return `#${Math.random() .toString(16) .substr(-6)}` }
/** * Helper function to create a random guid * @returns {string} GUID */ const get_guid = function () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }