Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wiki #3537

Merged
merged 6 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 12 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,19 @@ 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 (summary.wiki === undefined) { // override if #wiki exist in unified target configuration
if (urlExists(urlBoard)) {
urlWiki = urlBoard;
}
} else {
urlWiki = summary.wiki;
}
HThuren marked this conversation as resolved.
Show resolved Hide resolved
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
12 changes: 12 additions & 0 deletions src/js/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ 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();
if (http.status !== 404) {
return true;
} else {
return false;
}
HThuren marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Returns jquery sorted option list with optional value staying on top of the list.
*
Expand Down