jQuery(function ($) {
reload_page_function();
$j("#nav > li.c-item").hover(function(){
$j(this).addClass("c-item-hover");
}, function(){
$j(this).removeClass("c-item-hover");
});
$j(".channel_follow").hover(function(){
$j(this).addClass("channel_follow_hover");
}, function(){
$j(this).removeClass("channel_follow_hover");
});
$j("#nav > li.more > a.c-item").click(function(){
var follow_channels = $j('#follow_channels');
if (follow_channels.css('display') == 'none') {
follow_channels.show();
$j('#nav-wrap').hide();
}
return false;
});
$j("a#follow_channels_close").click(function(){
var follow_channels = $j('#follow_channels');
if ($j('#nav-wrap').css('display') == 'none') {
follow_channels.hide();
$j('#nav-wrap').show();
}
return false;
});
RegEvent_TopSearch();
RegEvent_FollowButtonClick();
RegEvent_ChannelWarningHover();
RegEvent_MedalHover();
});
/* cookies */
function set_cookie(n,v,d) {
var today = new Date();
var expire = new Date();
if (d==null || d==0) d=1;
expire.setTime(today.getTime() + 3600000*24*d);
document.cookie = n+"="+escape(v) + ";path=/;expires="+expire.toGMTString();
}
function get_cookie(n) {
var start = document.cookie.indexOf(n + "=");
var len = start + n.length + 1;
if ((!start) && (n != document.cookie.substring(0, n.length))) {
return null;
}
if (start == -1) return null;
var end = document.cookie.indexOf(";", len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len, end));
}
function delete_cookie(name,path,domain) {
if (get_cookie(name)) document.cookie = name + "=" +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
/* toggle */
function toggleBlock(id) {
var block = $j('#'+id);
$j(block).toggle();
return false;
}
function toggleButton(id) {
var button = $j('#'+id);
if ($j(button).attr("disabled")) {
$j(button).removeAttr("disabled");
} else {
$j(button).attr("disabled","true");
}
return false;
}
/* Ultilities */
function setFocus(id) {
$j("#" + id).focus();
}
/* Show/hide comment outline */
function toggleSubFeeds(feedId,show) {
if (show == 1) {
$j("#ftoggler-close-"+feedId).css("display","inline");
$j("#ftoggler-open-"+feedId).css("display","none");
$j("#fshort-"+feedId).hide();
} else {
$j("#ftoggler-open-"+feedId).css("display","inline");
$j("#ftoggler-close-"+feedId).css("display","none");
$j("#fshort-"+feedId).show();
}
$j("#fdetails-"+feedId).slideToggle("fast");
return false;
}
/* ajax paging */
function ajaxPaging(action,filter,page,return_id,query){
$j("#ajaxLoading").show();
if(query==null) {
query="";
}else{
query+="&";
}
if(filter!=null)
query += "filter="+filter+"&";
query += "page=" + page;
$j.post(my_base_url+my_pligg_base+"/"+action, query,
function(result) {
ajaxPagingCallback(result,return_id);
}
);
return false;
}
function ajaxPagingCallback(result,return_id){
$j("#"+return_id).html(result);
$j("#ajaxLoading").hide();
}
/* Link vote */
var is_vote = 1;
function vote(lId,value,type) {
var ok = 1;
if(value < 0) {
if (window.confirm('Báo link nội dung xấu?')) {
ok = 1;
} else {
ok = 0;
}
}
if (ok && is_vote) {
is_vote = 0;
$j("#ajaxLoading").show();
var query = "id=" + lId + "&value=" + value;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkVote", query,
function(result) {
is_vote = 1;
if (/ERROR:/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if (value < 0 && type != "full") {
$j("#news_item_summary_"+lId).fadeOut("slow");
} else if (value < 0 && type == "full") {
$j("#link-"+lId+"-badded").show();
$j("#link-"+lId+"-voter").remove();
$j("#link-"+lId+"-report").remove();
} else {
$j("#link-"+lId+"-votes").html(result);
$j("#link-"+lId+"-voter").attr("class","voted").html('Hot');
$j("#link-"+lId+"-report").remove();
}
}
$j("#ajaxLoading").hide();
}
);
}
return false;
}
/**
* Friend
*/
var add_friend_active = 0;
function addFriend(user_id,return_id,intro_id){
if(add_friend_active == 0) {
$j("#ajaxLoading").show();
add_friend_active = 1;
var query = "to_id=" + user_id;
$j.post(my_base_url+my_pligg_base+"/ajaxFriendFollow", query,
function(result) {
if (/ERROR:/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if(return_id == 'user-follow') {
$j("#"+return_id).html("Bỏ quan tâm ");
} else if(return_id == 'mini-follow') {
$j("#"+return_id).html("Bỏ quan tâm ");
}else {
if(intro_id){
$j("#"+return_id).html("Bỏ quan tâm ");
} else {
$j("#"+return_id).html("Đã quan tâm ").removeClass("btn-rounded");
}
}
}
$j("#ajaxLoading").hide();
add_friend_active = 0;
}
);
} else {
window.alert('Hệ thống đang xử lý, vui lòng đợi trong giây lát!');
}
}
var remove_friend_active = 0;
function removeFriend(user_id, return_id, intro_id){
if(window.confirm('Bạn có chắc chắn muốn bỏ quan tâm người này?')){
if(remove_friend_active == 0){
$j("#ajaxLoading").show();
remove_friend_active = 1;
var query = "followed_id=" + user_id;
$j.post(my_base_url+my_pligg_base+"/ajaxFriendUnfollow", query,
function(result) {
if (/ERROR:/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if(return_id == 'user_suggest_follow') {
$j("#"+return_id).html("Quan tâm ");
} else if (return_id == 'unfollow_user_page'){
$j("#"+return_id).html("
").attr("id","follow").addClass("btn-rounded");
} else {
if(intro_id){
$j("#"+return_id).html("Quan tâm ");
} else {
$j("#"+return_id).html("Quan tâm ");
}
}
}
$j("#ajaxLoading").hide();
remove_friend_active = 0;
}
);
} else {
window.alert('Hệ thống đang xử lý, vui lòng đợi trong giây lát!');
}
}
}
// Ajax validator
function checkField(type, fId, rId) {
$j("#ajaxLoading").show();
var value = $j("#"+fId).val();
var query = "type="+encodeURIComponent(type)+"&value="+encodeURIComponent(value);
$j("#"+rId).html("");
$j.post(my_base_url+my_pligg_base+"/ajaxValidator", query,
function(result) {
checkFieldCallback(rId,result);
}
);
}
function checkFieldCallback(rId,result){
if (/ERROR:/.test(result)) {
result = result.substring(7, result.length);
$j("#"+rId).css("color","red");
$j("#"+rId).html(result);
} else {
$j("#"+rId).css("color","green");
$j("#"+rId).html(result);
}
$j("#ajaxLoading").hide();
}
//Ajax channel validator
var check_valid_channel_active = 0;
function validate_channel_name(type,cId,rId1,rId2){
if(check_valid_channel_active == 0){
var value = $j("#"+cId).val();
if(value.length >= 3 && value.length <= 50){
check_valid_channel_active = 1;
var query = "type="+encodeURIComponent(type)+"&value="+encodeURIComponent(value);
if(type == 'name'){
$j("#"+rId1).val("");
$j("#"+rId2).html("");
}else{
$j("#"+rId1).html("");
$j("#"+rId2).html("");
}
$j.post(my_base_url+my_pligg_base+"/ajaxValidatorChannel", query,
function(result) {
if(type == 'name'){
$j("#"+rId1).val(result);
$j("#"+rId2).html(result);
}else{
if (/ERROR:/.test(result)) {
result = result.substring(7, result.length);
$j("#"+rId1).html(result);
$j("#"+rId2).html("nick-kênh");
}else{
$j("#"+rId2).html(result);
}
}
check_valid_channel_active = 0;
}
);
}
}
}
/* Close announcement */
function ajaxCloseAnnouncement(rId){
$j.post(my_base_url+my_pligg_base+"/ajaxCloseAnnouncement", null,
function(result) {
$j("#"+rId).remove();
}
);
return false;
}
function ajaxCloseNewFriends(rId,type){
$j("#ajaxLoading").show();
var query = "type=" + type;
$j.post(my_base_url+my_pligg_base+"/ajaxCloseNewFriends", query,
function(result) {
$j("#"+rId).remove();
$j("#ajaxLoading").hide();
}
);
return false;
}
function ajaxCloseLandingPage(rId,para){
$j("#ajaxLoading").show();
var query = "para=" + para;
$j.post(my_base_url+my_pligg_base+"/ajaxCloseLandingPage", query,
function(result) {
$j("#"+rId).remove();
$j("#ajaxLoading").hide();
}
);
return false;
}
/* Ham lay toa do cua 1 doi tuong (usage: var x = $j("#id").x();) */
$j.fn.x = function(n) {
var result = null;
this.each(function() {
var o = this;
if (n === undefined) {
var x = 0;
if (o.offsetParent) {
while (o.offsetParent) {
x += o.offsetLeft;
o = o.offsetParent;
}
}
if (result === null) result = x;
else result = Math.min(result, x);
} else o.style.left = n + 'px';
});
return result;
};
$j.fn.y = function(n) {
var result = null;
this.each(function() {
var o = this;
if (n === undefined) {
var y = 0;
if (o.offsetParent) {
while (o.offsetParent) {
y += o.offsetTop;
o = o.offsetParent;
}
}
if (result === null) result = y;
else result = Math.min(result, y);
} else o.style.top = n + 'px';
});
return result;
};
/* show/hide dropdown menu */
function hideDiv(id){
$j('#'+id).css("visibility","hidden");
$j('#'+id).css("display","none");
}
function showDiv(id){
$j('#'+id).css("visibility","visible");
$j('#'+id).css("display","block");
}
/* Show/Hide user info */
function showUserInfo(obj, u, id) {
var infoId = "user-info-"+id;
setTimeout(function(){showDiv(infoId)},400);
var html = 'Loading...
';// inner div
if ($j("#"+infoId).html()=="") {// if not loaded yet then call ajax to load
$j("#"+infoId).append(html);
var innerId = 'inner-' + id + u;
var query = "user_id=" + u;
$j.post(my_base_url+my_pligg_base+"/ajaxMiniProfile", query,
function(result) {
$j("#"+innerId).html(result);
}
);
}
return false;
}
var timerId = 0;
function hideUserInfo(id) {
var infoId = "user-info-" + id;
timerId = setTimeout(function(){hideDiv(infoId)},400);
return false;
}
function holdUserInfo(id) {
var infoId = "user-info-" + id;
if ($j("#"+infoId).css('display') == 'block') {
clearTimeout(timerId);
}
return false;
}
/* Show/Hide embedded video */
function showEmbedVideo(lId){
var toggler = $j("#show-embed-video-"+lId);
var togglerbtn = $j("#btn-show-embed-video-"+lId);
var vidDiv = $j("#embed-video-"+lId);
if(vidDiv.css("display")=="none"){
var loaded = 0;
var loading = ""
+ "
"
+ "
"
$j(vidDiv).html(loading);
$j(vidDiv).show();
if(loaded==0) {
$j.post(my_base_url+my_pligg_base+"/ajaxVideoGetEmbedCode", "id="+lId,
function(result) {
vidDiv.html(result);
$j(toggler).html(" ");
$j(toggler).attr('title','Stop');
$j(togglerbtn).html('Tắt');
loaded = 1;
}
);
}
} else {
$j(vidDiv).hide();
$j(toggler).html(" ");
$j(toggler).attr('title','Play');
$j(togglerbtn).html('Bật');
}
return false;
}
/* Use in Submit forms */
function selectThumb(thumb){
$j("#thumb_path").val(thumb);
}
/* Copy to clipboard function */
function copyToClipboard(obj) {
var ref = $j(obj);
ref.select();
var copiedText = ref.val();
$j.copy(copiedText);
var mess = "Đã copy! Bấm Ctrl+V để chia sẻ link với bạn bè. ";
var position = ref.offset();
var top = parseInt(position.top) + parseInt(ref.height());
$j('#clipboard_alert').remove();
$j('body').append(""+mess+"
");
$j('#clipboard_alert').fadeTo("slow",1,function(){
$j(this).fadeTo(2000,0, function(){$j(this).remove();});
});
ref.select();
}
/* Save a link */
function ajaxLinkSaved(id,return_id){
var query ='id='+id;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkSaved", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
return false;
} else{
$j("#"+return_id).html(result);
}
}
);
return false;
}
function ajaxDeleteLinkSaved(linkid){
var query = 'id='+linkid;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkSavedDelete", query,
function(result) {
$j("#fav-link-"+linkid).remove();
}
);
return false;
}
/* Load a box on sidebar using ajax */
function ajaxSidebarLoadBox(action,query,rid) {
$j("#"+rid).html("");
$j.post(my_base_url+my_pligg_base+action, query,
function(result) {
$j("#"+rid).html(result);
}
);
return false;
}
function ajaxSidebarLoadBoxTopicMore(action,query,rid) {
$j("#"+rid).html("");
$j.post(my_base_url+my_pligg_base+action, query,
function(result) {
eval("var result="+result);
$j("#"+rid).html(result.sidebar_topic_more);
$j("#"+rid + "_button").html(result.button_topic_more);
$j("#"+rid + "_button2").html(result.button_topic_more2);
}
);
return false;
}
var bitly_link = '';
function ajaxSidebarLoadBoxBitly(action,query,rid) {
$j.getJSON(my_base_url+my_pligg_base+action,query,
function(data) {
$j("#"+rid).append('('+data.link_bitly.count+' clicks )');
bitly_link = data.link_bitly.href;
}
);
return false;
}
// Taskbar
function open_notification_box(id_box, id_icon) {
var id_box_obj = $j(id_box);
var id_icon_obj = $j(id_icon);
if (id_box_obj.css('display') == 'none') {
id_box_obj.show();
$j('#notifications_count').hide();
//Load ajax for notification read
var number_new = $j('#notifications_count > strong').html();
if(number_new > 0){
var query="";
$j.get(my_base_url+my_pligg_base+"/ajaxNotificationRead", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
} else {
$j('#notifications_count > strong').html('0');
}
}
);
}
id_icon_obj.addClass('notify_icon_active');
} else {
id_box_obj.hide();
id_icon_obj.removeClass('notify_icon_active');
}
}
function active_notifyicon() {
$j(".notify_icon").mouseover(function(){
$j(this).addClass('notify_icon_hover');
})
.mouseout(function() {
$j(this).removeClass('notify_icon_hover');
});
}
function active_icon_hover() {
// Left blast form
$j("#presence_blast_tab").mouseover(function(){
$j(this).addClass('presence_blast_hover');
})
.mouseout(function() {
$j(this).removeClass('presence_blast_hover');
});
// Right write note
$j("#presence_bar_right > .note").mouseover(function(){
$j(this).addClass('note_hover');
})
.mouseout(function() {
$j(this).removeClass('note_hover');
});
// Right filter
$j("#presence_filter_tab").mouseover(function(){
$j(this).addClass('presence_filter_hover');
})
.mouseout(function() {
$j(this).removeClass('presence_filter_hover');
});
// Right blast
$j("#presence_bar_right > .blast").mouseover(function(){
$j(this).addClass('hover');
})
.mouseout(function() {
$j(this).removeClass('hover');
});
$j("#presence_bar_left > .taskbar-item").mouseover(function(){
$j(this).addClass('taskbar-item-hover');
})
.mouseout(function() {
$j(this).removeClass('taskbar-item-hover');
});
}
function show_blast_update_form(){
var update_blast_box = $j("#presence_blast");
var target = $j("#presence_blast_tab");
var content = $j("#presence_blast_form_content");
if (update_blast_box.css('display') == 'none') {
content.addClass('presence_blast_loading');
content.html(" ");
$j.getJSON(my_base_url+my_pligg_base+"/ajaxBlastTaskbar?action=get",
function(data){
if(/ERROR/.test(data.error)) {
window.alert(data.error);
} else {
var html = "";
html += "";
html += "
"
html += "
" + data.blast_title + "
";
html += "
";
html += "
";
/*if(data.has_twitter.length!=0){
html += "Tweet blast này
";
html += "";
} else {
html += " />Tweet blast này ";
}
}*/
html += "
";
content.removeClass('presence_blast_loading');
content.html(html);
}
});
update_blast_box.show();
target.addClass('presence_blast_active');
} else {
update_blast_box.hide();
target.removeClass('presence_blast_active');
}
return false;
}
function hide_blast_update_form(){
$j("#presence_blast").hide();
$j("#presence_blast_tab").removeClass('presence_blast_active');
return false;
}
function show_filter_link(){
var filter_link = $j("#presence_filter");
var target = $j("#presence_filter_tab");
if (filter_link.css('display') == 'none') {
filter_link.show();
target.addClass('presence_filter_active');
} else {
filter_link.hide();
target.removeClass('presence_filter_active');
}
}
function update_blast_taskbar(){
var blast = "";
$j("#ajaxLoading").show();
$j('#presence_blast_button').attr("disabled","disabled");
blast += $j("#presence_blast_content").val();
var query = "blast=" + encodeURIComponent(blast);
$j.post(my_base_url+my_pligg_base+"/ajaxBlast", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
show_blast_update_form();
}
$j("#ajaxLoading").hide();
$j('#presence_blast_button').attr("disabled","");
}
);
return false;
}
function ajaxGetNotification() {
var query="";
$j.get(my_base_url+my_pligg_base+"/ajaxNotification", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
} else {
eval("var result="+result);
if (result.count_new > 0) {
$j('#notifications_count > strong').html(result.count_new);
if ($j('.notifications_box').css('display') == 'none') {
$j('#notifications_count').show();
}
}
$j("div.notifications_list").html(result.notification);
setTimeout(function(){ajaxGetNotification()},30000);
}
}
);
return false;
}
function active_typingicon() {
var indicator = $j("#typing_indicator");
var mode = get_cookie('linkhay_typing');
$j(".typing_icon").mouseover(function(){
$j(this).addClass('typing_icon_hover');
})
.mouseout(function() {
$j(this).removeClass('typing_icon_hover');
});
if (mode == 'V') {
setMethod(0);
indicator.attr("src",my_base_url+my_pligg_base+"/templates/images/icons/typing/vi.gif");
} else {
set_cookie('linkhay_typing','E',29);
setMethod(-1);
}
$j(".typing_icon").click(function() {
mode = get_cookie('linkhay_typing');
if (mode != null) {
if (mode == 'E') {
set_cookie('linkhay_typing','V',29);
setMethod(0);
indicator.attr("src",my_base_url+my_pligg_base+"/templates/images/icons/typing/vi.gif");
} else {
set_cookie('linkhay_typing','E',29);
setMethod(-1);
indicator.attr("src",my_base_url+my_pligg_base+"/templates/images/icons/typing/en.gif");
}
}
});
}
/* Share link via Blast */
function share2Blast() {
var blast = "";
var attach = "";
var link_origin = "";
var r = "no";
var tp = "";
var t = "no";
$j("#blast-loading").show();
$j('#blast-submit').attr("disabled","true");
blast += $j("#blast_content").val();
attach += $j("#link_url").val();
link_origin += $j("#link_origin").val();
if($j("#tweet_this:checked").val() != null) {
t = "yes";
tp = $j("#twitter_pass").val();
}
if($j("#pwd_remember:checked").val() != null){
r = "yes";
}
var query = "blast=" + encodeURIComponent(blast) + "&link_origin=" + encodeURIComponent(link_origin) + "&attach=" + encodeURIComponent(attach) + "&t=" + t + "&remember=" + r + "&tp=" + encodeURIComponent(tp);
$j.post(my_base_url+my_pligg_base+"/ajaxBlast", query,
function(result) {
share2BlastCallback(result);
}
);
return false;
}
function share2BlastCallback(result){
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
$j('#blast-submit').removeAttr("disabled");
} else {
$j('#share-message').append("Chia sẻ thành công! ");
$j('#share-message').addClass("message");
$j('#share-message').fadeTo("slow",1,function() {
$j('#share-message').fadeTo(1000,0, function() {tb_remove();});
});
}
$j("#blast-loading").hide();
return false;
}
//Xu ly su kien chuot
function onPressAccount(id, e){
var keynum;
if(window.event){
keynum = e.keyCode;
}else if(e.which){
keynum = e.which;
}
if( keynum == 13 && id == 1 ) { // Truong hop tao tai khoan moi
$j("#linkhay_email_post").focus();
}else if( keynum == 13 && id == 2 ){
ajaxChangeName(1);
}else if(keynum == 13 && id == 3){ // Truong hop noi voi account tren linkhay
$j("#existing_password").focus();
}else if(keynum == 13 && id == 4){
onJoinAccount(1);
}else if(keynum == 13 && id == 5){ // Truong hop cap nhat Email
updateEmailBig4();
}else if(keynum == 13 && id == 6){ // Truong hop noi voi account tren linkhay
$j("#existing_password").focus();
}else if(keynum == 13 && id == 7){
onJoinAccount(2);
}
}
//Cap nhat Email Big4
function updateEmailBig4(){
var linkhay_open_id = "";
var linkhay_user_id = "";
var linkhay_service_id = "";
var linkhay_email_post = "";
linkhay_open_id += $j( "#linkhay_open_id" ).val();
linkhay_user_id += $j( "#linkhay_user_id" ).val();
linkhay_service_id += $j( "#linkhay_service_id" ).val();
linkhay_email_post += $j( "#linkhay_email_post" ).val();
$j("#submit-loading").show();
$j('#linkhay_name_submit').attr("disabled","true");
var query = "linkhay_email_post=" + encodeURIComponent(linkhay_email_post) + "&linkhay_open_id=" + encodeURIComponent(linkhay_open_id) + "&linkhay_user_id=" + encodeURIComponent(linkhay_user_id) + "&linkhay_service_id=" + encodeURIComponent(linkhay_service_id);
$j.post(my_base_url + my_pligg_base + "/ajaxUpdateEmailBig4", query,
function(result) {
ajaxUpdateEmailCallback(result);
}, "json"
);
return false;
}
function ajaxUpdateEmailCallback(result){
if( result['error_u'] == 1 ){
$j("#error_username").html( result['str_u'] );
$j("#error_username").css("display", "block");
$j("#error_email").html("");
$j("#error_email").css("display", "none");
}else if( result['error_e'] == 2 ){
$j("#error_username").html("");
$j("#error_username").css("display", "none");
$j("#error_email").html( result['str_e'] );
$j("#error_email").css("display", "block");
}else {
//Redirect
$j("#submit-loading").hide();
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
}
$j('#linkhay_name_submit').removeAttr("disabled");
$j("#submit-loading").hide();
return false;
}
//Submit form cho phep join voi account linkhay
function onJoinAccount(type){
if(type == 1){
$j("#submit-loading-join").show();
$j('#join_account').attr("disabled","true");
$j("#show_connect").submit();
}else{
$j("#submit-loading-join-2").show();
$j('#join_account_2').attr("disabled","true");
$j("#show_connect_2").submit();
}
}
/* Change name by Facebook and Twitter and openid registeration */
function ajaxChangeName(cancel) {
var linkhay_username = "";
var linkhay_fullname = "";
var linkhay_avatar = "";
var linkhay_open_id = "";
var linkhay_service = "";
var linkhay_twitter_onnet = "";
var linkhay_publicemail = "";
var linkhay_sessionkey = "";
var linkhay_email = "";
$j("#submit-loading").show();
$j('#linkhay_name_submit').attr("disabled","true");
linkhay_username += $j( "#linkhay_username_post" ).val();
linkhay_fullname += $j( "#linkhay_fullname" ).val();
linkhay_avatar += $j( "#linkhay_avatar" ).val();
linkhay_open_id += $j( "#linkhay_open_id" ).val();
linkhay_service += $j( "#linkhay_service" ).val();
linkhay_sessionkey += $j( "#linkhay_sessionkey" ).val();
linkhay_publicemail += $j( "#linkhay_publicemail" ).val();
linkhay_twitter_onnet += $j( "#linkhay_twitter_onnet" ).val();
linkhay_email += $j( "#linkhay_email_post" ).val();
if(cancel == 0) linkhay_username = "";
var query = "linkhay_email="+ encodeURIComponent(linkhay_email) +"&linkhay_username=" + encodeURIComponent(linkhay_username) + "&linkhay_fullname=" + encodeURIComponent(linkhay_fullname) + "&linkhay_avatar=" + encodeURIComponent(linkhay_avatar) + "&linkhay_open_id=" + encodeURIComponent(linkhay_open_id) + "&linkhay_service=" + encodeURIComponent(linkhay_service)+ "&linkhay_twitter_onnet=" + encodeURIComponent(linkhay_twitter_onnet) + "&linkhay_publicemail=" + encodeURIComponent(linkhay_publicemail) + "&linkhay_sessionkey=" + encodeURIComponent(linkhay_sessionkey);
$j.post(my_base_url+my_pligg_base+"/ajaxChangeName", query,
function(result) {
ajaxChangeNameCallback(result);
}, "json"
);
return false;
}
/*Callback for change name by Facebook and Twitter and openid registeration*/
function ajaxChangeNameCallback(result){
if( result['error_u'] == 1 && result['error_e'] == 2 ){
$j("#error_username").html( result['str_u'] );
$j("#error_username").css("display", "block");
$j("#error_email").html( result['str_e'] );
$j("#error_email").css("display", "block");
}else if( result['error_u'] == 1 ){
$j("#error_username").html( result['str_u'] );
$j("#error_username").css("display", "block");
$j("#error_email").html("");
$j("#error_email").css("display", "none");
}else if( result['error_e'] == 2 ){
$j("#error_username").html("");
$j("#error_username").css("display", "none");
$j("#error_email").html( result['str_e'] );
$j("#error_email").css("display", "block");
}else {
$j('#connect-message').append("Tạo tài khoản thành công! ");
$j('#connect-message').fadeTo("slow",1,function() {
$j('#connect-message').fadeTo(1000,0, function() {tb_remove();});
});
//Redirect
$j("#submit-loading").hide();
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
}
$j('#linkhay_name_submit').removeAttr("disabled");
$j("#submit-loading").hide();
return false;
}
/*Intro user for my friend */
function introFriend(intro_id) {
var blast = "";
$j("#blast-loading").show();
blast += $j("#blast_content_intro").val();
var query = "blast=" + encodeURIComponent(blast) + "&intro_id=" + intro_id;
//var query = "";
$j.post(my_base_url+my_pligg_base+"/ajaxFriendIntro", query,
function(result) {
//share2BlastCallback(result);
}
);
return false;
}
// Add suggested onNet Profile
function addSuggestedProfile(s_id,p_name,p_acc) {
$j("#ajaxLoading").show();
$j.getJSON(my_base_url+my_pligg_base+"/ajaxOnNetProfileAdd?name="+p_name+"&url="+p_acc+"&service_id="+s_id,
function(data) {
$j.each(data.object, function(i,obj) {
if(/ERROR/.test(obj.error)) {
window.alert(obj.msg);
} else {
$j("#suggested_profile_"+s_id).remove();
}
$j("#ajaxLoading").hide();
});
});
return false;
}
// Cancel suggested onNet Profile
function cancelSuggestedProfile(s_id) {
$j("#ajaxLoading").show();
var query = "service_id=" + s_id;
$j.post(my_base_url+my_pligg_base+"/ajaxOnNetProfileCancel", query,
function(result) {
$j("#suggested_profile_"+s_id).remove();
$j("#ajaxLoading").hide();
}
);
return false;
}
// Hide box suggested onNet Profile
function hideSuggestedProfile() {
$j("#ajaxLoading").show();
var query = "";
$j.post(my_base_url+my_pligg_base+"/ajaxOnNetProfileHideBox", query,
function(result) {
$j("#onnet_box_profile").remove();
$j("#ajaxLoading").hide();
}
);
return false;
}
// Check all contact item checkbox in invite from email page
function checkAll(value) {
$j("form#invite_email_form * input[type='checkbox']").each(function() {
this.checked = (value==1) ? true:false;
});
return false;
}
//For new submit link
function ignore_filter_comment_author(userid){
$j('#user_filter_'+userid).find(".checkbox").addClass("checkbox_click");
var query = 'userid=' + userid;
$j.post(my_base_url+my_pligg_base+"/ajaxCommentSubcribeAuthor", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else{
$j('#user_filter_'+userid).fadeOut();
}
}
);
return false;
}
//For filter user & domain
function ignore_filter_user(userid){
$j('#user_filter_'+userid).find(".checkbox").addClass("checkbox_click");
var query = 'userid=' + userid;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkSubcribeAuthor", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else{
$j('#user_filter_'+userid).fadeOut();
}
}
);
return false;
}
function ignore_filter_domain(domain_id,domain){
$j('#domain_filter_'+domain_id).find(".checkbox").addClass("checkbox_click");
var query = 'domain=' + domain;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkSubcribeDomain", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else{
$j('#domain_filter_'+domain_id).fadeOut();
}
}
);
return false;
}
//Show all profile onnet
function showAllProfileOnnet(prefix_string,total_id){
for(i=0;i<=total_id;i++){
$j(prefix_string + i).css('display','block');
}
$j('#user_profile_onnet_edit_link').css('display','');
$j('#show_profile_onnet_detail').css('display','none');
}
//Subcribe Channel
function ajax_channel_subcribe(channel_id,from_service,repending){
$j("#ajaxLoading").show();
var query = "id=" + channel_id;
if(repending != null) query = query + "&repending=" + repending;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelSubcribe", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if(from_service){
if(from_service == "mini-profile"){
$j('#mini-channel-profile-' + channel_id).html('');
}else if(from_service == "repending"){
$j("#btn_channel_repending").remove();
}else if(from_service == "mini-profile-repending"){
$j('#mini-channel-repending-' + channel_id).remove();
}
} else {
$j("#btn_channel_subcribe").html("Đã quan tâm ");
$j("#btn_channel_subcribe").removeClass('btn-rounded');
}
}
$j("#ajaxLoading").hide();
}
);
return false;
}
//Unsubcribe Channel
function ajax_channel_unsubcribe(channel_id,from_service){
if(window.confirm('Bạn muốn bỏ quan tâm tin tức từ kênh này?')){
$j("#ajaxLoading").show();
var query = "id=" + channel_id;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelUnsubcribe", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if(from_service) {
if(from_service == "mini-profile"){
$j('#mini-channel-profile-' + channel_id).html(' ');
}else if(from_service == "homepage"){
$j('#homepage_follow_channel_' + channel_id).remove();
$j('#li_small_homepage_' + channel_id).remove();
}
} else {
$j("#btn_channel_unsubcribe").remove();
}
}
$j("#ajaxLoading").hide();
}
);
}
return false;
}
//Admin process Unsubcribe channel
function ajax_admin_channel_unsubcribe(userid,channel_id){
if (window.confirm('Bạn muốn loại bỏ người dùng này?')) {
$j("#ajaxLoading").show();
var query = "id=" + channel_id + "&uid=" + userid;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelModUnsubcriber", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
$j("#subcribers_channel_set_unsubcribe_" + userid).addClass("greenie").html("Đã loại bỏ");
$j("#subcribers_channel_set_admin_" + userid).remove();
}
$j("#ajaxLoading").hide();
}
);
}
return false;
}
//Admin process recover user
function ajax_admin_channel_recover(userid,channel_id){
$j("#ajaxLoading").show();
var query = "id=" + channel_id + "&uid=" + userid;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelModRecover", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
$j("#subcribers_channel_recover_" + userid).addClass("greenie").html("Đã khôi phục");
}
$j("#ajaxLoading").hide();
}
);
return false;
}
//Admin process pending user
function ajax_admin_channel_pending(userid,channel_id,status){
$j("#ajaxLoading").show();
var query = "id=" + channel_id + "&uid=" + userid + "&status=" + status;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelModPending", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if(status == 1){
$j("#subcribers_channel_accept_" + userid).addClass("greenie").html("Đã chấp nhận");
$j("#subcribers_channel_ignore_" + userid).remove();
}else{
$j("#subcribers_channel_accept_" + userid).addClass("greenie").html("Đã loại bỏ");
$j("#subcribers_channel_ignore_" + userid).remove();
}
}
$j("#ajaxLoading").hide();
}
);
return false;
}
//Admin process set admin channel
function ajax_admin_channel_set_admin(userid,channel_id,type){
$j("#ajaxLoading").show();
var query = "id=" + channel_id + "&uid=" + userid + "&type=" + type;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelModSetAdmin", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
$j("#subcribers_channel_set_admin_" + userid).addClass("greenie");
if(type == 'add'){
$j("#subcribers_channel_set_admin_" + userid).html("Đã là Mod");
$j("#subcribers_channel_set_unsubcribe_" + userid).remove();
}else if(type == 'minus'){
$j("#subcribers_channel_unset_admin_" + userid).html("Đã bỏ Mod");
}
}
$j("#ajaxLoading").hide();
}
);
return false;
}
//For channel
var timerShowChannel = new Array();
var timerHideChannel = new Array();
function showChannelInfo(inputid,obj,channelid){
var channel_hover_div = $j("#"+inputid+channelid);
var left = $j(obj).offset().left - 5;
var top = $j(obj).offset().top + 60;
if (channel_hover_div.length > 0) {
channel_hover_div.css({top: top, left: left});
timerShowChannel[channelid] = setTimeout(function(){showDiv(inputid+channelid)},500);
} else {
var div_hover = $j("
").attr({"id":"channel_hover_"+channelid, "class":"channel-hover channel-hover-load"});
div_hover.html('Loading...
');
div_hover.css({top: top, left: left});
//console.log(actualWidth);
$j("body").append(div_hover);
var query = "channelid=" + channelid;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelProfile", query,
function(result) {
//$j("#"+inputid+channelid).html(result);
div_hover.removeClass("channel-hover-load");
div_hover.html(result);
div_hover.mouseover(function(){
holdChannelInfo('channel_hover_',channelid);
});
div_hover.mouseout(function(){
hideChannelInfo('channel_hover_',channelid);
});
//Reload thickbox
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
);
}
return false;
}
function hideChannelInfo(inputid,channelid){
clearTimeout(timerShowChannel[channelid]);
timerHideChannel[channelid] = setTimeout(function(){hideDiv(inputid+channelid)},100);
return false;
}
function holdChannelInfo(inputid,channelid) {
clearTimeout(timerHideChannel[channelid]);
if ($j("#"+inputid+channelid).css('display') == 'none') {
showDiv(inputid+channelid);
}
return false;
}
function share_twitter(content) {
var content_share = "";
content_share = (bitly_link.length > 0) ? content + " " + bitly_link : content;
window.open("http://twitter.com/home?status=" + encodeURIComponent(content_share));
}
function share_facebook() {
u = location.href;
t = document.title;
window.open("http://www.facebook.com/share.php?u=" + encodeURIComponent(u) + "&t=" + encodeURIComponent(t));
}
//Ajax sort subcribe channel
function ajax_sort_subcriber_channel(channel_id,filter){
$j("#ajaxLoading").show();
var page_normal = $j("#page_normal").val();
var query = "channel_id=" + channel_id + "&filter=" + filter + "&page="+page_normal;
$j.post(my_base_url+my_pligg_base+"/ajaxChannelSubcriberSort", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
//Process result
if(filter == "az"){
$j("#filter_menu").html('Mới | A-Z ');
}else if(filter == "newest"){
$j("#filter_menu").html('Mới | A-Z ');
}
$j("#list_normal_subcriber_channel").html(result);
}
$j("#ajaxLoading").hide();
}
);
return false;
}
function ajax_mailbox_agree(message_id,channel_id,sender_name,sender_url,channel_name,channel_url){
//Process
var query = "id=" + channel_id + "&message_id=" + message_id;
$j("#invite_loading_" + message_id).show();
$j.post(my_base_url+my_pligg_base+"/ajaxChannelSubcribe", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
$j("#invite_loading_" + message_id).hide();
window.alert(result);
} else{
//Inner HTML
$j('#mailbox_invite_channel_' + message_id).addClass('message');
$j('#mailbox_invite_channel_' + message_id).html('');
$j("#invite_loading_" + message_id).hide();
}
}
);
return false;
}
function ajax_mailbox_disagree(message_id,sender_name,sender_url,channel_name,channel_url){
//Process
var query = "message_id=" + message_id;
$j("#invite_loading_" + message_id).show();
$j.post(my_base_url+my_pligg_base+"/ajaxChannelIgnoreInvite", query,
function(result) {
//Inner HTML
$j('#mailbox_invite_channel_' + message_id).addClass('message');
$j('#mailbox_invite_channel_' + message_id).html('');
$j("#invite_loading_" + message_id).hide();
}
);
return false;
}
function reload_page_function(){
active_hover_news_item();
$j("#account-link").unbind().hover(function(){
$j(this).addClass("username_hover");
}, function() {
$j(this).removeClass("username_hover");
});
// share hover
$j(".share-storylist").unbind().hover(function() {
$j(this).addClass("show-share-list");
$j(this).find(".share_url").select();
}, function() {
$j(this).removeClass("show-share-list");
});
$j(".channel_order").hover(function() {
$j(this).addClass("channel-item-hover");
}, function() {
$j(this).removeClass("channel-item-hover");
});
// Filter link click
$j(".report > a").unbind().click(function() {
var linkId = $j(this).attr("id").split("-")[2];
if ($j("#report-dropdown-menu-"+linkId).css("display")=="none") {
$j("#report-dropdown-menu-"+linkId).show();
} else {
$j("#report-dropdown-menu-"+linkId).hide();
}
return false;
});
// Edit link click
$j(".manage > a").unbind().click(function() {
var drop_down_menu = $j(this).parent().eq(0).find(".report-dropdown-menu");
if (drop_down_menu.css("display")=="none") {
drop_down_menu.show();
} else {
drop_down_menu.hide();
}
return false;
});
$j("a.news-report").unbind().click(function() {
var linkId = $j(this).attr("id").replace("hide-link-","");
var page = $j(this).attr("rel");
if (page=="link-detail") {
vote(linkId,-1,'full');
} else {
vote(linkId,-1,'summary');
}
});
$j("a.comment-count").hover(function() {
$j(this).parents(":first").find("span.icon").css("background-position","0 -17px");
});
$j(".comment-block > .icon").click(function() {
var parent = $j(this).parents(":first");
if (parent.hasClass("recent-comment-expand")) {
parent.removeClass("recent-comment-expand");
$j(this).parents(":first").find("span.icon").css("background-position","0 0");
} else {
parent.addClass("recent-comment-expand");
}
});
//function hover for sponsored item
$j(".lhsponsored").mouseover(function(){
$j(this).addClass('lhsponsored-hover');
}).mouseout(function(){
$j(this).removeClass('lhsponsored-hover');
});
var filterMsg = 'Link đã được lọc. Refesh lại trang để cập nhật thay đổi.
Click vào đây để quản lý lọc tin.
';
$j("a.filter-link").unbind().click(function() {
if (window.confirm('Bạn muốn lọc bỏ link này?')) {
$j("#ajaxLoading").show();
var linkId = $j(this).attr("id").split("-")[2];
var page = $j(this).attr("rel");
var query = "id=" + linkId;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkIgnore", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if (page=="link-detail") {
$j("#news_item_summary_"+linkId).remove();
} else {
$j("#news_item_summary_"+linkId).html(filterMsg);
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
$j("#ajaxLoading").hide();
}
);
}
$j(".report-dropdown-menu").hide();
return false;
});
$j("a.filter-domain").unbind().click(function() {
if (window.confirm('Bạn muốn lọc bỏ những link từ nguồn này?')) {
$j("#ajaxLoading").show();
var linkId = $j(this).attr("id").split("-")[2];
var page = $j(this).attr("rel");
var query = "id=" + linkId;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkIgnoreDomain", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if (page=="link-detail") {
$j("#news_item_summary_"+linkId).remove();
} else {
$j("#news_item_summary_"+linkId).html(filterMsg);
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
$j("#ajaxLoading").hide();
}
);
}
$j(".report-dropdown-menu").hide();
return false;
});
$j("a.filter-author").unbind().click(function() {
if (window.confirm('Bạn muốn lọc bỏ những link được gửi bởi người này?')) {
$j("#ajaxLoading").show();
var linkId = $j(this).attr("id").split("-")[2];
var page = $j(this).attr("rel");
var query = "id=" + linkId;
$j.post(my_base_url+my_pligg_base+"/ajaxLinkIgnoreAuthor", query,
function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if (page=="link-detail") {
$j("#news_item_summary_"+linkId).remove();
} else {
$j("#news_item_summary_"+linkId).html(filterMsg);
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
$j("#ajaxLoading").hide();
}
);
}
$j(".report-dropdown-menu").hide();
return false;
});
}
function active_hover_news_item(){
$j("div.news-item").mouseover(function(){
$j(this).addClass('news-item-hover');
}).mouseout(function(){
$j(this).removeClass('news-item-hover');
});
}
function RegEvent_TopSearch(){
//Search
var default_search_text = 'Gõ để vào kênh';
var hasData = false;
var childs = null;
var childidx = -1;
jQuery('#search_keyword').focus(function() {
if ($j(this).val() == default_search_text) {
$j(this).attr('value', '');
}
if ($j(this).val() != default_search_text) {
$j(this).select();
}
}).blur(function() {
if ($j(this).val() == '') {
$j(this).attr('value', default_search_text);
}
}).keyup(function(e) {
var obj = $j(this);
var query = $j.trim(obj.val());
if(query.length == 0) {
// Hide the suggestion box.
$j('#suggestions').hide();
$j('#universal_search').css({'background-position':'left -196px'});
} else {
if (query.length >= 1) {
if ((e.which != 13) && (e.which != 37) && (e.which != 38) && (e.which != 39) && (e.which != 40)) {
var url = my_pligg_base + '/ajaxChannelSuggestion';
$j.post(url, {keyword: ""+encodeURIComponent(query)+""}, function(data){
if(data.length >0) {
$j('#universal_search').css({'background-position':'left -223px'});
$j('#suggestions').show();
$j('#autoSuggestionsList').html(data);
hasData = true;
childs = $j('#autoSuggestionsList').children('li.clearfix');
childidx = -1;
}else{
$j('#autoSuggestionsList').html('Không tìm thấy kênh nào<\/span><\/li>');
hasData = false;
}
});
}else{
if(hasData){
switch(e.which){
case 40: //down
if(childidx < childs.length-1){
childidx = childidx+1;
var nextchild = $j(childs[childidx]);
childs.removeClass('hover');
nextchild.addClass('hover');
}
break;
case 38: //up
if(childidx>0){
childidx = childidx-1;
var prevchild = $j(childs[childidx]);
childs.removeClass('hover');
prevchild.addClass('hover');
}
break;
case 13: //enter
var curchild = $j(childs[childidx]);
if(curchild.length>0){
var channel_url = $j('div.search-img a',curchild).attr('href');
document.location = channel_url;
}
break;
default:
}
}
}
}
}
}); //end search
jQuery('#autoSuggestionsList > li').live('mouseover mouseout', function(event) {
if (event.type == 'mouseover') {
$j(this).addClass('hover');
} else {
$j(this).removeClass('hover');
}
});
jQuery('#universal_search_submit').click(function(){
var keyword_input = jQuery('#search_keyword'), keyword = jQuery.trim(keyword_input.val());
if (keyword==default_search_text){
keyword_input.focus();
} else {
jQuery('#top_search_form').submit();
}
return false;
});
}
function RegEvent_FollowButtonClick(){ // Xu ly su kien cho nut Quan tam
$j(".btn").live('click', function(){
var loading_obj = $j("#ajaxLoading");
var btn = $j(this);
var arr = btn.attr("rel").split("-");
var action = arr[0];
var type = arr[1];
var id = arr[2];
var domain = arr[3];
if (type=="channel") {
if (action=="follow") {
loading_obj.show();
var query = "id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxChannelSubcribe";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
btn.parents(":first").html(' Đã quan tâm').addClass('btn-follow-success');
}
}
);
}else if (action == "suggestfollow"){
loading_obj.show();
var query = "id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxChannelSubcribe";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
removeChannelSuggestion(id);
}
}
);
}else if (action=="unfollow") {
if(window.confirm('Bạn muốn bỏ quan tâm tin tức từ kênh này?')){
loading_obj.show();
var query = "id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxChannelUnsubcribe";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
btn.parent().parent().remove();
}
}
);
}
}
} else if (type=="user") {
if (action == "follow") {
loading_obj.show();
var query = "to_id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxFriendFollow";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
btn.parents(":first").html(' Đã quan tâm').addClass('btn-follow-success');
}
}
);
}else if (action == "suggestfollow"){
loading_obj.show();
var query = "to_id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxFriendFollow";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
removeFollowSuggestion(id);
}
}
);
}else if (action == "topfollow"){
loading_obj.show();
var query = "to_id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxFriendFollow";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
removeTopSuggestion(id);
}
}
);
}else if (action=="unfollow") {
//Unfollow user
if(window.confirm('Bạn có chắc chắn muốn bỏ quan tâm người này?')){
loading_obj.show();
var query = "followed_id=" + id;
var uri = my_base_url+my_pligg_base+"/ajaxFriendUnfollow";
$j.post(uri, query,
function(result) {
loading_obj.hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
btn.parents(":first").html(' Đã bỏ quan tâm').addClass('btn-follow-success');
}
}
);
}
}
}
return false;
}) //end Quan tam button click
}
function RegEvent_ChannelWarningHover(){
/*if(typeof(channel)!='undefined' && channel==''){ //Kiem tra neu la trang kenh chi tiet thi bind event
}*/
$j("#channel-info").hover(function(){
$j("a.ch-warning",this).css("display","block");
},function(){
$j("a.ch-warning",this).css("display","none");
});
}
/* Hide and load another Channel Suggestion */
function removeChannelSuggestion(id) {
$j("#ajaxLoading").show();
$j("#chn-suggest-"+id).fadeOut(1000);
$j.ajax({
type: "POST",
url: my_base_url+my_pligg_base+"/connect/ajaxChannelSuggestionRemove",
data: "id="+id,
success: function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
$j("#channel-info").html(result);
}
$j("#ajaxLoading").hide();
}
});
return false;
}
function insert_msg(val){
if(val!="Khác"){
$j('#admin_note').hide();
}else{
$j('#admin_note').show();
$j('#admin_note').focus();
}
$j('#admin_note').val(val);
};
function turn_off_notify(type,item_id,obj) {
if (window.confirm('Bạn muốn bỏ loại thông báo này?')){
$j("#ajaxLoading").show();
var query = 'type='+type+'&id='+parseInt(item_id);
$j.post(my_base_url+my_pligg_base+"/ajaxTurnOffNotify", query,
function(result) {
$j("#ajaxLoading").hide();
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else{
jQuery(obj).parent().parent().remove();
}
}
);
}
return false
}
function select_time(){
var pagename =$j('#pagename').val();
var filter = $j('#filter').val();
window.location.href = my_base_url+my_pligg_base+"/top/"+pagename+"/"+filter;
return false;
}
function ajaxReceiveHotMail(action,return_id,form,input_rcvemail,input_rcvtype){
$j("#ajaxLoading").show();
for( i = 0; i < form.input_rcvtype.length; i++ )
{
if( form.input_rcvtype[i].checked == true )
val_rcvtype = form.input_rcvtype[i].value;
}
query = "rcvemail=" + form.input_rcvemail.value + "&rcvtype=" + val_rcvtype;
$j.post(my_pligg_base+'/'+action, query,
function(result) {
$j("#ajaxLoading").hide();
$j("#newsletter_register_message").html(result);
}
);
return false;
}
function ajaxReceiveHotMailCallback(result,return_id){
$j("#"+return_id).html(result);
$j("#ajaxLoading").hide();
}
function ajaxUserWarning(type,item_id,checkid){
var ok = 1;
var content;
if(type == 'channel')
content = 'Báo kênh xấu';
else if(type == 'note')
content = 'Báo note xấu';
else if(type == 'feed')
content = 'Báo feed xấu';
query = "type=" + type + "&item_id=" + item_id + "&content=" + content;
$j.post(
my_base_url+my_pligg_base+"/ajaxUserWarning",
query,
function(result){
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
}else{
window.alert('Cảnh báo của bạn đã được gửi cho Ban quản trị');
}
}
);
return false;
}
//Form
$j('#link_category').change(function () {
var label = $j('#link_category option:selected').attr('title');
if (label == "1") {
$j('#new_link_submit_category_warning').show();
}
else {
$j('#new_link_submit_category_warning').hide();
}
})
var hideDelayTimer = null;
function RegEvent_MedalHover(){
jQuery('.medal').live('mouseover mouseout', function (event) {
if (event.type == 'mouseover') {
var obj = jQuery(this),
user_id = obj.attr('rel'),
medal_color = obj.attr('class').replace('medal medal-','');
var left = obj.x()+15, top = obj.y()+18;
jQuery('.badges-hovercard').css({"display":"none","visibility":"hidden"});
var badges_hovercard = jQuery('#badges_hovercard_'+user_id);
if (badges_hovercard.length > 0){
jQuery("#badges_hovercard_"+user_id).css({"left": left+"px", "top": top+"px","display":"block","visibility":"visible"});
return
} else {
badges_hovercard = jQuery('").css({
left: left,
top: top,
"display":"block",
"visibility":"visible"
});
badges_hovercard.appendTo('body');
//Check input hidden
if(jQuery('#hidden-badges-hovercard-'+user_id).length > 0){
badges_hovercard_content = jQuery('#hidden-badges-hovercard-'+user_id).val();
jQuery("#badges_hovercard_"+user_id).html(badges_hovercard_content);
return
} else {
jQuery.post(my_pligg_base+"/ajaxGetUserInfo", {user_id: user_id},
function(result) {
var r = eval(result);
badges_hovercard_content = '';
badges_hovercard_content+= '
'+r.badget+'
';
var s = '';
switch(r.badget_number) {
case 0:
s = 'là thành viên mới tham gia cộng đồng LinkHay.com';
break;
case 1:
s = 'là thành viên quen thuộc với cộng đồng LinkHay.com';
break;
case 2:
s = 'là thành viên tích cực đóng góp cho cộng đồng LinkHay.com';
break;
case 3:
s = 'là thành viên có nhiều đóng góp cho cộng đồng LinkHay.com';
break;
}
if(r.badget_number == 4){
badges_hovercard_content+= '
Thành viên quản trị LinkHay.com
';
}else{
badges_hovercard_content+= '
'+r.user_login+' '+s+'. Đã gửi '+r.statistic_link+' tin, '+r.statistic_comment+' bình luận và được '+r.statistic_follower+' người quan tâm.
';
}
/*badges_hovercard_content+= '
';*/
badges_hovercard_content+= '
';
//jQuery('#hidden-badges-hovercard-'+user_id).val(badges_hovercard_content);
jQuery("#badges_hovercard_"+user_id).html(badges_hovercard_content);
jQuery("#badges_hovercard_"+user_id).mouseenter(function() {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
return false;
});
jQuery("#badges_hovercard_"+user_id).mouseleave(function() {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
hideDelayTimer = setTimeout(function () {
jQuery("#badges_hovercard_"+user_id).css({"display":"none","visibility":"hidden"});
}, 200);
});
},'json');
}
}
} else {
// do something on mouseout
}
});
}
//For new Suggest at Home in tin moi
function openSuggestHomeWindow(type){
//Check yahoo and gmail
var _width = 550;
var Xpos = ( (screen.availWidth - _width)/2 );
var _height = 410;
var Ypos = ( (screen.availHeight - _height)/2 );
if( type == 2 ){
window.facebookWindow = window.open(my_base_url + my_pligg_base + '/oauth_facebook/request/5','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos);
facebookWindow.focus();
return false;
}else if( type == 3 ){
window.twitterWindow = window.open(my_base_url + my_pligg_base + '/oauth_twitter/request/5','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos);
twitterWindow.focus();
return false;
}else if( type == 4 ){
window.googleWindow = window.open(my_base_url + my_pligg_base + '/oauth_google/request/5','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos);
googleWindow.focus();
return false;
}else{
window.yahooWindow = window.open(my_base_url + my_pligg_base + '/oauth_yahoo/request/5','','width='+_width+',height='+_height+',toolbar=no,resizable=fixed,status=no,scrollbars=no,menubar=no,screenX='+Xpos+',screenY='+Ypos);
yahooWindow.focus();
return false;
}
}
/* Hide and load another Follow Suggestion */
function removeFollowSuggestion(id,from) {
$j("#ajaxLoading").show();
$j("#gs-suggestion-"+id).fadeOut(1000);
$j.ajax({
type: "POST",
url: my_base_url+my_pligg_base+"/connect/ajaxFollowSuggestionRemove",
data: "id="+id+"&from="+from,
success: function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if (result!="NA") {
$j("#gs-suggestion-" + id).after(result);
$j("#gs-suggestion-" + id).remove();
//Reload thickbox
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
$j("#ajaxLoading").hide();
}
});
return false;
}
/* Hide and load another Top Suggestion */
function removeTopSuggestion(id,from) {
$j("#ajaxLoading").show();
$j("#gs-suggestion-"+id).fadeOut(1000);
$j.ajax({
type: "POST",
url: my_base_url+my_pligg_base+"/connect/ajaxTopSuggestionRemove",
data: "id="+id+"&from="+from,
success: function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if (result!="NA") {
$j("#suggest-top-" + id).after(result);
$j("#suggest-top-" + id).remove();
//Reload thickbox
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
$j("#ajaxLoading").hide();
}
});
return false;
}
// Remove a node from list
function hideGraphNode(t, id,from) {
$j.ajax({
type: "POST",
url: my_base_url+my_pligg_base+"/ajaxNodeUpdate",
data: "nodeid=" + id + "&type=" + t + "&from=" + from,
success: function(result) {
if (/ERROR/.test(result)) {
result = result.substring(7, result.length);
window.alert(result);
} else {
if(t == 'invite') {
var item = "#invite_item"+id;
$j(item).remove();
} else if(t == 'suggest') {
$j("#suggest_item" + id).after(result);
$j("#suggest_item" + id).remove();
//Reload thickbox
$j('.thickbox').each(function(i) {
$j(this).unbind('click');
});
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
}
});
return false;
}