2024-05-14 11:13:46 +02:00
|
|
|
// scripts for the submission type
|
2024-05-13 09:29:48 +02:00
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('nav-url-tab').addEventListener('click', function (e) {
|
2024-05-13 09:29:48 +02:00
|
|
|
// switch to tab for capture of URL(s)
|
|
|
|
|
|
|
|
// default: single capture field
|
|
|
|
document.getElementById("singleCaptureField").required = true;
|
|
|
|
document.getElementById("singleCaptureField").classList.remove("d-none");
|
|
|
|
// hide multiple captures field
|
|
|
|
document.getElementById('multipleCaptures').checked = false;
|
|
|
|
document.getElementById("multipleCapturesField").required = false;
|
|
|
|
document.getElementById("multipleCapturesField").classList.add("d-none");
|
|
|
|
|
|
|
|
document.getElementById("document").required = false;
|
2024-05-08 10:20:04 +02:00
|
|
|
});
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('nav-doc-tab').addEventListener('click', function (e) {
|
2024-05-13 09:29:48 +02:00
|
|
|
// switch to tab for capture of document
|
|
|
|
document.getElementById("document").required = true;
|
|
|
|
document.getElementById("multipleCapturesField").required = false;
|
|
|
|
document.getElementById("singleCaptureField").required = false;
|
|
|
|
});
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('multipleCaptures').addEventListener('click', function (e) {
|
2024-05-13 09:29:48 +02:00
|
|
|
// switch input-fields between multiple and single capture
|
|
|
|
if (document.getElementById('multipleCaptures').checked === true) {
|
|
|
|
// enable multiple captures
|
|
|
|
document.getElementById('singleCaptureField').value = '';
|
|
|
|
document.getElementById("singleCaptureField").classList.add("d-none");
|
|
|
|
document.getElementById("singleCaptureField").required = false;
|
|
|
|
document.getElementById("multipleCapturesField").classList.remove("d-none");
|
|
|
|
document.getElementById("multipleCapturesField").required = true;
|
|
|
|
} else {
|
|
|
|
// disable multiple captures
|
|
|
|
document.getElementById('multipleCapturesField').value = '';
|
|
|
|
document.getElementById("multipleCapturesField").classList.add("d-none");
|
|
|
|
document.getElementById("multipleCapturesField").required = false;
|
|
|
|
document.getElementById("singleCaptureField").classList.remove("d-none");
|
|
|
|
document.getElementById("singleCaptureField").required = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// scripts for browser configuration of the capture
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById("os").addEventListener("change", function () {
|
2024-05-13 09:29:48 +02:00
|
|
|
let osSelect = document.getElementById("os");
|
2024-05-14 09:23:09 +02:00
|
|
|
let os_name = osSelect.options[osSelect.selectedIndex].value.replace(/(:|\.|\[|\]|,|=|\\)/g, "\\$1").replace(/ /g, "_");
|
2024-05-15 12:27:05 +02:00
|
|
|
let first_browser_name = document.querySelector(`[id='${os_name}'] select option:first-child`).value.replace(/(:|\.|\[|\]|,|=|\\)/g, "\\$1").replace(/ /g, "_");
|
2024-05-08 10:20:04 +02:00
|
|
|
|
|
|
|
// Hide and disable everything
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll("#os option").forEach(function (option) {
|
2024-05-08 10:20:04 +02:00
|
|
|
option.removeAttribute('selected');
|
|
|
|
});
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll(".style-sub-1").forEach(function (element) {
|
2024-05-08 10:20:04 +02:00
|
|
|
element.style.display = 'none';
|
|
|
|
});
|
2024-05-15 12:27:05 +02:00
|
|
|
document.querySelectorAll(".style-sub-1 > label > span > select").forEach(function (select) {
|
2024-05-08 10:20:04 +02:00
|
|
|
select.disabled = true;
|
2024-05-13 09:45:57 +02:00
|
|
|
select.querySelectorAll('option').forEach(function (option) {
|
2024-05-08 10:20:04 +02:00
|
|
|
option.removeAttribute('selected');
|
|
|
|
});
|
|
|
|
});
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll(".style-sub-2").forEach(function (element) {
|
2024-05-08 10:20:04 +02:00
|
|
|
element.style.display = 'none';
|
|
|
|
});
|
2024-05-15 12:27:05 +02:00
|
|
|
document.querySelectorAll(".style-sub-2 > label > span > select").forEach(function (select) {
|
2024-05-08 10:20:04 +02:00
|
|
|
select.disabled = true;
|
2024-05-13 09:45:57 +02:00
|
|
|
select.querySelectorAll('option').forEach(function (option) {
|
2024-05-08 10:20:04 +02:00
|
|
|
option.removeAttribute('selected');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Re-enable and show what makes sense
|
2024-05-15 12:27:05 +02:00
|
|
|
document.querySelector(`[id='${os_name}']`).style.display = 'block';
|
|
|
|
document.querySelectorAll(`[id='${os_name}'] > label > span > select`).forEach(function (select) {
|
2024-05-08 10:20:04 +02:00
|
|
|
select.disabled = false;
|
|
|
|
select.querySelector('option:first-child').selected = true;
|
|
|
|
});
|
2024-05-15 12:27:05 +02:00
|
|
|
document.querySelector(`[id='${os_name}_${first_browser_name}']`).style.display = 'block';
|
|
|
|
document.querySelectorAll(`[id='${os_name}_${first_browser_name}'] > label > span > select`).forEach(function (select) {
|
2024-05-08 10:20:04 +02:00
|
|
|
select.disabled = false;
|
|
|
|
select.querySelector('option:first-child').selected = true;
|
|
|
|
});
|
2019-07-05 15:44:52 +02:00
|
|
|
});
|
|
|
|
|
2024-05-14 11:13:46 +02:00
|
|
|
document.querySelectorAll('select[name="browser"]').forEach( function(element)
|
|
|
|
{
|
|
|
|
element.addEventListener('change', function (e) {
|
|
|
|
let browser_name = element.options[element.selectedIndex].value.replace(/(:|\.|\[|\]|,|=|\\)/g, "\\$1").replace(/ /g, "_");
|
|
|
|
let osSelect = document.getElementById("os");
|
|
|
|
let os_name = osSelect.options[osSelect.selectedIndex].value.replace(/(:|\.|\[|\]|,|=|\\)/g, "\\$1").replace(/ /g, "_");
|
2019-07-05 15:44:52 +02:00
|
|
|
|
2024-05-15 12:27:05 +02:00
|
|
|
// Hide and disable every useragent
|
2024-05-14 11:13:46 +02:00
|
|
|
document.querySelectorAll(".style-sub-2").forEach(function (element) {
|
|
|
|
element.style.display = 'none';
|
|
|
|
});
|
2024-05-15 12:27:05 +02:00
|
|
|
document.querySelectorAll(".style-sub-2 > label > span > select").forEach(function (select) {
|
2024-05-14 11:13:46 +02:00
|
|
|
select.disabled = true;
|
|
|
|
select.querySelectorAll('option').forEach(function (option) {
|
|
|
|
option.removeAttribute('selected');
|
|
|
|
});
|
|
|
|
});
|
2024-05-15 12:27:05 +02:00
|
|
|
|
2024-05-14 11:13:46 +02:00
|
|
|
// Show only the correct user-agent
|
2024-05-15 12:27:05 +02:00
|
|
|
document.querySelector(`[id='${os_name}_${browser_name}']`).style.display = 'block';
|
|
|
|
document.querySelectorAll(`[id='${os_name}_${browser_name}'] > label > span > select`).forEach(function (select) {
|
2024-05-14 11:13:46 +02:00
|
|
|
select.disabled = false;
|
|
|
|
select.querySelector('option:first-child').selected = true;
|
2024-05-08 10:20:04 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('personal_ua_select').addEventListener('click', function (e) {
|
2024-05-13 09:29:48 +02:00
|
|
|
//disable select fields when personal useragent (ua) selected etc...
|
2024-05-08 10:20:04 +02:00
|
|
|
document.getElementById('personal_ua').disabled = false;
|
|
|
|
document.getElementById('freetext_ua').disabled = true;
|
|
|
|
disablePredefinedUA();
|
2019-07-05 15:44:52 +02:00
|
|
|
});
|
2024-05-08 10:20:04 +02:00
|
|
|
|
2024-05-13 09:29:48 +02:00
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('predefined_ua_select').addEventListener('click', function (e) {
|
2024-05-13 09:29:48 +02:00
|
|
|
document.getElementById('os-type').value = 'desktop';
|
|
|
|
document.getElementById('os-type').dispatchEvent(new Event('change'));
|
|
|
|
document.getElementById('freetext_ua').disabled = true;
|
|
|
|
document.getElementById('personal_ua').disabled = true;
|
|
|
|
// Enable predefinded user-agent
|
2024-05-08 10:20:04 +02:00
|
|
|
let os_type = document.getElementById('os-type');
|
|
|
|
os_type.value = 'desktop';
|
|
|
|
os_type.dispatchEvent(new Event('change'))
|
|
|
|
});
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('freetext_ua_select').addEventListener('click', function (e) {
|
2024-05-13 09:29:48 +02:00
|
|
|
// Enable freetext user-agent
|
2024-05-08 10:20:04 +02:00
|
|
|
document.getElementById('freetext_ua').disabled = false;
|
|
|
|
document.getElementById('personal_ua').disabled = true;
|
|
|
|
disablePredefinedUA()
|
2024-05-13 09:29:48 +02:00
|
|
|
})
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
const disablePredefinedUA = function () {
|
2024-05-13 09:29:48 +02:00
|
|
|
document.getElementById('os-type').disabled = true;
|
|
|
|
document.getElementById('device-name-mobile').disabled = true;
|
|
|
|
document.getElementById('os').disabled = true;
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll('select[name="browser"]').forEach(function (element) {
|
|
|
|
element.disabled = true;
|
|
|
|
});
|
|
|
|
document.querySelectorAll('select[name="user_agent"]').forEach(function (element) {
|
|
|
|
element.disabled = true;
|
|
|
|
});
|
2024-05-08 10:20:04 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
document.getElementById('os-type').addEventListener('change', function () {
|
2024-05-13 09:29:48 +02:00
|
|
|
document.getElementById('os-type').disabled = false;
|
2024-05-13 09:45:57 +02:00
|
|
|
if (this.value === "mobile") {
|
2024-05-13 09:29:48 +02:00
|
|
|
document.getElementById("mobiles-list").style.display = 'block';
|
|
|
|
document.getElementById('device-name-mobile').disabled = false;
|
2024-05-08 10:20:04 +02:00
|
|
|
|
2024-05-13 09:29:48 +02:00
|
|
|
document.getElementById("desktops-list").style.display = 'none';
|
|
|
|
document.getElementById('os').disabled = true;
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll('select[name="browser"]').forEach(function (element) {
|
2024-05-13 09:29:48 +02:00
|
|
|
element.disabled = true;
|
|
|
|
});
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll('select[name="user_agent"]').forEach(function (element) {
|
2024-05-13 09:29:48 +02:00
|
|
|
element.disabled = true;
|
|
|
|
});
|
|
|
|
} else { // os-type is desktop
|
|
|
|
document.getElementById("desktops-list").style.display = 'block';
|
|
|
|
document.getElementById('os').disabled = false;
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll('select[name="browser"]:not([hidden])').forEach(function (element) {
|
2024-05-13 09:29:48 +02:00
|
|
|
element.disabled = false;
|
|
|
|
});
|
2024-05-13 09:45:57 +02:00
|
|
|
document.querySelectorAll('select[name="user_agent"]:not([hidden])').forEach(function (element) {
|
2024-05-13 09:29:48 +02:00
|
|
|
element.disabled = false;
|
|
|
|
});
|
|
|
|
document.getElementById("mobiles-list").style.display = 'none';
|
|
|
|
document.getElementById('device-name-mobile').disabled = true;
|
|
|
|
}
|
2024-05-08 10:20:04 +02:00
|
|
|
});
|
2024-05-13 09:45:57 +02:00
|
|
|
|
|
|
|
// admin-only report-form
|
2024-05-15 12:27:05 +02:00
|
|
|
let report_form = document.getElementById("auto-report");
|
|
|
|
if (report_form) { // admin is logged in
|
|
|
|
report_form.addEventListener('change', function() {
|
|
|
|
let show_form = document.getElementById("auto-report").checked;
|
|
|
|
if(show_form) {
|
|
|
|
document.getElementById("collapseMailConfiguration").style.display = "block";
|
|
|
|
} else {
|
|
|
|
document.getElementById("collapseMailConfiguration").style.display = "none";
|
|
|
|
}
|
|
|
|
});
|
2024-05-13 09:45:57 +02:00
|
|
|
}
|
2024-05-15 12:27:05 +02:00
|
|
|
|
2024-05-13 09:45:57 +02:00
|
|
|
|