diff --git a/src/js/tabs/firmware_flasher.js b/src/js/tabs/firmware_flasher.js index ed2cfd7d60..38d673aea5 100644 --- a/src/js/tabs/firmware_flasher.js +++ b/src/js/tabs/firmware_flasher.js @@ -16,7 +16,7 @@ import serial from '../serial'; import STM32DFU from '../protocols/stm32usbdfu'; import { gui_log } from '../gui_log'; import semver from 'semver'; -import { checkChromeRuntimeError } from '../utils/common'; +import { checkChromeRuntimeError, urlExists } from '../utils/common'; import { generateFilename } from '../utils/generate_filename'; const firmware_flasher = { @@ -107,10 +107,15 @@ firmware_flasher.initialize = function (callback) { $('div.release_info #targetMCU').text(summary.mcu); $('div.release_info .configFilename').text(self.isConfigLocal ? self.configFilename : "[default]"); - // Wiki link to url found in unified target configuration or if not defined to general wiki url + // Wiki link: #wiki found in unified target configuration, if board description exist or generel board missing + let urlWiki = 'https://betaflight.com/docs/wiki/boards/missing'; // generel board missing + const urlBoard = `https://betaflight.com/docs/wiki/boards/${summary.target}`; // board description + if (urlExists(urlBoard)) { + urlWiki = urlBoard; + } const targetWiki = $('#targetWikiInfoUrl'); targetWiki.html(`   [Wiki]`); - targetWiki.attr("href", summary.wiki === undefined ? "https://betaflight.com/docs/wiki/" : summary.wiki); + targetWiki.attr("href", urlWiki); if (summary.cloudBuild) { $('div.release_info #cloudTargetInfo').show(); diff --git a/src/js/utils/common.js b/src/js/utils/common.js index a23331ed32..11e0ac7007 100644 --- a/src/js/utils/common.js +++ b/src/js/utils/common.js @@ -91,6 +91,14 @@ export function getTextWidth(text) { return Math.ceil(context.measureText(text).width); } +export function urlExists(url) { + let http = new XMLHttpRequest (); + + http.open('HEAD', url, false); + http.send(); + return http.status !== 404; +} + /** * Returns jquery sorted option list with optional value staying on top of the list. *