diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 5e14d6a..4379f10 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -1058,12 +1058,10 @@ function sleep(milliseconds) $(".sccp-restore").click(function() { //input is sent by data-for where for as an attribute - var id = $(this).data("for"), input = $("#" + id); + var id = $(this).data("for"), input = $("#" + id), radId = id + "_"; var edit_style = document.getElementById("edit_" + id).style; if ($(this).data("type") === 'radio') { input = document.getElementsByName(id); - console.log('have radio type'); - // Need to use getElementBy Name } console.log(input); @@ -1075,13 +1073,29 @@ $(".sccp-restore").click(function() { edit_style.display = 'block'; if ($(this).data("type") === 'radio') { // simulate read only for checkboxes - $(':radio:not(:checked)').attr('disabled', true) - return; + input.forEach( + function(radioElement) { + radioElement.setAttribute('disabled', true); + if (radioElement.hasAttribute('checked')) { + radioElement.removeAttribute('disabled'); + } + } + ); + return; } input.prop("readonly", true); } else { console.log('restore/unchecked'); edit_style.display = 'none'; + if ($(this).data("type") === 'radio') { + // simulate read only for checkboxes + input.forEach( + function(radioElement) { + radioElement.removeAttribute('disabled'); + } + ); + return; + } input.data("custom", input.val()); input.prop("readonly", true); input.val(input.data("default")); @@ -1094,9 +1108,6 @@ $(".sccp-edit").click(function() { var edit_style = document.getElementById("edit_" + id).style; if ($(this).data("type") === 'radio') { input = document.getElementsByName(id); - console.log('have radio type'); - // $(':radio:not(:checked)').attr('disabled', true); to make readonly - // Need to use getElementBy Name } console.log(input); @@ -1107,15 +1118,22 @@ $(".sccp-edit").click(function() { console.log('edit/checked'); edit_style.display = 'block'; if ($(this).data("type") === 'radio') { - $(':radio:not(:checked)').attr('disabled', false) - return; + // Security - attribute should not exist. + input.forEach( + function(radioElement) { + if (radioElement.hasAttribute('disabled')) { + radioElement.removeAttribute('disabled'); + } + } + ); + return; } input.prop("readonly", false); input.focus(); } else { console.log('edit/unchecked'); edit_style.display = 'none'; - if (input == 'radio') { + if ($(this).data("type") === 'radio') { return; } input.data("custom", input.val()); diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 32f793a..a2e5060 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -127,7 +127,7 @@ foreach ($items as $child) { if (!empty($fvalues[$res_n]['data'])) { if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { $usingSysDefaults = false; - } + } } //} // Default to chan-sccp defaults, not xml defaults. @@ -526,7 +526,7 @@ foreach ($items as $child) { } else {$val_check = "";} } else {$val_check = "";} } - echo ''; + echo ""; echo ''; $i++; }