Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea on how to improve raw ingridients search #841

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions www/activities/foodlist/js/open-food-facts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ app.OpenFoodFacts = {
//Build search string
let url;

let usdaEnabled = app.Settings.get("integration", "usda") && (app.Settings.get("integration", "usda-key") != "");
let barcodeOnlySearch = (app.Settings.get("integration", "off-only-barcode") || false) && usdaEnabled;

// If query is a number, assume it's a barcode
if (isNaN(query))
if (isNaN(query)){
// If the user only wants to use OFF for barcode scans return empty list and hope the next provider has the data
if (barcodeOnlySearch)
return resolve(undefined);
url = "https://world.openfoodfacts.org/cgi/search.pl?search_terms=" + encodeURIComponent(query) + "&search_simple=1&page_size=50&sort_by=unique_scans_n&action=process&json=1";
else
} else
url = "https://world.openfoodfacts.org/api/v0/product/" + encodeURIComponent(query) + ".json";

//Get country name
Expand Down
3 changes: 2 additions & 1 deletion www/activities/settings/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ app.Settings = {
"search-language": "Default",
"search-country": "All",
"upload-country": "Auto",
usda: false
usda: false,
"off-only-barcode": false
},
tts: {
"speed": 1,
Expand Down
14 changes: 14 additions & 0 deletions www/activities/settings/views/integration.html
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,20 @@
</div>
</li>

<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title" data-localize="settings.integration.off-only-barcode">Barcode Only Search</div>
<div class="item-after">
<label class="toggle toggle-init">
<input type="checkbox" field="integration" name="off-only-barcode" />
<span class="toggle-icon"></span>
</label>
</div>
</div>
</div>
</li>

<li class="item-divider" data-localize="settings.integration.usda-title">U.S. DEPARTMENT OF AGRICULTURE</li>

<li>
Expand Down