@@ -212,7 +212,7 @@ setup.initialize = function (callback) {
212212 build_date_e = $ ( ".build-date" ) ,
213213 build_type_e = $ ( ".build-type" ) ,
214214 build_info_e = $ ( ".build-info" ) ,
215- build_options_e = $ ( ".build-options " ) ;
215+ build_firmware_e = $ ( ".build-firmware " ) ;
216216
217217 // DISARM FLAGS
218218 // We add all the arming/disarming flags available, and show/hide them if needed.
@@ -364,80 +364,104 @@ setup.initialize = function (callback) {
364364 }
365365 }
366366
367+ // Gets the build root base URI for build.betaflight.com
368+ const getBuildRootBaseUri = function ( ) {
369+ return `https://build.betaflight.com/api/builds/${ FC . CONFIG . buildKey } ` ;
370+ } ;
371+
372+ // Fills in the "Build info" part of the "Firmware info" box
367373 const showBuildInfo = function ( ) {
368- const supported = FC . CONFIG . buildKey . length === 32 ;
374+ const isIspConnected = ispConnected ( ) ;
375+ const buildKeyValid = FC . CONFIG . buildKey . length === 32 ;
369376
370- if ( supported && ispConnected ( ) ) {
371- const buildRoot = `https://build.betaflight.com/api/builds/${ FC . CONFIG . buildKey } ` ;
377+ if ( buildKeyValid && isIspConnected ) {
378+ const buildRoot = getBuildRootBaseUri ( ) ;
379+
380+ // Creates the "Config" button
372381 const buildConfig = `<span class="buildInfoBtn" title="${ i18n . getMessage (
373382 "initialSetupInfoBuildConfig" ,
374383 ) } : ${ buildRoot } /json">
375- <a href="${ buildRoot } /json" target="_blank"><strong>${ i18n . getMessage (
384+ <a href="${ buildRoot } /json" target="_blank"><strong>${ i18n . getMessage (
376385 "initialSetupInfoBuildConfig" ,
377386) } </strong></a></span>`;
387+
388+ // Creates the "Log" button
378389 const buildLog = `<span class="buildInfoBtn" title="${ i18n . getMessage (
379390 "initialSetupInfoBuildLog" ,
380391 ) } : ${ buildRoot } /log">
381- <a href="${ buildRoot } /log" target="_blank"><strong>${ i18n . getMessage (
392+ <a href="${ buildRoot } /log" target="_blank"><strong>${ i18n . getMessage (
382393 "initialSetupInfoBuildLog" ,
383394) } </strong></a></span>`;
384- build_info_e . html ( `<span class="buildInfoBtn" title="${ i18n . getMessage (
385- "initialSetupInfoBuildOptions" ,
386- ) } ">
387- <a class="buildOptions" href=#"><strong>${ i18n . getMessage (
388- "initialSetupInfoBuildOptionList" ,
389- ) } </strong></a></span>`) ;
395+
396+ // Shows the "Config" and "Log" buttons
390397 build_info_e . html ( `${ buildConfig } ${ buildLog } ` ) ;
391398 } else {
392399 build_info_e . html (
393- supported ? i18n . getMessage ( "initialSetupNotOnline" ) : i18n . getMessage ( "initialSetupNoBuildInfo" ) ,
400+ isIspConnected
401+ ? i18n . getMessage ( "initialSetupNoBuildInfo" )
402+ : i18n . getMessage ( "initialSetupNotOnline" ) ,
394403 ) ;
395404 }
396405 } ;
397406
398- const showBuildOptions = function ( ) {
399- const supported =
400- ( ( semver . eq ( FC . CONFIG . apiVersion , API_VERSION_1_45 ) && ispConnected ( ) ) ||
407+ // Fills in the "Firmware" part of the "Firmware info" box
408+ const showBuildFirmware = function ( ) {
409+ const isIspConnected = ispConnected ( ) ;
410+ const buildOptionsValid =
411+ ( ( semver . eq ( FC . CONFIG . apiVersion , API_VERSION_1_45 ) && isIspConnected ) ||
401412 semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_46 ) ) &&
402413 FC . CONFIG . buildOptions . length ;
403-
404- if ( supported ) {
405- let buildOptionList = `<div class="dialogBuildInfoGrid-container">` ;
406- for ( const buildOptionElement of FC . CONFIG . buildOptions ) {
407- buildOptionList += `<div class="dialogBuildInfoGrid-item">${ buildOptionElement } </div>` ;
408- }
409- buildOptionList += `</div>` ;
410-
411- build_options_e . html ( `<span class="buildInfoBtn" title="${ i18n . getMessage (
412- "initialSetupInfoBuildOptions" ,
413- ) } ">
414- <a class="buildOptions" href=#"><strong>${ i18n . getMessage (
415- "initialSetupInfoBuildOptionList" ,
416- ) } </strong></a></span>`) ;
417-
418- const buildOptions = `<span class="buildInfoBtn" title="${ i18n . getMessage (
419- "initialSetupInfoBuildOptionList" ,
420- ) } ">
421- <a class="buildOptions" href=#"><strong>${ i18n . getMessage (
414+ const buildKeyValid = FC . CONFIG . buildKey . length === 32 ;
415+ const buildRoot = getBuildRootBaseUri ( ) ;
416+
417+ if ( buildOptionsValid || buildKeyValid ) {
418+ // Creates the "Options" button (if possible)
419+ const buildOptions = buildOptionsValid
420+ ? `<span class="buildInfoBtn" title="${ i18n . getMessage ( "initialSetupInfoBuildOptionList" ) } ">
421+ <a class="buildOptions" href="#"><strong>${ i18n . getMessage (
422422 "initialSetupInfoBuildOptions" ,
423- ) } </strong></a></span>`;
424-
425- build_options_e . html ( buildOptions ) ;
423+ ) } </strong></a></span>`
424+ : "" ;
425+
426+ // Creates the "Download" button (if possible)
427+ const buildDownload = buildKeyValid
428+ ? `<span class="buildInfoBtn" title="${ i18n . getMessage (
429+ "initialSetupInfoBuildDownload" ,
430+ ) } : ${ buildRoot } /hex">
431+ <a href="${ buildRoot } /hex" target="_blank"><strong>${ i18n . getMessage (
432+ "initialSetupInfoBuildDownload" ,
433+ ) } </strong></a></span>`
434+ : "" ;
435+
436+ // Shows the "Options" and/or "Download" buttons
437+ build_firmware_e . html ( `${ buildOptions } ${ buildDownload } ` ) ;
438+
439+ if ( buildOptionsValid ) {
440+ // Creates and attaches the "Options" dialog
441+ let buildOptionList = `<div class="dialogBuildInfoGrid-container">` ;
442+ for ( const buildOptionElement of FC . CONFIG . buildOptions ) {
443+ buildOptionList += `<div class="dialogBuildInfoGrid-item">${ buildOptionElement } </div>` ;
444+ }
445+ buildOptionList += `</div>` ;
426446
427- $ ( "a.buildOptions" ) . on ( "click" , async function ( ) {
428- showDialogBuildInfo (
429- `<h3>${ i18n . getMessage ( "initialSetupInfoBuildOptionList" ) } </h3>` ,
430- buildOptionList ,
431- ) ;
432- } ) ;
447+ $ ( "a.buildOptions" ) . on ( "click" , async function ( ) {
448+ showDialogBuildInfo (
449+ `<h3>${ i18n . getMessage ( "initialSetupInfoBuildOptionList" ) } </h3>` ,
450+ buildOptionList ,
451+ ) ;
452+ } ) ;
453+ }
433454 } else {
434- // should not happen, but just in case
435- build_options_e . html ( `${ i18n . getMessage ( "initialSetupNoBuildInfo" ) } ` ) ;
455+ build_firmware_e . html (
456+ isIspConnected
457+ ? i18n . getMessage ( "initialSetupNoBuildInfo" )
458+ : i18n . getMessage ( "initialSetupNotOnline" ) ,
459+ ) ;
436460 }
437461 } ;
438462
463+ // Fills in the "Firmware info" box
439464 function showFirmwareInfo ( ) {
440- // Firmware info
441465 msp_api_e . text ( FC . CONFIG . apiVersion ) ;
442466 build_date_e . text ( FC . CONFIG . buildInfo ) ;
443467
@@ -448,7 +472,7 @@ setup.initialize = function (callback) {
448472 : i18n . getMessage ( "initialSetupInfoBuildLocal" ) ,
449473 ) ;
450474 showBuildInfo ( ) ;
451- showBuildOptions ( ) ;
475+ showBuildFirmware ( ) ;
452476 }
453477 }
454478
0 commit comments