Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/js/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down