This commit is contained in:
2025-08-12 15:04:01 +08:00
parent df3f5f5269
commit 6708fb8eeb
544 changed files with 75169 additions and 17 deletions
@@ -0,0 +1,28 @@
import optionsFromStrings from "./optionsFromStrings.js";
import defaults from "../options/defaults.js";
function getOptionsFromElement(element){
var options = {};
for(var property in defaults){
if(defaults.hasOwnProperty(property)){
// jsbarcode-*
if(element.hasAttribute("jsbarcode-" + property.toLowerCase())){
options[property] = element.getAttribute("jsbarcode-" + property.toLowerCase());
}
// data-*
if(element.hasAttribute("data-" + property.toLowerCase())){
options[property] = element.getAttribute("data-" + property.toLowerCase());
}
}
}
options["value"] = element.getAttribute("jsbarcode-value") || element.getAttribute("data-value");
// Since all atributes are string they need to be converted to integers
options = optionsFromStrings(options);
return options;
}
export default getOptionsFromElement;