Fix reset of defaults for text fields
Still need to address bindaddress:port and externalIP: Name
This commit is contained in:
parent
8268bbf81a
commit
8953484e1f
|
@ -1187,52 +1187,53 @@ function sleep(milliseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".sccp-restore").click(function() {
|
$(".sccp-restore").click(function() {
|
||||||
//input is sent by data-for where for is an attribute
|
//input is sent by data-for where for is an attribute
|
||||||
var id = $(this).data("for"), input = $("#" + id);
|
var id = $(this).data("for"), input = $("#" + id);
|
||||||
var edit_style = document.getElementById("edit_" + id).style;
|
var edit_style = document.getElementById("edit_" + id).style;
|
||||||
if ($(this).data("type") === 'radio') {
|
|
||||||
input = document.getElementsByName(id);
|
|
||||||
}
|
|
||||||
if (input.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($(this).is(":checked")) {
|
|
||||||
edit_style.display = 'block';
|
|
||||||
var defaultVal = $(this).data("default");
|
|
||||||
if ($(this).data("type") === 'radio') {
|
if ($(this).data("type") === 'radio') {
|
||||||
// simulate read only for checkboxes
|
input = document.getElementsByName(id);
|
||||||
console.log(input);
|
} else if ($(this).data("type") === 'text') {
|
||||||
input.forEach(
|
input = document.getElementsByName(id);
|
||||||
function(radioElement) {
|
}
|
||||||
radioElement.setAttribute('disabled', true);
|
if (input.length === 0) {
|
||||||
if (radioElement.value === defaultVal){
|
return;
|
||||||
radioElement.removeAttribute('disabled');
|
}
|
||||||
radioElement.setAttribute('checked', true);
|
if ($(this).is(":checked")) {
|
||||||
} else {
|
console.log("Restore checked");
|
||||||
|
edit_style.display = 'block';
|
||||||
|
var defaultVal = $(this).data("default");
|
||||||
|
if ($(this).data("type") === 'radio') {
|
||||||
|
// simulate read only for checkboxes except default
|
||||||
|
input.forEach(
|
||||||
|
function(radioElement) {
|
||||||
radioElement.setAttribute('disabled', true);
|
radioElement.setAttribute('disabled', true);
|
||||||
radioElement.removeAttribute('checked');
|
if (radioElement.value === defaultVal){
|
||||||
|
radioElement.removeAttribute('disabled');
|
||||||
|
radioElement.setAttribute('checked', true);
|
||||||
|
} else {
|
||||||
|
radioElement.removeAttribute('checked');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
return;
|
||||||
return;
|
} else if ($(this).data("type") === 'text') {
|
||||||
}
|
input[0].value = defaultVal;
|
||||||
input.prop("readonly", true);
|
input[0].readOnly = true;
|
||||||
} else {
|
}
|
||||||
console.log('restore/unchecked');
|
} else {
|
||||||
edit_style.display = 'none';
|
edit_style.display = 'none';
|
||||||
if ($(this).data("type") === 'radio') {
|
if ($(this).data("type") === 'radio') {
|
||||||
// simulate read only for checkboxes
|
input.forEach(
|
||||||
input.forEach(
|
function(radioElement) {
|
||||||
function(radioElement) {
|
radioElement.removeAttribute('disabled');
|
||||||
radioElement.removeAttribute('disabled');
|
}
|
||||||
}
|
);
|
||||||
);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
input.data("custom", input.val());
|
||||||
input.data("custom", input.val());
|
input.prop("readonly", true);
|
||||||
input.prop("readonly", true);
|
input.val(input.data("default"));
|
||||||
input.val(input.data("default"));
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".sccp-edit").click(function() {
|
$(".sccp-edit").click(function() {
|
||||||
|
|
|
@ -94,8 +94,10 @@ class formcreate
|
||||||
} else {
|
} else {
|
||||||
// reverting to chan-sccp default values
|
// reverting to chan-sccp default values
|
||||||
echo " data-for={$res_id}";
|
echo " data-for={$res_id}";
|
||||||
|
echo " data-type=text";
|
||||||
echo " class=sccp-restore";
|
echo " class=sccp-restore";
|
||||||
echo " id=usedefault_{$res_id}";
|
echo " id=usedefault_{$res_id}";
|
||||||
|
echo " data-default={$sccp_defaults[$res_n]['systemdefault']}";
|
||||||
echo " ";
|
echo " ";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue