feat: added density conversion
This commit is contained in:
parent
bac7a14f95
commit
df26f0243b
5 changed files with 415 additions and 12 deletions
|
|
@ -159,15 +159,31 @@
|
|||
spans.forEach(function (span) {
|
||||
var type = span.getAttribute('data-measurement-type');
|
||||
var isHybrid = span.getAttribute('data-hybrid') === 'true';
|
||||
var useVolumeMode = isHybrid && measureByVolume;
|
||||
|
||||
var effectiveType = useVolumeMode ? 'volume' : type;
|
||||
var scalableAttr, defaultAttr, altAttr, effectiveType;
|
||||
|
||||
if (isHybrid && measureByVolume && type === 'weight') {
|
||||
// weight measurement in volume mode -> use volume data
|
||||
scalableAttr = 'data-volume-scalable';
|
||||
defaultAttr = 'data-volume-default';
|
||||
altAttr = 'data-volume-alt';
|
||||
effectiveType = 'volume';
|
||||
} else if (isHybrid && !measureByVolume && type === 'volume') {
|
||||
// volume measurement in weight mode -> use weight data
|
||||
scalableAttr = 'data-weight-scalable';
|
||||
defaultAttr = 'data-weight-default';
|
||||
altAttr = 'data-weight-alt';
|
||||
effectiveType = 'weight';
|
||||
} else {
|
||||
// default: use primary data
|
||||
scalableAttr = 'data-scalable';
|
||||
defaultAttr = 'data-default';
|
||||
altAttr = 'data-alt';
|
||||
effectiveType = type;
|
||||
}
|
||||
|
||||
var imperial = !!showingAlt[effectiveType];
|
||||
|
||||
var scalableAttr = useVolumeMode ? 'data-volume-scalable' : 'data-scalable';
|
||||
var defaultAttr = useVolumeMode ? 'data-volume-default' : 'data-default';
|
||||
var altAttr = useVolumeMode ? 'data-volume-alt' : 'data-alt';
|
||||
|
||||
var scalableRaw = span.getAttribute(scalableAttr);
|
||||
|
||||
if (scalableRaw && scale !== 1) {
|
||||
|
|
@ -258,9 +274,10 @@
|
|||
if (span.getAttribute('data-hybrid') === 'true') hasHybrid = true;
|
||||
});
|
||||
|
||||
// Hybrid measurements in volume mode need the volume metric/imperial toggle
|
||||
// Hybrid measurements need both weight and volume metric/imperial toggles
|
||||
if (hasHybrid) {
|
||||
typeHasToggle['volume'] = true;
|
||||
typeHasToggle['weight'] = true;
|
||||
}
|
||||
|
||||
var hasAny = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue