<commit_before>var app = angular.module('app', []);

app.config(function ($httpProvider) {
  $httpProvider.defaults.transformRequest = function (data) {
    if (data === undefined) {
      return data;
    }
    return $.param(data);
  };
  $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;';
});

app.controller('MainCtrl', function ($scope, $http, $timeout, patternService, variableService) {
  $scope.brightness = "255";
  $scope.busy = false;
  $scope.power = 1;
  $scope.color = "#0000ff"
  $scope.r = 0;
  $scope.g = 0;
  $scope.b = 255;
  $scope.noiseSpeedX = 0;
  $scope.noiseSpeedY = 0;
  $scope.noiseSpeedZ = 0;
  $scope.noiseScale = 0;
  $scope.powerText = "On";
  $scope.status = "Please enter your access token.";
  $scope.disconnected = false;
  $scope.accessToken = "";
  $scope.isDeviceSelected = false;

  $scope.patterns = [];
  $scope.patternIndex = 0;

  $scope.devices = [];

  $scope.onSelectedDeviceChange = function() {
    $scope.isDeviceSelected = $scope.device != null;

    var devicePatterns = localStorage["deviceId" + $scope.device.id + "patterns"];

    if(devicePatterns === undefined)
      $scope.patterns = null;
    else
      $scope.patterns = JSON.parse(devicePatterns);
  }

  $scope.getDevices = function () {
    $scope.status = 'Getting devices...';

    $http.get('https://api.particle.io/v1/devices?access_token=' + $scope.accessToken).
      success(function (data, status, headers, config) {
        if (data && data.length > 0) {
          if (Modernizr.localstorage) {
            var deviceId = localStorage["deviceId"];

          for (var i = 0; i < data.length; i++) {
            var device = data[i];
            device.title = (device.connected == true ? "● " : "◌ ") + device.name;
            device.status = device.connected == true ? "online" : "offline";

            if (deviceId) {
                if (data[i].id == deviceId) {
                  $scope.device = data[i];
                  $scope.onSelectedDeviceChange();
                  break;
                }
              }
            }
          }

        $scope.devices = data;

          if (!$scope.device)
            $scope.device = data[0];

        $scope.isDeviceSelected = $scope.device != null;
        }
        $scope.status = 'Loaded devices';
      }).
      error(function (data, status, headers, config) {<commit_msg>Fixed issue with device selector.<commit_after>var app = angular.module('app', []);

app.config(function ($httpProvider) {
  $httpProvider.defaults.transformRequest = function (data) {
    if (data === undefined) {
      return data;
    }
    return $.param(data);
  };
  $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;';
});

app.controller('MainCtrl', function ($scope, $http, $timeout, patternService, variableService) {
  $scope.brightness = "255";
  $scope.busy = false;
  $scope.power = 1;
  $scope.color = "#0000ff"
  $scope.r = 0;
  $scope.g = 0;
  $scope.b = 255;
  $scope.noiseSpeedX = 0;
  $scope.noiseSpeedY = 0;
  $scope.noiseSpeedZ = 0;
  $scope.noiseScale = 0;
  $scope.powerText = "On";
  $scope.status = "Please enter your access token.";
  $scope.disconnected = false;
  $scope.accessToken = "";
  $scope.isDeviceSelected = false;

  $scope.patterns = [];
  $scope.patternIndex = 0;

  $scope.devices = [];

  $scope.onSelectedDeviceChange = function() {
    $scope.isDeviceSelected = $scope.device != null;

    var devicePatterns = localStorage["deviceId" + $scope.device.id + "patterns"];

    if(devicePatterns === undefined)
      $scope.patterns = null;
    else
      $scope.patterns = JSON.parse(devicePatterns);
  }

  $scope.getDevices = function () {
    $scope.status = 'Getting devices...';

    $http.get('https://api.particle.io/v1/devices?access_token=' + $scope.accessToken).
      success(function (data, status, headers, config) {
        if (data && data.length > 0) {
          var deviceId = null;

          if (Modernizr.localstorage) {
            deviceId = localStorage["deviceId"];
          }

          for (var i = 0; i < data.length; i++) {
            var device = data[i];
            device.title = (device.connected == true ? "● " : "◌ ") + device.name;
            device.status = device.connected == true ? "online" : "offline";

            if (data[i].id == deviceId) {
              $scope.device = data[i];
              $scope.onSelectedDeviceChange();
            }
          }

          $scope.devices = data;

            if (!$scope.device)
              $scope.device = data[0];

          $scope.isDeviceSelected = $scope.device != null;
        }
        $scope.status = 'Loaded devices';
      }).
      error(function (data, status, headers, config) {
{'fraction_non_alphanumeric': 0.1596303297626549, 'fraction_numerical': 0.00924175593362739, 'mean_word_length': 2.458242556281772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2385997', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1472, 'n_words': 299}