1
- import { terminal } from "./gui" ;
2
- import { busActive , busControllable , ConnectionState , transientActive } from "../network/telemetry" ;
3
- import * as commands from '../network/commands' ;
4
- import * as connection from '../network/connection' ;
5
- import * as helper from '../helper' ;
6
- import * as sliders from './sliders' ;
7
- import * as scripting from '../scripting' ;
8
- import * as midiServer from '../midi/midi_server' ;
9
- import * as ui_helper from './ui_helper' ;
1
+ import * as helper from "../helper" ;
10
2
import * as media_player from "../media/media_player" ;
3
+ import * as midiServer from "../midi/midi_server" ;
4
+ import * as commands from "../network/commands" ;
5
+ import * as connection from "../network/connection" ;
6
+ import { busActive , busControllable , transientActive } from "../network/telemetry" ;
7
+ import * as scripting from "../scripting" ;
8
+ import { terminal } from "./constants" ;
9
+ import * as sliders from "./sliders" ;
10
+ import * as ui_helper from "./ui_helper" ;
11
11
12
12
export function init ( ) {
13
- const port = $ ( ' #toolbar #tb_toolbar_item_port' ) ;
13
+ const port = $ ( " #toolbar #tb_toolbar_item_port" ) ;
14
14
port . on ( "keypress" , ( e ) => {
15
15
console . log ( e ) ;
16
- if ( e . originalEvent . key == "Enter" ) {
17
- w2ui . toolbar . set ( ' port' , { value : this . value } ) ;
16
+ if ( e . originalEvent . key === "Enter" ) {
17
+ w2ui . toolbar . set ( " port" , { value : this . value } ) ;
18
18
w2ui . toolbar . refresh ( ) ;
19
- w2ui [ ' toolbar' ] . click ( ' connect' ) ;
19
+ w2ui . toolbar . click ( " connect" ) ;
20
20
}
21
21
} ) ;
22
22
}
23
23
24
24
export function onConnected ( ) {
25
25
terminal . io . println ( "connected" ) ;
26
- w2ui [ ' toolbar' ] . get ( ' connect' ) . text = ' Disconnect' ;
27
- w2ui [ ' toolbar' ] . refresh ( ) ;
26
+ w2ui . toolbar . get ( " connect" ) . text = " Disconnect" ;
27
+ w2ui . toolbar . refresh ( ) ;
28
28
console . log ( "Updated menu" ) ;
29
29
}
30
30
31
31
export function onDisconnect ( ) {
32
- w2ui [ ' toolbar' ] . get ( ' connect' ) . text = ' Connect' ;
33
- w2ui [ ' toolbar' ] . refresh ( ) ;
32
+ w2ui . toolbar . get ( " connect" ) . text = " Connect" ;
33
+ w2ui . toolbar . refresh ( ) ;
34
34
}
35
35
36
- let currentScript : ( ( ) => Promise < any > ) [ ] = null ;
36
+ let currentScript : Array < ( ) => Promise < any > > = null ;
37
37
38
- export function setScript ( script : ( ( ) => Promise < any > ) [ ] ) {
38
+ export function setScript ( script : Array < ( ) => Promise < any > > ) {
39
39
currentScript = script ;
40
40
}
41
41
42
42
export function onCtrlMenuClick ( event ) {
43
43
switch ( event . target ) {
44
- case ' connect' :
44
+ case " connect" :
45
45
connect ( ) ;
46
46
break ;
47
- case ' cls' :
47
+ case " cls" :
48
48
commands . clear ( ) ;
49
49
break ;
50
- case ' mnu_command:bus' :
50
+ case " mnu_command:bus" :
51
51
if ( busActive ) {
52
52
commands . busOff ( ) ;
53
53
} else {
54
- helper . warn ( ' WARNING!<br>The coil will be energized.' , commands . busOn ) ;
54
+ helper . warn ( " WARNING!<br>The coil will be energized." , commands . busOn ) ;
55
55
}
56
56
break ;
57
- case ' mnu_command:transient' :
57
+ case " mnu_command:transient" :
58
58
commands . setTransientEnabled ( ! transientActive ) ;
59
59
break ;
60
- case ' mnu_command:settings' :
61
- commands . sendCommand ( ' config_get\r' ) ;
60
+ case " mnu_command:settings" :
61
+ commands . sendCommand ( " config_get\r" ) ;
62
62
break ;
63
- case ' mnu_command:startStopMidi' :
63
+ case " mnu_command:startStopMidi" :
64
64
if ( midiServer . active ) {
65
65
midiServer . close ( ) ;
66
66
} else {
67
67
midiServer . requestName ( )
68
68
. then ( ( ) =>
69
69
ui_helper . inputPort ( "Please enter the port for the local MIDI server" , "MIDI over IP Server" ,
70
- midiServer . port )
71
- ) . then ( port => {
70
+ midiServer . port ) ,
71
+ ) . then ( ( port ) => {
72
72
midiServer . setPort ( port ) ;
73
73
midiServer . start ( ) ;
74
74
} ) ;
75
75
}
76
76
break ;
77
- case ' mnu_command:Load EEPROM-Config' :
78
- helper . warn ( ' WARNING!<br>Are you sure to load the configuration from EEPROM?' ,
77
+ case " mnu_command:Load EEPROM-Config" :
78
+ helper . warn ( " WARNING!<br>Are you sure to load the configuration from EEPROM?" ,
79
79
commands . eepromSave ) ;
80
80
break ;
81
- case ' mnu_command:Save EEPROM-Config' :
82
- helper . warn ( ' WARNING!<br>Are you sure to save the configuration to EEPROM?' ,
81
+ case " mnu_command:Save EEPROM-Config" :
82
+ helper . warn ( " WARNING!<br>Are you sure to save the configuration to EEPROM?" ,
83
83
commands . eepromSave ) ;
84
84
break ;
85
- case ' mnu_midi:Play' :
85
+ case " mnu_midi:Play" :
86
86
media_player . startPlaying ( ) ;
87
87
break ;
88
- case ' mnu_midi:Stop' :
88
+ case " mnu_midi:Stop" :
89
89
media_player . stopPlaying ( ) ;
90
90
break ;
91
- case ' mnu_script:Start' :
92
- if ( currentScript == null ) {
91
+ case " mnu_script:Start" :
92
+ if ( currentScript === null ) {
93
93
terminal . io . println ( "Please select a script file using drag&drop first" ) ;
94
94
break ;
95
95
}
96
96
scripting . startScript ( currentScript ) ;
97
97
break ;
98
- case ' mnu_script:Stop' :
99
- if ( currentScript == null ) {
98
+ case " mnu_script:Stop" :
99
+ if ( currentScript === null ) {
100
100
terminal . io . println ( "Please select a script file using drag&drop first" ) ;
101
101
break ;
102
102
}
@@ -106,40 +106,40 @@ export function onCtrlMenuClick(event) {
106
106
}
107
107
scripting . cancel ( ) ;
108
108
break ;
109
- case ' kill_set' :
109
+ case " kill_set" :
110
110
commands . setKill ( ) ;
111
111
break ;
112
- case ' kill_reset' :
112
+ case " kill_reset" :
113
113
commands . resetKill ( ) ;
114
114
break ;
115
115
}
116
116
}
117
117
118
118
119
- function connect ( ) {
119
+ function connect ( ) {
120
120
if ( connection . connection ) {
121
121
connection . disconnect ( ) ;
122
122
} else {
123
- const port = w2ui [ ' toolbar' ] . get ( ' port' ) ;
123
+ const port = w2ui . toolbar . get ( " port" ) ;
124
124
connection . connect ( port . value ) ;
125
125
}
126
126
}
127
127
128
128
export function updateBusActive ( ) {
129
129
if ( busControllable ) {
130
- helper . changeMenuEntry ( "mnu_command" , "bus" , "Bus " + ( busActive ? "OFF" : "ON" ) ) ;
130
+ helper . changeMenuEntry ( "mnu_command" , "bus" , "Bus " + ( busActive ? "OFF" : "ON" ) ) ;
131
131
}
132
132
sliders . updateSliderAvailability ( ) ;
133
133
}
134
134
135
135
export function updateTransientActive ( ) {
136
- helper . changeMenuEntry ( "mnu_command" , "transient" , "TR " + ( transientActive ? "Stop" : "Start" ) ) ;
136
+ helper . changeMenuEntry ( "mnu_command" , "transient" , "TR " + ( transientActive ? "Stop" : "Start" ) ) ;
137
137
sliders . updateSliderAvailability ( ) ;
138
138
}
139
139
140
140
export function updateBusControllable ( ) {
141
141
if ( busControllable ) {
142
- helper . addFirstMenuEntry ( "mnu_command" , "bus" , "Bus " + ( busActive ? "OFF" : "ON" ) , ' fa fa-bolt' ) ;
142
+ helper . addFirstMenuEntry ( "mnu_command" , "bus" , "Bus " + ( busActive ? "OFF" : "ON" ) , " fa fa-bolt" ) ;
143
143
} else {
144
144
helper . removeMenuEntry ( "mnu_command" , "bus" ) ;
145
145
}
0 commit comments