<commit_before>'use strict';

var ConnectDialog = function() {};

ConnectDialog.show = function(onComplete) {
  lib.ensureRuntimeDependencies();
  $('a[rel*=leanModal]').leanModal({closeButton: '#connect'});
  
  var port = null;
  var bitrate = 9600;
  var $portPicker = $('#port-picker');
  var $bitratePicker = $('#bitrate-picker');

  // Build port picker
  chrome.runtime.getBackgroundPage(function(bgPage) {
    bgPage.serial_lib.getPorts(function(ports) {
        var eligiblePorts = ports.filter(function(port) {
          return !port.match(/[Bb]luetooth/);
        });

        if (eligiblePorts.length > 0) {
          eligiblePorts.forEach(function(port) {
            var $option = $('<option>' + port + '</option>').attr('value', port);
            $portPicker.append($option);
          });

          // Show setup dialog
          $('#connect-dialog-trigger').click();

        } else {
          // Show error dialog      
          MessageDialog.show('Could not find serial device. Please check your serial connection and try again.');
        }
    });
  });

  $('#connect').click(function() {
    if (onComplete) {
      onComplete({
        port: $portPicker.val(),
        bitrate: $bitratePicker.val()
      });
    }
  });
};
<commit_msg>save and load the last selected bitrate.<commit_after>'use strict';

var ConnectDialog = function() {};

ConnectDialog.show = function(onComplete) {
  lib.ensureRuntimeDependencies();
  $('a[rel*=leanModal]').leanModal({closeButton: '#connect'});
  
  var port = null;
  var bitrate = 9600;
  var $portPicker = $('#port-picker');
  var $bitratePicker = $('#bitrate-picker');
  var storage = chrome.storage.local;
  
  var BITRATE_KEY = 'bit_rate';
  var obj = {};
  
  storage.get(BITRATE_KEY,function(result){
    console.log('have;? : ' + result.bit_rate);
    if (result.bitrate != '') { //if not empty or not in a list of bitrate
        $('#bitrate-picker').val(result.bit_rate);
    }
  });
  
  // Build port picker
  chrome.runtime.getBackgroundPage(function(bgPage) {
    bgPage.serial_lib.getPorts(function(ports) {
        var eligiblePorts = ports.filter(function(port) {
          return !port.match(/[Bb]luetooth/);
        });

        if (eligiblePorts.length > 0) {
          eligiblePorts.forEach(function(port) {
            var $option = $('<option>' + port + '</option>').attr('value', port);
            $portPicker.append($option);
          });

          // Show setup dialog
          $('#connect-dialog-trigger').click();

        } else {
          // Show error dialog
          MessageDialog.show('Could not find serial device. Please check your serial connection and try again.');
        }
    });
  });

  $('#connect').click(function() {
    if (onComplete) {
      // save bitrate
      obj[BITRATE_KEY] = $bitratePicker.val();
      storage.set(obj);

      onComplete({
        port: $portPicker.val(),
        bitrate: $bitratePicker.val()
      });
    }
  });
};


{'fraction_non_alphanumeric': 0.16307277628032346, 'fraction_numerical': 0.0033692722371967657, 'mean_word_length': 2.5857487922705316, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3929574', 'n_tokens_mistral': 906, 'n_tokens_neox': 888, 'n_words': 179}