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
13 changes: 7 additions & 6 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { tracking } from "../Analytics";
import PortHandler from "../port_handler";
import { gui_log } from "../gui_log";
import semver from "semver";
import { urlExists } from "../utils/common";
import read_hex_file from "../workers/hex_parser.js";
import Sponsor from "../Sponsor";
import FileSystem from "../FileSystem";
Expand Down Expand Up @@ -1283,11 +1282,13 @@ firmware_flasher.initialize = async function (callback) {
const targetSupportInfo = $("#targetSupportInfoUrl");

targetSupportInfo.on("click", function () {
let urlSupport = "https://betaflight.com/docs/wiki/boards/archive/Missing"; // general board missing
const urlBoard = `https://betaflight.com/docs/wiki/boards/current/${self.selectedBoard}`; // board description
if (urlExists(urlBoard)) {
urlSupport = urlBoard;
}
const baseBoardUrl = "https://betaflight.com/docs/wiki/boards/current";
const hasBoardSelection = self.selectedBoard && self.selectedBoard !== "0";

const urlSupport = hasBoardSelection
? `${baseBoardUrl}/${encodeURIComponent(self.selectedBoard)}` // selected board description
: "https://betaflight.com/docs/wiki/boards/archive/Missing"; // general board missing

targetSupportInfo.attr("href", urlSupport);
});

Expand Down
8 changes: 0 additions & 8 deletions src/js/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ 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