/** * Form Renderer Utility Module * Responsible for generating HTML forms based on schema definitions. */ import { getNestedValue } from './utils.js'; import { CLOSE_ICON_SVG } from './icons.js'; import { generateCategoryDropdownHTML } from './categories.js'; /** * Generates attributes to prevent password manager detection and autofill * Only applied to specific fields that cause performance issues * @param {string} inputType - The type of input ('password', 'text', etc.) * @returns {string} HTML attributes string */ function getPasswordManagerPreventionAttributes(inputType = 'text') { const attributes = [ 'autocomplete="off"', 'data-lpignore="true"', 'data-form-type="other"', 'data-1p-ignore="true"', 'data-bwignore="true"', 'spellcheck="false"' ]; // For password fields, use more specific autocomplete value if (inputType === 'password') { attributes[0] = 'autocomplete="new-password"'; } return attributes.join(' '); } /** * Determines if a field should have password manager prevention attributes * Only applies to the specific fields that cause performance issues * @param {string} fieldName - The field name * @param {object} field - The field definition * @returns {boolean} Whether to apply prevention attributes */ function shouldPreventPasswordManager(fieldName, field) { if (!fieldName) return false; // Only these exact fields need password manager prevention const targetFields = [ 'notifiarr.apikey', // Notifiarr API key (password field) 'user', // qBittorrent username (text field) 'pass' // qBittorrent password (password field) ]; return targetFields.includes(fieldName); } /** * Generates the HTML for a given section. * @param {object} config - The configuration object for the section. * @param {object} data - The current data for the section. * @returns {string} The HTML string for the section. */ export function generateSectionHTML(config, data) { let html = `
${config.description || ''}