merged crown jewels
This commit is contained in:
@@ -156,6 +156,9 @@ function showQuestion(questionId) {
|
||||
const question = document.getElementById(questionId);
|
||||
question.classList.remove('d-none');
|
||||
progressBar();
|
||||
if (questionId == 'q7') {
|
||||
setupSensitiveDataValidator();
|
||||
}
|
||||
}
|
||||
|
||||
function setButtonVisiblity(buttonId, visible) {
|
||||
@@ -229,4 +232,50 @@ function progressBar() {
|
||||
basicBarWrap.classList.add('d-none');
|
||||
advancedBarWrap.classList.add('d-none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupSensitiveDataValidator() {
|
||||
const dataTypes = [
|
||||
{checkbox: 'personal_applicable', radios: 'personal_impact'},
|
||||
{checkbox: 'financial_applicable', radios: 'financial_impact'},
|
||||
{checkbox: 'ip_applicable', radios: 'ip_impact'},
|
||||
{checkbox: 'operational_applicable', radios: 'operational_impact'},
|
||||
{checkbox: 'government_applicable', radios: 'government_impact'}
|
||||
];
|
||||
function updateRadios(type) {
|
||||
const cb = document.getElementById(type.checkbox);
|
||||
const radios = document.querySelectorAll(`input[name="${type.radios}"]`);
|
||||
const noneCb = document.getElementById('none_applicable');
|
||||
if (noneCb && noneCb.checked) {
|
||||
radios.forEach(radio => {
|
||||
radio.disabled = true;
|
||||
radio.checked = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
radios.forEach(radio => {
|
||||
radio.disabled = !cb.checked;
|
||||
if (!cb.checked) radio.checked = false;
|
||||
});
|
||||
}
|
||||
dataTypes.forEach(type => {
|
||||
const cb = document.getElementById(type.checkbox);
|
||||
if (cb) {
|
||||
cb.addEventListener('change', () => updateRadios(type));
|
||||
updateRadios(type);
|
||||
}
|
||||
});
|
||||
const noneCb = document.getElementById('none_applicable');
|
||||
if (noneCb) {
|
||||
noneCb.addEventListener('change', function() {
|
||||
if (noneCb.checked) {
|
||||
['personal_applicable','financial_applicable','ip_applicable','operational_applicable','government_applicable'].forEach(id => {
|
||||
const cb = document.getElementById(id);
|
||||
if (cb) cb.checked = false;
|
||||
});
|
||||
}
|
||||
dataTypes.forEach(type => updateRadios(type));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user