<commit_before>/*
 * Spotmop
 * By <NAME> (http://jamesbarnsley.co.nz)
 * 
 * Integration and authentication with Spotify API
 */
 
 
function checkToken(){

	// if we don't have an authorization_code, go get one
	if( localStorage.authorization_code == null ){        
        return getAuthorizationCode();
	
	// if we don't have a token (or it has expired), go get one
	}else if( localStorage.access_token == null || localStorage.token_expiry < new Date().getTime() ){        
        getNewToken();
        return true;
    }
    
    return true;
};

/*
 * Get a Spotify API authorisation code
*/
function getAuthorizationCode(){
	
    // save current URL, before we redirect
    localStorage.returnURL = window.location.href;
	
    var newURL = '';
    newURL += 'https://accounts.spotify.com/authorize?client_id='+localStorage.settings_clientid;
    newURL += '&redirect_uri='+window.location.protocol+'//'+window.location.host+'/authenticate.php';
    newURL += '&scope=playlist-modify-private%20playlist-modify-public%20playlist-read-private&response_type=code';
    <commit_msg>Forcing dialog visibility for spotify API - allows changing of user<commit_after>/*
 * Spotmop
 * By <NAME> (http://jamesbarnsley.co.nz)
 * 
 * Integration and authentication with Spotify API
 */
 
 
function checkToken(){

	// if we don't have an authorization_code, go get one
	if( localStorage.authorization_code == null ){        
        return getAuthorizationCode();
	
	// if we don't have a token (or it has expired), go get one
	}else if( localStorage.access_token == null || localStorage.token_expiry < new Date().getTime() ){        
        getNewToken();
        return true;
    }
    
    return true;
};

/*
 * Get a Spotify API authorisation code
*/
function getAuthorizationCode(){
	
    // save current URL, before we redirect
    localStorage.returnURL = window.location.href;
	
    var newURL = '';
    newURL += 'https://accounts.spotify.com/authorize?client_id='+localStorage.settings_clientid;
    newURL += '&redirect_uri='+window.location.protocol+'//'+window.location.host+'/authenticate.php';
    newURL += '&scope=playlist-modify-private%20playlist-modify-public%20playlist-read-private&response_type=code';
    newURL += '&show_dialog=true';
    
{'fraction_non_alphanumeric': 0.12814847547503314, 'fraction_numerical': 0.003535130357931949, 'mean_word_length': 3.4305283757338554, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5773072', 'n_tokens_mistral': 712, 'n_tokens_neox': 675, 'n_words': 163}