From 37c89e6c5cbfc11ac1f188a7de006de7a2eef271 Mon Sep 17 00:00:00 2001 From: Mattk70 Date: Wed, 9 Oct 2024 11:45:29 +0100 Subject: [PATCH] Clear custom list button --- Help/settings.html | 4 +--- index.html | 5 ++++- js/ui.js | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Help/settings.html b/Help/settings.html index 266be382..1f7b02e1 100644 --- a/Help/settings.html +++ b/Help/settings.html @@ -52,10 +52,8 @@
  • Search only for a specific species
  • You may use a different custom list for both BirdNET and Chirpity models. The format for a - custom list file is "scientific name_common name", with each species on a new line. You can export a starting + custom list file is "scientific name_common name", with each species on a new line. Importantly, the custom list needs to use labels in your selected language. You can export a starting list in the correct format from the Help menu, using the "What species are detected?" link. - -

    If you wish to see the full list of classes each model was trained on, check the Help menu > What species are detected?.

    diff --git a/index.html b/index.html index 1d2b7a48..184d2001 100644 --- a/index.html +++ b/index.html @@ -111,12 +111,15 @@
    Settings
    -
    +
    +
    + clear +
    diff --git a/js/ui.js b/js/ui.js index ce8d85df..b8affab7 100644 --- a/js/ui.js +++ b/js/ui.js @@ -4404,6 +4404,19 @@ DOM.gain.addEventListener('input', () => { case 'locate-missing-file': { (async () => await locateFile(MISSING_FILE))(); break } + case 'clear-custom-list': { + config.customListFile[config.model] = ''; + delete LIST_MAP.custom; + config.list = 'birds'; + DOM.listToUse.value = config.list; + DOM.customListFile.value = ''; + updateListIcon(); + updatePrefs('config.json', config) + resetResults({clearSummary: true, clearPagination: true, clearResults: true}); + setListUIState(config.list); + if (currentFile && STATE.analysisDone) worker.postMessage({ action: 'update-list', list: config.list, refreshResults: true }) + break; + } case 'compress-and-organise': {compressAndOrganise(); break} case 'purge-file': { deleteFile(currentFile); break } @@ -4597,7 +4610,8 @@ DOM.gain.addEventListener('input', () => { config.list = element.value; updateListIcon(); resetResults({clearSummary: true, clearPagination: true, clearResults: true}); - worker.postMessage({ action: 'update-list', list: config.list, refreshResults: STATE.analysisDone}); + // Don't call this for custom lists + config.list === 'custom' || worker.postMessage({ action: 'update-list', list: config.list, refreshResults: STATE.analysisDone}); break; } case 'locale': {