UNPKG

boilerplate.js

Version:

Development Tools

42 lines (36 loc) 1.26 kB
//Comparer Function (array.sort(GetSortOrder("EmployeeName"));) function GetSortOrder(prop) { return function (a, b) { if (a[prop] > b[prop]) { return 1; } else if (a[prop] < b[prop]) { return -1; } return 0; }; } // Check if IE/Edge function IE() { if (/Edge\/|Trident\/|MSIE /.test(window.navigator.userAgent)) return true; return false; } function isURL(str) { var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name and extension '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address '(\\:\\d+)?' + // port '(\\/[-a-z\\d%@_.~+&:]*)*' + // path '(\\?[;&a-z\\d%@_.,~+&:=-]*)?' + // query string '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator return pattern.test(str); } function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } function toCamelCase(string) { string = string[0] === '/' ? string.substring(1) : string; if (string.length === 0) return 'home'; return string.replace(/(-|\_)([a-z])/g, function (g) { return g[1].toUpperCase(); }); }