@@ -261,6 +261,7 @@ function init() {
261261 initTouchHandlers ( ) ;
262262 connectWebSocket ( ) ;
263263 requestSystemInfo ( ) ;
264+ fetchVersion ( ) ;
264265
265266 startAgeUpdateTimer ( ) ;
266267
@@ -591,6 +592,17 @@ function handleCommandResponse(line) {
591592 if ( status === 'OK' ) {
592593 showCommandStatus ( `${ cmdId } : OK` , 'success' ) ;
593594
595+
596+ if ( cmdId === 'VER' ) {
597+ const verPart = parts . find ( p => p . startsWith ( 'version=' ) ) ;
598+ if ( verPart ) {
599+ appVersion = verPart . split ( '=' ) [ 1 ] ;
600+ console . log ( '[VER] Получена версия:' , appVersion ) ;
601+ updateFooterVersion ( ) ;
602+ }
603+ return ;
604+ }
605+
594606 if ( cmdId === 'CNA?' ) {
595607 const active = parts . find ( p => p . startsWith ( 'active=' ) ) ?. split ( '=' ) [ 1 ] ;
596608 if ( ! systemInfo ) systemInfo = { } ;
@@ -813,7 +825,7 @@ function updateControlButtons() {
813825 // Кнопка соединения — всегда enabled
814826 if ( btnConnection && connText ) {
815827 btnConnection . disabled = false ;
816- if ( systemInfo . connectionActive ) {
828+ if ( systemInfo && systemInfo . connectionActive ) { // <-- проверка на null
817829 connText . textContent = i18n . t ( 'close' ) ;
818830 btnConnection . className = 'ctrl-btn disconnect' ;
819831 btnConnection . querySelector ( '.btn-icon' ) . textContent = '🔌' ;
@@ -826,8 +838,8 @@ function updateControlButtons() {
826838
827839 // Кнопка опроса — enabled только когда соединение активно
828840 if ( btnInterrogation && interText ) {
829- btnInterrogation . disabled = ! systemInfo . connectionActive ;
830- if ( systemInfo . interrogationActive ) {
841+ btnInterrogation . disabled = ! ( systemInfo && systemInfo . connectionActive ) ; // <-- проверка
842+ if ( systemInfo && systemInfo . interrogationActive ) { // <-- проверка
831843 interText . textContent = i18n . t ( 'pause' ) ;
832844 btnInterrogation . className = 'ctrl-btn stop' ;
833845 btnInterrogation . querySelector ( '.btn-icon' ) . textContent = '⏸' ;
@@ -2626,6 +2638,51 @@ function applySuggestionText(input, text, isCommand) {
26262638 input . setSelectionRange ( input . value . length , input . value . length ) ;
26272639}
26282640
2641+ // ========== ВЕРСИЯ ПРИЛОЖЕНИЯ ==========
2642+
2643+ let appVersion = '' ;
2644+ let versionFetched = false ;
2645+
2646+ function fetchVersion ( ) {
2647+ if ( versionFetched ) return ;
2648+
2649+ if ( ! ws || ws . readyState === WebSocket . CONNECTING ) {
2650+ console . log ( '[VER] WS в состоянии CONNECTING, ждём...' ) ;
2651+ setTimeout ( fetchVersion , 500 ) ;
2652+ return ;
2653+ }
2654+
2655+ if ( ws . readyState !== WebSocket . OPEN ) {
2656+ console . log ( '[VER] WS не открыт (state=' + ws . readyState + ')' ) ;
2657+ return ;
2658+ }
2659+
2660+ versionFetched = true ;
2661+ console . log ( '[VER] Отправляем VER' ) ;
2662+ ws . send ( 'VER' ) ;
2663+ addLogEntry ( '>> VER' ) ;
2664+ }
2665+
2666+ function updateFooterVersion ( ) {
2667+ const footer = document . getElementById ( 'footer-panel' ) ;
2668+ if ( ! footer ) return ;
2669+
2670+ if ( document . getElementById ( 'app-version' ) ) return ;
2671+
2672+ const copyrightDiv = footer . querySelector ( 'div:last-child' ) ;
2673+ if ( ! copyrightDiv ) return ;
2674+
2675+ const versionLink = document . createElement ( 'a' ) ;
2676+ versionLink . id = 'app-version' ;
2677+ versionLink . href = 'https://github.com/ucnl/AzimuthConsole/blob/main/src/changelog.md' ;
2678+ versionLink . target = '_blank' ;
2679+ versionLink . rel = 'noopener' ;
2680+ versionLink . style . cssText = 'color: #4a90e2; text-decoration: none; font-weight: bold; margin-right: 6px;' ;
2681+ versionLink . title = 'История изменений' ;
2682+ versionLink . textContent = `${ appVersion } ` ;
2683+
2684+ copyrightDiv . insertBefore ( versionLink , copyrightDiv . firstChild ) ;
2685+ }
26292686
26302687
26312688
0 commit comments