2019-05-19 19:55:51 +02:00
|
|
|
$(document).ready(function () {
|
2019-05-22 21:17:53 +02:00
|
|
|
highlightNewEntry();
|
2019-05-19 19:55:51 +02:00
|
|
|
$("input[type=checkbox]").change(checkItem);
|
|
|
|
$("#remove").click(deleteCheckeditems);
|
|
|
|
$("#nameField").focus();
|
|
|
|
$("#anzahl").on("focus", function () { $(this).select(); });
|
|
|
|
$("#nameField").on("focus", function () { $(this).select(); });
|
|
|
|
});
|
|
|
|
|
2019-05-22 21:17:53 +02:00
|
|
|
function highlightNewEntry(){
|
|
|
|
var cookies = document.cookie;
|
2019-05-23 08:47:48 +02:00
|
|
|
var cookieRegExp = new RegExp(/;?\s+newItem=(\d+)/g);
|
|
|
|
var match = cookieRegExp.exec(cookies);
|
|
|
|
if(match!=null){
|
|
|
|
var newID = match[1];
|
|
|
|
var checkBox = $("[data-id=" + newID + "]");
|
|
|
|
var newRow = checkBox.parent().parent();
|
|
|
|
newRow.removeClass($(checkBox).data("color"));
|
|
|
|
newRow.addClass("alert-primary");
|
|
|
|
setTimeout(function () {
|
|
|
|
newRow.removeClass("alert-primary");
|
|
|
|
newRow.addClass($(checkBox).data("color"));
|
|
|
|
}, 1000);
|
|
|
|
document.cookie = "newItem=-1"
|
|
|
|
console.log(document.cookie);
|
|
|
|
}
|
2019-05-22 21:17:53 +02:00
|
|
|
}
|
|
|
|
|
2019-05-19 18:37:00 +02:00
|
|
|
function deleteCheckeditems() {
|
|
|
|
$.post({
|
|
|
|
url: "api/list/del",
|
|
|
|
data: {
|
|
|
|
function: "del"
|
|
|
|
},
|
|
|
|
success: function () {
|
|
|
|
location.reload();
|
|
|
|
}
|
2018-10-24 15:00:27 +02:00
|
|
|
});
|
2019-05-19 18:37:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkItem() {
|
|
|
|
var dataId = $(this).data("id");
|
|
|
|
$.post({
|
|
|
|
url: "api/list/check",
|
|
|
|
data: {
|
|
|
|
function: "check",
|
|
|
|
id: dataId,
|
|
|
|
status: $(this).prop("checked")
|
|
|
|
},
|
|
|
|
success: function () {
|
|
|
|
var color = $("[data-id='" + dataId + "'").data("color");
|
|
|
|
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().removeClass("bg-danger");
|
|
|
|
|
|
|
|
if($("[data-id='" + dataId + "'").prop("checked")){
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().removeClass(color);
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().addClass("bg-success");
|
2018-10-24 15:00:27 +02:00
|
|
|
}
|
2019-05-19 18:37:00 +02:00
|
|
|
else{
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().removeClass("bg-success");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().addClass(color);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().addClass("bg-danger");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().data("toggle", "popover");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().data("container", "body");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().data("placement", "top");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().data("html", true);
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().data("trigger", "focus");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().data("content", "Dieses Element konnte nicht gespeichert werden.<br />Bitte die Seite Aktualisieren");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().attr("title", "Fehler!");
|
|
|
|
$("[data-id='" + dataId + "'").parent().parent().popover('show');
|
|
|
|
}
|
2018-10-24 15:00:27 +02:00
|
|
|
});
|
2019-05-19 19:55:51 +02:00
|
|
|
}
|