This commit is contained in:
Vojtěch Sajdl 2018-08-23 20:54:35 +02:00
parent 93565fc014
commit 668502f1df
No known key found for this signature in database
GPG Key ID: 5D4EB1361A272390
2 changed files with 30 additions and 30 deletions

View File

@ -15,44 +15,44 @@
$("#new-incident .panel.new .panel-heading i").get(0).className = icons[val]; $("#new-incident .panel.new .panel-heading i").get(0).className = icons[val];
$("#new-incident .panel.new").get(0).className = classes[val] + " new"; $("#new-incident .panel.new").get(0).className = classes[val] + " new";
$('#time_input').val(''); $("#time_input").val("");
$('#end_time').val(''); $("#end_time").val("");
}); });
$("#new-incident select").trigger("change"); $("#new-incident select").trigger("change");
$("body").on("submit","#new-incident",function(){ $("body").on("submit","#new-incident",function(){
var time = Date.parse($('#time_input').val()); var time = Date.parse($("#time_input").val());
var end_time = Date.parse($('#end_time').val()); var end_time = Date.parse($("#end_time").val());
var type = $("#type").val() || 0; var type = $("#type").val() || 0;
if (type == 2 &&(isNaN(time) || isNaN(end_time))) if (parseInt(type) === 2 &&(isNaN(time) || isNaN(end_time)))
{ {
if (isNaN(end_time)) if (isNaN(end_time))
{ {
$('#time_input').addClass("error"); $("#time_input").addClass("error");
$.growl.error({ message: "Start time is invalid!" }); $.growl.error({ message: "Start time is invalid!" });
} }
if (isNaN(end_time)) if (isNaN(end_time))
{ {
$('#end_time').addClass("error"); $("#end_time").addClass("error");
$.growl.error({ message: "End time is invalid!" }); $.growl.error({ message: "End time is invalid!" });
} }
return false; return false;
} }
else if (type == 2 && time >= end_time) else if (parseInt(type) === 2 && time >= end_time)
{ {
$.growl.error({ message: "End time is either the same or earlier than start time!" }); $.growl.error({ message: "End time is either the same or earlier than start time!" });
$('#time').addClass("error"); $("#time").addClass("error");
$('#end_time').addClass("error"); $("#end_time").addClass("error");
return false; return false;
} }
if($('#status-container :checkbox:checked').length == 0) if($("#status-container :checkbox:checked").length === 0)
{ {
$.growl.error({ message: "Please check at least one service!" }); $.growl.error({ message: "Please check at least one service!" });
$('#status-container').addClass("error"); $("#status-container").addClass("error");
return false; return false;
} }
}); });

View File

@ -26,5 +26,5 @@ function timeago()
timeago(); timeago();
}); });
}); });
})(); })();