All files / src/renderers AdminRenderer.js

86.8% Statements 283/326
52.72% Branches 174/330
70.37% Functions 19/27
88.29% Lines 279/316

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528    1x   1x 36x 36x   4x     32x 32x         32x   32x       1x       1x 1x     1x       1x 1x 1x     1x 1x 1x 1x 1x 1x     1x   1x   1x 1x   1x 1x 1x   1x     1x 1x 1x     1x 1x 1x 1x 2x 2x     2x 2x 2x 2x 3x     2x 2x 2x 2x     2x 2x 2x 2x   2x   1x   1x       1x 1x 1x 1x     1x           1x               1x 1x 1x 1x 1x 1x   1x               1x 1x     1x   1x 1x   1x 1x       1x 1x 1x 1x     1x 2x 2x     2x 2x       2x 2x   2x 1x       1x   2x     1x       1x 1x 1x 1x 1x 1x 1x 1x 1x   1x     1x 1x 1x 1x 1x 1x   1x                                     1x 4x 4x 4x 4x     1x       1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x     1x 1x 1x     1x 1x 1x 1x 2x     1x     1x 1x 1x 1x 1x 1x             1x     1x 1x 1x         1x 1x       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x       1x     1x                                           1x   1x     1x 1x 1x     1x 1x 1x 1x 2x 2x 2x 2x     2x 2x 1x 1x 2x   1x 1x 1x 2x       2x 2x 1x 1x 1x 1x 1x     2x 2x 2x     2x 2x 2x     2x 1x 1x 1x   1x 1x 3x 3x 3x 3x 3x   1x 1x 1x 1x 1x 3x   3x 3x 3x 3x         3x   3x 3x 3x       3x   3x 3x 3x 3x       3x 9x 9x 9x 9x 9x   3x     1x     1x 1x 1x 1x 5x     1x   2x 2x   1x       1x 1x 1x 1x 1x 1x 1x 1x       1x 1x 2x 2x 2x 2x                     2x     2x   1x             3x   3x 3x 3x 2x   3x 2x   3x 2x   3x 2x   3x 3x       3x 2x   3x 2x   3x    
// src/renderers/AdminRenderer.js
export function renderUUID(uuid) {
  let output = '';
  // Loop through each character of the uuid string.
  for (let i = 0; i < uuid.length; i++) {
    let ch = uuid[i];
    if (ch === '-') {
      // If the character is a hyphen, add it unstyled.
      output += ch;
    } else {
      // Convert hex digit to a number (0-15)
      let value = parseInt(ch, 16);
      Iif (isNaN(value)) {
        // If not a valid hex digit, add it unstyled.
        output += ch;
      } else {
        // Compute hue: linear interpolation from 0 (red) for 0 to ~270 (violet) for F.
        let hue = (value / 15) * 270;
        // Adjust saturation and lightness as needed.
        output += `<span style="color: hsl(${hue}, 100%, 40%)">${ch}</span>`;
      }
    }
  }
  return output;
}
 
export function renderAdminData(adminData, language) {
  const container = document.getElementById('adminData');
  container.innerHTML = '';
 
  // Localized title for Administrative Data.
  const adminTitleMapping = {
    de: 'Administrative Daten',
    en: 'Administrative Data'
  };
  const title = document.createElement('h2');
  title.textContent = adminTitleMapping[language] || adminTitleMapping.en;
  container.appendChild(title);
 
  // ----- CORE DATA SECTION -----
  Eif (adminData['dcc:coreData']) {
    const coreData = adminData['dcc:coreData'];
    const coreContainer = document.createElement('div');
    coreContainer.style.marginBottom = '20px';
    coreContainer.style.border = '1px solid #ccc';
    coreContainer.style.padding = '8px';
 
    // Get the UUID from coreData.
    const uuid = coreData['dcc:uniqueIdentifier'];
    // If a UUID exists, format it using renderUUID; otherwise use 'N/A'
    const formattedUUID = uuid ? renderUUID(uuid) : 'N/A';
 
    const uuidDivText = document.createElement('div');
    uuidDivText.innerHTML = `<strong>UUID:</strong> ${formattedUUID}`;
    // Increase font size and boldness
    uuidDivText.style.marginBottom = '10px';
    uuidDivText.style.fontSize = '24px';
    uuidDivText.style.fontWeight = 'bold';
 
    coreContainer.appendChild(uuidDivText);
 
    // Identifications table
    Eif (coreData['dcc:identifications'] && coreData['dcc:identifications']['dcc:identification']) {
      let identifications = coreData['dcc:identifications']['dcc:identification'];
      Iif (!Array.isArray(identifications)) {
        identifications = [identifications];
      }
      const idTable = document.createElement('table');
      idTable.style.width = '100%';
      idTable.style.borderCollapse = 'collapse';
      identifications.forEach(id => {
        const tr = document.createElement('tr');
        tr.style.borderBottom = '1px solid #ccc';
 
        // Identification Name (language-aware)
        let idName = '';
        Eif (id['dcc:name'] && id['dcc:name']['dcc:content']) {
          const content = id['dcc:name']['dcc:content'];
          idName = Array.isArray(content)
              ? (content.find(item => item.$ && item.$.lang === language) || content[0])._ || ''
              : content._ || '';
        }
        const tdName = document.createElement('td');
        tdName.style.padding = '4px';
        tdName.innerHTML = `<strong>${idName}</strong>`;
        tr.appendChild(tdName);
 
        // Issuer and Value
        const tdIssuerValue = document.createElement('td');
        tdIssuerValue.style.padding = '4px';
        tdIssuerValue.innerHTML = `<em>${id['dcc:issuer'] || ''}</em>: ${id['dcc:value'] || ''}`;
        tr.appendChild(tdIssuerValue);
 
        idTable.appendChild(tr);
      });
      coreContainer.appendChild(idTable);
    }
    container.appendChild(coreContainer);
  }
 
  // ----- ADDRESSES SECTION -----
  const addressesContainer = document.createElement('div');
  addressesContainer.style.display = 'flex';
  addressesContainer.style.justifyContent = 'space-between';
  addressesContainer.style.marginBottom = '20px';
 
  // Mapping for Calibration Laboratory and Customer static labels.
  const labLabelMapping = {
    de: 'Kalibrierlabor',
    en: 'Calibration Laboratory',
    fr: "Laboratoire d'étalonnage",
    es: 'Laboratorio de calibración'
  };
  const custLabelMapping = {
    de: 'Kunde',
    en: 'Customer',
    fr: 'Client',
    es: 'Cliente'
  };
 
  // Calibration Laboratory (left side)
  Eif (adminData['dcc:calibrationLaboratory'] && adminData['dcc:calibrationLaboratory']['dcc:contact']) {
    const calLab = adminData['dcc:calibrationLaboratory']['dcc:contact'];
    const labDiv = document.createElement('div');
    labDiv.style.width = '45%';
    labDiv.style.border = '1px solid #ccc';
    labDiv.style.padding = '8px';
    // Render logo from descriptionData if available:
    Iif (calLab['dcc:descriptionData']) {
      const descData = calLab['dcc:descriptionData'];
      let logoImg = '';
      if (descData['dcc:dataBase64'] && descData['dcc:mimeType']) {
        logoImg = `<img src="data:${descData['dcc:mimeType']};base64,${descData['dcc:dataBase64']}" style="max-width:150px; max-height:150px; display:block; margin-bottom:8px;" />`;
      }
      labDiv.innerHTML += logoImg;
    }
    labDiv.innerHTML += `<strong>${labLabelMapping[language] || 'Calibration Laboratory'}:</strong><br>`;
    labDiv.innerHTML += renderAddress(calLab);
 
    // ----- RESPONSIBLE PERSONS SECTION -----
    Eif (adminData['dcc:respPersons'] && adminData['dcc:respPersons']['dcc:respPerson']) {
      // Separation line
      const hr = document.createElement('hr');
      labDiv.appendChild(hr);
      // Header for Responsible Persons (localized)
      const respPersonsHeader = document.createElement('h3');
      const respPersonsMapping = {
        de: "Verantwortliche Personen",
        en: "Responsible Persons"
      };
      respPersonsHeader.textContent = respPersonsMapping[language] || respPersonsMapping.en;
      labDiv.appendChild(respPersonsHeader);
      let respPersons = adminData['dcc:respPersons']['dcc:respPerson'];
      Iif (!Array.isArray(respPersons)) {
        respPersons = [respPersons];
      }
      respPersons.forEach(respPerson => {
        let personName = "";
        Eif (respPerson['dcc:person'] &&
            respPerson['dcc:person']['dcc:name'] &&
            respPerson['dcc:person']['dcc:name']['dcc:content']) {
          const content = respPerson['dcc:person']['dcc:name']['dcc:content'];
          personName = Array.isArray(content)
              ? (content.find(c => c.$ && c.$.lang === language) || content[0])._ || ''
              : content._ || content;
        }
        const personDiv = document.createElement('div');
        personDiv.textContent = personName;
        // Mark main signer if applicable.
        if (respPerson['dcc:mainSigner'] === 'true' || respPerson['dcc:mainSigner'] === true) {
          const mainSignerMapping = {
            de: " (Hauptunterzeichner)",
            en: " (Main Signer)"
          };
          personDiv.textContent += mainSignerMapping[language] || mainSignerMapping.en;
        }
        labDiv.appendChild(personDiv);
      });
    }
    addressesContainer.appendChild(labDiv);
  }
 
  // Customer (right side)
  Eif (adminData['dcc:customer']) {
    const customer = adminData['dcc:customer'];
    const custDiv = document.createElement('div');
    custDiv.style.width = '45%';
    custDiv.style.border = '1px solid #ccc';
    custDiv.style.padding = '8px';
    custDiv.innerHTML = `<strong>${custLabelMapping[language] || 'Customer'}:</strong><br>`;
    custDiv.innerHTML += renderAddress(customer);
    addressesContainer.appendChild(custDiv);
  }
  container.appendChild(addressesContainer);
 
  // ----- PERFORMANCE FIELDS SECTION -----
  Eif (adminData['dcc:coreData']) {
    const coreData = adminData['dcc:coreData'];
    const performanceContainer = document.createElement('div');
    performanceContainer.style.marginBottom = '20px';
    performanceContainer.style.border = '1px solid #ccc';
    performanceContainer.style.padding = '8px';
    // Mapping for performance fields.
    const performanceLabels = {
      'dcc:beginPerformanceDate': {
        de: 'Begin der Kalibrierung',
        en: 'Calibration Start'
      },
      'dcc:endPerformanceDate': {
        de: 'Ende der Kalibrierung',
        en: 'Calibration End'
      },
      'dcc:performanceLocation': {
        de: 'Prüfungsort',
        en: 'Performance Location'
      },
      'dcc:issueDate': {
        de: 'Ausstellungsdatum',
        en: 'Issue Date'
      }
    };
    // Loop through each performance field and render if available.
    Object.keys(performanceLabels).forEach(key => {
      Eif (coreData[key]) {
        const fieldDiv = document.createElement('div');
        fieldDiv.innerHTML = `<strong>${performanceLabels[key][language] || performanceLabels[key].en}:</strong> ${coreData[key]}`;
        performanceContainer.appendChild(fieldDiv);
      }
    });
    container.appendChild(performanceContainer);
  }
 
  // ----- ITEMS SECTION (Updated for inline image with mouseover enlargement) -----
  Eif (adminData['dcc:items'] && adminData['dcc:items']['dcc:item']) {
    let items = adminData['dcc:items']['dcc:item'];
    Eif (!Array.isArray(items)) items = [items];
    const itemsContainer = document.createElement('div');
    itemsContainer.style.marginBottom = '20px';
    itemsContainer.innerHTML = `<h3>Items</h3>`;
    items.forEach(item => {
      // Create a flex container for the item details and image.
      const itemDiv = document.createElement('div');
      itemDiv.style.border = '1px solid #ccc';
      itemDiv.style.padding = '8px';
      itemDiv.style.marginBottom = '10px';
      itemDiv.style.display = 'flex';
      itemDiv.style.justifyContent = 'space-between';
      itemDiv.style.alignItems = 'center';
 
      // Left side: textual details
      const detailsDiv = document.createElement('div');
      detailsDiv.style.flex = '1';
      detailsDiv.style.marginRight = '10px';
 
      // Item Name (language-aware)
      let itemName = '';
      Eif (item['dcc:name'] && item['dcc:name']['dcc:content']) {
        const content = item['dcc:name']['dcc:content'];
        itemName = Array.isArray(content)
            ? (content.find(c => c.$ && c.$.lang === language) || content[0])._ || ''
            : content._ || '';
      }
      detailsDiv.innerHTML += `<strong>Item:</strong> ${itemName}<br>`;
 
      // Manufacturer details
      Eif (item['dcc:manufacturer']) {
        const manu = item['dcc:manufacturer'];
        let manuName = '';
        Eif (manu['dcc:name'] && manu['dcc:name']['dcc:content']) {
          const content = manu['dcc:name']['dcc:content'];
          Iif (Array.isArray(content)) {
            let found = content.find(c => c.$ && c.$.lang === language);
            if (!found) {
              found = content.find(c => !c.$ || !c.$.lang);
            }
            manuName = found ? (typeof found === 'string' ? found : found._ || '') : '';
          } else {
            manuName = typeof content === 'string' ? content : content._ || '';
          }
        }
        detailsDiv.innerHTML += `<strong>Manufacturer:</strong> ${manuName}<br>`;
        Eif (manu['dcc:location']) {
          detailsDiv.innerHTML += `<strong>Location:</strong> ${renderAddress(manu['dcc:location'])}<br>`;
        }
      }
 
      // Model
      Eif (item['dcc:model']) {
        detailsDiv.innerHTML += `<strong>Model:</strong> ${item['dcc:model']}<br>`;
      }
 
      // Item Identifications
      Eif (item['dcc:identifications'] && item['dcc:identifications']['dcc:identification']) {
        let identifications = item['dcc:identifications']['dcc:identification'];
        Eif (!Array.isArray(identifications)) identifications = [identifications];
        detailsDiv.innerHTML += `<strong>Identifications:</strong><br>`;
        identifications.forEach(id => {
          let idName = '';
          Eif (id['dcc:name'] && id['dcc:name']['dcc:content']) {
            const content = id['dcc:name']['dcc:content'];
            idName = Array.isArray(content)
                ? (content.find(item => item.$ && item.$.lang === language) || content[0])._ || ''
                : content._ || '';
          }
          detailsDiv.innerHTML += `<em>${id['dcc:issuer'] || ''}</em> - ${idName}: ${id['dcc:value'] || ''}<br>`;
        });
      }
 
      itemDiv.appendChild(detailsDiv);
 
      // Right side: always display image (if available) as an inline thumbnail
      Iif (item['dcc:description'] && item['dcc:description']['dcc:file']) {
        let file = item['dcc:description']['dcc:file'];
        if (!Array.isArray(file)) file = [file];
        const firstFile = file[0];
        if (firstFile['dcc:dataBase64'] && firstFile['dcc:mimeType']) {
          const img = document.createElement('img');
          img.src = `data:${firstFile['dcc:mimeType']};base64,${firstFile['dcc:dataBase64']}`;
          img.style.maxWidth = '150px';
          img.style.maxHeight = '150px';
          img.style.transition = 'transform 0.3s';
          img.style.cursor = 'pointer';
          // Enlarge on mouse over
          img.addEventListener('mouseover', () => {
            img.style.transform = 'scale(1.5)';
          });
          img.addEventListener('mouseout', () => {
            img.style.transform = 'scale(1)';
          });
          itemDiv.appendChild(img);
        }
      }
 
      itemsContainer.appendChild(itemDiv);
    });
    container.appendChild(itemsContainer);
  }
  // ----- STATEMENTS SECTION -----
  Eif (adminData['dcc:statements'] && adminData['dcc:statements']['dcc:statement']) {
    let statements = adminData['dcc:statements']['dcc:statement'];
    Iif (!Array.isArray(statements)) {
      statements = [statements];
    }
    const statementsContainer = document.createElement('div');
    statementsContainer.style.marginBottom = '20px';
    statementsContainer.innerHTML = `<h3>Statements</h3>`;
    statements.forEach(stmt => {
      const details = document.createElement('details');
      details.style.border = '1px solid #ccc';
      details.style.padding = '8px';
      details.style.marginBottom = '10px';
 
      // Summary: use dcc:name if available; if not, fallback to declaration's name
      let stmtName = '';
      if (stmt['dcc:name'] && stmt['dcc:name']['dcc:content']) {
        const content = stmt['dcc:name']['dcc:content'];
        stmtName = Array.isArray(content)
            ? (content.find(item => item.$ && item.$.lang === language) || content[0])._ || ''
            : content._ || '';
      } else Eif (stmt['dcc:declaration'] && stmt['dcc:declaration']['dcc:name'] && stmt['dcc:declaration']['dcc:name']['dcc:content']) {
        const content = stmt['dcc:declaration']['dcc:name']['dcc:content'];
        stmtName = Array.isArray(content)
            ? (content.find(item => item.$ && item.$.lang === language) || content[0])._ || ''
            : content._ || '';
      }
      // If thumbnail available, render it
      let thumbHtml = '';
      if (stmt['dcc:declaration'] && stmt['dcc:declaration']['dcc:file']) {
        let file = stmt['dcc:declaration']['dcc:file'];
        Eif (!Array.isArray(file)) file = [file];
        const firstFile = file[0];
        Eif (firstFile['dcc:dataBase64'] && firstFile['dcc:mimeType']) {
          thumbHtml = `<img src="data:${firstFile['dcc:mimeType']};base64,${firstFile['dcc:dataBase64']}" style="max-height:30px; vertical-align:middle; margin-right:8px;" />`;
        }
      }
      const summary = document.createElement('summary');
      summary.innerHTML = thumbHtml + stmtName;
      details.appendChild(summary);
 
      // Expanded content
      const contentDiv = document.createElement('div');
      contentDiv.style.marginTop = '8px';
      contentDiv.style.fontFamily = 'sans-serif';
 
      // Decision rule statements: render quantities in a table with merged value/unit
      if (stmt.$ && stmt.$.refType && stmt.$.refType.includes('basic_decisionRule')) {
        const table = document.createElement('table');
        table.style.width = '100%';
        table.style.borderCollapse = 'collapse';
        // Header: Quantity, Value, Description
        const headerRow = document.createElement('tr');
        ['Quantity', 'Value', 'Description'].forEach(text => {
          const th = document.createElement('th');
          th.style.border = '1px solid #ccc';
          th.style.padding = '4px';
          th.textContent = text;
          headerRow.appendChild(th);
        });
        table.appendChild(headerRow);
        Eif (stmt['dcc:data'] && stmt['dcc:data']['dcc:quantity']) {
          let quantities = stmt['dcc:data']['dcc:quantity'];
          Iif (!Array.isArray(quantities)) quantities = [quantities];
          quantities.forEach(q => {
            const row = document.createElement('tr');
            // Quantity Name
            let qtyName = '';
            Eif (q['dcc:name'] && q['dcc:name']['dcc:content']) {
              const content = q['dcc:name']['dcc:content'];
              qtyName = Array.isArray(content)
                  ? (content.find(item => item.$ && item.$.lang === language) || content[0])._ || ''
                  : content._ || '';
            }
            // Value and Unit merged
            let value = (q['si:real'] && q['si:real']['si:value']) ||
                (q['si:realListXMLList'] && q['si:realListXMLList']['si:valueXMLList']) || '';
            let unit = '';
            if (q['si:real'] && q['si:real']['si:unit']) {
              unit = q['si:real']['si:unit'].trim();
            } else Eif (q['si:realListXMLList'] && q['si:realListXMLList']['si:unitXMLList']) {
              unit = q['si:realListXMLList']['si:unitXMLList'].trim();
            }
            const valueWithUnit = unit ? `${value} ${unit}` : value;
            // Description
            let description = '';
            Eif (q['dcc:description'] && q['dcc:description']['dcc:content']) {
              const desc = q['dcc:description']['dcc:content'];
              description = Array.isArray(desc)
                  ? (desc.find(item => item.$ && item.$.lang === language) || desc[0])._ || ''
                  : desc._ || '';
            }
            [qtyName, valueWithUnit, description].forEach(cellText => {
              const td = document.createElement('td');
              td.style.border = '1px solid #ccc';
              td.style.padding = '4px';
              td.textContent = cellText;
              row.appendChild(td);
            });
            table.appendChild(row);
          });
        }
        contentDiv.appendChild(table);
      } else {
        // For other statements, show declaration content (language-specific)
        let declText = '';
        Eif (stmt['dcc:declaration'] && stmt['dcc:declaration']['dcc:content']) {
          const decl = stmt['dcc:declaration']['dcc:content'];
          declText = Array.isArray(decl)
              ? (decl.find(c => c.$ && c.$.lang === language) || decl[0])._ || ''
              : decl._ || '';
        }
        contentDiv.innerHTML = declText;
      }
      details.appendChild(contentDiv);
      statementsContainer.appendChild(details);
    });
    container.appendChild(statementsContainer);
  }
 
// ----- SOFTWARE SECTION (Updated) -----
  Eif (adminData['dcc:dccSoftware'] && adminData['dcc:dccSoftware']['dcc:software']) {
    let softwares = adminData['dcc:dccSoftware']['dcc:software'];
    Iif (!Array.isArray(softwares)) softwares = [softwares];
    const softwareDiv = document.createElement('div');
    softwareDiv.style.border = '1px solid #ccc';
    softwareDiv.style.padding = '8px';
    softwareDiv.style.marginBottom = '20px';
    const softwareTitleMapping = {
      de: 'Verwendete Software',
      en: 'Used Software'
    };
    softwareDiv.innerHTML = `<strong>${softwareTitleMapping[language] || softwareTitleMapping.en}:</strong><br>`;
    softwares.forEach(sw => {
      let swName = '';
      Eif (sw['dcc:name'] && sw['dcc:name']['dcc:content']) {
        const content = sw['dcc:name']['dcc:content'];
        Iif (Array.isArray(content)) {
          // Try to find an entry with a matching language.
          const matching = content.find(c => c.$ && c.$.lang === language);
          if (matching && matching._) {
            swName = matching._;
          } else {
            // If no matching lang is found, use the first element regardless of its language attribute.
            swName = (typeof content[0] === 'object' ? (content[0]._ || '') : content[0]);
          }
        } else {
          // If content is not an array, check if it's an object with a "_" property or a plain string.
          swName = typeof content === 'object' ? (content._ || '') : content;
        }
      }
      softwareDiv.innerHTML += `${swName} (Release: ${sw['dcc:release'] || ''}, Type: ${sw['dcc:type'] || ''})<br>`;
    });
    container.appendChild(softwareDiv);
  }
 
}
 
// Helper function to render a full address from a location/contact object
function renderAddress(addressObj) {
  let addressStr = '';
  // If the object has a 'dcc:location', use that; otherwise use the object directly.
  const loc = addressObj['dcc:location'] || addressObj;
  Eif (loc) {
    if (loc['dcc:street']) {
      addressStr += loc['dcc:street'] + ' ';
    }
    if (loc['dcc:streetNo']) {
      addressStr += loc['dcc:streetNo'] + '<br>';
    }
    if (loc['dcc:postCode']) {
      addressStr += loc['dcc:postCode'] + ' ';
    }
    if (loc['dcc:city']) {
      addressStr += loc['dcc:city'] + '<br>';
    }
    Eif (loc['dcc:countryCode']) {
      addressStr += loc['dcc:countryCode'] + '<br>';
    }
  }
  // Also add email/phone if present
  if (addressObj['dcc:eMail']) {
    addressStr += addressObj['dcc:eMail'] + '<br>';
  }
  if (addressObj['dcc:phone']) {
    addressStr += addressObj['dcc:phone'] + '<br>';
  }
  return addressStr;
}