@@ -274,37 +274,22 @@ Code.checkDeviceOnline = function (device) {
274274 } ;
275275
276276 device . check = function ( v ) {
277- device . boardEvent = webduino . BoardEvent ,
278- device . board = new webduino . WebArduino ( {
279- device : v ,
280- multi : true
281- } ) ;
282- device . icon . setAttribute ( 'class' , 'check board-error icon-power' ) ;
283-
284- device . board . on ( device . boardEvent . READY , function ( ) {
285- console . log ( v + ' : ok' ) ;
277+ boardReady ( {
278+ device : v ,
279+ multi : true
280+ } , function ( board ) {
286281 device . icon . setAttribute ( 'class' , 'check board-online icon-power' ) ;
287- device . board . _analogPinMapping . forEach ( function ( pinNum ) {
288- device . board . disableAnalogPin ( device . board . getPin ( pinNum ) . analogNumber ) ;
282+ board . once ( webduino . BoardEvent . DISCONNECT , function ( e ) {
283+ device . icon . setAttribute ( 'class' , 'check board-error icon-power' ) ;
289284 } ) ;
290285 } ) ;
291-
292- device . board . on ( device . boardEvent . ERROR , function ( ) {
293- device . icon . setAttribute ( 'class' , 'check board-error icon-power' ) ;
294- } ) ;
295- }
286+ device . icon . setAttribute ( 'class' , 'check board-error icon-power' ) ;
287+ } ;
296288
297289 device . inputArea . oninput = function ( ) {
298290 localStorage . boardState = this . value ;
299291 if ( this . value . length > 3 ) {
300- if ( device . board ) {
301- device . board . on ( 'disconnect' , function ( ) {
302- device . check ( localStorage . boardState . toString ( ) ) ;
303- } ) ;
304- device . board . disconnect ( ) ;
305- } else {
306- device . check ( localStorage . boardState . toString ( ) ) ;
307- }
292+ device . check ( this . value ) ;
308293 } else {
309294 device . icon . setAttribute ( 'class' , 'check icon-power' ) ;
310295 }
@@ -1421,7 +1406,10 @@ Promise.all([
14211406 Code . ga ( ) ;
14221407 Code . importPrettify ( ) ;
14231408 Code . bindHotkey ( window . document ) ;
1424- Code . loadJs ( baseUrl + '/lib/webduino-base.min.js' , function ( ) {
1409+ Promise . all ( [
1410+ Code . loadJs ( baseUrl + '/lib/webduino-base.min.js' ) ,
1411+ Code . loadJs ( baseUrl + '/webduino-blockly.js' )
1412+ ] ) . then ( function ( ) {
14251413 Code . checkDeviceOnline ( ) ;
14261414 } ) ;
14271415 Code . loadJs ( baseUrl + '/webduino-samples.js' , function ( ) {
0 commit comments