<commit_before>var session = {
    userid: null,
	name: null,
	nickname: null,
	email: null,
	isLoggedIn: false,
	loginCount: -1,
	goToClosittOnLogin: false,
	
	init: function(){	   
	   if (sessionInit.active){
	       session.userid = sessionInit.userid;
	       session.email = sessionInit.email;
	       session.name = sessionInit.name;   
	       session.nickname = session.name.split(" ")[0];
	       session.isLoggedIn = true;	       	       
	       session.userDataAvailableCallback();
    	   session.updateLoggedInDropdownMenu();
	       session.loggedInCallback();
	   }else{
	       session.updateLoggedOutDropdownMenu();
	       session.loggedOutCallback();
	   }	   	   

        $(document).on("click", ".loggedoutBtns .register, #getstarted", function(e){
            e.preventDefault();
            $("#signupModalTabBtn").tab('show');
        });       
        
        $(document).on("click", ".loggedoutBtns .login", function(e){
            e.preventDefault();
            session.goToClosittOnLogin = $(e.currentTarget).hasClass("myclositt");                                    
            $("#loginModalTabBtn").tab('show');
        });         
	},
	
	login: function(email, password, remember){
		
		$("#loginModalSubmit").addClass("disabled").val("Logging in...");
		
		$.post( window.HOME_ROOT + "u/login", {e: email, p: password, remember: remember }, function(result){
	          try{
	               var user = JSON.parse(result);
	               
	               if (typeof user == "object" && user.id && user.n && user.e){    			    
     			     session.userid = user.id;
     			     session.name = user.n;
     			     session.nickname = session.name.split(" ")[0];
     			     session.email = user.e;
     			     session.isLoggedIn = true; 			     
     			     session.loggedInCallback(); 
	               }      
	          }catch(e){
	               Messenger.error("The username/password were incorrect! Please try again."); 		               	               
 			  }	
 			  
 			  setTimeout(function(){
 			    $("#loginModalSubmit").removeClass("disabled").val("Login Now")
 			  }, 1000); 			   			    			  
		});				                           	
	},
	
	signup: function(email, password, remember, name, username){
	   
	    $("#signupModalSubmit").addClass("disabled").val("Signing Up...");
	    
		$.post( window.HOME_ROOT + "u/signup", {e: email, n: name, p: password, remember: remember }, function(result){
		      try{
	               var user = JSON.parse(result);
	               
	               if (typeof user == "object" && user.id && user.n && user.e){    			    
                         session.userid = user.id;
          			     session.name = user.n;
          			     session.email = user.e;
          			     session.isLoggedIn = true;
          			     session.loggedInCallback();
	               }         
	          }catch(e){
	               if (result == "Incorrect credentials"){
	                   Messenger.error("There is already a clositt user with that email address in our system!", 8000);
	                   Messenger.error("Go to the login tab and try again. If you forgot your password, use the forgot password link.", 8000);
	                   $("#loginModalTab-inputEmail").val(email);
	               }else{	           
    	               Messenger.error("Whoops! We encountered an issue while signing you up!", 8000);
    	               Messenger.error("Please try again or use the contact link at the bottom of the page to let us know of the issue.", 8000);	               
        		     
        		       var userData = { e: email, n: name, s: "Failed Signup Attempt", t: "issue" };
        		       $.post(window.HOME_ROOT + "e/contact", userData);
	               }
 			  }	
 			  
 			  if (!session.isLoggedIn){
 			        $("#signupModalSubmit").removeClass("disabled").val("Sign Up"); 
 			  }		  
        });
				
	},	
	
	loggedInCallback: function(){	
	    if (sessionStorage.isActiveUser == null || sessionStorage.isActiveUser == "null"){
	       sessionStorage.isActiveUser = true;	       	       
	       	       	      
	       if (session.goToClosittOnLogin){
                location.href = window.CLOSITT_PAGE; 
                return;
           }else if(typeof loggedIn == 'function'){
                session.updateLoggedInDropdownMenu();                
                loggedIn();                
                Messenger.success("Thanks " + session.nickname + "! You are now logged in and ready to go!");
		   }          	
        }else if(typeof loggedIn == 'function'){
            session.updateLoggedInDropdownMenu();
			loggedIn();
			Messenger.success("Thanks " + session.nickname + "! You are now logged in and ready to go!");
		}  
		
		$("#loginSignupModal").modal('hide');
	},
	
	loggedOutCallback: function(){	
        sessionStorage.isActiveUser = null;	                   
	       	   
		if(typeof loggedOut == 'function')
		{
			loggedOut();
		}  		
	},
	
	loggedOutErrorCallback: function(){	   
	    sessionStorage.isActiveUser = null;
	   
		if(typeof loggedOutError == 'function')
		{
			loggedOutError();
		}  		
	},
	
	userDataAvailableCallback: function(){
		if(typeof userDataReady == 'function')
		{
			userDataReady(session.name);
		}   
	},
	
	updateLoggedInDropdownMenu: function(){	 
	    var pageUrl;
	    var linkTitle;
	    var linkClass;
	    var icon;
	    var iconTag;
	    
	    if (location.href.indexOf("clositt") > 0){
	       pageUrl = "#";
	       linkTitle = session.nickname + "'s Account";  
	       icon = "glyphicon glyphicon-user";
	       iconTag = "<span>";
	       linkClass = "user-settings";
	    }else{
	       pageUrl = window.CLOSITT_PAGE;
	       linkTitle = session.nickname + "'s Clositt";
	       icon = "icon-svg20"; // hanger
	       iconTag = "<i>";
	       linkClass = "";
	    }
	     
		$("#loginBtns").html("")	    	
	    	.append( 
        	      $('<li>').append( $('<a>').attr('href', pageUrl).addClass(linkClass)	    	      
        	    	 .append(
        	    	      $("<span>").append( 
        	    	            $(iconTag).addClass(icon)
        	    	      ).append(<commit_msg>fixing issue with account link on clositt.com<commit_after>var session = {
    userid: null,
	name: null,
	nickname: null,
	email: null,
	isLoggedIn: false,
	loginCount: -1,
	goToClosittOnLogin: false,
	
	init: function(){	   
	   if (sessionInit.active){
	       session.userid = sessionInit.userid;
	       session.email = sessionInit.email;
	       session.name = sessionInit.name;   
	       session.nickname = session.name.split(" ")[0];
	       session.isLoggedIn = true;	       	       
	       session.userDataAvailableCallback();
    	   session.updateLoggedInDropdownMenu();
	       session.loggedInCallback();
	   }else{
	       session.updateLoggedOutDropdownMenu();
	       session.loggedOutCallback();
	   }	   	   

        $(document).on("click", ".loggedoutBtns .register, #getstarted", function(e){
            e.preventDefault();
            $("#signupModalTabBtn").tab('show');
        });       
        
        $(document).on("click", ".loggedoutBtns .login", function(e){
            e.preventDefault();
            session.goToClosittOnLogin = $(e.currentTarget).hasClass("myclositt");                                    
            $("#loginModalTabBtn").tab('show');
        });         
	},
	
	login: function(email, password, remember){
		
		$("#loginModalSubmit").addClass("disabled").val("Logging in...");
		
		$.post( window.HOME_ROOT + "u/login", {e: email, p: password, remember: remember }, function(result){
	          try{
	               var user = JSON.parse(result);
	               
	               if (typeof user == "object" && user.id && user.n && user.e){    			    
     			     session.userid = user.id;
     			     session.name = user.n;
     			     session.nickname = session.name.split(" ")[0];
     			     session.email = user.e;
     			     session.isLoggedIn = true; 			     
     			     session.loggedInCallback(); 
	               }      
	          }catch(e){
	               Messenger.error("The username/password were incorrect! Please try again."); 		               	               
 			  }	
 			  
 			  setTimeout(function(){
 			    $("#loginModalSubmit").removeClass("disabled").val("Login Now")
 			  }, 1000); 			   			    			  
		});				                           	
	},
	
	signup: function(email, password, remember, name, username){
	   
	    $("#signupModalSubmit").addClass("disabled").val("Signing Up...");
	    
		$.post( window.HOME_ROOT + "u/signup", {e: email, n: name, p: password, remember: remember }, function(result){
		      try{
	               var user = JSON.parse(result);
	               
	               if (typeof user == "object" && user.id && user.n && user.e){    			    
                         session.userid = user.id;
          			     session.name = user.n;
          			     session.email = user.e;
          			     session.isLoggedIn = true;
          			     session.loggedInCallback();
	               }         
	          }catch(e){
	               if (result == "Incorrect credentials"){
	                   Messenger.error("There is already a clositt user with that email address in our system!", 8000);
	                   Messenger.error("Go to the login tab and try again. If you forgot your password, use the forgot password link.", 8000);
	                   $("#loginModalTab-inputEmail").val(email);
	               }else{	           
    	               Messenger.error("Whoops! We encountered an issue while signing you up!", 8000);
    	               Messenger.error("Please try again or use the contact link at the bottom of the page to let us know of the issue.", 8000);	               
        		     
        		       var userData = { e: email, n: name, s: "Failed Signup Attempt", t: "issue" };
        		       $.post(window.HOME_ROOT + "e/contact", userData);
	               }
 			  }	
 			  
 			  if (!session.isLoggedIn){
 			        $("#signupModalSubmit").removeClass("disabled").val("Sign Up"); 
 			  }		  
        });
				
	},	
	
	loggedInCallback: function(){	
	    if (sessionStorage.isActiveUser == null || sessionStorage.isActiveUser == "null"){
	       sessionStorage.isActiveUser = true;	       	       
	       	       	      
	       if (session.goToClosittOnLogin){
                location.href = window.CLOSITT_PAGE; 
                return;
           }else if(typeof loggedIn == 'function'){
                session.updateLoggedInDropdownMenu();                
                loggedIn();                
                Messenger.success("Thanks " + session.nickname + "! You are now logged in and ready to go!");
		   }          	
        }else if(typeof loggedIn == 'function'){
            session.updateLoggedInDropdownMenu();
			loggedIn();
			Messenger.success("Thanks " + session.nickname + "! You are now logged in and ready to go!");
		}  
		
		$("#loginSignupModal").modal('hide');
	},
	
	loggedOutCallback: function(){	
        sessionStorage.isActiveUser = null;	                   
	       	   
		if(typeof loggedOut == 'function')
		{
			loggedOut();
		}  		
	},
	
	loggedOutErrorCallback: function(){	   
	    sessionStorage.isActiveUser = null;
	   
		if(typeof loggedOutError == 'function')
		{
			loggedOutError();
		}  		
	},
	
	userDataAvailableCallback: function(){
		if(typeof userDataReady == 'function')
		{
			userDataReady(session.name);
		}   
	},
	
	updateLoggedInDropdownMenu: function(){	 
	    var pageUrl;
	    var linkTitle;
	    var linkClass;
	    var icon;
	    var iconTag;
	    
	    if (location.href.indexOf(".com/clositt") > 0){
	       pageUrl = "#";
	       linkTitle = session.nickname + "'s Account";  
	       icon = "glyphicon glyphicon-user";
	       iconTag = "<span>";
	       linkClass = "user-settings";
	    }else{
	       pageUrl = window.CLOSITT_PAGE;
	       linkTitle = session.nickname + "'s Clositt";
	       icon = "icon-svg20"; // hanger
	       iconTag = "<i>";
	       linkClass = "";
	    }
	     
		$("#loginBtns").html("")	    	
	    	.append( 
        	      $('<li>').append( $('<a>').attr('href', pageUrl).addClass(linkClass)	    	      
        	    	 .append(
        	    	      $("<span>").append( 
        	    	            $(iconTag).addClass(icon)
        	    	      ).append(
{'fraction_non_alphanumeric': 0.1305050505050505, 'fraction_numerical': 0.004202020202020202, 'mean_word_length': 1.6478391099700471, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4847812', 'n_tokens_mistral': 3953, 'n_tokens_neox': 3489, 'n_words': 713}