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 | 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x 3x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 4x 4x 4x 4x 4x 4x 5x 5x 5x 5x 5x 5x 5x 1x 3x 3x 1x 20x 15x 15x 19x 15x 5x 5x 5x 14x 5x 5x 4x 4x 4x 5x 5x 4x | // src/renderers/MeasuringEquipmentsRenderer.js import {DCCQuantity, DCCRealListQuantity, DCCRealQuantity} from '../dccQuantity.js'; import tippy from 'tippy.js'; import 'tippy.js/dist/tippy.css'; export class MeasuringEquipmentsRenderer { constructor(measuringEquipmentsData, language) { this.data = measuringEquipmentsData; this.language = language; } render() { const container = document.createElement('div'); container.innerHTML = `<h3>Measuring Equipments</h3>`; let equipments = this.data && this.data['dcc:measuringEquipment']; Iif (!equipments) { container.textContent = 'No measuring equipments data available.'; return container; } Iif (!Array.isArray(equipments)) { equipments = [equipments]; } // For each measuring equipment, create an individual collapsible section. equipments.forEach(equipment => { const details = document.createElement('details'); // Apply styling similar to influence conditions renderer details.style.margin = '0'; details.style.padding = '8px'; details.style.border = '1px solid #ccc'; details.style.marginBottom = '10px'; details.open = false; // collapsed by default // Summary: always visible – shows equipment name, manufacturer, model and first identification. const summary = document.createElement('summary'); summary.style.fontWeight = 'bold'; // Equipment name const eqName = this._getText(equipment['dcc:name']); // Manufacturer name (if available) const manufacturer = equipment['dcc:manufacturer'] ? this._getText(equipment['dcc:manufacturer']['dcc:name']) : ''; // Model const model = equipment['dcc:model'] || ''; // First identification (if available) let firstId = ''; if ( equipment['dcc:identifications'] && equipment['dcc:identifications']['dcc:identification'] ) { let idents = equipment['dcc:identifications']['dcc:identification']; Eif (!Array.isArray(idents)) { idents = [idents]; } const first = idents[0]; firstId = `<small>${this._getText(first['dcc:name'])}: ${first['dcc:value']}</small>`; } summary.innerHTML = `<strong>${eqName}</strong> – ${manufacturer} – Model: ${model} – ${firstId}`; details.appendChild(summary); // Expanded content container const contentDiv = document.createElement('div'); contentDiv.style.marginTop = '8px'; contentDiv.style.fontFamily = 'sans-serif'; // Render full identifications if available if (equipment['dcc:identifications']) { const identSection = document.createElement('div'); identSection.innerHTML = `<h4>Identifications</h4>`; let idents = equipment['dcc:identifications']['dcc:identification']; Eif (!Array.isArray(idents)) { idents = [idents]; } idents.forEach(id => { const idName = this._getText(id['dcc:name']); const idValue = id['dcc:value'] || ''; const issuer = id['dcc:issuer'] || ''; identSection.innerHTML += `<p><small>${idName} (${issuer}): ${idValue}</small></p>`; }); contentDiv.appendChild(identSection); } // Render measuring equipment quantities as a table (if available) if ( equipment['dcc:measuringEquipmentQuantities'] && equipment['dcc:measuringEquipmentQuantities']['dcc:measuringEquipmentQuantity'] ) { const qtyData = equipment['dcc:measuringEquipmentQuantities']['dcc:measuringEquipmentQuantity']; const quantities = Array.isArray(qtyData) ? qtyData : [qtyData]; const table = document.createElement('table'); table.style.width = '100%'; table.style.borderCollapse = 'collapse'; // Table header const headerRow = document.createElement('tr'); ['Quantity', 'Value','Description'].forEach(text => { const th = document.createElement('th'); th.textContent = text; th.style.border = '1px solid #ccc'; th.style.padding = '4px'; headerRow.appendChild(th); }); table.appendChild(headerRow); // Render each equipment quantity quantities.forEach(q => { const row = document.createElement('tr'); const nameCell = document.createElement('td'); nameCell.style.border = '1px solid #ccc'; nameCell.style.padding = '4px'; nameCell.textContent = this._getText(q['dcc:name']); row.appendChild(nameCell); const valueCell = document.createElement('td'); valueCell.style.border = '1px solid #ccc'; valueCell.style.padding = '4px'; const qtyObj = new DCCRealQuantity(q); // Use the DSIUnit library to convert the unit string into HTML valueCell.innerHTML = qtyObj.getValues().join(' ') + ' ' + qtyObj.getUnit({ oneLine: true }); // Attach tooltip for additional data if present const additional = this._getAdditionalData(q); if (Object.keys(additional).length > 0) { const infoSpan = document.createElement('span'); infoSpan.textContent = ' ⓘ'; infoSpan.style.cursor = 'pointer'; infoSpan.style.color = '#888'; valueCell.appendChild(infoSpan); tippy(infoSpan, { content: formatAdditionalInfoHTML(additional), allowHTML: true, theme: 'light' }); } row.appendChild(valueCell); // Column 3: Description for the quantity const descCell = document.createElement('td'); descCell.style.border = '1px solid #ccc'; descCell.style.padding = '4px'; descCell.textContent = this._getText(q['dcc:description']); row.appendChild(descCell); table.appendChild(row); }); contentDiv.appendChild(table); } details.appendChild(contentDiv); container.appendChild(details); }); return container; } // Helper: extract language-specific text from a node _getText(node) { if (!node) return ''; const content = node['dcc:content']; Eif (Array.isArray(content)) { const match = content.find(item => item.$ && item.$.lang === this.language) || content[0]; return match._ || match; } return content._ || content; } // Helper: extract additional data (all keys except the common ones) for tooltip purposes _getAdditionalData(quantity) { const exclude = ['dcc:name', 'dcc:description', 'si:real', 'si:realListXMLList']; const additional = {}; Object.keys(quantity).forEach(key => { if (!exclude.includes(key)) { additional[key] = quantity[key]; } }); return additional; } } function formatAdditionalInfoHTML(additional) { Iif (typeof additional !== 'object' || additional === null) { return String(additional); } let parts = []; for (const [key, value] of Object.entries(additional)) { const valStr = (typeof value === 'object' && value !== null) ? JSON.stringify(value) : String(value); parts.push( `<span class="tooltip-key" style="color:#007acc;">${key}</span>: ` + `<span class="tooltip-value" style="color:#cc7000;">${valStr}</span>` ); } return parts.join(', '); } |