Files
BeWoPlaner/BeWoPlanerMobil/Scripts/utils.js

75 lines
1.5 KiB
JavaScript

function makeAjaxCall(pType, pUrl, pSuccess, pData, pComplete) {
$.ajax({
type: pType,
url: pUrl,
data: pData,
success: pSuccess,
error: showAjaxError,
complete: pComplete
});
}
function removeElementFromArray(pArray, pKey) {
const newArray = {};
for(let key in pArray) {
const keyAsNumber = Number(key);
if(keyAsNumber !== pKey) {
newArray[keyAsNumber] = pArray[keyAsNumber];
}
}
return newArray;
}
function toggleLabel(inputId) {
const label = $(`label[for="${inputId}"]`);
var topValue;
if($(`#${inputId}`).is(":focus")) {
$(label).animate({ top: "-6px" }, 100);
return;
}
topValue = "12px";
if($(`#${inputId}`).val()) {
topValue = "-6px";
}
$(label).animate({ top: topValue }, 75);
}
function adjustLabel(inputId) {
const label = $(`label[for="${inputId}"]`);
var topValue;
topValue = "12px";
if($(`#${inputId}`).val()) {
topValue = "-6px";
}
$(label).animate({ top: topValue }, 75);
}
function isInEditingMode() {
return $("#isInEditModeIndicator").val() == "true";
}
function isElementInArray(array, element) {
try {
for(let item of array) {
if(item === element) {
return true;
}
}
return false;
} catch(error) {
console.log(error.message);
return false;
}
}