<commit_before>// -*- mode: java; c-basic-offset: 2; -*-
// Copyright © 2012-2016 Massachusetts Institute of Technology. All rights reserved.

/**
 * @license
 * @fileoverview Visual blocks editor for MIT App Inventor
 * Initialize the blocks editor workspace.
 *
 * @author <EMAIL> (<NAME>)
 * @author <EMAIL> (<NAME>)
 * @author <EMAIL> (<NAME>)
 */

'use strict';

goog.provide('AI.Blockly.BlocklyEditor');

goog.require('AI.Blockly.Drawer');

// App Inventor extensions to Blockly
goog.require('Blockly.TypeBlock');

goog.require('Blockly.Flyout');

// Make dragging a block from flyout work in any direction (default: 70)
Blockly.Flyout.prototype.dragAngleRange_ = 360;

if (Blockly.BlocklyEditor === undefined) {
  Blockly.BlocklyEditor = {};
}

Blockly.allWorkspaces = {};

Blockly.configForTypeBlock = {
  frame: 'ai_frame',
  typeBlockDiv: 'ai_type_block',
  inputText: 'ac_input_text'
};

Blockly.BlocklyEditor.render = function() {
};

function unboundVariableHandler(myBlock, yailText) {
  var unbound_vars = Blockly.LexicalVariable.freeVariables(myBlock);
  unbound_vars = unbound_vars.toList();
  if (unbound_vars.length == 0) {
    Blockly.ReplMgr.putYail(yailText, myBlock);
  } else {
    var form = "<form onsubmit='return false;'>" + Blockly.Msg.DIALOG_ENTER_VALUES + "<br>";
    for (var v in unbound_vars) {
      form  +=  unbound_vars[v] + ' = <input type=text name=' + unbound_vars[v] + '><br>';
    }
    form += "</form>";
    var dialog = new Blockly.Util.Dialog(Blockly.Msg.DIALOG_UNBOUND_VAR, form, Blockly.Msg.DO_IT, false, Blockly.Msg.REPL_CANCEL, 10, function (button) {
      if (button == Blockly.Msg.DIALOG_SUBMIT) {
        var code = "(let (";
        for (var i in unbound_vars) {
          code += '($' + unbound_vars[i] + ' ' + Blockly.Yail.quotifyForREPL(document.querySelector('input[name="' + unbound_vars[i] + '"]').value) + ') ';
        };
        code += ")" + yailText + ")";
        Blockly.ReplMgr.putYail(code, myBlock);
      }
      dialog.hide();
    });
  };
}

Blockly.BlocklyEditor.addPngExportOption = function(myBlock, options) {<commit_msg>Fix unbound variable dialog button<commit_after>// -*- mode: java; c-basic-offset: 2; -*-
// Copyright © 2012-2016 Massachusetts Institute of Technology. All rights reserved.

/**
 * @license
 * @fileoverview Visual blocks editor for MIT App Inventor
 * Initialize the blocks editor workspace.
 *
 * @author <EMAIL> (<NAME>)
 * @author <EMAIL> (<NAME>)
 * @author <EMAIL> (<NAME>)
 */

'use strict';

goog.provide('AI.Blockly.BlocklyEditor');

goog.require('AI.Blockly.Drawer');

// App Inventor extensions to Blockly
goog.require('Blockly.TypeBlock');

goog.require('Blockly.Flyout');

// Make dragging a block from flyout work in any direction (default: 70)
Blockly.Flyout.prototype.dragAngleRange_ = 360;

if (Blockly.BlocklyEditor === undefined) {
  Blockly.BlocklyEditor = {};
}

Blockly.allWorkspaces = {};

Blockly.configForTypeBlock = {
  frame: 'ai_frame',
  typeBlockDiv: 'ai_type_block',
  inputText: 'ac_input_text'
};

Blockly.BlocklyEditor.render = function() {
};

function unboundVariableHandler(myBlock, yailText) {
  var unbound_vars = Blockly.LexicalVariable.freeVariables(myBlock);
  unbound_vars = unbound_vars.toList();
  if (unbound_vars.length == 0) {
    Blockly.ReplMgr.putYail(yailText, myBlock);
  } else {
    var form = "<form onsubmit='return false;'>" + Blockly.Msg.DIALOG_ENTER_VALUES + "<br>";
    for (var v in unbound_vars) {
      form  +=  unbound_vars[v] + ' = <input type=text name=' + unbound_vars[v] + '><br>';
    }
    form += "</form>";
    var dialog = new Blockly.Util.Dialog(Blockly.Msg.DIALOG_UNBOUND_VAR, form, Blockly.Msg.DO_IT, false, Blockly.Msg.REPL_CANCEL, 10, function (button) {
      if (button == Blockly.Msg.DO_IT) {
        var code = "(let (";
        for (var i in unbound_vars) {
          code += '($' + unbound_vars[i] + ' ' + Blockly.Yail.quotifyForREPL(document.querySelector('input[name="' + unbound_vars[i] + '"]').value) + ') ';
        };
        code += ")" + yailText + ")";
        Blockly.ReplMgr.putYail(code, myBlock);
      }
      dialog.hide();
    });
  };
}

Blockly.BlocklyEditor.addPngExportOption = function(myBlock, options) {
{'fraction_non_alphanumeric': 0.15998101115594587, 'fraction_numerical': 0.008070258723000238, 'mean_word_length': 3.8270332187857963, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7549573', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1455, 'n_words': 298}