@@ -50,8 +50,39 @@ $(document).ready(function(){
50
50
$ . post ( 'socketmessage.php' , { messageType : "dateTimeFormatDisplay" , message : $ ( "#datetime-format-display" ) . val ( ) } ) ;
51
51
} ) ;
52
52
53
+ function update_serial_selector ( ) {
54
+ if ( $ ( '#connection-type' ) . val ( ) === '1' ) {
55
+ $ ( 'select.port-address' ) . hide ( ) ;
56
+ $ ( 'input.port-address' ) . show ( ) ;
57
+ }
58
+ else {
59
+ $ . ajax ( {
60
+ type : "POST" ,
61
+ dataType :"json" ,
62
+ contentType :"application/x-www-form-urlencoded; charset=utf-8" ,
63
+ url : 'socketmessage.php' ,
64
+ data : { messageType : "getSerialDevicesAvailable" , message : "" } ,
65
+ success : function ( list ) {
66
+ $ ( 'select.port-address' ) . empty ( ) ;
67
+ for ( var i = 0 ; i < list . length ; i ++ ) {
68
+ $ ( 'select.port-address' ) . append ( $ ( '<option>' ) . attr ( 'value' , list [ i ] ) . text ( list [ i ] ) ) ;
69
+ } ;
70
+ $ ( 'input.port-address' ) . hide ( ) ;
71
+ $ ( 'select.port-address' ) . show ( ) ;
72
+ } ,
73
+ error : function ( ) {
74
+ $ ( 'select.port-address' ) . hide ( ) ;
75
+ $ ( 'input.port-address' ) . show ( ) ;
76
+ }
77
+ } ) ;
78
+ }
79
+ }
80
+
81
+ $ ( "#connection-type" ) . change ( update_serial_selector ) ;
82
+ update_serial_selector ( ) ;
83
+
53
84
$ ( "button.apply-connection" ) . button ( { icons : { primary : "ui-icon-check" } } ) . unbind ( 'click' ) . click ( function ( ) {
54
- const port_address = $ ( "# port-address" ) . val ( ) . trim ( ) ;
85
+ const port_address = $ ( ". port-address:visible " ) . val ( ) . trim ( ) ;
55
86
let message ;
56
87
if ( $ ( "#connection-type" ) . val ( ) == 1 ) {
57
88
// ip address selected. Add socket:// and port 6666
@@ -138,8 +169,6 @@ $(document).ready(function(){
138
169
startRefreshLogs ( 2000 , 0 , 1 , '#reprogram-arduino' ) ; // autorefresh stderr as long as the tab remains open
139
170
$ ( "#program-stderr-header" ) . text ( "Programming... keep an eye on the output below to see the progress." ) ;
140
171
} ) ;
141
-
142
-
143
172
} ) ;
144
173
145
174
boardNames = { "core" : "Core" , "photon" : "Photon" , "leonardo" : "Arduino" , "uno" : "Arduino" } ;
0 commit comments