Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getToolbox() {
// Interpolate translated messages into toolbox.
let toolboxText = window.document.getElementById('toolbox').outerHTML;
toolboxText = toolboxText.replace(/{(\w+)}/g, (m, p1) => window.MSG[p1]);
let blocks = '';
const lang = I18n.getLanguage();
for (let cb = 0; cb < this.Blockly.CustomBlocks.length; cb++) {
const name = this.Blockly.CustomBlocks[cb];
// add blocks
blocks += '';
for (const _b in this.Blockly[name].blocks) {
if (this.Blockly[name].blocks.hasOwnProperty(_b)) {
blocks += this.Blockly[name].blocks[_b];
}
}
blocks += '';
}
toolboxText = toolboxText.replace('%%CUSTOM_BLOCKS%%', blocks);
return toolboxText;
}
onEdit(id) {
const obj = this.state.funcs.find(e => e._id === id) || this.state.rooms.find(e => e._id === id);
let smartName = Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
smartName = smartName || Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()});
this.setState({editId: id, editedSmartName: smartName});
}
.then(obj => {
let smartName = device.common.smartName ? device.common.smartName : device._id;
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
this.editedSmartName = smartName;
this.setState({editId: id, editedSmartName: smartName, editObjectName: Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()})});
});
return true;
.then(obj => {
let smartName = device.additionalApplianceDetails.friendlyNames ? device.additionalApplianceDetails.friendlyNames : device.friendlyName;
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
this.editedSmartName = smartName;
let editedSmartType = null;
if (!device.additionalApplianceDetails.group) {
editedSmartType = device.additionalApplianceDetails.smartType;
}
this.setState({editId: id, editedSmartType, editedSmartName: smartName, editObjectName: Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()})});
});
return true;
key="simple"
checked={this.state.mode === 'simple'}
onChange={e => this.setMode('simple')}
/><label> this.setMode('simple')}
style={this.state.mode !== 'simple' ? {color: 'lightgrey'} : {}}>{I18n.t('sc_simple')}</label>
this.setMode('complex')}
/><label> this.setMode('complex')} style={this.state.mode !== 'complex' ? {color: 'lightgrey'} : {}}>{I18n.t('sc_cron')}</label>)}
{this.state.mode === 'simple' &&
( this.setState({cron})}
language={I18n.getLanguage()}
/>)}
{this.state.mode === 'wizard' &&
( this.setState({cron})}
language={I18n.getLanguage()}
/>)}
{this.state.mode === 'complex' &&
( this.setState({cron})}
language={I18n.getLanguage()}
/>)}
<button> this.handleOk()} color="primary">{this.props.ok || I18n.t('Ok')}</button>