feat: Implement Polish translation for UI elements and properties in ObjectFlowDesigner

This commit is contained in:
2025-06-27 13:08:02 +02:00
parent a9dd3111df
commit a4faba92ff

524
script.js
View File

@@ -1,3 +1,273 @@
// Polish translation system
const translations = {
en: {
// UI Elements
"Power System Designer": "Power System Designer",
"Calculate Voltage Drops": "Calculate Voltage Drops",
"Clear All": "Clear All",
"Export Data": "Export Data",
"Import Data": "Import Data",
"Objects": "Objects",
"Transformer": "Transformer",
"Cable Box": "Cable Box",
"Pole": "Pole",
"End Connection": "End Connection",
"Cables": "Cables",
"Underground Cable": "Underground Cable",
"Overhead Cable": "Overhead Cable",
"Tools": "Tools",
"Select Mode": "Select Mode",
"Delete Mode": "Delete Mode",
"Auto Arrange - One Click to Make Everything Look Nice and Tidy": "Auto Arrange - One Click to Make Everything Look Nice and Tidy",
"Properties": "Properties",
"No object selected": "No object selected",
// Object Properties
"Transformer Properties": "Transformer Properties",
"Number:": "Number:",
"Name:": "Name:",
"Upper Voltage (V):": "Upper Voltage (V):",
"Bottom Voltage (V):": "Bottom Voltage (V):",
"Power (kVA):": "Power (kVA):",
"Description:": "Description:",
"Transformer Info": "Transformer Info",
"Type:": "Type:",
"ID:": "ID:",
"Position:": "Position:",
"Ratio:": "Ratio:",
"Outputs:": "Outputs:",
"Actions": "Actions",
"Delete Transformer": "Delete Transformer",
// Node Properties
"Node Properties": "Node Properties",
"Box": "Box",
"End": "End",
"Enter type description": "Enter type description",
"3-Phase Consumers (7kW each):": "3-Phase Consumers (7kW each):",
"1-Phase Consumers (3kW each):": "1-Phase Consumers (3kW each):",
"Custom Power (kW):": "Custom Power (kW):",
"Node Info": "Node Info",
"Total Power:": "Total Power:",
"3-Phase:": "3-Phase:",
"consumers": "consumers",
"1-Phase:": "1-Phase:",
"Custom:": "Custom:",
"Inputs:": "Inputs:",
"Delete Node": "Delete Node",
// Cable Properties
"Power Cable Properties": "Power Cable Properties",
"Label:": "Label:",
"Cable Type:": "Cable Type:",
"YAKY (Ground Cable)": "YAKY (Ground Cable)",
"NA2XY-J (Ground Cable)": "NA2XY-J (Ground Cable)",
"AL (Overhead Cable)": "AL (Overhead Cable)",
"AsXSn (Overhead Cable)": "AsXSn (Overhead Cable)",
"Cross Section (mm²):": "Cross Section (mm²):",
"Length (m):": "Length (m):",
"Cable Info": "Cable Info",
"From:": "From:",
"To:": "To:",
"Specifications:": "Specifications:",
"Section Resistance:": "Section Resistance:",
"Section Current:": "Section Current:",
"Voltage Drop:": "Voltage Drop:",
"Total Consumers:": "Total Consumers:",
"Diversity Factor:": "Diversity Factor:",
"⚠️ Overhead cables can only connect to poles or end connections!": "⚠️ Overhead cables can only connect to poles or end connections!",
"Delete Cable": "Delete Cable",
// Error Messages
"Cannot connect object to itself!": "Cannot connect object to itself!",
"Connection already exists!": "Connection already exists!",
"Transformer can only have one outgoing connection!": "Transformer can only have one outgoing connection!",
"Node can only have one incoming connection!": "Node can only have one incoming connection!",
"End connections cannot have outgoing connections!": "End connections cannot have outgoing connections!",
"Cannot connect from end connections!": "Cannot connect from end connections!",
"Cannot connect from node to transformer!": "Cannot connect from node to transformer!",
"Failed to import file: Invalid format": "Failed to import file: Invalid format",
"Need at least 2 objects to align": "Need at least 2 objects to align",
"Select at least 2 objects to align": "Select at least 2 objects to align",
"Need at least 3 objects to distribute": "Need at least 3 objects to distribute",
"No transformer found for auto-arrangement": "No transformer found for auto-arrangement",
// Confirmation Messages
"Are you sure you want to clear all objects and connections?": "Are you sure you want to clear all objects and connections?",
// Cable Names
"Cable": "Cable",
// Node Types Display
"Ground": "Ground",
"Overhead": "Overhead",
"Node": "Node"
},
pl: {
// UI Elements
"Power System Designer": "Analiza sieci nN",
"Calculate Voltage Drops": "Oblicz Spadki Napięcia",
"Clear All": "Wyczyść Wszystko",
"Export Data": "Eksportuj Dane",
"Import Data": "Importuj Dane",
"Objects": "Obiekty",
"Transformer": "Transformator",
"Cable Box": "Złącze Kablowe",
"Pole": "Słup",
"End Connection": "Odbiorca (napowietrzny)",
"Cables": "Kable",
"Underground Cable": "Kabel Ziemny",
"Overhead Cable": "Kabel Napowietrzny",
"Tools": "Narzędzia",
"Select Mode": "Tryb Wyboru",
"Delete Mode": "Tryb Usuwania",
"Auto Arrange - One Click to Make Everything Look Nice and Tidy": "Auto Rozmieszczenie",
"Properties": "Właściwości",
"No object selected": "Nie wybrano obiektu",
// Object Properties
"Transformer Properties": "Właściwości Transformatora",
"Number:": "Numer:",
"Name:": "Nazwa:",
"Upper Voltage (V):": "Napięcie Górne (V):",
"Bottom Voltage (V):": "Napięcie Dolne (V):",
"Power (kVA):": "Moc (kVA):",
"Description:": "Opis:",
"Transformer Info": "Informacje o Transformatorze",
"Type:": "Typ:",
"ID:": "ID:",
"Position:": "Pozycja:",
"Ratio:": "Przekładnia:",
"Outputs:": "Wyjścia:",
"Actions": "Akcje",
"Delete Transformer": "Usuń Transformator",
// Node Properties
"Node Properties": "Właściwości Węzła",
"Box": "Złącze Kablowe",
"End": "Koniec",
"Enter type description": "Wprowadź opis typu",
"3-Phase Consumers (7kW each):": "Odbiorcy 3-fazowi (7kW każdy):",
"1-Phase Consumers (3kW each):": "Odbiorcy 1-fazowi (3kW każdy):",
"Custom Power (kW):": "Niestandardowa Moc (kW):",
"Node Info": "Informacje o Węźle",
"Total Power:": "Moc Całkowita:",
"3-Phase:": "3-fazowe:",
"consumers": "odbiorców",
"1-Phase:": "1-fazowe:",
"Custom:": "Niestandardowe:",
"Inputs:": "Wejścia:",
"Delete Node": "Usuń Węzeł",
// Cable Properties
"Power Cable Properties": "Właściwości Kabla Zasilającego",
"Label:": "Etykieta:",
"Cable Type:": "Typ Kabla:",
"YAKY (Ground Cable)": "YAKY",
"NA2XY-J (Ground Cable)": "NA2XY-J",
"AL (Overhead Cable)": "AL",
"AsXSn (Overhead Cable)": "AsXSn",
"Cross Section (mm²):": "Przekrój (mm²):",
"Length (m):": "Długość (m):",
"Cable Info": "Informacje o Kablu",
"From:": "Od:",
"To:": "Do:",
"Specifications:": "Specyfikacje:",
"Section Resistance:": "Rezystancja Odcinka:",
"Section Current:": "Prąd Odcinka:",
"Voltage Drop:": "Spadek Napięcia:",
"Total Consumers:": "Łączna Liczba Odbiorców:",
"Diversity Factor:": "Współczynnik Jednoczesności:",
"⚠️ Overhead cables can only connect to poles or end connections!": "Kable napowietrzne mogą łączyć się tylko ze słupami lub końcowymi połączeniami!",
"Delete Cable": "Usuń Kabel",
// Error Messages
"Cannot connect object to itself!": "Nie można połączyć obiektu z samym sobą!",
"Connection already exists!": "Połączenie już istnieje!",
"Transformer can only have one outgoing connection!": "Transformator może mieć tylko jedno połączenie wychodzące!",
"Node can only have one incoming connection!": "Węzeł może mieć tylko jedno połączenie przychodzące!",
"End connections cannot have outgoing connections!": "Końcowe połączenia nie mogą mieć połączeń wychodzących!",
"Cannot connect from end connections!": "Nie można łączyć z końcowych połączeń!",
"Cannot connect from node to transformer!": "Nie można łączyć z węzła do transformatora!",
"Failed to import file: Invalid format": "Błąd importu pliku: Nieprawidłowy format",
"Need at least 2 objects to align": "Potrzeba co najmniej 2 obiektów do wyrównania",
"Select at least 2 objects to align": "Wybierz co najmniej 2 obiekty do wyrównania",
"Need at least 3 objects to distribute": "Potrzeba co najmniej 3 obiektów do rozłożenia",
"No transformer found for auto-arrangement": "Nie znaleziono transformatora do automatycznego rozmieszczenia",
// Confirmation Messages
"Are you sure you want to clear all objects and connections?": "Czy na pewno chcesz wyczyścić wszystkie obiekty i połączenia?",
// Cable Names
"Cable": "Kabel",
// Node Types Display
"Ground": "Podziemny",
"Overhead": "Napowietrzny",
"Node": "Węzeł"
}
};
// Current language setting
let currentLanguage = 'pl'; // Default to Polish
// Translation function
function t(key) {
return translations[currentLanguage][key] || translations.en[key] || key;
}
// Translate static HTML UI elements
function translateStaticUI() {
// Header and buttons
const header = document.querySelector(".header h1");
if (header) header.textContent = t("Power System Designer");
const calculateBtn = document.getElementById("calculateBtn");
if (calculateBtn) calculateBtn.textContent = t("Calculate Voltage Drops");
const clearBtn = document.getElementById("clearBtn");
if (clearBtn) clearBtn.textContent = t("Clear All");
const exportBtn = document.getElementById("exportBtn");
if (exportBtn) exportBtn.textContent = t("Export Data");
const importBtn = document.getElementById("importBtn");
if (importBtn) importBtn.textContent = t("Import Data");
// Toolbar labels
document.querySelectorAll(".toolbar-label").forEach((el) => {
if (el.textContent.trim() === "Objects") el.textContent = t("Objects");
if (el.textContent.trim() === "Cables") el.textContent = t("Cables");
if (el.textContent.trim() === "Tools") el.textContent = t("Tools");
});
// Icon tooltips
document.querySelectorAll(".icon-btn[data-type]").forEach((btn) => {
const type = btn.getAttribute("data-type");
if (type === "triangle") btn.title = t("Transformer");
if (type === "box") btn.title = t("Cable Box");
if (type === "pole") btn.title = t("Pole");
if (type === "end") btn.title = t("End Connection");
if (type === "underground") btn.title = t("Underground Cable");
if (type === "overhead") btn.title = t("Overhead Cable");
});
// Tool buttons tooltips
const selectBtn = document.getElementById("selectBtn");
if (selectBtn) selectBtn.title = t("Select Mode");
const deleteBtn = document.getElementById("deleteBtn");
if (deleteBtn) deleteBtn.title = t("Delete Mode");
const autoArrangeBtn = document.getElementById("autoArrangeBtn");
if (autoArrangeBtn) autoArrangeBtn.title = t("Auto Arrange - One Click to Make Everything Look Nice and Tidy");
// Properties panel
const propertiesPanel = document.querySelector(".properties-panel h3");
if (propertiesPanel) propertiesPanel.textContent = t("Properties");
}
// Call translation on DOMContentLoaded
window.addEventListener("DOMContentLoaded", translateStaticUI);
class ObjectFlowDesigner {
constructor() {
this.canvas = document.getElementById("canvas");
@@ -1069,7 +1339,7 @@ class ObjectFlowDesigner {
} else if (this.selectedConnection) {
this.updateConnectionProperties(panel);
} else {
panel.innerHTML = '<p class="no-selection">No object selected</p>';
panel.innerHTML = `<p class="no-selection">${t("No object selected")}</p>`;
}
}
@@ -1080,37 +1350,31 @@ class ObjectFlowDesigner {
// Transformer properties
panel.innerHTML = `
<div class="property-group">
<h4>Transformer Properties</h4>
<label>Number:</label>
<h4>${t("Transformer Properties")}</h4>
<label>${t("Number:")}</label>
<input type="text" id="objNumber" value="${obj.data.number}">
<label>Name:</label>
<label>${t("Name:")}</label>
<input type="text" id="objName" value="${obj.data.name}">
<label>Upper Voltage (V):</label>
<label>${t("Upper Voltage (V):")}</label>
<input type="number" id="objUpperVoltage" value="${obj.data.upperVoltage}">
<label>Bottom Voltage (V):</label>
<label>${t("Bottom Voltage (V):")}</label>
<input type="number" id="objBottomVoltage" value="${obj.data.bottomVoltage}">
<label>Power (kVA):</label>
<label>${t("Power (kVA):")}</label>
<input type="number" id="objPowerKVA" value="${obj.data.powerKVA}">
<label>Description:</label>
<label>${t("Description:")}</label>
<textarea id="objDescription">${obj.data.description}</textarea>
</div>
<div class="property-group">
<h4>Transformer Info</h4>
<p><strong>Type:</strong> Transformer</p>
<p><strong>ID:</strong> ${obj.id}</p>
<p><strong>Position:</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
<p><strong>Ratio:</strong> ${obj.data.upperVoltage}V / ${
obj.data.bottomVoltage
}V</p>
<p><strong>Outputs:</strong> ${obj.connections.outputs.length}/1</p>
<h4>${t("Transformer Info")}</h4>
<p><strong>${t("Type:")}</strong> ${t("Transformer")}</p>
<p><strong>${t("ID:")}</strong> ${obj.id}</p>
<p><strong>${t("Position:")}</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
<p><strong>${t("Ratio:")}</strong> ${obj.data.upperVoltage}V / ${obj.data.bottomVoltage}V</p>
<p><strong>${t("Outputs:")}</strong> ${obj.connections.outputs.length}/1</p>
</div>
<div class="property-group">
<h4>Actions</h4>
<button class="btn btn-danger" onclick="designer.deleteObject(${
obj.id
})">Delete Transformer</button>
<h4>${t("Actions")}</h4>
<button class="btn btn-danger" onclick="designer.deleteObject(${obj.id})">${t("Delete Transformer")}</button>
</div>
`;
@@ -1143,94 +1407,50 @@ class ObjectFlowDesigner {
// Square (Node) properties
panel.innerHTML = `
<div class="property-group">
<h4>Node Properties</h4>
<h4>${t("Node Properties")}</h4>
<!-- Node Type Icons -->
<div class="node-type-selector">
<button type="button" class="node-type-btn ${
obj.data.nodeType === "cable_box" ? "active" : ""
}"
data-type="cable_box" title="Cable Box">
<button type="button" class="node-type-btn ${obj.data.nodeType === "cable_box" ? "active" : ""}" data-type="cable_box" title="${t("Cable Box")}">
<span class="node-icon">⬛</span>
<span class="node-label">Box</span>
<span class="node-label">${t("Box")}</span>
</button>
<button type="button" class="node-type-btn ${
obj.data.nodeType === "pole" ? "active" : ""
}"
data-type="pole" title="Pole">
<button type="button" class="node-type-btn ${obj.data.nodeType === "pole" ? "active" : ""}" data-type="pole" title="${t("Pole")}">
<span class="node-icon">⬆</span>
<span class="node-label">Pole</span>
<span class="node-label">${t("Pole")}</span>
</button>
<button type="button" class="node-type-btn ${
obj.data.nodeType === "end_connection" ? "active" : ""
}"
data-type="end_connection" title="End Connection">
<button type="button" class="node-type-btn ${obj.data.nodeType === "end_connection" ? "active" : ""}" data-type="end_connection" title="${t("End Connection")}">
<span class="node-icon">⬤</span>
<span class="node-label">End</span>
<span class="node-label">${t("End")}</span>
</button>
</div>
<!-- Number -->
<label>Number:</label>
<label>${t("Number:")}</label>
<input type="text" id="objNumber" value="${obj.data.number}">
<!-- Type Description -->
<label>Type:</label>
<input type="text" id="objBoxPoleType" value="${
obj.data.boxPoleType
}" placeholder="Enter type description">
<!-- Power Settings -->
<label>3-Phase Consumers (7kW each):</label>
<input type="number" id="objConsumers3Phase" value="${
obj.data.consumers3Phase || 0
}" min="0">
<label>1-Phase Consumers (3kW each):</label>
<input type="number" id="objConsumers1Phase" value="${
obj.data.consumers1Phase || 0
}" min="0">
<label>Custom Power (kW):</label>
<input type="number" id="objCustomPowerKW" value="${
obj.data.customPowerKW || 0
}" step="0.1" min="0">
<!-- Description -->
<label>Description:</label>
<label>${t("Type:")}</label>
<input type="text" id="objBoxPoleType" value="${obj.data.boxPoleType}" placeholder="${t("Enter type description")}">
<label>${t("3-Phase Consumers (7kW each):")}</label>
<input type="number" id="objConsumers3Phase" value="${obj.data.consumers3Phase || 0}" min="0">
<label>${t("1-Phase Consumers (3kW each):")}</label>
<input type="number" id="objConsumers1Phase" value="${obj.data.consumers1Phase || 0}" min="0">
<label>${t("Custom Power (kW):")}</label>
<input type="number" id="objCustomPowerKW" value="${obj.data.customPowerKW || 0}" step="0.1" min="0">
<label>${t("Description:")}</label>
<textarea id="objDescription">${obj.data.description}</textarea>
</div>
<div class="property-group">
<h4>Node Info</h4>
<p><strong>Type:</strong> ${
obj.data.nodeType === "cable_box"
? "Cable Box"
: obj.data.nodeType === "pole"
? "Pole"
: "End Connection"
}</p>
<p><strong>ID:</strong> ${obj.id}</p>
<p><strong>Position:</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
<p><strong>Total Power:</strong> ${this.calculateNodeTotalPower(obj)} kW</p>
<p><strong>3-Phase:</strong> ${obj.data.consumers3Phase || 0} consumers (${
(obj.data.consumers3Phase || 0) * 7
}kW)</p>
<p><strong>1-Phase:</strong> ${obj.data.consumers1Phase || 0} consumers (${
(obj.data.consumers1Phase || 0) * 3
}kW)</p>
<p><strong>Custom:</strong> ${obj.data.customPowerKW || 0} kW</p>
<p><strong>Inputs:</strong> ${obj.connections.inputs.length}${
obj.data.nodeType === "end_connection" ? "" : "/1"
}</p>
<p><strong>Outputs:</strong> ${obj.connections.outputs.length}${
obj.data.nodeType === "end_connection" ? "/0" : ""
}</p>
<h4>${t("Node Info")}</h4>
<p><strong>${t("Type:")}</strong> ${obj.data.nodeType === "cable_box" ? t("Cable Box") : obj.data.nodeType === "pole" ? t("Pole") : t("End Connection")}</p>
<p><strong>${t("ID:")}</strong> ${obj.id}</p>
<p><strong>${t("Position:")}</strong> (${Math.round(obj.x)}, ${Math.round(obj.y)})</p>
<p><strong>${t("Total Power:")}</strong> ${this.calculateNodeTotalPower(obj)} kW</p>
<p><strong>${t("3-Phase:")}</strong> ${obj.data.consumers3Phase || 0} ${t("consumers")} (${(obj.data.consumers3Phase || 0) * 7}kW)</p>
<p><strong>${t("1-Phase:")}</strong> ${obj.data.consumers1Phase || 0} ${t("consumers")} (${(obj.data.consumers1Phase || 0) * 3}kW)</p>
<p><strong>${t("Custom:")}</strong> ${obj.data.customPowerKW || 0} kW</p>
<p><strong>${t("Inputs:")}</strong> ${obj.connections.inputs.length}${obj.data.nodeType === "end_connection" ? "" : "/1"}</p>
<p><strong>${t("Outputs:")}</strong> ${obj.connections.outputs.length}${obj.data.nodeType === "end_connection" ? "/0" : ""}</p>
</div>
<div class="property-group">
<h4>Actions</h4>
<button class="btn btn-danger" onclick="designer.deleteObject(${
obj.id
})">Delete Node</button>
<h4>${t("Actions")}</h4>
<button class="btn btn-danger" onclick="designer.deleteObject(${obj.id})">${t("Delete Node")}</button>
</div>
`;
@@ -1302,97 +1522,41 @@ class ObjectFlowDesigner {
updateConnectionProperties(panel) {
const conn = this.selectedConnection;
const isOverheadCable =
conn.data.cableType === "AL" || conn.data.cableType === "AsXSn";
// Calculate electrical properties for display
const hasElectricalData =
conn.data.sectionCurrent !== null &&
conn.data.sectionCurrent !== undefined;
const isOverheadCable = conn.data.cableType === "AL" || conn.data.cableType === "AsXSn";
const hasElectricalData = conn.data.sectionCurrent !== null && conn.data.sectionCurrent !== undefined;
panel.innerHTML = `
<div class="property-group">
<h4>Power Cable Properties</h4>
<label>Label:</label>
<h4>${t("Power Cable Properties")}</h4>
<label>${t("Label:")}</label>
<input type="text" id="connLabel" value="${conn.data.label}">
<label>Cable Type:</label>
<label>${t("Cable Type:")}</label>
<select id="connCableType">
<option value="YAKY" ${
conn.data.cableType === "YAKY" ? "selected" : ""
}>YAKY (Ground Cable)</option>
<option value="NA2XY-J" ${
conn.data.cableType === "NA2XY-J" ? "selected" : ""
}>NA2XY-J (Ground Cable)</option>
<option value="AL" ${
conn.data.cableType === "AL" ? "selected" : ""
}>AL (Overhead Cable)</option>
<option value="AsXSn" ${
conn.data.cableType === "AsXSn" ? "selected" : ""
}>AsXSn (Overhead Cable)</option>
<option value="YAKY" ${conn.data.cableType === "YAKY" ? "selected" : ""}>${t("YAKY (Ground Cable)")}</option>
<option value="NA2XY-J" ${conn.data.cableType === "NA2XY-J" ? "selected" : ""}>${t("NA2XY-J (Ground Cable)")}</option>
<option value="AL" ${conn.data.cableType === "AL" ? "selected" : ""}>${t("AL (Overhead Cable)")}</option>
<option value="AsXSn" ${conn.data.cableType === "AsXSn" ? "selected" : ""}>${t("AsXSn (Overhead Cable)")}</option>
</select>
<label>Cross Section (mm²):</label>
<input type="number" id="connCrossSection" value="${
conn.data.crossSection
}" min="1">
<label>Length (m):</label>
<input type="number" id="connLength" value="${
conn.data.length
}" min="0.1" step="0.1">
<label>Description:</label>
<label>${t("Cross Section (mm²):")}</label>
<input type="number" id="connCrossSection" value="${conn.data.crossSection}" min="1">
<label>${t("Length (m):")}</label>
<input type="number" id="connLength" value="${conn.data.length}" min="0.1" step="0.1">
<label>${t("Description:")}</label>
<textarea id="connDescription">${conn.data.description}</textarea>
</div>
<div class="property-group">
<h4>Cable Info</h4>
<p><strong>ID:</strong> ${conn.id}</p>
<p><strong>Type:</strong> ${conn.data.cableType} ${
isOverheadCable ? "(Overhead)" : "(Ground)"
}</p>
<p><strong>From:</strong> ${conn.from.data.number || conn.from.data.name} (${
conn.from.type === "triangle"
? "Transformer"
: this.getNodeDisplayType(conn.from.data.nodeType)
})</p>
<p><strong>To:</strong> ${conn.to.data.number || conn.to.data.name} (${
conn.to.type === "triangle"
? "Transformer"
: this.getNodeDisplayType(conn.to.data.nodeType)
})</p>
<p><strong>Specifications:</strong> ${conn.data.crossSection}mm² × ${
conn.data.length
}m</p>
${
hasElectricalData
? `
<p><strong>Section Resistance:</strong> ${
Math.round(conn.data.sectionResistance * 1000) / 1000
} Ω</p>
<p><strong>Section Current:</strong> ${
Math.round(conn.data.sectionCurrent * 10) / 10
} A (per phase)</p>
<p><strong>Voltage Drop:</strong> ${
Math.round(conn.data.voltageDrop * 1000) / 1000
} V</p>
<p><strong>Total Consumers:</strong> ${this.getTotalConsumers(conn.to)}</p>
<p><strong>Diversity Factor:</strong> ${(
this.getDiversityFactor(this.getTotalConsumers(conn.to)) * 100
).toFixed(0)}%</p>
`
: ""
}
${
isOverheadCable
? '<p class="warning"><strong>⚠️ Overhead cables can only connect to poles or end connections!</strong></p>'
: ""
}
<h4>${t("Cable Info")}</h4>
<p><strong>${t("ID:")}</strong> ${conn.id}</p>
<p><strong>${t("Type:")}</strong> ${conn.data.cableType} ${isOverheadCable ? `(${t("Overhead")})` : `(${t("Ground")})`}</p>
<p><strong>${t("From:")}</strong> ${conn.from.data.number || conn.from.data.name} (${conn.from.type === "triangle" ? t("Transformer") : this.getNodeDisplayType(conn.from.data.nodeType)})</p>
<p><strong>${t("To:")}</strong> ${conn.to.data.number || conn.to.data.name} (${conn.to.type === "triangle" ? t("Transformer") : this.getNodeDisplayType(conn.to.data.nodeType)})</p>
<p><strong>${t("Specifications:")}</strong> ${conn.data.crossSection}mm² × ${conn.data.length}m</p>
${hasElectricalData ? `<p><strong>${t("Section Resistance:")}</strong> ${Math.round(conn.data.sectionResistance * 1000) / 1000} Ω</p><p><strong>${t("Section Current:")}</strong> ${Math.round(conn.data.sectionCurrent * 10) / 10} A (per phase)</p><p><strong>${t("Voltage Drop:")}</strong> ${Math.round(conn.data.voltageDrop * 1000) / 1000} V</p><p><strong>${t("Total Consumers:")}</strong> ${this.getTotalConsumers(conn.to)}</p><p><strong>${t("Diversity Factor:")}</strong> ${(this.getDiversityFactor(this.getTotalConsumers(conn.to)) * 100).toFixed(0)}%</p>` : ""}
${isOverheadCable ? `<p class="warning"><strong>${t("⚠️ Overhead cables can only connect to poles or end connections!")}</strong></p>` : ""}
</div>
<div class="property-group">
<h4>Actions</h4>
<button class="btn btn-primary" onclick="designer.updateCalculations()">Calculate Voltage Drops</button>
<button class="btn btn-danger" onclick="designer.deleteConnection(${
conn.id
})">Delete Cable</button>
<h4>${t("Actions")}</h4>
<button class="btn btn-primary" onclick="designer.updateCalculations()">${t("Calculate Voltage Drops")}</button>
<button class="btn btn-danger" onclick="designer.deleteConnection(${conn.id})">${t("Delete Cable")}</button>
</div>
`;
@@ -1573,18 +1737,15 @@ class ObjectFlowDesigner {
z-index: 10000;
animation: slideIn 0.3s ease;
`;
error.textContent = message;
error.textContent = t(message);
document.body.appendChild(error);
setTimeout(() => {
error.remove();
}, 3000);
}
clearAll() {
if (
confirm("Are you sure you want to clear all objects and connections?")
) {
if (confirm(t("Are you sure you want to clear all objects and connections?"))) {
this.objects = [];
this.connections = [];
this.selectedObject = null;
@@ -1690,6 +1851,7 @@ class ObjectFlowDesigner {
return "Pole";
case "end_connection":
return "End Connection";
default:
return "Node";
}