add additional config settings to modify
This commit is contained in:
+96
-2
@@ -5,7 +5,14 @@ var stripe_pk = "";
|
||||
function validate(what, text) {
|
||||
if (what == 'alias') {
|
||||
var re = /^[a-zA-Z0-9 ]{1,25}$/;
|
||||
} else if (what == 'smsnumber') {
|
||||
var re = /^\+[0-9]{11,11}$/;
|
||||
} else if (what == 'email') {
|
||||
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
} else if (what == 'greenzone') {
|
||||
var re = /^$|^[0-9]+\.[0-9]+,[0-9]+\.[0-9],[0-9]+\.[0-9],[0-9]+\.[0-9]$/;
|
||||
}
|
||||
|
||||
return re.test(text);
|
||||
}
|
||||
|
||||
@@ -46,11 +53,37 @@ $(document).ready(function () {
|
||||
abos_to_buy = {};
|
||||
$(".show-modal").click(function () {
|
||||
$("#alias_exclamation").hide();
|
||||
$("#smsnumber_exclamation").hide();
|
||||
$("#email_exclamation").hide();
|
||||
$("#greenzone_exclamation").hide();
|
||||
|
||||
var alias = $(this).prev().html();
|
||||
|
||||
var deveui = $(this).prev().attr('id').replace("alias_", "");
|
||||
$('#deveui').html(deveui);
|
||||
var smsalarmactive = $('#smsalarmactive_'+deveui).html();
|
||||
var smsnumber = $('#smsnumber_'+deveui).html();
|
||||
var emailalarmactive = $('#emailalarmactive_'+deveui).html();
|
||||
var email = $('#email_'+deveui).html();
|
||||
var greenzone = $('#greenzone_'+deveui).html();
|
||||
|
||||
$("#alias").val(alias);
|
||||
|
||||
if (smsalarmactive == "1") {
|
||||
$('#smscheckbox').prop('checked', true);
|
||||
} else {
|
||||
$('#smscheckbox').prop('checked', false);
|
||||
}
|
||||
$("#smsnumber").val(smsnumber);
|
||||
|
||||
if (emailalarmactive == "1") {
|
||||
$('#emailcheckbox').prop('checked', true);
|
||||
} else {
|
||||
$('#emailcheckbox').prop('checked', false);
|
||||
}
|
||||
$("#email").val(email);
|
||||
$("#greenzone").val(greenzone);
|
||||
|
||||
$("#modal").addClass("is-active");
|
||||
});
|
||||
|
||||
@@ -140,6 +173,15 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
$("#modal-save").click(function () {
|
||||
var smsalarmactive = "0";
|
||||
if ($('#smscheckbox').prop('checked')) {
|
||||
smsalarmactive = "1";
|
||||
}
|
||||
var emailalarmactive = "0";
|
||||
if ($('#emailcheckbox').prop('checked')) {
|
||||
emailalarmactive = "1";
|
||||
}
|
||||
|
||||
// Validation Code
|
||||
var is_valid = true;
|
||||
if (!validate('alias', $('#alias').val())) {
|
||||
@@ -153,6 +195,39 @@ $(document).ready(function () {
|
||||
$("#alias_exclamation").hide();
|
||||
}
|
||||
|
||||
if (!validate('smsnumber',$('#smsnumber').val())) {
|
||||
$('#smsnumber_errormsg').html('Beispiel einer gültigen SMS Nummer: +41761234567');
|
||||
$("#smsnumber").addClass("is-danger");
|
||||
$("#smsnumber_exclamation").show();
|
||||
is_valid = false;
|
||||
} else {
|
||||
$('#smsnumber_errormsg').html('');
|
||||
$("#smsnumber").removeClass("is-danger");
|
||||
$("#smsnumber_exclamation").hide();
|
||||
}
|
||||
|
||||
if (!validate('email',$('#email').val())) {
|
||||
$('#email_errormsg').html('Beispiel einer gültigen E-Mail Adresse: max.mustermann@example.com');
|
||||
$("#email").addClass("is-danger");
|
||||
$("#email_exclamation").show();
|
||||
is_valid = false;
|
||||
} else {
|
||||
$('#email_errormsg').html('');
|
||||
$("#email").removeClass("is-danger");
|
||||
$("#email_exclamation").hide();
|
||||
}
|
||||
|
||||
if (!validate('greenzone',$('#greenzone').val())) {
|
||||
$('#greenzone_errormsg').html('Eingabe: lat_min,lon_min,lat_max,lon_max oder aber leeres Feld');
|
||||
$("#greenzone").addClass("is-danger");
|
||||
$("#greenzone_exclamation").show();
|
||||
is_valid = false;
|
||||
} else {
|
||||
$('#greenzone_errormsg').html('');
|
||||
$("#greenzone").removeClass("is-danger");
|
||||
$("#greenzone_exclamation").hide();
|
||||
}
|
||||
|
||||
if (!(is_valid)) {
|
||||
return;
|
||||
}
|
||||
@@ -163,11 +238,30 @@ $(document).ready(function () {
|
||||
dataType: "json",
|
||||
data: {
|
||||
deveui: $('#deveui').html(),
|
||||
alias: $('#alias').val()
|
||||
alias: $('#alias').val(),
|
||||
smsnumber: $("#smsnumber").val(),
|
||||
smsalarmactive: smsalarmactive,
|
||||
email: $("#email").val(),
|
||||
emailalarmactive: emailalarmactive,
|
||||
greenzone: $("#greenzone").val()
|
||||
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.rc == 0) {
|
||||
$('#alias_' + $('#deveui').html()).html($('#alias').val());
|
||||
$('#alias_'+$('#deveui').html()).html($('#alias').val());
|
||||
var smsalarmactive = "0";
|
||||
if ($('#smscheckbox').prop('checked')) {
|
||||
smsalarmactive = "1";
|
||||
}
|
||||
$('#smsalarmactive_'+$('#deveui').html()).html(smsalarmactive);
|
||||
$('#smsnumber_'+$('#deveui').html()).html($('#smsnumber').val());
|
||||
var emailalarmactive = "0";
|
||||
if ($('#emailcheckbox').prop('checked')) {
|
||||
emailalarmactive = "1";
|
||||
}
|
||||
$('#emailalarmactive_'+$('#deveui').html()).html(emailalarmactive);
|
||||
$('#email_'+$('#deveui').html()).html($('#email').val());
|
||||
$('#greenzone_'+$('#deveui').html()).html($('#greenzone').val());
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
|
||||
Reference in New Issue
Block a user