chore: initial import for test contour with k3s CI
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Единая нормализация onlineMode для Stimulus/record.js.
|
||||
* dataset и API могут отдавать true/false, "1"/"0", 1/0.
|
||||
*/
|
||||
function isOnlineMode(value) {
|
||||
if (value === true || value === 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value === false || value === 0 || value === null || value === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const normalized = String(value).trim().toLowerCase();
|
||||
|
||||
if (normalized === '' || normalized === '0' || normalized === 'false' || normalized === 'no' || normalized === 'off') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function toOnlineType(value) {
|
||||
return isOnlineMode(value) ? 1 : 0;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isOnlineMode,
|
||||
toOnlineType,
|
||||
};
|
||||
Reference in New Issue
Block a user