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

app.controller('DataCtrl', function($scope, $http) {
  $scope.loading = true;
  $scope.initialized = false;
  $scope.enrollment = true;
  $scope.waitlist = true;

  function responsiveTable(newWidth, oldWidth) {
    if(!$scope.initialized) {
      if(newWidth < 641) {
        $scope.time = false;
        $scope.location = false;
        $scope.instructor = false;
        $scope.updated = false;
      }
      else if(newWidth < 1025) {
        $scope.time = true;
        $scope.location = true;
        $scope.instructor = false;
        $scope.updated = false;
      }
      else {
        $scope.time = true;
        $scope.location = true;
        $scope.instructor = true;
        $scope.updated = true;
      }
      $scope.initialized = true;
    }
    else {
      if(newWidth < 641) {
        if(!(oldWidth < 641)) {
          $scope.time = false;
          $scope.location = false;
          $scope.instructor = false;
          $scope.updated = false;
        }
      }
      else if(newWidth < 1025) {
        if(!(oldWidth < 1025 && oldWidth > 640)) {
          $scope.time = true;
          $scope.location = true;
          $scope.instructor = false;
          $scope.updated = false;
        }
      }
      else {
        $scope.time = true;
        $scope.location = true;
        $scope.instructor = true;
        $scope.updated = true;
      }
    }
  }

  $scope.$watch(
    function() { return $(window).width(); },
    responsiveTable
  );

  $(window).resize(function() {
    $scope.$apply();
  });

  $scope.init = function(id, course) {
    $http.get('/api/sections/'+id+'/'+course)
      .success(function(data) {
        $scope.sections = data;
        $scope.loading = false;
      })
      .error(function(data) {
        console.log('Error: ' + data);
      });
  };

  $scope.loadAllData = function() {
    angular.forEach($scope.sections, function(section, key) {
      var ccn = section.ccn;
      $scope.loadData(key, ccn);
    });
  };

  $scope.loadData = function(index, ccn) {
    $scope.sections[index].loading = true;
    $http.get('/api/enrollment/'+ccn)
      .success(function(data) {
        $scope.sections[index].date = new Date().toLocaleString();
        if(data.enroll != null) {
          $scope.sections[index].enroll = data.enroll;
          $scope.sections[index].enrollLimit = data.enrollLimit;
          $scope.sections[index].enrollment = data.enroll + '/' + data.enrollLimit;
          if(data.enroll == data.enrollLimit) {
            $scope.sections[index].filled = true;
            $scope.sections[index].hide = $scope.hide;
          }
        }
        if(data.waitlist != null)
          $scope.sections[index].waitlist = data.waitlist + '/' + data.waitlistLimit;
        $scope.sections[index].loading = false;
      })
      .error(function(data) {
        console.log('Error: ' + data);
      });
  };

  $scope.toggleHide = function() {
    angular.forEach($scope.sections, function(section, key) {
      if(section.enroll != null && section.enrollLimit != null && section.enroll == section.enrollLimit) {
        section.hide = !$scope.hide;
      }
    });
  };
});

app.controller('AcctCtrl', function($scope, $http) {
  $scope.noEmail = false;
  $scope.noMobile = false;
  $scope.editing = false;
  $scope.saved = {};
  $scope.noSubscriptions = false;
  $scope.subscriptions = [];

  $scope.init = function(subscriptions, email, mobile) {
    if(subscriptions.length == 0)
      $scope.noSubscriptions = true;
    else
      for(course in subscriptions) {
        $http.get('/api/section/'+course.ccn)
        .success(function(data) {
          $scope.subscriptions.push(data);
        })
        .error(function(data) {
          console.log('Error: ' + data);
        });
      }
    if(email.length == 0)
      $scope.email = '';
    else
      $scope.email = email[0].address;
    if(mobile.length == 0)
      $scope.mobile = '';
    else
      $scope.mobile = mobile[0].number;

    if(email == '')
      $scope.noEmail = true;
    if(mobile == '')
      $scope.noMobile = true;


    $scope.saved.email = email;
    $scope.saved.mobile = mobile;
    $scope.saved.noEmail = $scope.noEmail;
    $scope.saved.noMobile = $scope.noMobile;
  }

  $scope.removeSection = function(ccn) {
    angular.forEach($scope.subscriptions, function(subscription, key) {
      if(subscription.ccn == ccn) {
        $http.post('/unsubscribe/'+ccn)
        .success(function(data) {
          console.log('Unsubscribed from section '+ccn);
        })
        .error(function(data) {
          console.log('Error: ' + data);
        });
        subscription.hide = true;<commit_msg>Fixed angular array parsing<commit_after>var app = angular.module("enrollmentApp", []);

app.controller('DataCtrl', function($scope, $http) {
  $scope.loading = true;
  $scope.initialized = false;
  $scope.enrollment = true;
  $scope.waitlist = true;

  function responsiveTable(newWidth, oldWidth) {
    if(!$scope.initialized) {
      if(newWidth < 641) {
        $scope.time = false;
        $scope.location = false;
        $scope.instructor = false;
        $scope.updated = false;
      }
      else if(newWidth < 1025) {
        $scope.time = true;
        $scope.location = true;
        $scope.instructor = false;
        $scope.updated = false;
      }
      else {
        $scope.time = true;
        $scope.location = true;
        $scope.instructor = true;
        $scope.updated = true;
      }
      $scope.initialized = true;
    }
    else {
      if(newWidth < 641) {
        if(!(oldWidth < 641)) {
          $scope.time = false;
          $scope.location = false;
          $scope.instructor = false;
          $scope.updated = false;
        }
      }
      else if(newWidth < 1025) {
        if(!(oldWidth < 1025 && oldWidth > 640)) {
          $scope.time = true;
          $scope.location = true;
          $scope.instructor = false;
          $scope.updated = false;
        }
      }
      else {
        $scope.time = true;
        $scope.location = true;
        $scope.instructor = true;
        $scope.updated = true;
      }
    }
  }

  $scope.$watch(
    function() { return $(window).width(); },
    responsiveTable
  );

  $(window).resize(function() {
    $scope.$apply();
  });

  $scope.init = function(id, course) {
    $http.get('/api/sections/'+id+'/'+course)
      .success(function(data) {
        $scope.sections = data;
        $scope.loading = false;
      })
      .error(function(data) {
        console.log('Error: ' + data);
      });
  };

  $scope.loadAllData = function() {
    angular.forEach($scope.sections, function(section, key) {
      var ccn = section.ccn;
      $scope.loadData(key, ccn);
    });
  };

  $scope.loadData = function(index, ccn) {
    $scope.sections[index].loading = true;
    $http.get('/api/enrollment/'+ccn)
      .success(function(data) {
        $scope.sections[index].date = new Date().toLocaleString();
        if(data.enroll != null) {
          $scope.sections[index].enroll = data.enroll;
          $scope.sections[index].enrollLimit = data.enrollLimit;
          $scope.sections[index].enrollment = data.enroll + '/' + data.enrollLimit;
          if(data.enroll == data.enrollLimit) {
            $scope.sections[index].filled = true;
            $scope.sections[index].hide = $scope.hide;
          }
        }
        if(data.waitlist != null)
          $scope.sections[index].waitlist = data.waitlist + '/' + data.waitlistLimit;
        $scope.sections[index].loading = false;
      })
      .error(function(data) {
        console.log('Error: ' + data);
      });
  };

  $scope.toggleHide = function() {
    angular.forEach($scope.sections, function(section, key) {
      if(section.enroll != null && section.enrollLimit != null && section.enroll == section.enrollLimit) {
        section.hide = !$scope.hide;
      }
    });
  };
});

app.controller('AcctCtrl', function($scope, $http) {
  $scope.noEmail = false;
  $scope.noMobile = false;
  $scope.editing = false;
  $scope.saved = {};
  $scope.noSubscriptions = false;
  $scope.subscriptions = [];

  $scope.init = function(subscriptions, email, mobile) {
    console.log(subscriptions);
    console.log(email);
    console.log(mobile);
    
    if(subscriptions.length == 0)
      $scope.noSubscriptions = true;
    else {
      for(var i = 0; i < subscriptions.length; i++) {
        $http.get('/api/section/'+subscriptions[i].ccn)
        .success(function(data) {
          $scope.subscriptions.push(data);
        })
        .error(function(data) {
          console.log('Error: ' + data);
        });
      }
    }
    if(email.length == 0) {
      $scope.email = '';
      $scope.noEmail = true;
    }
    else
      $scope.email = email[0].address;
    if(mobile.length == 0) {
      $scope.mobile = '';
      $scope.noMobile = true;
    }
    else
      $scope.mobile = mobile[0].number;

    $scope.saved.email = email;
    $scope.saved.mobile = mobile;
    $scope.saved.noEmail = $scope.noEmail;
    $scope.saved.noMobile = $scope.noMobile;
  }

  $scope.removeSection = function(ccn) {
    angular.forEach($scope.subscriptions, function(subscription, key) {
      if(subscription.ccn == ccn) {
        $http.post('/unsubscribe/'+ccn)
        .success(function(data) {
          console.log('Unsubscribed from section '+ccn);
        })
        .error(function(data) {
          console.log('Error: ' + data);
        });
        subscription.hide = true;
{'fraction_non_alphanumeric': 0.16018907563025211, 'fraction_numerical': 0.006197478991596638, 'mean_word_length': 2.15787728026534, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 5, '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': '224509', 'n_tokens_mistral': 3081, 'n_tokens_neox': 3027, 'n_words': 484}