Skip to content

Commit

Permalink
Merge pull request #82 from openfoodfacts/barcode-display-by-default
Browse files Browse the repository at this point in the history
feat: barcode display by default
  • Loading branch information
DanieliusAsm authored Dec 17, 2023
2 parents 7819e3c + 278615e commit e281b35
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion OpenFoodFactsPower.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ ul#products_match_all > li > a > span { display: table-cell; width: 70%; vert
<li>(?) or (h): this present help</li>
<hr>
<li><input class="pus-checkbox" type="checkbox" id="pus-ingredients-font"><label for="pus-ingredients-font">Ingredients fixed-width font</label></li>
<li><input class="pus-checkbox" type="checkbox" id="pus-always-show-barcode"><label for="pus-always-show-barcode">Always show barcodes</label></li>
<hr>
<li>(Shift+L): List edit mode</li>
<li>(Shift+b): Show/hide barcodes</li>
Expand All @@ -1119,11 +1120,12 @@ ul#products_match_all > li > a > span { display: table-cell; width: 70%; vert
$("#pwe_help").click(function(){
togglePowerUserInfo(listhelp);
toggleIngredientsMonospace();
toggleAlwaysShowBarcodes();
});

// detect product codes and add them as attributes
addCodesToProductList();

loadAlwaysShowBarcodesFromStorage();

// Show an easier to read number of products
/*
Expand Down Expand Up @@ -1628,6 +1630,31 @@ ul#products_match_all > li > a > span { display: table-cell; width: 70%; vert

});
}

function toggleAlwaysShowBarcodes(){

if(getLocalStorage("pus-always-show-barcode") === "always"){
$('#pus-always-show-barcode').prop("checked", true);
}

$('#pus-always-show-barcode').change(function() {
if(this.checked){
localStorage.setItem('pus-always-show-barcode', "always");
}else{
localStorage.setItem('pus-always-show-barcode', "never");
}
toggleListBarcodes();
});
}

function loadAlwaysShowBarcodesFromStorage(){
$( window ).on( "load", function() {
if(getLocalStorage("pus-always-show-barcode") === "always"){
toggleListBarcodes();
}
});

}


/**
Expand Down

0 comments on commit e281b35

Please sign in to comment.