71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
function makeAjaxCall(pType, pUrl, pSuccess, pData, pComplete) {
|
|
$.ajax({
|
|
type: pType,
|
|
url: pUrl,
|
|
data: pData,
|
|
success: pSuccess,
|
|
error: showAjaxError,
|
|
complete: pComplete
|
|
});
|
|
}
|
|
|
|
function getDateTimeStringWithLeadingZeros(pDate) {
|
|
var dateStr = getDateStringWithLeadingZeros(pDate);
|
|
|
|
var hh = (pDate.getHours() < 10 ? "0" : "") + pDate.getHours();
|
|
var m = (pDate.getMinutes() < 10 ? "0" : "") + pDate.getMinutes();
|
|
var ss = (pDate.getSeconds() < 10 ? "0" : "") + pDate.getSeconds();
|
|
|
|
return dateStr + " " + hh + ":" + m + ":" + ss;
|
|
}
|
|
|
|
function getDateStringWithLeadingZeros(pDate) {
|
|
var dd = (pDate.getDate() < 10 ? "0" : "") + pDate.getDate();
|
|
var mm = ((pDate.getMonth() + 1) < 10 ? "0" : "") + (pDate.getMonth() + 1);
|
|
var yyyy = pDate.getFullYear();
|
|
|
|
return dd + "." + mm + "." + yyyy;
|
|
}
|
|
|
|
function subtractDates(date1, date2) {
|
|
var t1 = date1.getTime();
|
|
var t2 = date2.getTime();
|
|
var diff = (t2 - t1) / 60000;
|
|
|
|
return Math.abs(diff);
|
|
}
|
|
|
|
function addMinutes(date, minutes) {
|
|
return new Date(date.getTime() + minutes * 60000);
|
|
}
|
|
|
|
function stringToTime(str) {
|
|
var defaultResult = [-1, -1];
|
|
var minutes = 0;
|
|
|
|
str = str.replace(':', '');
|
|
str = str.replace('.', '');
|
|
str = str.replace(' ', '');
|
|
|
|
if (str.length < 3) {
|
|
if (str.length < 2) {
|
|
str = "0" + str;
|
|
}
|
|
while (str.length < 4) {
|
|
str = str + "0";
|
|
}
|
|
} else {
|
|
while (str.length < 4) {
|
|
str = "0" + str;
|
|
}
|
|
}
|
|
|
|
minutes = str.slice(2, 4);
|
|
var hours = str.slice(0, 2);
|
|
|
|
defaultResult[0] = parseInt(hours);
|
|
defaultResult[1] = parseInt(minutes);
|
|
|
|
return defaultResult;
|
|
}
|