Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. post_hidden = function(facebook_id,value,fanpageid){
  2. is_hidden = value == 1 ? true : false;
  3. var link_getPageToken = DOMAIN + '/api.php?mod=social&cmd=fanpageToken';
  4. update_status_comment('comment_status',value,facebook_id);
  5. $.post( link_getPageToken, {
  6. 'projectToken': thisProjectToken,
  7. 'FanpageId': fanpageid
  8. }, function(data) {
  9. if(data.status == 1){
  10. link_post = 'https://graph.facebook.com/'+facebook_id+'?is_hidden='+is_hidden+'&access_token='+data.projectToken;
  11. $.post(link_post,function(res){
  12. if(value==1){
  13. $('#hide_'+facebook_id+' i').css('color','#00a4f2');
  14. $('#hide_'+facebook_id).attr('onclick','post_hidden(\''+ facebook_id +'\',0,\''+fanpageid+'\')');
  15. }else{
  16. $('#hide_'+facebook_id+' i').css('color','');
  17. $('#hide_'+facebook_id).attr('onclick','post_delete(\''+ facebook_id +'\',1,\''+fanpageid+'\')');
  18. }
  19. }).fail(function() {
  20. alert('Không thể ẩn hoặc bỏ ẩn cmt này!');
  21. return false;
  22. })
  23. }
  24. }, "json");
  25. }
  26. post_like = function(facebook_id,value,fanpageid){
  27. var link_getPageToken = DOMAIN + '/api.php?mod=social&cmd=fanpageToken';
  28. try {
  29. update_status_comment('is_liked',value,facebook_id);
  30. }
  31. catch(err) {
  32. debugjs(err);
  33. }
  34.  
  35. $.post( link_getPageToken, {
  36. 'projectToken': thisProjectToken,
  37. 'FanpageId': fanpageid
  38. }, function(data) {
  39. if(data.status == 1){
  40. if(value == 1){
  41. link_post = 'https://graph.facebook.com/'+facebook_id+'/likes?access_token='+data.projectToken;
  42. }else{
  43. link_post = 'https://graph.facebook.com/'+facebook_id+'/likes?access_token='+data.projectToken+'&method=delete';
  44. }
  45. $.post(link_post,function(){
  46. if(value==1){
  47. $('#like_'+facebook_id+' i').css('color','#00a4f2');
  48. $('#like_'+facebook_id).attr('onclick','post_like(\''+ facebook_id +'\',0)');
  49. }else{
  50. $('#like_'+facebook_id+' i').css('color','');
  51. $('#like_'+facebook_id).attr('onclick','post_like(\''+ facebook_id +'\',1)');
  52. }
  53. });
  54. }
  55. }, "json");
  56. }
  57. open_inbox = function(id,fanpageid,user_fb_id){
  58. $('#input_'+id).html('<div class="input-inbox"><textarea data-id="'+id+'" id="text-'+id+'" class="input-control" /><span class="btn btn-xs btn-info" onclick="send_private(\''+id+'\',\''+fanpageid+'\',\''+user_fb_id+'\')">Gửi</span><span class="cancel-input btn btn-xs btn-default" onclick="close_inbox()">Hủy</span></div>');
  59.  
  60. var height_div = $('#input_'+id).parents('.content_chat').height();
  61. $('.div_msg_chat').animate({scrollTop: height_div},400);
  62. $('#text-'+id).focus();
  63. }
  64. close_inbox = function(){
  65. try{
  66. $('.input-inbox').remove();
  67. }catch ( err ){
  68. console.log(err);
  69. }
  70. }
  71. update_status_comment = function(field,value,facebook_id){
  72. var link_update_status = DOMAIN + '/api.php?mod=comments&cmd=updateStatus&field='+field+'&value='+value+'&message_id='+facebook_id;
  73. $.post(link_update_status);
  74. }
  75. send_private = function (id,fanpageid,user_fb_id){
  76.  
  77. try {
  78. var text = $('#text-'+id).val();
  79. if(text.length > 0){
  80. var link_getPageToken = DOMAIN + '/api.php?mod=social&cmd=fanpageToken';
  81. $('#input_'+id+' .input-inbox').prepend('<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>');
  82. $.post( link_getPageToken, {
  83. 'projectToken': thisProjectToken,
  84. 'FanpageId': fanpageid
  85. }, function(data) {
  86. if (data.status == 1) {
  87. // var url = 'https://graph.facebook.com/' + id + '/private_replies?access_token=' + data.projectToken + '&message=' + encodeURIComponent(text);
  88. var url = DOMAIN+'/api.php?mod=chat&cmd=SendMsgFromComment';
  89. $.post(url,{
  90. 'token': data.projectToken,
  91. 'fanpage_id': fanpageid,
  92. 'facebook_id': user_fb_id,
  93. 'comment_id': id,
  94. 'text': text
  95. }, function (res) {
  96. $('#input_'+id).html('');
  97. });
  98. }
  99. },'json');
  100. }
  101. }
  102. catch(err) {
  103. debugjs(err);
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement