<commit_before>define(function(require) {
  /*
    DEPENDENCIES
   */

  require('foundation.tab');
  var BaseFormPanel = require('utils/form-panels/form-panel');
  var Sunstone = require('sunstone');
  var Locale = require('utils/locale');
  var Tips = require('utils/tips');
  var TemplateUtils = require('utils/template-utils');
  var WizardFields = require('utils/wizard-fields');
  var VNetsTable = require('tabs/vnets-tab/datatable');
  var Utils = require('../utils/common');

  /*
    TEMPLATES
   */

  var TemplateWizardHTML = require('hbs!./create/wizard');
  var TemplateAdvancedHTML = require('hbs!./create/advanced');

  /*
    CONSTANTS
   */

  var FORM_PANEL_ID = require('./create/formPanelId');
  var TAB_ID = require('../tabId');

  /*
    CONSTRUCTOR
   */

  function FormPanel() {
    this.formPanelId = FORM_PANEL_ID;
    this.tabId = TAB_ID;
    this.actions = {
      'create': {
        'title': Locale.tr("Create Security Group"),
        'buttonText': Locale.tr("Create"),
        'resetButton': true
      },
      'update': {
        'title': Locale.tr("Update Security Group"),
        'buttonText': Locale.tr("Update"),
        'resetButton': false
      }
    };

    BaseFormPanel.call(this);
  }

  FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
  FormPanel.prototype = Object.create(BaseFormPanel.prototype);
  FormPanel.prototype.constructor = FormPanel;
  FormPanel.prototype.htmlWizard = _htmlWizard;
  FormPanel.prototype.htmlAdvanced = _htmlAdvanced;
  FormPanel.prototype.submitWizard = _submitWizard;
  FormPanel.prototype.submitAdvanced = _submitAdvanced;
  FormPanel.prototype.onShow = _onShow;
  FormPanel.prototype.fill = _fill;
  FormPanel.prototype.setup = _setup;

  return FormPanel;

  /*
    FUNCTION DEFINITIONS
   */

  function _htmlWizard() {

    var opts = {
      info: false,
      select: true
    };

    this.vnetsTable = new VNetsTable("new_sg_rule", opts);

    return TemplateWizardHTML({
      'formPanelId': this.formPanelId,
      'vnetsTableHTML': this.vnetsTable.dataTableHTML
    });
  }

  function _htmlAdvanced() {
    return TemplateAdvancedHTML({formPanelId: this.formPanelId});
  }

  function _setup(context) {
    var that = this;

    context.off("change", '.security_group_rule_protocol');
    context.on("change", '.security_group_rule_protocol', function(){
      $('.range_row', context).hide();
      $('.range_row input', context).removeAttr('required');

      $('.icmp_type_wrapper', context).hide();

      switch ($(this).val()) {
      case "TCP":
      case "UDP":
        $('.range_row', context).show();
        $(".range_row select", context).trigger("change");
        break;
      case "ICMP":
        $('.icmp_type_wrapper', context).show();
        break;
      case "IPSEC":
      case "ALL":
        break;
      }
    });

    context.off("change", '.security_group_rule_network_sel');
    context.on("change", '.security_group_rule_network_sel', function(){
      $('.security_group_rule_network',context).hide();
      $('div.security_group_rule_network input',context).removeAttr('required');
      that.vnetsTable.idInput().removeAttr("required");

      $('.vnet_select',context).hide();

      switch ($(this).val()) {
      case "ANY":
        break;
      case "NETWORK":
        $('.security_group_rule_network',context).show();
        $('div.security_group_rule_network input',context).attr('required', '');
        break;
      case "VNET":
        $('.vnet_select',context).show();
        that.vnetsTable.idInput().attr("required", "");

        that.vnetsTable.refreshResourceTableSelect();

        break;
      }
    });

    context.off("change", '.security_group_rule_range_sel');
    context.on("change", '.security_group_rule_range_sel', function(){
      switch ($(this).val()) {
      case "ALL":
        $('.security_group_rule_range', context).hide();
        $(".security_group_rule_range input", context).removeAttr('required');
        break;
      case "RANGE":
        $('.security_group_rule_range', context).show();
        $(".security_group_rule_range input", context).attr('required', '');
        break;
      }
    });

    $('#rules_form_wizard',context).off('invalid');
    $('#rules_form_wizard',context).off('valid');

    $('#rules_form_wizard',context).on('invalid', function () {

    }).on('valid', function() {
      var rule = {};

      rule["PROTOCOL"] = $(".security_group_rule_protocol", context).val();
      rule["RULE_TYPE"] = $(".security_group_rule_type", context).val();

      switch ($('.security_group_rule_range_sel', context).val()) {
      case "ALL":
        break;
      case "RANGE":
        rule["RANGE"] = $(".security_group_rule_range input", context).val();
        break;
      }

      switch ($('.security_group_rule_network_sel', context).val()) {
      case "ANY":
        break;
      case "NETWORK":
        rule["IP"] = $('#security_group_rule_first_ip', context).val();
        rule["SIZE"] = $('#security_group_rule_size', context).val();
        break;
      case "VNET":
        rule["NETWORK_ID"] = that.vnetsTable.retrieveResourceTableSelect();
        break;
      }

      if (rule["PROTOCOL"] == "ICMP" ){<commit_msg>bug #3945: Fix abide event for add rule form<commit_after>define(function(require) {
  /*
    DEPENDENCIES
   */

  require('foundation.tab');
  var BaseFormPanel = require('utils/form-panels/form-panel');
  var Sunstone = require('sunstone');
  var Locale = require('utils/locale');
  var Tips = require('utils/tips');
  var TemplateUtils = require('utils/template-utils');
  var WizardFields = require('utils/wizard-fields');
  var VNetsTable = require('tabs/vnets-tab/datatable');
  var Utils = require('../utils/common');

  /*
    TEMPLATES
   */

  var TemplateWizardHTML = require('hbs!./create/wizard');
  var TemplateAdvancedHTML = require('hbs!./create/advanced');

  /*
    CONSTANTS
   */

  var FORM_PANEL_ID = require('./create/formPanelId');
  var TAB_ID = require('../tabId');

  /*
    CONSTRUCTOR
   */

  function FormPanel() {
    this.formPanelId = FORM_PANEL_ID;
    this.tabId = TAB_ID;
    this.actions = {
      'create': {
        'title': Locale.tr("Create Security Group"),
        'buttonText': Locale.tr("Create"),
        'resetButton': true
      },
      'update': {
        'title': Locale.tr("Update Security Group"),
        'buttonText': Locale.tr("Update"),
        'resetButton': false
      }
    };

    BaseFormPanel.call(this);
  }

  FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
  FormPanel.prototype = Object.create(BaseFormPanel.prototype);
  FormPanel.prototype.constructor = FormPanel;
  FormPanel.prototype.htmlWizard = _htmlWizard;
  FormPanel.prototype.htmlAdvanced = _htmlAdvanced;
  FormPanel.prototype.submitWizard = _submitWizard;
  FormPanel.prototype.submitAdvanced = _submitAdvanced;
  FormPanel.prototype.onShow = _onShow;
  FormPanel.prototype.fill = _fill;
  FormPanel.prototype.setup = _setup;

  return FormPanel;

  /*
    FUNCTION DEFINITIONS
   */

  function _htmlWizard() {

    var opts = {
      info: false,
      select: true
    };

    this.vnetsTable = new VNetsTable("new_sg_rule", opts);

    return TemplateWizardHTML({
      'formPanelId': this.formPanelId,
      'vnetsTableHTML': this.vnetsTable.dataTableHTML
    });
  }

  function _htmlAdvanced() {
    return TemplateAdvancedHTML({formPanelId: this.formPanelId});
  }

  function _setup(context) {
    var that = this;
    context.foundation('abide', 'reflow');

    context.off("change", '.security_group_rule_protocol');
    context.on("change", '.security_group_rule_protocol', function(){
      $('.range_row', context).hide();
      $('.range_row input', context).removeAttr('required');

      $('.icmp_type_wrapper', context).hide();

      switch ($(this).val()) {
      case "TCP":
      case "UDP":
        $('.range_row', context).show();
        $(".range_row select", context).trigger("change");
        break;
      case "ICMP":
        $('.icmp_type_wrapper', context).show();
        break;
      case "IPSEC":
      case "ALL":
        break;
      }
    });

    context.off("change", '.security_group_rule_network_sel');
    context.on("change", '.security_group_rule_network_sel', function(){
      $('.security_group_rule_network',context).hide();
      $('div.security_group_rule_network input',context).removeAttr('required');
      that.vnetsTable.idInput().removeAttr("required");

      $('.vnet_select',context).hide();

      switch ($(this).val()) {
      case "ANY":
        break;
      case "NETWORK":
        $('.security_group_rule_network',context).show();
        $('div.security_group_rule_network input',context).attr('required', '');
        break;
      case "VNET":
        $('.vnet_select',context).show();
        that.vnetsTable.idInput().attr("required", "");

        that.vnetsTable.refreshResourceTableSelect();

        break;
      }
    });

    context.off("change", '.security_group_rule_range_sel');
    context.on("change", '.security_group_rule_range_sel', function(){
      switch ($(this).val()) {
      case "ALL":
        $('.security_group_rule_range', context).hide();
        $(".security_group_rule_range input", context).removeAttr('required');
        break;
      case "RANGE":
        $('.security_group_rule_range', context).show();
        $(".security_group_rule_range input", context).attr('required', '');
        break;
      }
    });

    $('#rules_form_wizard',context).off('invalid.fndtn.abide');
    $('#rules_form_wizard',context).off('valid.fndtn.abide');

    $('#rules_form_wizard',context).on('invalid.fndtn.abide', function () {

    }).on('valid.fndtn.abide', function() {
      var rule = {};

      rule["PROTOCOL"] = $(".security_group_rule_protocol", context).val();
      rule["RULE_TYPE"] = $(".security_group_rule_type", context).val();

      switch ($('.security_group_rule_range_sel', context).val()) {
      case "ALL":
        break;
      case "RANGE":
        rule["RANGE"] = $(".security_group_rule_range input", context).val();
        break;
      }

      switch ($('.security_group_rule_network_sel', context).val()) {
      case "ANY":
        break;
      case "NETWORK":
        rule["IP"] = $('#security_group_rule_first_ip', context).val();
        rule["SIZE"] = $('#security_group_rule_size', context).val();
        break;
      case "VNET":
        rule["NETWORK_ID"] = that.vnetsTable.retrieveResourceTableSelect();
        break;
      }

      if (rule["PROTOCOL"] == "ICMP" ){
{'fraction_non_alphanumeric': 0.16707826747720364, 'fraction_numerical': 0.00037993920972644377, 'mean_word_length': 3.1161063330727132, 'pattern_counts': {'":': 30, '<': 3, '<?xml version=': 0, '>': 3, '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': '1693431', 'n_tokens_mistral': 3341, 'n_tokens_neox': 3237, 'n_words': 518}