<commit_before>var makernode = {};

makernode.app = angular.module('MakerNode', ['ngRoute']);

makernode.routes = {
  init: {
    hash: '',
    controller: 'InitCtrl',
    template: 'empty',
  },
  // NOTE if you want a route with controller FormCtrl to be able to send its
  // data to the server, you must give it a socket_msg_type
  set_hostname: {
    hash: 'set_hostname',
    controller: 'FormCtrl',
    template: 'set_hostname',
    socket_msg_type: 'set_hostname',
  },
  set_root_password: {
    hash: 'set_root_password',
    controller: 'FormCtrl',
    template: 'set_root_password',
    socket_msg_type: 'set_root_password',
  },
  wifi_setup: {
    hash: 'wifi_setup',
    controller: 'FormCtrl',
    template: 'wifi_setup',
    socket_msg_type: 'router_setup',
  },
  connecting: {
    hash: 'connecting',
    controller: 'EmptyCtrl',
    template: 'connecting_to_router',
  },
  test_pin: {
    hash: 'test_pin',
    controller: 'FormCtrl',
    template: 'test_pin',
  },
  next_steps: {
    hash: 'home',
    controller: 'EmptyCtrl',
    template: 'next_steps',
  },
  controller: {
    hash: 'pin_monitor',
    controller: 'EmptyCtrl',
    template: 'controller',
  },
};

makernode.app.config(['$routeProvider',
  function($routeProvider) {
    _.each(makernode.routes, function(o, route) {
      $routeProvider.when('/' + o.hash, {
        templateUrl: 'templates/' + o.template + '.html',
        controller: o.controller,
      });
    });
  }
]);

// steps order
makernode.setup_steps = [
  'set_hostname',
  'wifi_setup',
  'connecting',
  'test_pin',
  'next_steps',
];

// The highest level app controller from which all others inherit
makernode.app.controller('AppCtrl', ['$scope',
  function($scope) {

    window.$scope = $scope;

    $scope.routes = makernode.routes;

    // pins data structure
    $scope.d = makernode.d();
    // websocket connection with server
    $scope.ws = io();
    // sync pins with server
    var pinsync = makernode.ws_pin_sync($scope, 'ws', 'd');

    $scope.scan_wifi = function() {
      if (true || makernode.rc.currentRouteKey() == 'wifi_setup') {
        $scope.ws.on('networks', function(networks) {
          console.log('got wifi network list: ' + networks);
          $('#combo-01 option').remove();
          for (var i = 0; networks && i < networks.length; i++) {
            var value = networks[i];
            if (value.indexOf('x00\\x00') === -1) { //don't show hidden networks
              var element = '<option value="' + value + '">' + value + '</option>';
              $('#combo-01').append(element);
            }
          }
          $('#combo-01').scombobox({
            empty: true
          });
          $('.scombobox-display').focus().attr('placeholder', 'Network');
          $('.show-on-load').css({
            'display': 'block'
          });
          $('.hide-on-load').css({
            'display': 'none'
          });
        });
        $scope.ws.emit('networks', {});
      }

    }<commit_msg>Fixed another bug with the wifi network list<commit_after>var makernode = {};

makernode.app = angular.module('MakerNode', ['ngRoute']);

makernode.routes = {
  init: {
    hash: '',
    controller: 'InitCtrl',
    template: 'empty',
  },
  // NOTE if you want a route with controller FormCtrl to be able to send its
  // data to the server, you must give it a socket_msg_type
  set_hostname: {
    hash: 'set_hostname',
    controller: 'FormCtrl',
    template: 'set_hostname',
    socket_msg_type: 'set_hostname',
  },
  set_root_password: {
    hash: 'set_root_password',
    controller: 'FormCtrl',
    template: 'set_root_password',
    socket_msg_type: 'set_root_password',
  },
  wifi_setup: {
    hash: 'wifi_setup',
    controller: 'FormCtrl',
    template: 'wifi_setup',
    socket_msg_type: 'router_setup',
  },
  connecting: {
    hash: 'connecting',
    controller: 'EmptyCtrl',
    template: 'connecting_to_router',
  },
  test_pin: {
    hash: 'test_pin',
    controller: 'FormCtrl',
    template: 'test_pin',
  },
  next_steps: {
    hash: 'home',
    controller: 'EmptyCtrl',
    template: 'next_steps',
  },
  controller: {
    hash: 'pin_monitor',
    controller: 'EmptyCtrl',
    template: 'controller',
  },
};

makernode.app.config(['$routeProvider',
  function($routeProvider) {
    _.each(makernode.routes, function(o, route) {
      $routeProvider.when('/' + o.hash, {
        templateUrl: 'templates/' + o.template + '.html',
        controller: o.controller,
      });
    });
  }
]);

// steps order
makernode.setup_steps = [
  'set_hostname',
  'wifi_setup',
  'connecting',
  'test_pin',
  'next_steps',
];

// The highest level app controller from which all others inherit
makernode.app.controller('AppCtrl', ['$scope',
  function($scope) {

    window.$scope = $scope;

    $scope.routes = makernode.routes;

    // pins data structure
    $scope.d = makernode.d();
    // websocket connection with server
    $scope.ws = io();
    // sync pins with server
    var pinsync = makernode.ws_pin_sync($scope, 'ws', 'd');

    $scope.scan_wifi = function() {
      if (true || makernode.rc.currentRouteKey() == 'wifi_setup') {
        $scope.ws.on('networks', function(networks) {
          console.log('got wifi network list: ' + networks);
          // $('#combo-01 .wifi-network').remove();
          for (var i = 0; networks && i < networks.length; i++) {
            var value = networks[i];
            if (value.indexOf('x00\\x00') === -1) { //don't show hidden networks
              var element = '<option class="wifi-network" value="' + value + '">' + value + '</option>';
              $('#combo-01').append(element);
            }
          }
          $('#combo-01').scombobox({
            empty: true
          });
          $('.scombobox-display').focus().attr('placeholder', 'Network');
          $('.show-on-load').css({
            'display': 'block'
          });
          $('.hide-on-load').css({
            'display': 'none'
          });
        });
        $scope.ws.emit('networks', {});
      }

    }
{'fraction_non_alphanumeric': 0.16826446280991736, 'fraction_numerical': 0.003966942148760331, 'mean_word_length': 2.548973607038123, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '2846924', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1957, 'n_words': 414}