$.niceDate = function (date) { return kendo.toString(date, "dddd, MMMM d").toUpperCase(); }; $.validateTimeInput = function (input) { return $.isHourAndMinute(input.val()); }; $.timeInput = function (container, options) { $('') .appendTo(container) .kendoMaskedTextBox({ mask: "00:00" }); }; $.getTimeOfDay = function (date) { return kendo.toString(new Date(date), "HH:mm"); }; $.handlePhoneInput = function (evt) { let theEvent = evt || window.event; let key; if (theEvent.type === "paste") { key = event.clipboardData.getData("text/plain"); } else { let key = theEvent.keyCode || theEvent.which; key = String.fromCharCode(key); } let regex = /[0-9|+]|\./; if (!regex.test(key)) { theEvent.returnValue = false; if (theEvent.preventDefault) theEvent.preventDefault(); } }; $.notificate = function (title, message, type, noautohide) { $('body') .toast({ title: title, message: message, class: type, displayTime: noautohide ? 0 : 5000 }); }; $.isHourAndMinute = function (value) { let r = /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/; return r.test(value); }; $.isEmail = function (email) { let re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; return re.test(String(email).toLowerCase()); }; $.isIe = function () { let ua = window.navigator.userAgent; let msie = ua.indexOf("MSIE "); return msie > 0; }; $.isPhoneNumber = function (phone) { if (phone.length < 8 || phone.length > 13) return false; let re = /(0047|\\+47|47)?\d/; return re.test(String(phone)); }; $.urlParam = function (name) { let results = new RegExp("[?&]" + name + "=([^&#]*)").exec( window.location.href ); if (results == null) { return 0; } return results[1] || 0; }; $.isGuid = function (stringToTest) { if (stringToTest[0] === "{") { stringToTest = stringToTest.substring(1, stringToTest.length - 1); } let regexGuid = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/gi; return regexGuid.test(stringToTest); }; $.isMobile = function () { let x = window.matchMedia("(max-width: 700px)"); x.addEventListener("change", $.isMobile); return x.matches; };