1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
$.niceDate = function (date) {
return kendo.toString(date, "dddd, MMMM d").toUpperCase();
};
$.validateTimeInput = function (input) {
return $.isHourAndMinute(input.val());
};
$.timeInput = function (container, options) {
$('<input name="' + options.field + '"/>')
.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;
};
|