Files
BeWoPlaner/BeWoPlanerMobil/Scripts/initialization.js

309 lines
11 KiB
JavaScript
Raw Normal View History

2016-06-27 01:45:38 +02:00
var isEnddateSet;
$(document).ready(function () {
if (!$("#zeiterfassung").length) {
return;
}
toggleErrorPopup2('errorPopupDiv2');
2017-04-26 14:57:32 +02:00
$("#leistungen_select,#kategorien_select,#recordLoader_select,#textbausteine_select").prop("disabled", false);
2016-06-27 01:45:38 +02:00
toggleSelectClassesForElement("#kategorien_select", "#kategorien-select-container");
toggleSelectClassesForElement("#leistungen_select", "#leistungen-select-container");
toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container");
2017-04-26 14:57:32 +02:00
toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container");
2016-06-27 01:45:38 +02:00
2017-04-26 14:57:32 +02:00
//Lade Dokumentationsreiter aus Bewo
initializeDocumentationTextareas();
2016-06-27 01:45:38 +02:00
//ist EndDate Gewünscht
checkEndDate();
initBeWoMobile(loadGoalsUrl);
var h = $("#datum_textbox").css("height");
$(".dropdownlist-for").css("height", h);
$("#statistik-button").css("height", h);
$("#statistik-button").css("width", h);
$("#statistik-button-td").css("width", h);
2017-02-01 13:53:59 +01:00
//if (localStorage.getItem("Zeitdaten") != null || localStorage.getItem("Kalenderdaten") != null) {
// console.log("Ich bin hier drinne weil Storage vorhanden");
// if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 1 ||
// document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == null ||
// document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 0) {
// console.log("Ich bin hier beim Laden einer Zeiterfassung ");
// LoadOnly(1, 2);
// DeletStorage(1);
// DeletStorage(2);
// } else {
// ErrorZeiterfassungAfterCrash();
// console.log(" ich bin hier nach dem Crash ")
// }
//} else {
// console.log("Ich bin hier drinne weil Storage nicht vorhanden");
//}
2016-06-27 01:45:38 +02:00
ErfolgteSpx();
vm = new KlientenVM();
ko.applyBindings(vm);
loadSettingsAccordingToBWP();
});
function initBeWoMobile(actionPath) {
try {
2017-04-26 14:57:32 +02:00
$("#recordLoader_select, #kategorien_select, #leistungen_select, #textbausteine_select").prop("disabled", true);
2016-06-27 01:45:38 +02:00
toggleSelectClassesForElement("#kategorien_select", "#kategorien-select-container");
toggleSelectClassesForElement("#leistungen_select", "#leistungen-select-container");
toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container");
2017-04-26 14:57:32 +02:00
toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container");
2016-06-27 01:45:38 +02:00
var selectedSC = $($("#scDropDown")).find(":selected").val();
if (selectedSC !== "-1") {
$("#recordLoader_select").prop("disabled", false);
if ($("#anlegenEditierenBtn").val() == "Anlegen") {
activateForm(actionPath);
}
$("#datum_textbox").val(getDateStringWithLeadingZeros(new Date()));
}
2017-04-26 14:57:32 +02:00
$(".not-required-input").on("click blur change focus",
2016-06-27 01:45:38 +02:00
function () {
var v = $(this).attr("id");
2017-04-26 14:57:32 +02:00
setTimeout(function () { toggleLabel(v); }, 1);
2016-06-27 01:45:38 +02:00
}
);
$("#start_textbox").on("blur", function () {
var startHasValue = $("#start_textbox").val() != "";
var endHasValue = $("#ende_textbox").val() != "";
var durationHasValue = $("#duration_textbox").val() != "";
if (startHasValue && endHasValue) {
calcDurationByStartEnd();
} else if (startHasValue && durationHasValue) {
calcEndByStartDuration();
}
});
$("#ende_textbox").on("blur", function () {
var startHasValue = $("#start_textbox").val() != "";
var endHasValue = $("#ende_textbox").val() != "";
var durationHasValue = $("#duration_textbox").val() != "";
if (endHasValue && startHasValue) {
calcDurationByStartEnd();
} else if (endHasValue && durationHasValue) {
calcStartByEndDuration();
}
});
$("#duration_textbox").on("blur", function () {
var startHasValue = $("#start_textbox").val() != "";
var endHasValue = $("#ende_textbox").val() != "";
var durationHasValue = $("#duration_textbox").val() != "";
clearZED();
if (durationHasValue && startHasValue) {
calcEndByStartDuration();
} else if (durationHasValue && endHasValue) {
calcStartByEndDuration();
}
});
} catch (err) {
console.log("Fehler: " + err.message);
}
}
function toggleSelectClassesForElement(elementIdentifier, parentElement) {
var enabled = $(elementIdentifier).prop("disabled") === false;
if (enabled) {
$(parentElement).removeClass("disabled-select-container");
$(parentElement).addClass("styled-select-div");
} else {
$(parentElement).removeClass("styled-select-div");
$(parentElement).addClass("disabled-select-container");
}
}
function toggleErrorPopup2(errorMessage) {
var isDisplayNone = $("#errorPopupDiv2").css("display") == "none";
var displayValue = isDisplayNone ? "block" : "none";
$("#errorPopupDiv2").css("display", displayValue);
$(".modalWrapper").css("display", displayValue);
$(".modalWrapper").css("height", $(document).height());
if (isDisplayNone) {
$("#errorPopupText2").text(errorMessage);
var h = 0;
var t = $("#errorPopupTitle2").outerHeight();
var u = $("#errorPopupText2").outerHeight();
var v = $("#errorPopupBtnDiv2").outerHeight();
var w = $("#errorPopupOkBtn2").outerHeight();
h += t + u + v + w + w;
$("#errorPopupDiv2").css("height", h + "px");
$("#errorPopupDiv2").css("top", window.pageYOffset + window.innerHeight / 2 - h / 2);
$("#errorPopupDiv2").css("margin-top", "0");
} else {
$("#errorPopupDiv2").css("margin-top", "auto");
}
}
function logoutSettingsAccordingToBWP(timeoutTime) {
if (timeoutTime > 0) {
timeoutTime = timeoutTime * 1000 * 60;
clearTimeout();
setTimeout(function() {
$.ajax({
type: "POST",
url: LogoutUrl,
success: function() {
writeFatalErrorMessage("Ihre Sitzung ist abgelaufen.");
setTimeout(function() {
location.reload();
}, 3000);
},
error: function() {}
});
}, timeoutTime);
}
}
var TimeoutSetting;
function loadSettingsAccordingToBWP() {
$.ajax({
type: "GET",
url: LoadSessionSettingsFromBWPUrl,
success: function (json) {
var s = $.parseJSON(json);
TimeoutSetting = parseInt(s);
logoutSettingsAccordingToBWP(TimeoutSetting);
}
});
}
function checkEndDate() {
$.ajax({
type: "GET",
url: CheckEndDateUrl,
success: function (json) {
var s = $.parseJSON(json);
var EndDateSetting = parseInt(s);
if (EndDateSetting == 1) {
document.getElementById('EndDate_div').style.display = 'block';
$("#enddatum_textbox").val($("#datum_textbox").val());
}
else {
document.getElementById('EndDate_div').style.display = 'none';
}
}
});
}
2017-04-26 14:57:32 +02:00
function initializeDocumentationTextareas() {
2016-06-27 01:45:38 +02:00
$.ajax({
type: "GET",
url: CheckDokuReiterUrl,
success: function (json) {
var s = $.parseJSON(json);
2017-04-26 14:57:32 +02:00
console.log(json);
2016-06-27 01:45:38 +02:00
var x = s.length;
2017-04-26 14:57:32 +02:00
2016-06-27 01:45:38 +02:00
if (x == 0) {
2017-04-26 14:57:32 +02:00
$("#tddokureiter").css("display", "none");
$("#trnormalDoku").css("display", "table-row");
$("#notiz_textbox").css("width", "100%");
focusedDokuTextarea = $("#notiz_textbox");
} else {
focusedDokuTextarea = $("#notiz_textbox1");
2016-06-27 01:45:38 +02:00
}
2017-04-26 14:57:32 +02:00
if (x == 1) {
$("#tddokureiter").css("display", "none");
$("#trnormalDoku").css("display", "table-row");
$("#notiz_textbox").css("width", "100%");
$("#trnormalDokuLabel").text(s[0].TypeDescription);
2016-06-27 01:45:38 +02:00
}
2017-04-26 14:57:32 +02:00
2016-06-27 01:45:38 +02:00
if (x == 2) {
2017-04-26 14:57:32 +02:00
$("#DokName1").text(s[0].TypeDescription);
$("#DokName2").text(s[1].TypeDescription);
$("#notiz_textbox1, #notiz_textbox2").css("width", "40%");
$("#Dokumentation1, #Dokumentation2").css("display", "block");
$("#Dokumentation1, #Dokumentation2").css("width","250%");
2016-06-27 01:45:38 +02:00
}
if (x == 3) {
2017-04-26 14:57:32 +02:00
$("#DokName1").text(s[0].TypeDescription);
$("#DokName2").text(s[1].TypeDescription);
$("#DokName3").text(s[2].TypeDescription);
$("#notiz_textbox1, #notiz_textbox2, #notiz_textbox3").css("width", "50%");
$("#Dokumentation1, #Dokumentation2, #Dokumentation3").css("display", "block");
$("#Dokumentation1, #Dokumentation2, #Dokumentation3").css("width", "250%");
2016-06-27 01:45:38 +02:00
}
if (x == 4) {
2017-04-26 14:57:32 +02:00
$("#DokName1").text(s[0].TypeDescription);
$("#DokName2").text(s[1].TypeDescription);
$("#DokName3").text(s[2].TypeDescription);
$("#DokName4").text(s[3].TypeDescription);
$("#notiz_textbox1, #notiz_textbox2, #notiz_textbox3, #notiz_textbox4").css("width", "76.9%");
2017-04-26 14:57:32 +02:00
$("#Dokumentation1, #Dokumentation2, #Dokumentation3, #Dokumentation4, #Dokumentation5").css("display", "block");
$("#Dokumentation1, #Dokumentation2, #Dokumentation3, #Dokumentation4, #Dokumentation5").css("width", "130%");
2016-06-27 01:45:38 +02:00
}
if (x == 5) {
2017-04-26 14:57:32 +02:00
$("#DokName1").text(s[0].TypeDescription);
$("#DokName2").text(s[1].TypeDescription);
$("#DokName3").text(s[2].TypeDescription);
$("#DokName4").text(s[3].TypeDescription);
$("#DokName5").text(s[4].TypeDescription);
$("#notiz_textbox1, #notiz_textbox2, #notiz_textbox3, #notiz_textbox4, #notiz_textbox5").css("width", "101%");
$("#Dokumentation1, #Dokumentation2, #Dokumentation3, #Dokumentation4, #Dokumentation5").css("display", "block");
$("#Dokumentation1, #Dokumentation2, #Dokumentation3, #Dokumentation4, #Dokumentation5").css("width", "99%");
2016-06-27 01:45:38 +02:00
}
2017-02-01 13:53:59 +01:00
if (x > 0) {
2017-04-26 14:57:32 +02:00
$("#DokName1").click();
2017-02-01 13:53:59 +01:00
}
2016-06-27 01:45:38 +02:00
}
});
}