<commit_before>var args = arguments[0] || {}, userModel = args.userModel;

if (userModel) {
	// 다른 사람 프로필
	Ti.API.info("[profile.js] another user");
} else if(AG.isLogIn()){
	Ti.API.info("[profile.js] loggedInUser");
	userModel = AG.loggedInUser;
} else{
	//에러 방지 차원에서 빈모델 생성
	userModel = Alloy.createModel('user');
}


// title & label 변경
var isMe = userModel.get('id') == AG.loggedInUser.get('id');
$.profile.title = isMe?L('me'):userModel.get('first_name');
$.foodRow.title = isMe?L('myLicks'):String.format(L('someoneLicks'),userModel.get('first_name'));


$.getView().addEventListener('focus', function(e) {
	$.setProperties();
});

$.mainContent.addEventListener('scroll', _.throttle(function(e){
	// $.profileBannerImage.setHeight( 212.5 - e.y);
	$.profileBannerImage.animate({
		duration: 5,
		height: 212.5 - e.y});
	$.controlBar.animate({
		duration: 5,
		top: 182.5 - e.y});
}, 5));

$.foodRow.addEventListener('click', function(e) {
	AG.utils.openController(AG.mainTabGroup.activeTab, "someonePhotoList", {
		userModel : userModel
		// photoModel : photoCol.get(e.itemId) //clicked Model
	});
});


$.settingDialog.addEventListener('click', function(e) {
	// alert(e);
	if (e.index === 0) {
		// AG.settings.get('cloudSessionId') ? AG.loginController.logout() : AG.loginController.requireLogin();
		AG.loginController.logout(function(e){
			AG.mainTabGroup.setActiveTab(0);
		});
	}
});
$.profileSettingBtn.addEventListener('click', function(e) {
	$.settingDialog.show();
});

//로그인 상태 변경시
AG.settings.on('change:cloudSessionId', loginChangeHandler);

//로그인된 사용자 모델(local에 저장한 properties model) 변경시
AG.loggedInUser.on('change', function(model) {

});

// $.loginBtn.addEventListener('click', function(e) {
	// AG.settings.get('cloudSessionId') ? AG.loginController.logout() : AG.loginController.requireLogin();
// });
function loginChangeHandler(changedValue) {
	if(changedValue && !userModel.get('id')){
		userModel = AG.loggedInUser;
	}
	
	// 최초에 이미 로그인 되어 있을 경우에 대한 처리
	if (AG.isLogIn() || userModel.get('id')) {
		// $.resetClass($.loginBtn, 'afterLogin');
		$.menuTable.setVisible(true);
		$.name.setVisible(true);
		$.wireForBtnImg.setVisible(true);
		$.profileSettingBtn.setVisible(true);
	} else {
		// $.resetClass($.loginBtn, 'beforeLogin');
		$.menuTable.setVisible(false);
		$.name.setVisible(false);
		$.wireForBtnImg.setVisible(false);
		$.profileSettingBtn.setVisible(false);
		
		$.profileBannerImage.setImage(null);
		$.profileImage.setImage( $.profileImage.getDefaultImage() );
	}
}
loginChangeHandler();

function showCamera() {
	AG.loginController.requireLogin(function() {
		Alloy.createController('cameraOveray', {
			collection : photoCol
		}).showCamera();
	});
}

exports.setProperties = function() {
	if (!userModel.get('id')) {
		return;
	}

	var fb_id = userModel.get('external_accounts')[0].external_id;
	$.name.text = userModel.get('first_name');
	$.profileImage.image = String.format("https://graph.facebook.com/%s/picture?width=%d&height=%d", fb_id, 140, 140);
	AG.facebook.requestWithGraphPath(fb_id, {
		fields : 'cover'
	}, "GET", function(e) {
		// alert(e);
		if (e.success) {
			// alert(JSON.parse(e.result).cover.source);
			$.profileBannerImage.image = JSON.parse(e.result).cover.source;
		}
	});
};<commit_msg>자신의 profile이 아닐경우 setting 버튼 감추기<commit_after>var args = arguments[0] || {}, userModel = args.userModel;

if (userModel) {
	// 다른 사람 프로필
	Ti.API.info("[profile.js] another user");
} else if(AG.isLogIn()){
	Ti.API.info("[profile.js] loggedInUser");
	userModel = AG.loggedInUser;
} else{
	//에러 방지 차원에서 빈모델 생성
	userModel = Alloy.createModel('user');
}


// title & label 변경
var isMe = userModel.get('id') == AG.loggedInUser.get('id');
$.profile.title = isMe?L('me'):userModel.get('first_name');
$.foodRow.title = isMe?L('myLicks'):String.format(L('someoneLicks'),userModel.get('first_name'));

$.getView().addEventListener('focus', function(e) {
	$.setProperties();
});

$.mainContent.addEventListener('scroll', _.throttle(function(e){
	// $.profileBannerImage.setHeight( 212.5 - e.y);
	$.profileBannerImage.animate({
		duration: 5,
		height: 212.5 - e.y});
	$.controlBar.animate({
		duration: 5,
		top: 182.5 - e.y});
}, 5));

$.foodRow.addEventListener('click', function(e) {
	AG.utils.openController(AG.mainTabGroup.activeTab, "someonePhotoList", {
		userModel : userModel
		// photoModel : photoCol.get(e.itemId) //clicked Model
	});
});


$.settingDialog.addEventListener('click', function(e) {
	// alert(e);
	if (e.index === 0) {
		// AG.settings.get('cloudSessionId') ? AG.loginController.logout() : AG.loginController.requireLogin();
		AG.loginController.logout(function(e){
			AG.mainTabGroup.setActiveTab(0);
		});
	}
});
$.profileSettingBtn.addEventListener('click', function(e) {
	$.settingDialog.show();
});

//로그인 상태 변경시
AG.settings.on('change:cloudSessionId', loginChangeHandler);

//로그인된 사용자 모델(local에 저장한 properties model) 변경시
AG.loggedInUser.on('change', function(model) {

});

// $.loginBtn.addEventListener('click', function(e) {
	// AG.settings.get('cloudSessionId') ? AG.loginController.logout() : AG.loginController.requireLogin();
// });
function loginChangeHandler(changedValue) {
	if(changedValue && !userModel.get('id')){
		userModel = AG.loggedInUser;
	}
	
	// 최초에 이미 로그인 되어 있을 경우에 대한 처리
	if (AG.isLogIn() || userModel.get('id')) {
		// $.resetClass($.loginBtn, 'afterLogin');
		$.menuTable.setVisible(true);
		$.name.setVisible(true);
		
	} else {
		// $.resetClass($.loginBtn, 'beforeLogin');
		$.menuTable.setVisible(false);
		$.name.setVisible(false);
		$.wireForBtnImg.setVisible(false);
		$.profileSettingBtn.setVisible(false);
		
		$.profileBannerImage.setImage(null);
		$.profileImage.setImage( $.profileImage.getDefaultImage() );
	}
	
	isMe = userModel.get('id') == AG.loggedInUser.get('id');
	$.wireForBtnImg.visible = isMe;
	$.profileSettingBtn.visible = isMe;
}
loginChangeHandler();

function showCamera() {
	AG.loginController.requireLogin(function() {
		Alloy.createController('cameraOveray', {
			collection : photoCol
		}).showCamera();
	});
}

exports.setProperties = function() {
	if (!userModel.get('id')) {
		return;
	}

	var fb_id = userModel.get('external_accounts')[0].external_id;
	$.name.text = userModel.get('first_name');
	$.profileImage.image = String.format("https://graph.facebook.com/%s/picture?width=%d&height=%d", fb_id, 140, 140);
	AG.facebook.requestWithGraphPath(fb_id, {
		fields : 'cover'
	}, "GET", function(e) {
		// alert(e);
		if (e.success) {
			// alert(JSON.parse(e.result).cover.source);
			$.profileBannerImage.image = JSON.parse(e.result).cover.source;
		}
	});
};
{'fraction_non_alphanumeric': 0.1967287596547024, 'fraction_numerical': 0.007572315614114796, 'mean_word_length': 4.798068481123793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1521577', 'n_tokens_mistral': 2578, 'n_tokens_neox': 2534, 'n_words': 348}