<commit_before>(function () {
	'use strict';

	function MainView() {
		this.container = null; // jQuery object
		this.ninjaMarginTop = 0;
		this.ninjaMarginLeft = -30;
	}
	
	function load(container) {
                $.get("http://morriswinkler.koding.io/getSpace", function(data){
                    //alert(data.Channel);
                    container.find('.mission').hide();
                    container.find('.team-up').show();
                            var string = "";
                            var games = data.Games;
                            for(var i = 0; i < data.Space.length; i++){
                                string += "<li id="+data.Space[i].UserId+">"+data.Space[i].UserName+"</li>";
                            }
                            $("#all-online-users ul").empty();
                            $("#all-online-users ul").append(string);
                            string = "";
                            for(var i = 0; i < games.length; i++){
                                string += "<li class='game'>Game " + (i+1) + "</li><ul class='room-user-list'>";
                                for(var j = 0; j < games[i].Player.length; j++){
                                    string += "<li id='" + games[i].Player[j].UserId + "'>" + games[i].Player[j].UserName + "</li>";
                                }
                                string += '</ul><button id="btn-join-room-'+games[i].GameId+'" class="btn btn-primary btn-sm btn-join-room">Join</button>';
                            }
                            $("#available-games ul").empty();
                            $("#available-games ul").append(string);
                            $("[id^=btn-join-room-]").on('click', function() {
                                container.find('.team-up').hide();
                                container.find('.room-master').show();
                                var game_id = $(this).attr('id').replace('btn-join-room-', '');
                                $.get("http://morriswinkler.koding.io/joinGame?userId="+ROOT.user_id+"&gameId="+game_id, function(data) {
                                    string = "";
                                    for(var i = 0; i < data.Player.length; i++) {
                                        string += "<li>"+data.Player[i].UserName+"</li>";
                                    }
                                    $("#room-users ul").empty();
                                    $("#room-users ul").append(string);
                                });
                            });
                });
            }

	MainView.prototype.setup = function(jQueryContainerObject) {
		if (arguments.length) {
			this.container = jQueryContainerObject;
			this.container.hide();

			var ninjaMarginLeftPx = String(this.ninjaMarginLeft) + 'px';
			this.container.find('.ninja>img').css('margin-left', ninjaMarginLeftPx);

			var that = this;
			preloadimages(['media/main-view-ninja.svg'], function(images) {
				that.onWindowResize();
			});

			this.container.find('#main-view-modal').modal({
				keyboard: false,
				backdrop: 'static',
				show: false
			});

			// Hide all main view modal parts except first one
			this.container.find('.mission').hide();
			this.container.find('.team-up').hide();
			this.container.find('.room-master').hide();
			this.container.find('.room-client').hide();

			this.container.find('.story button').click(function(){
				that.container.find('.story').hide();
				that.container.find('.mission').show();
			});

			this.container.find('.mission .btn-back').click(function(){
				that.container.find('.mission').hide();
				that.container.find('.story').show();
			});
            
			this.container.find('.mission .btn-forward').click(function(){
				//alert();
				if (ROOT.user_id === undefined){
					$.ajax({
						url: "http://morriswinkler.koding.io/newUser", 
						data: { userName: prompt("Please insert your username") },
						success: function (data){
							ROOT.user_id = data.Space[0].UserId;
							ROOT.user_name = data.Space[0].UserName;
						}
					});
				}
				else{
				load(that.container);
				}
			});

			this.container.find('.team-up .btn-forward').click(function(){<commit_msg>Add loading team-up view right after submitting user name prompt<commit_after>(function () {
	'use strict';

	function MainView() {
		this.container = null; // jQuery object
		this.ninjaMarginTop = 0;
		this.ninjaMarginLeft = -30;
	}
	
	function load(container) {
                $.get("http://morriswinkler.koding.io/getSpace", function(data){
                    //alert(data.Channel);
                    container.find('.mission').hide();
                    container.find('.team-up').show();
                            var string = "";
                            var games = data.Games;
                            for(var i = 0; i < data.Space.length; i++){
                                string += "<li id="+data.Space[i].UserId+">"+data.Space[i].UserName+"</li>";
                            }
                            $("#all-online-users ul").empty();
                            $("#all-online-users ul").append(string);
                            string = "";
                            for(var i = 0; i < games.length; i++){
                                string += "<li class='game'>Game " + (i+1) + "</li><ul class='room-user-list'>";
                                for(var j = 0; j < games[i].Player.length; j++){
                                    string += "<li id='" + games[i].Player[j].UserId + "'>" + games[i].Player[j].UserName + "</li>";
                                }
                                string += '</ul><button id="btn-join-room-'+games[i].GameId+'" class="btn btn-primary btn-sm btn-join-room">Join</button>';
                            }
                            $("#available-games ul").empty();
                            $("#available-games ul").append(string);
                            $("[id^=btn-join-room-]").on('click', function() {
                                container.find('.team-up').hide();
                                container.find('.room-master').show();
                                var game_id = $(this).attr('id').replace('btn-join-room-', '');
                                $.get("http://morriswinkler.koding.io/joinGame?userId="+ROOT.user_id+"&gameId="+game_id, function(data) {
                                    string = "";
                                    for(var i = 0; i < data.Player.length; i++) {
                                        string += "<li>"+data.Player[i].UserName+"</li>";
                                    }
                                    $("#room-users ul").empty();
                                    $("#room-users ul").append(string);
                                });
                            });
                });
            }

	MainView.prototype.setup = function(jQueryContainerObject) {
		if (arguments.length) {
			this.container = jQueryContainerObject;
			this.container.hide();

			var ninjaMarginLeftPx = String(this.ninjaMarginLeft) + 'px';
			this.container.find('.ninja>img').css('margin-left', ninjaMarginLeftPx);

			var that = this;
			preloadimages(['media/main-view-ninja.svg'], function(images) {
				that.onWindowResize();
			});

			this.container.find('#main-view-modal').modal({
				keyboard: false,
				backdrop: 'static',
				show: false
			});

			// Hide all main view modal parts except first one
			this.container.find('.mission').hide();
			this.container.find('.team-up').hide();
			this.container.find('.room-master').hide();
			this.container.find('.room-client').hide();

			this.container.find('.story button').click(function(){
				that.container.find('.story').hide();
				that.container.find('.mission').show();
			});

			this.container.find('.mission .btn-back').click(function(){
				that.container.find('.mission').hide();
				that.container.find('.story').show();
			});
            
			this.container.find('.mission .btn-forward').click(function(){
				//alert();
				if (ROOT.user_id === undefined){
					$.ajax({
						url: "http://morriswinkler.koding.io/newUser", 
						data: { userName: prompt("Please insert your username") },
						success: function (data){
							ROOT.user_id = data.Space[0].UserId;
							ROOT.user_name = data.Space[0].UserName;
							load(that.container);
						}
					});
				}
				else{
				load(that.container);
				}
			});

			this.container.find('.team-up .btn-forward').click(function(){
{'fraction_non_alphanumeric': 0.1751286850725316, 'fraction_numerical': 0.002339728591483388, 'mean_word_length': 1.5263002364066194, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4855938', 'n_tokens_mistral': 2613, 'n_tokens_neox': 2297, 'n_words': 347}