From 654dca2a191357f943edde1203b7bd2ddea6fe14 Mon Sep 17 00:00:00 2001 From: haslinghuis Date: Sat, 14 Jan 2023 21:38:03 +0100 Subject: [PATCH] Add new wiki to configurator tabs (#3237) * Add new wiki to configurator tabs * Unify connecting characters in URL --- src/js/gui.js | 7 ++++--- src/js/tabs/firmware_flasher.js | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/js/gui.js b/src/js/gui.js index a9c8f287bf..d637d2a2d0 100644 --- a/src/js/gui.js +++ b/src/js/gui.js @@ -318,9 +318,10 @@ class GuiControl { const documentationButton = $('div#content #button-documentation'); documentationButton.html("Wiki"); - if (GUI.active_tab !== 'firmware_flasher') { // hack till we have a nice solution for individual wiki URLs for each page - documentationButton.attr("href", "https://github.com/betaflight/betaflight/wiki"); - } + const tRex = GUI.active_tab.replaceAll('_', '-').toLowerCase(); + const url = `https://betaflight.com/docs/configurator/${tRex}-tab`; + + fetch(url).then(res => documentationButton.attr("href", res.ok ? url : `https://betaflight.com/docs/wiki`)); // loading tooltip jQuery(function () { diff --git a/src/js/tabs/firmware_flasher.js b/src/js/tabs/firmware_flasher.js index 8ca80333c4..359abbf939 100644 --- a/src/js/tabs/firmware_flasher.js +++ b/src/js/tabs/firmware_flasher.js @@ -76,13 +76,9 @@ firmware_flasher.initialize = function (callback) { $('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 - let targetWiki = $('#targetWikiInfoUrl'); + const targetWiki = $('#targetWikiInfoUrl'); targetWiki.html(`   [Wiki]`); - if (summary.wiki === undefined) { - targetWiki.attr("href", "https://github.com/betaflight/betaflight/wiki/"); - } else { - targetWiki.attr("href", summary.wiki); - } + targetWiki.attr("href", summary.wiki === undefined ? "https://betaflight.com/docs/wiki/" : summary.wiki); if (summary.cloudBuild) { $('div.release_info #cloudTargetInfo').show();