-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
65 lines (60 loc) · 1.82 KB
/
utils.js
File metadata and controls
65 lines (60 loc) · 1.82 KB
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
function getDate() {
return parseDate(new Date());
}
function parseDate(date) {
var dd = String(date.getDate()).padStart(2, '0');
var mm = String(date.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = date.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
return today
}
function modifyDate(date, modifier) {
let dateObj = new Date(date)
dateObj.setDate(dateObj.getDate() + modifier)
return parseDate(dateObj)
}
function getMonthName(date){
const monthNames = ["Styczeń", "Luty", "Marzec", "Kwieceń", "Maj", "Czerwiec",
"Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"
];
return monthNames[date.getMonth()]
}
function getDayName(date){
const dayNames = ["niedziela","poniedziałek","wtorek","sroda","czwartek","piątek","sobota"]
return dayNames[date.getDay()]
}
var getJSON = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function () {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}