<commit_before>var currentWindow = $.login;

$.closeBtn.addEventListener('click', function(e) {
	currentWindow.close();
});

$.termsLabel.addEventListener('click', function(e) {
	var win = Ti.UI.createWindow();
	win.add(Ti.UI.createWebView({
		url : (ENV_DEV || ENV_TEST)?'http://192.168.0.2:8080/terms.html':'http://www.licky.co/terms.html'
	}));
	currentWindow.openWindow(win);
});

if(OS_IOS){
	$.termsLabel.attributedString = Ti.UI.iOS.createAttributedString({
		text : L('termsAndPrivacy'),
		attributes:[{
			type : Ti.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
			value : Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
			range : [L('termsAndPrivacy').indexOf('이용약관'),'이용약관'.length]
		},
		{
			type : Ti.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
			value : Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
			range : [L('termsAndPrivacy').indexOf('개인정보 취급정책'),'개인정보 취급정책'.length]
		}
		]
	});
}

// currentWindow.addEventListener('swipe', function(e){
	// if( e.direction === 'down'){
		// currentWindow.close();
	// }
// });


var fbHandler = function(e){
	Ti.API.info("fb: "+ JSON.stringify(e));
	if (e.type == 'login') {
        var token = this.accessToken;
        Ti.API.info('Logged in ' + token);
        AG.Cloud.SocialIntegrations.externalAccountLogin({
		    type: 'facebook',
		    token: token
		}, function (e) {
			Ti.API.info(e);
		    if (e.success) {
		        var user = e.users[0];
		        AG.settings.save('cloudSessionId', AG.Cloud.sessionId);
		        AG.loggedInUser.save(user);
		        
		        subscribePushChannel('comment');
		        
				$.fbLogin.title = L("facebookConnect");
				currentWindow.close();
				
		    } else {
		        alert('Error:\n' +
		            ((e.error && e.message) || JSON.stringify(e)));
		     	$.fbLogin.title = L("facebookConnect");
		    }
		});
    }else{
    }
};

$.fbLogin.addEventListener('click', function(e) {
	$.fbLogin.title = L('facebookConnecting');
	
	if(OS_IOS){
		AG.facebook.authorize({
			forceDialogAuth : false
		});
	}else{
		AG.Cloud.Users.login({
		    login: 'admin',
		    password: '<PASSWORD>'
		}, function (e) {
		    if (e.success) {
		        var user = e.users[0];
		        
		        AG.settings.save('cloudSessionId', AG.Cloud.sessionId);
		        AG.loggedInUser.save(user);<commit_msg>login 컨트롤로를 닫을 때 null로 재지정해서 생기는 문제 예외처리<commit_after>var currentWindow = $.login;

$.closeBtn.addEventListener('click', function(e) {
	currentWindow.close();
});

$.termsLabel.addEventListener('click', function(e) {
	var win = Ti.UI.createWindow();
	win.add(Ti.UI.createWebView({
		url : (ENV_DEV || ENV_TEST)?'http://192.168.0.2:8080/terms.html':'http://www.licky.co/terms.html'
	}));
	currentWindow.openWindow(win);
});

if(OS_IOS){
	$.termsLabel.attributedString = Ti.UI.iOS.createAttributedString({
		text : L('termsAndPrivacy'),
		attributes:[{
			type : Ti.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
			value : Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
			range : [L('termsAndPrivacy').indexOf('이용약관'),'이용약관'.length]
		},
		{
			type : Ti.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
			value : Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
			range : [L('termsAndPrivacy').indexOf('개인정보 취급정책'),'개인정보 취급정책'.length]
		}
		]
	});
}

// currentWindow.addEventListener('swipe', function(e){
	// if( e.direction === 'down'){
		// currentWindow.close();
	// }
// });


var fbHandler = function(e){
	Ti.API.info("fb: "+ JSON.stringify(e));
	if (e.type == 'login') {
        var token = this.accessToken;
        Ti.API.info('Logged in ' + token);
        AG.Cloud.SocialIntegrations.externalAccountLogin({
		    type: 'facebook',
		    token: token
		}, function (e) {
			Ti.API.info(e);
		    if (e.success) {
		        var user = e.users[0];
		        AG.settings.save('cloudSessionId', AG.Cloud.sessionId);
		        AG.loggedInUser.save(user);
		        
		        subscribePushChannel('comment');
		        
				//$.fbLogin.title = L("facebookConnect");
				currentWindow.close();
				
		    } else {
		        alert('Error:\n' +
		            ((e.error && e.message) || JSON.stringify(e)));
		     	$.fbLogin.title = L("facebookConnect");
		    }
		});
    }else{
    }
};

$.fbLogin.addEventListener('click', function(e) {
	$.fbLogin.title = L('facebookConnecting');
	
	if(OS_IOS){
		AG.facebook.authorize({
			forceDialogAuth : false
		});
	}else{
		AG.Cloud.Users.login({
		    login: 'admin',
		    password: '<PASSWORD>'
		}, function (e) {
		    if (e.success) {
		        var user = e.users[0];
		        
		        AG.settings.save('cloudSessionId', AG.Cloud.sessionId);
		        AG.loggedInUser.save(user);
{'fraction_non_alphanumeric': 0.1812622843415593, 'fraction_numerical': 0.006114872242847783, 'mean_word_length': 2.938091143594153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '7356882', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1715, 'n_words': 223}