<commit_before>var app = angular.module("TwitchApp", ["ngRoute", "ngAnimate"]);
app.config(function($routeProvider, $locationProvider) {
	$routeProvider.when("/", {
		templateUrl: "partials/main_page.html",
		controller: "MainPageController"
	});
	$routeProvider.when("/search-list", {
		templateUrl: "partials/quality_list.html",
		controller: "StreamQualityListController"
	});
	$locationProvider.html5Mode(true);
})
app.controller('StreamSearchController', function($rootScope, $scope, $http, $location){
	$rootScope.streamer = null;
	$scope.checkField = function() {
		var channel = $rootScope.streamer;
		if(channel !== null) {
			channel = $scope.parseChannelName(channel);
			if(channel.length > 0) {
				console.log("Input not empty");
				$scope.getHlsStream(channel.toLowerCase());
			}
		}
	}
	$rootScope.getHlsStream = function(channel) {
		$http.get("/api/get-channel", {
			params: {
				"channel": channel
			}
		}).then(function(res) {
			console.log("Received");
			console.log(res);
			$rootScope.streamArray = res.data;
			console.log($rootScope.streamArray);
			$location.path("/search-list");
		}, function(err) {
			console.log(err);
		});
	}
	$scope.parseChannelName = function(name) {
		var n = name.lastIndexOf('/');
		if(n != -1 && n < name.length) {
			return name.substr(n + 1);
		}
		return name;
	}
	$rootScope.showLoadingView = function(show) {
		console.log(show);
		if(show === true) {
			$(".loading").css("display", "block");
			$(".main-view").css("display", "none");
		} else {
			$(".loading").css("display", "none");
			$(".main-view").css("display", "block");
		}
	}
	$(".search-input").keypress(function(e) {
		var key = e.which;
		if(key == 13) {
			$(".search-btn").click();
			return false;
		}
	})
})
app.controller('MainPageController', function($rootScope, $scope, $http){
	$scope.channelLimit = 0;
	$scope.popularChannelArray = [];
	$scope.showLoading = false;
	$scope.loadPopularStream = function() {
		console.log($scope.channelLimit + 25);
		if($scope.channelLimit + 25 <= 100) {
			$http.get("/api/get-popular-channel", {
				params: {
					"limit": $scope.channelLimit
				}
			}).then(function(res) {
				$scope.popularChannelArray = $scope.popularChannelArray.concat(res.data);
				$scope.channelLimit = $scope.channelLimit + 15;
				updateGrid = true;
				console.log(res.data);
			});
		}
	}
	$scope.loadPopularStream();
	$scope.checkChannel = function(name) {
		console.log(name);
		if(name !== null && name !== undefined) {
			$scope.showLoading = true;
			$rootScope.streamer = name;
			$rootScope.getHlsStream($rootScope.streamer);
		}
	}
	$scope.substringUrl = function(url) {
		return url.length > 50 ? url.substring(0,50) + "...": url;
	}
	var updateGrid = true;
	$(window).scroll(function() {
		console.log("SCROLL");
	    if(($(window).scrollTop() >= $(document).height() - $(window).height() - 200) && updateGrid && $scope.showLoading) {
	    	console.log("BOTTOM");
	    	updateGrid = false;
	    	$scope.loadPopularStream();
	    }
	});
})
app.controller('StreamQualityListController', function($rootScope, $scope, $location){
	$scope.isError = function() {
		if(typeof $rootScope.streamArray != "undefined")
			return $rootScope.streamArray.error;
		else
			$location.path("/");
	}
	$scope.substringUrl = function(url) {
		return url.length > 100 ? url.substring(0,100) + "...": url;
	}
})<commit_msg>Fix page behaviour<commit_after>var app = angular.module("TwitchApp", ["ngRoute", "ngAnimate"]);
app.config(function($routeProvider, $locationProvider) {
	$routeProvider.when("/", {
		templateUrl: "partials/main_page.html",
		controller: "MainPageController"
	});
	$routeProvider.when("/search-list", {
		templateUrl: "partials/quality_list.html",
		controller: "StreamQualityListController"
	});
	$locationProvider.html5Mode(true);
})
app.controller('StreamSearchController', function($rootScope, $scope, $http, $location){
	$rootScope.streamer = null;
	$scope.checkField = function() {
		var channel = $rootScope.streamer;
		if(channel !== null) {
			channel = $scope.parseChannelName(channel);
			if(channel.length > 0) {
				console.log("Input not empty " + channel);
				$scope.getHlsStream(channel.toLowerCase());
			}
		}
	}
	$rootScope.getHlsStream = function(channel) {
		$http.get("/api/get-channel", {
			params: {
				"channel": channel
			}
		}).then(function(res) {
			console.log("Received");
			console.log(res);
			$rootScope.streamArray = res.data;
			console.log($rootScope.streamArray);
			$location.path("/search-list");
		}, function(err) {
			console.log(err);
		});
	}
	$scope.parseChannelName = function(name) {
		var n = name.lastIndexOf('/');
		if(n != -1 && n < name.length) {
			return name.substr(n + 1);
		}
		return name;
	}
	$rootScope.showLoadingView = function(show) {
		console.log(show);
		if(show === true) {
			$(".loading").css("display", "block");
			$(".main-view").css("display", "none");
		} else {
			$(".loading").css("display", "none");
			$(".main-view").css("display", "block");
		}
	}
	$(".search-input").keypress(function(e) {
		var key = e.which;
		if(key == 13) {
			$(".search-btn").click();
			return false;
		}
	})
})
app.controller('MainPageController', function($rootScope, $scope, $http){
	$scope.channelLimit = 0;
	$scope.popularChannelArray = [];
	$scope.showLoading = false;
	$scope.loadPopularStream = function() {
		console.log($scope.channelLimit + 25);
		if($scope.channelLimit + 25 <= 100) {
			$http.get("/api/get-popular-channel", {
				params: {
					"limit": $scope.channelLimit
				}
			}).then(function(res) {
				$scope.popularChannelArray = $scope.popularChannelArray.concat(res.data);
				$scope.channelLimit = $scope.channelLimit + 15;
				updateGrid = true;
				console.log(res.data);
			});
		}
	}
	$scope.loadPopularStream();
	$scope.checkChannel = function(name) {
		console.log(name);
		if(name !== null && name !== undefined) {
			$scope.showLoading = true;
			$rootScope.streamer = name;
			$rootScope.getHlsStream($rootScope.streamer);
		}
	}
	$scope.substringUrl = function(url) {
		return url.length > 50 ? url.substring(0,50) + "...": url;
	}
	var updateGrid = true;
	$(window).scroll(function() {
		console.log("SCROLL");
	    if(($(window).scrollTop() >= $(document).height() - $(window).height() - 200) && updateGrid) {
	    	console.log("BOTTOM");
	    	updateGrid = false;
	    	$scope.loadPopularStream();
	    }
	});
})
app.controller('StreamQualityListController', function($rootScope, $scope, $location){
	$scope.isError = function() {
		if(typeof $rootScope.streamArray != "undefined")
			return $rootScope.streamArray.error;
		else
			$location.path("/");
	}
	$scope.substringUrl = function(url) {
		return url.length > 100 ? url.substring(0,100) + "...": url;
	}
})
{'fraction_non_alphanumeric': 0.1955166270783848, 'fraction_numerical': 0.009204275534441805, 'mean_word_length': 4.0999242997728995, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 11, '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': '1027930', 'n_tokens_mistral': 2602, 'n_tokens_neox': 2301, 'n_words': 354}