Show different warning in the case that at least one of the domains to be added were already present

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2018-11-29 19:47:57 +01:00
parent 99b0535f8e
commit bd84160d4f
2 changed files with 19 additions and 3 deletions
+4
View File
@@ -59,6 +59,10 @@ function getFullName() {
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Failure! Something went wrong, see output below:<br/><br/><pre><span id="err"></span></pre>
</div>
<div id="alWarning" class="alert alert-warning alert-dismissible fade in" role="alert" hidden="true">
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
At least one domain was already present, see output below:<br/><br/><pre><span id="warn"></span></pre>
</div>
<!-- Domain List -->
+15 -3
View File
@@ -140,23 +140,35 @@ function add(arg) {
var alInfo = $("#alInfo");
var alSuccess = $("#alSuccess");
var alFailure = $("#alFailure");
var alWarning = $("#alWarning");
var err = $("#err");
var warn = $("#warn");
alInfo.show();
alSuccess.hide();
alFailure.hide();
alWarning.hide();
$.ajax({
url: "scripts/pi-hole/php/add.php",
method: "post",
data: {"domain":domain.val().trim(), "list":locallistType, "token":token},
success: function(response) {
if (!wild && response.indexOf("] Pi-hole blocking is ") === -1 ||
if (!wild && response.indexOf(" already exists in ") !== -1) {
alWarning.show();
warn.html(response);
alWarning.delay(8000).fadeOut(2000, function() {
alWarning.hide();
});
alInfo.delay(8000).fadeOut(2000, function() {
alInfo.hide();
});
} else if (!wild && response.indexOf("] Pi-hole blocking is ") === -1 ||
wild && response.length > 1) {
alFailure.show();
err.html(response);
alFailure.delay(4000).fadeOut(2000, function() {
alFailure.delay(8000).fadeOut(2000, function() {
alFailure.hide();
});
alInfo.delay(4000).fadeOut(2000, function() {
alInfo.delay(8000).fadeOut(2000, function() {
alInfo.hide();
});
} else {