<commit_before>var marrowApp = angular.module('marrowApp',
                               ['ngRoute', 'marrowApp.services', 'marrowApp.directives', 'marrowApp.utils',
                                'marrowApp.directives.boneList']);

var compareTo = function() { return {
  require: "ngModel",
  scope: { otherModelValue: "=compareTo" },
  link: function(scope, element, attributes, ngModel) {
    ngModel.$validators.compareTo = function(modelValue) {
      return modelValue == scope.otherModelValue;
    };
    scope.$watch("otherModelValue", function() {
      ngModel.$validate();
    });
  }
};};

marrowApp.directive("compareTo", compareTo);

function deleteLink($scope) {
  injector = angular.injector(['ng']);
  $http = injector.get('$http');
  return function (linkid) {
    $http.delete('/api/bones/link/'+linkid).success(function (deleted) {
      deleted = JSON.parse(deleted);
      if (deleted === true) { $scope.update(); }
    });
  };
}

function check_login() {
  injector = angular.injector(['ng']);
  $http = injector.get('$http');
  return $http.get("/api/user/check").success(function(is_loggedon) {
    is_loggedon = JSON.parse(is_loggedon);
    console.log(is_loggedon);
    if (is_loggedon === true) {
      angular.element(document.body).addClass('is-logged-on');
    }
  });
}

marrowApp.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
      when('/login', {templateUrl: 'partials/login.html', controller: 'LoginCtrl'}).
      when('/random', {templateUrl: 'partials/random.html', controller: 'RandomMarrowCtrl'}).
      when('/settings', {templateUrl: 'partials/user-settings.html', controller: 'UserSettingCtrl'}).
      when('/subscriptions', {templateUrl: 'partials/subscription.html', controller: 'SubscriptionCtrl'}).
      when('/', {templateUrl: 'partials/default.html', controller: 'MarrowCtrl'}).
      when('/user/:user', {template: '<div ng-include="templateUrl">Loading...</div>', controller: 'UserCtrl'});
  }
]);

marrowApp.config(['$locationProvider',
  function($locationProvider) {
    $locationProvider.html5Mode(true);
  }
]);

marrowApp.controller('LoginCtrl', function ($scope,$http,$route,$location) {
  $scope.message = '';

  check_login().success(
    function(is_loggedon) {
      is_loggedon = JSON.parse(is_loggedon);
      if (is_loggedon) { $location.url('/');}
  });

  $scope.newuser = function () {
    var username = $scope.username;
    var password = $<PASSWORD>;
    var postObj = {"username":username, "password": password};
    console.log(postObj);
    $http.post("/api/user/add", postObj)
    .success(function(added_user) {
      if (added_user.status === true) {$location.url('/');}
      else {$scope.message = added_user.message;}
    });
  };

  $scope.login = function () {
    var username = $scope.username;
    var password = $<PASSWORD>;

    $http.post("/api/user/login", {"username":username, "password":password})
    .success(
      function (login_succeeded) {
        var el = angular.element(document.querySelector('#login_form'));
        if (login_succeeded.status === true) {$location.url('/');}
        else {$scope.message = login_succeeded.message;}
    });
  };
});

marrowApp.controller('RootCtrl', function ($scope,$http,$location,$route) {
  $scope.url = "";
  $scope.title = "";
  $scope.bone.sectionTitle = "";

  $scope.update = function() {
    return $http.get(getendpoint).success(function(data) {
      $scope.bone.sectionTitle = data.sectionTitle;
      $scope.bone = data.marrow;
    });
  };

  check_login().success(
    function(is_loggedon) {
      is_loggedon = JSON.parse(is_loggedon);
      if (!is_loggedon) { $location.url('/login');}
  }).finally(function (){

    $scope.update().success(function(data) {
      $scope.bone.sectionTitle = data.sectionTitle;
      $scope.bone = data.marrow;
      if (afterGet !== undefined) {afterGet($scope,$http,$route);}
    });

    if (cb !== undefined) {cb($scope,$http,$route);}
  });
});


function controllerFactory(name, getendpoint, cb, afterGet) {
  us = null;
  marrowApp.controller(name, function ($scope,$http,$location,$route, SubscribedTo, UserService) {
    us=UserService;
    $scope.url = "";
    $scope.title = "";
    //$scope.sectionTitle = "";
    $scope.friends = SubscribedTo.get();

    $scope.update = function() {
      var config = {params: $scope.args? $scope.args: {}};
      q = config;
      return $http.get(getendpoint, config).success(function(data) {
        $scope.bone = data;
      });
    };

    check_login().success(
      function(is_loggedon) {
        is_loggedon = JSON.parse(is_loggedon);
        if (!is_loggedon) { $location.url('/login');}
    }).finally(function (){

      $scope.update().success(function(data) {
        $scope.bone = data;
        if (afterGet !== undefined) {afterGet($scope,$http,$route, null, SubscribedTo, UserService);}<commit_msg>Limit list of friends on subscription page<commit_after>var marrowApp = angular.module('marrowApp',
                               ['ngRoute', 'marrowApp.services', 'marrowApp.directives', 'marrowApp.utils',
                                'marrowApp.directives.boneList']);

var compareTo = function() { return {
  require: "ngModel",
  scope: { otherModelValue: "=compareTo" },
  link: function(scope, element, attributes, ngModel) {
    ngModel.$validators.compareTo = function(modelValue) {
      return modelValue == scope.otherModelValue;
    };
    scope.$watch("otherModelValue", function() {
      ngModel.$validate();
    });
  }
};};

marrowApp.directive("compareTo", compareTo);

function deleteLink($scope) {
  injector = angular.injector(['ng']);
  $http = injector.get('$http');
  return function (linkid) {
    $http.delete('/api/bones/link/'+linkid).success(function (deleted) {
      deleted = JSON.parse(deleted);
      if (deleted === true) { $scope.update(); }
    });
  };
}

function check_login() {
  injector = angular.injector(['ng']);
  $http = injector.get('$http');
  return $http.get("/api/user/check").success(function(is_loggedon) {
    is_loggedon = JSON.parse(is_loggedon);
    console.log(is_loggedon);
    if (is_loggedon === true) {
      angular.element(document.body).addClass('is-logged-on');
    }
  });
}

marrowApp.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
      when('/login', {templateUrl: 'partials/login.html', controller: 'LoginCtrl'}).
      when('/random', {templateUrl: 'partials/random.html', controller: 'RandomMarrowCtrl'}).
      when('/settings', {templateUrl: 'partials/user-settings.html', controller: 'UserSettingCtrl'}).
      when('/subscriptions', {templateUrl: 'partials/subscription.html', controller: 'SubscriptionCtrl'}).
      when('/', {templateUrl: 'partials/default.html', controller: 'MarrowCtrl'}).
      when('/user/:user', {template: '<div ng-include="templateUrl">Loading...</div>', controller: 'UserCtrl'});
  }
]);

marrowApp.config(['$locationProvider',
  function($locationProvider) {
    $locationProvider.html5Mode(true);
  }
]);

marrowApp.controller('LoginCtrl', function ($scope,$http,$route,$location) {
  $scope.message = '';

  check_login().success(
    function(is_loggedon) {
      is_loggedon = JSON.parse(is_loggedon);
      if (is_loggedon) { $location.url('/');}
  });

  $scope.newuser = function () {
    var username = $scope.username;
    var password = $scope.password;
    var postObj = {"username":username, "password": password};
    console.log(postObj);
    $http.post("/api/user/add", postObj)
    .success(function(added_user) {
      if (added_user.status === true) {$location.url('/');}
      else {$scope.message = added_user.message;}
    });
  };

  $scope.login = function () {
    var username = $scope.username;
    var password = $scope.password;

    $http.post("/api/user/login", {"username":username, "password":password})
    .success(
      function (login_succeeded) {
        var el = angular.element(document.querySelector('#login_form'));
        if (login_succeeded.status === true) {$location.url('/');}
        else {$scope.message = login_succeeded.message;}
    });
  };
});

marrowApp.controller('RootCtrl', function ($scope,$http,$location,$route) {
  $scope.url = "";
  $scope.title = "";
  $scope.bone.sectionTitle = "";

  $scope.update = function() {
    return $http.get(getendpoint).success(function(data) {
      $scope.bone.sectionTitle = data.sectionTitle;
      $scope.bone = data.marrow;
    });
  };

  check_login().success(
    function(is_loggedon) {
      is_loggedon = JSON.parse(is_loggedon);
      if (!is_loggedon) { $location.url('/login');}
  }).finally(function (){

    $scope.update().success(function(data) {
      $scope.bone.sectionTitle = data.sectionTitle;
      $scope.bone = data.marrow;
      if (afterGet !== undefined) {afterGet($scope,$http,$route);}
    });

    if (cb !== undefined) {cb($scope,$http,$route);}
  });
});


function controllerFactory(name, getendpoint, cb, afterGet) {
  us = null;
  marrowApp.controller(name, function ($scope,$http,$location,$route, SubscribedTo, UserService) {
    us=UserService;
    $scope.url = "";
    $scope.title = "";
    //$scope.sectionTitle = "";
    $scope.friends = {data: []};

    $scope.update = function() {
      var config = {params: $scope.args? $scope.args: {}};
      q = config;
      return $http.get(getendpoint, config).success(function(data) {
        $scope.bone = data;
      });
    };

    check_login().success(
      function(is_loggedon) {
        is_loggedon = JSON.parse(is_loggedon);
        if (!is_loggedon) { $location.url('/login');}
    }).finally(function (){

      $scope.update().success(function(data) {
        $scope.bone = data;

        var following_set = Object.create(null);
        $scope.bone.marrow.map(function(o) {
          if (!(o.poster in following_set)) {
            following_set[o.poster] = true;
            $scope.friends.data.push(o.poster);
          }
        });

        if (afterGet !== undefined) {afterGet($scope,$http,$route, null, SubscribedTo, UserService);}
{'fraction_non_alphanumeric': 0.18254993540693631, 'fraction_numerical': 0.00019874788830368678, 'mean_word_length': 3.5008944543828266, 'pattern_counts': {'":': 8, '<': 9, '<?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': '5496612', 'n_tokens_mistral': 3201, 'n_tokens_neox': 3168, 'n_words': 506}