commit
ce365acdf2
|
@ -1190,43 +1190,47 @@ $(".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);
|
input = document.getElementsByName(id);
|
||||||
}
|
|
||||||
if (input.length === 0) {
|
if (input.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($(this).is(":checked")) {
|
if ($(this).is(":checked")) {
|
||||||
console.log('restore/checked');
|
// Restoring defaults
|
||||||
edit_style.display = 'block';
|
edit_style.display = 'block';
|
||||||
|
var defaultVal = $(this).data("default");
|
||||||
if ($(this).data("type") === 'radio') {
|
if ($(this).data("type") === 'radio') {
|
||||||
// simulate read only for checkboxes
|
// simulate read only for checkboxes except default
|
||||||
input.forEach(
|
input.forEach(
|
||||||
function(radioElement) {
|
function(radioElement) {
|
||||||
radioElement.setAttribute('disabled', true);
|
radioElement.setAttribute('disabled', true);
|
||||||
if (radioElement.hasAttribute('checked')) {
|
if (radioElement.value === defaultVal){
|
||||||
radioElement.removeAttribute('disabled');
|
radioElement.removeAttribute('disabled');
|
||||||
|
radioElement.setAttribute('checked', true);
|
||||||
|
} else {
|
||||||
|
radioElement.removeAttribute('checked');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
} else if ($(this).data("type") === 'text') {
|
||||||
input.prop("readonly", true);
|
if ((input[0].id === "sccp_bindaddr") || (input[0].id === "sccp_externip")) {
|
||||||
|
// TODO: This is a dirty hack as default value is wrong - need to improve
|
||||||
|
input[0].value = '0.0.0.0';
|
||||||
} else {
|
} else {
|
||||||
console.log('restore/unchecked');
|
input[0].value = defaultVal;
|
||||||
|
input[0].readOnly = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// editing for custom value
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
input.data("custom", input.val());
|
|
||||||
input.prop("readonly", true);
|
|
||||||
input.val(input.data("default"));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<module>
|
<module>
|
||||||
<rawname>sccp_manager</rawname>
|
<rawname>sccp_manager</rawname>
|
||||||
<name>SCCP Manager</name>
|
<name>SCCP Manager</name>
|
||||||
<version>14.3.0.21</version>
|
<version>14.3.0.22</version>
|
||||||
<type>setup</type>
|
<type>setup</type>
|
||||||
<category>SCCP Connectivity</category>
|
<category>SCCP Connectivity</category>
|
||||||
<publisher>Steve Lad, Alex GP</publisher>
|
<publisher>Steve Lad, Alex GP</publisher>
|
||||||
|
|
|
@ -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 " ";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -398,6 +400,7 @@ class formcreate
|
||||||
// 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=radio";
|
echo " data-type=radio";
|
||||||
|
echo " data-default={$sccp_defaults[$res_n]['systemdefault']}";
|
||||||
echo " class=sccp-restore";
|
echo " class=sccp-restore";
|
||||||
echo " id=usedefault_{$res_id}";
|
echo " id=usedefault_{$res_id}";
|
||||||
echo " ";
|
echo " ";
|
||||||
|
|
Loading…
Reference in a new issue