diff --git a/apps/static/js/api.js b/apps/static/js/api.js index f658592..2290926 100644 --- a/apps/static/js/api.js +++ b/apps/static/js/api.js @@ -122,6 +122,10 @@ async function editFilter(id, formData) { return await ajaxRequest(`/api/filter/${id}/`, "PUT", formData); } +async function getFilterOptions() { + return await ajaxRequest("/api/filter/", "OPTIONS") +} + // Tracked Content diff --git a/apps/static/js/home/filters.js b/apps/static/js/home/filters.js index 802d59e..0a356cf 100644 --- a/apps/static/js/home/filters.js +++ b/apps/static/js/home/filters.js @@ -189,11 +189,11 @@ async function loadFilters(guildId, page=1, pageSize=null) { } } -$(document).ready(function() { - loadMatchingAlgorithms(); +$(document).ready(async function() { + await loadMatchingAlgorithms(); }); -function loadMatchingAlgorithms() { +async function loadMatchingAlgorithms() { // Disable input while options are loading $("#filterAlgorithm").prop("disabled", true); @@ -206,25 +206,22 @@ function loadMatchingAlgorithms() { // Clear select2 input $("#filterAlgorithm").val("").change(); - algorithms = [ - {id: "", name: "None"}, - {id: 1, name: "Any Words"}, - {id: 2, name: "All Words"}, - {id: 3, name: "Exact Match"}, - {id: 4, name: "Regular Expression"}, - {id: 5, name: "Fuzzy Match"}, - ] - - algorithms.forEach(algorithm => { - $("#filterAlgorithm").append($("