From: Moritz Warning Date: Sun, 7 Jun 2020 01:40:21 +0000 (+0200) Subject: limit packet list selection X-Git-Tag: v2.2.1~11^2^2 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1f45ecd3627ea0e678c6d2f88b6356b4fa49353e;p=web%2Ffirmware-selector-openwrt-org.git limit packet list selection the packet list can only contain unique items from the package index, a minus in front of a packet is allowed Signed-off-by: Moritz Warning --- diff --git a/index.js b/index.js index 4b6cb28..90a26c0 100644 --- a/index.js +++ b/index.js @@ -285,8 +285,13 @@ function updatePackageList(version, target) { .then(all_packages => { setupAutocompleteList($('packages'), all_packages, true, _ => {}, textarea => { textarea.value = split(textarea.value) - .filter((value, index, self) => self.indexOf(value) === index) // make list unique - //.filter((value, index) => all_packages.indexOf(value) !== -1) // limit to available packages + // make list unique, ignore minus + .filter((value, index, self) => { + var i = self.indexOf(value.replace(/^\-/, '')); + return (i === index) || (i < 0); + }) + // limit to available packages, ignore minus + .filter((value, index) => all_packages.indexOf(value.replace(/^\-/, '')) !== -1) .join(' '); }); });