`;
-
- stationsHtml += `
`;
-
- const getVisibleStopIndex = (targetCode) => {
- const targetCanonical = stationCanonicalByCode[String(targetCode || '').trim()] || String(targetCode || '').trim();
- return visibleStops.findIndex(code => (stationCanonicalByCode[code] || code) === targetCanonical);
- };
-
- const fromIndex = getVisibleStopIndex(selection[0]);
- const toIndex = getVisibleStopIndex(selection[1]);
- const sameLineSelection = fromIndex >= 0
- && toIndex >= 0
- && selection[0]
- && selection[1]
- && (!Array.isArray(currentRouteTransfers) || currentRouteTransfers.length === 0);
-
- if (sameLineSelection) {
- const startIndex = Math.min(fromIndex, toIndex);
- const endIndex = Math.max(fromIndex, toIndex);
- const left = (startIndex * nodeSlotWidth) + trackPadding;
- const width = Math.max((endIndex - startIndex) * nodeSlotWidth, 0);
- const arrowCount = Math.max(1, Math.floor(width / 40));
- let arrowsHtml = '';
- for (let i = 0; i < arrowCount; i++) {
- arrowsHtml += `
›`;
- }
- stationsHtml += `
-
- `;
- }
-
- let hasStations = false;
- stops.forEach(code => {
- if (code === '-') return;
- hasStations = true;
-
- const name = stationNameByCode[code] || code;
- const enName = stationEnByCode[code] || '';
-
- const isSelectedFrom = selection[0] === code;
- const isSelectedTo = selection[1] === code;
- const inRoute = Array.isArray(currentRoute) && currentRoute.includes(code);
-
- // Check transfers
- const canonical = stationCanonicalByCode[code] || code;
- const codesInGroup = stationCodesByCanonical[canonical] || [canonical];
- const linesForThisStation = new Set();
- codesInGroup.forEach(c => {
- allLinesData.forEach(l => {
- const lStops = Array.isArray(l.stops) ? l.stops : (Array.isArray(l.站点列表) ? l.站点列表 : []);
- if (lStops.includes(c)) linesForThisStation.add(l);
- });
- });
-
- const transferLines = Array.from(linesForThisStation).filter(l => String(l.id) !== String(activeLineId));
- const isTransfer = transferLines.length > 0;
-
- let nodeColor = activeLine.color || '#94a3b8';
- let nodeSize = isTransfer ? '20px' : '14px';
- let nodeBorder = isTransfer ? '4px' : '3px';
- let badgeHtml = '';
-
- if (isSelectedFrom) {
- nodeColor = 'var(--success, #16a34a)';
- nodeSize = '24px';
- badgeHtml = `
起点
`;
- } else if (isSelectedTo) {
- nodeColor = 'var(--danger, #dc2626)';
- nodeSize = '24px';
- badgeHtml = `
终点
`;
- } else if (inRoute) {
- nodeColor = 'var(--primary, #facc15)';
- if (!isTransfer) nodeSize = '18px';
- else nodeSize = '24px';
- }
-
- let transferDotsHtml = '';
- if (isTransfer) {
- transferDotsHtml = `
`;
- transferLines.slice(0, 3).forEach(l => {
- transferDotsHtml += `
`;
- });
- transferDotsHtml += `
`;
- }
-
- stationsHtml += `
-
-
-
-
- ${badgeHtml}
- ${transferDotsHtml}
-
-
-
-
-
-
${code}
-
${name}
- ${enName ? `
${enName}
` : ''}
-
-
- `;
- });
-
- if (!hasStations) {
- stationsHtml += `
该线路暂无站点
`;
- }
-
- stationsHtml += `