components/blockly-src/demos/blockfactory/factory.js
function updateLanguage() {
  var rootBlock = getRootBlock();
  if (!rootBlock) {
    return;
  }
  var blockType = rootBlock.getFieldValue('NAME').trim().toLowerCase();
  if (!blockType) {
    blockType = UNNAMED;
  }
  blockType = blockType.replace(/\W/g, '_').replace(/^(\d)/, '_\\1');
  switch (document.getElementById('format').value) {
    case 'JSON':
      var code = formatJson_(blockType, rootBlock);
      break;
    case 'JavaScript':
      var code = formatJavaScript_(blockType, rootBlock);
      break;
  }
  injectCode(code, 'languagePre');
  updatePreview();
}
function updateLanguage() {
  var rootBlock = getRootBlock();
  if (!rootBlock) {
    return;
  }
  var blockType = rootBlock.getFieldValue('NAME').trim().toLowerCase();
  if (!blockType) {
    blockType = UNNAMED;
  }
  blockType = blockType.replace(/\W/g, '_').replace(/^(\d)/, '_\\1');
  switch (document.getElementById('format').value) {
    case 'JSON':
      var code = formatJson_(blockType, rootBlock);
      break;
    case 'JavaScript':
      var code = formatJavaScript_(blockType, rootBlock);
      break;
  }
  injectCode(code, 'languagePre');
  updatePreview();
}
function updateLanguage ( ) { var rootBlock = getRootBlock ( ) ; if ( ! rootBlock ) { return ; } var blockType = rootBlock . getFieldValue ( 'NAME' ) . trim ( ) . toLowerCase ( ) ; if ( ! blockType ) { blockType = UNNAMED ; } blockType = blockType . replace ( / \W / g , '_' ) . replace ( / ^(\d) / , '_\\1' ) ; switch ( document . getElementById ( 'format' ) . value ) { case 'JSON' : var code = formatJson_ ( blockType , rootBlock ) ; break ; case 'JavaScript' : var code = formatJavaScript_ ( blockType , rootBlock ) ; break ; } injectCode ( code , 'languagePre' ) ; updatePreview ( ) ; }
Update the language code based on constructs made in Blockly.
Update the language code based on constructs made in Blockly .