Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.getInitWidgetsCode = function(widgetsContext) {
var renderedWidgets = getRenderedWidgets(widgetsContext);
var ids = renderedWidgets.ids;
var state = renderedWidgets.state;
var config = renderedWidgets.config;
var code = '';
if (!isObjectEmpty(state)) {
code += warp10.serialize(
state,
WARP10_STATE_SERIALIZATION_OPTIONS) +
';\n';
}
if (!isObjectEmpty(config)) {
code += warp10.serialize(
config,
WARP10_CONFIG_SERIALIZATION_OPTIONS) +
';\n';
}
code += '$markoWidgets("' + ids + '");';
return code;
};
var renderedWidgets = getRenderedWidgets(widgetsContext);
var ids = renderedWidgets.ids;
var state = renderedWidgets.state;
var config = renderedWidgets.config;
var code = '';
if (!isObjectEmpty(state)) {
code += warp10.serialize(
state,
WARP10_STATE_SERIALIZATION_OPTIONS) +
';\n';
}
if (!isObjectEmpty(config)) {
code += warp10.serialize(
config,
WARP10_CONFIG_SERIALIZATION_OPTIONS) +
';\n';
}
code += '$markoWidgets("' + ids + '");';
return code;
};
}
var widgetStateDeserializationCode;
var widgetConfigDeserializationCode;
if (isObjectEmpty(widgetStateStore)) {
widgetStateDeserializationCode = '';
} else {
widgetStateDeserializationCode = warp10.serialize(widgetStateStore, WARP10_STATE_SERIALIZATION_OPTIONS) +
';\n';
}
if (isObjectEmpty(widgetConfigStore)) {
widgetConfigDeserializationCode = '';
} else {
widgetConfigDeserializationCode = warp10.serialize(widgetConfigStore,WARP10_CONFIG_SERIALIZATION_OPTIONS) +
';\n';
}
var cspNonce = out.global.cspNonce;
var nonceAttr = cspNonce ? ' nonce='+JSON.stringify(cspNonce) : '';
if (immediate) {
out.write('' +
widgetStateDeserializationCode +
widgetConfigDeserializationCode +
'$markoWidgets("' + ids + '")');
} else {
out.write('' +
widgetStateDeserializationCode +
widgetConfigDeserializationCode +
'');
};
if (rootWidgetDefs) {
writeWidgets(rootWidgetDefs);
} else {
writeWidgets(rootWidgetDef.children);
rootWidgetDef.children = [];
}
var widgetStateDeserializationCode;
var widgetConfigDeserializationCode;
if (isObjectEmpty(widgetStateStore)) {
widgetStateDeserializationCode = '';
} else {
widgetStateDeserializationCode = warp10.serialize(widgetStateStore, WARP10_STATE_SERIALIZATION_OPTIONS) +
';\n';
}
if (isObjectEmpty(widgetConfigStore)) {
widgetConfigDeserializationCode = '';
} else {
widgetConfigDeserializationCode = warp10.serialize(widgetConfigStore,WARP10_CONFIG_SERIALIZATION_OPTIONS) +
';\n';
}
var cspNonce = out.global.cspNonce;
var nonceAttr = cspNonce ? ' nonce='+JSON.stringify(cspNonce) : '';
if (immediate) {
out.write('' +
widgetStateDeserializationCode +