Changeset 669585
- Timestamp:
- 02/18/2013 06:05:10 AM (13 years ago)
- Location:
- facebook-comments-notifier
- Files:
-
- 2 edited
-
tags/1.3/fb-comments.js (modified) (1 diff)
-
trunk/fb-comments.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
facebook-comments-notifier/tags/1.3/fb-comments.js
r669583 r669585 69 69 jQuery(document).ready(function($) { 70 70 71 // is form? 72 if ( ! $('#commentform')[0] ) { 73 return; 74 } 75 71 76 // check if fb is up 72 77 if ( typeof(FB) == 'undefined' ) { 78 $('#commentform').html( 'Facebook comments are currently unavailable' ); 79 return; 80 } 73 81 74 $('#commentform').html( 'Facebook comments are currently unavailable' ); 82 // get page id 83 var url; 84 if ( fcn_global_data.permalink ) { 85 url = fcn_global_data.permalink; 86 } else { 87 url = window.location.href; 88 url = url.replace(/#.*/, ''); 89 } 75 90 76 } else if ( $('#commentform')[0] ) { 91 // comment form 92 var html = ''; 93 if ( ! $('#fb-root')[0] ) { 94 html += '<div id="fb-root"></div>'; 95 } 96 html += '<fb:comments id="fbcomments" class="fbcomments" notify="true" href="' + fcn_htmlencode(url) + '" migrated="1"'; 77 97 78 // get page id 79 var url; 80 if ( fcn_global_data.permalink ) { 81 url = fcn_global_data.permalink; 82 } else { 83 url = window.location.href; 84 url = url.replace(/#.*/, ''); 98 // size control, clone/override 99 var width = 550; 100 if ( fcn_global_data.width ) { 101 width = fcn_global_data.width; 102 } else { 103 width = $('#commentform').width(); 104 105 // handle resize event 106 jQuery(window).resize(function() { 107 if ( $('.fb_ltr')[0] ) { 108 var width = $('#commentform').width(); 109 $('.fb_ltr').width( width ); 110 } 111 }); 112 } 113 html += 'width="' + fcn_htmlencode(width) + '"'; 114 115 html += '></fb:comments>' ; 116 $('#commentform').html(html); 117 $('#commentform').show(); 118 119 // add listener 120 FB.Event.subscribe("comment.create", function(response){ 121 122 if ( ! response || ! response.commentID ) { 123 fcn_log( 'fcn: no response' ); 124 return; 85 125 } 86 126 87 // comment form 88 var html = ''; 89 if ( ! $('#fb-root')[0] ) { 90 html += '<div id="fb-root"></div>'; 91 } 92 html += '<fb:comments id="fbcomments" class="fbcomments" notify="true" href="' + fcn_htmlencode(url) + '" migrated="1"'; 127 var href = response.href; 128 var commentID = response.commentID; 129 var parentCommentID = response.parentCommentID; // if reply 93 130 94 // size control, clone/override 95 var width = 550; 96 if ( fcn_global_data.width ) { 97 width = fcn_global_data.width; 98 } else { 99 width = $('#commentform').width(); 131 // get comments/reply text 132 var fbsqlComment = "SELECT text, fromid FROM comment WHERE post_fbid='"+fcn_addslashes(commentID)+"' AND ( object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"') or object_id in (select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"')))"; 100 133 101 // handle resize event 102 jQuery(window).resize(function() { 103 if ( $('.fb_ltr')[0] ) { 104 var width = $('#commentform').width(); 105 $('.fb_ltr').width( width ); 134 //fcn_log(fbsqlComment); 135 136 // get user 137 var commentQuery = FB.Data.query(fbsqlComment);; 138 var fbsqlUser = "SELECT name FROM user WHERE uid in (select fromid from {0})"; 139 var userQuery = FB.Data.query(fbsqlUser, commentQuery); 140 141 FB.Data.waitOn([commentQuery, userQuery], function() { 142 143 var commentText = ''; 144 var userName = ''; 145 146 if ( commentQuery.value && commentQuery.value[0] ) { 147 var commentRow = commentQuery.value[0]; 148 if ( commentRow ) { 149 commentText = commentRow.text; 150 } 151 } 152 153 if ( userQuery.value && userQuery.value[0] ) { 154 var userRow = userQuery.value[0]; 155 if ( userRow.name ) { 156 userName = userRow.name; 157 } 158 } 159 160 // post to ajax service 161 var data = { 162 "action": "fcn_comment_created", 163 "href": href, 164 "commentID": commentID, 165 "parentCommentID": parentCommentID, 166 "commentText": commentText, 167 "userName": userName 168 }; 169 170 $.post( fcn_global_data.ajaxurl, data , function(jsonstr){ 171 var response = $.parseJSON(jsonstr); 172 if ( response ) { 173 if ( ! response.status ) { 174 fcn_log( response ); 175 } 106 176 } 107 177 }); 108 } 109 html += 'width="' + fcn_htmlencode(width) + '"';178 }); 179 }); 110 180 111 html += '></fb:comments>' ;112 $('#commentform').html(html);113 $('#commentform').show();114 115 // add listener116 FB.Event.subscribe("comment.create", function(response){117 118 if ( ! response || ! response.commentID ) {119 return;120 }121 122 var href = response.href;123 var commentID = response.commentID;124 var parentCommentID = response.parentCommentID; // if reply125 126 // both comments and replies127 var fbsqlComment = "SELECT text, fromid FROM comment WHERE post_fbid='"+fcn_addslashes(commentID)+"' AND ( object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"') or object_id in (select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"')))";128 129 //fcn_log(fbsqlComment);130 131 var commentQuery = FB.Data.query(fbsqlComment);;132 133 var fbsqlUser = "SELECT name FROM user WHERE uid in (select fromid from {0})";134 var userQuery = FB.Data.query(fbsqlUser, commentQuery);135 136 FB.Data.waitOn([commentQuery, userQuery], function() {137 138 var commentText = '';139 var userName = '';140 141 if ( commentQuery.value && commentQuery.value[0] ) {142 var commentRow = commentQuery.value[0];143 if ( commentRow ) {144 commentText = commentRow.text;145 }146 }147 148 if ( userQuery.value && userQuery.value[0] ) {149 var userRow = userQuery.value[0];150 if ( userRow.name ) {151 userName = userRow.name;152 }153 }154 155 // post to ajax service156 var data = {157 "action": "fcn_comment_created",158 "href": href,159 "commentID": commentID,160 "parentCommentID": parentCommentID,161 "commentText": commentText,162 "userName": userName163 };164 165 $.post( fcn_global_data.ajaxurl, data , function(jsonstr){166 var response = $.parseJSON(jsonstr);167 if ( response ) {168 if ( ! response.status ) {169 fcn_log( response );170 }171 }172 });173 });174 });175 176 }177 181 178 182 }); -
facebook-comments-notifier/trunk/fb-comments.js
r669583 r669585 69 69 jQuery(document).ready(function($) { 70 70 71 // is form? 72 if ( ! $('#commentform')[0] ) { 73 return; 74 } 75 71 76 // check if fb is up 72 77 if ( typeof(FB) == 'undefined' ) { 78 $('#commentform').html( 'Facebook comments are currently unavailable' ); 79 return; 80 } 73 81 74 $('#commentform').html( 'Facebook comments are currently unavailable' ); 82 // get page id 83 var url; 84 if ( fcn_global_data.permalink ) { 85 url = fcn_global_data.permalink; 86 } else { 87 url = window.location.href; 88 url = url.replace(/#.*/, ''); 89 } 75 90 76 } else if ( $('#commentform')[0] ) { 91 // comment form 92 var html = ''; 93 if ( ! $('#fb-root')[0] ) { 94 html += '<div id="fb-root"></div>'; 95 } 96 html += '<fb:comments id="fbcomments" class="fbcomments" notify="true" href="' + fcn_htmlencode(url) + '" migrated="1"'; 77 97 78 // get page id 79 var url; 80 if ( fcn_global_data.permalink ) { 81 url = fcn_global_data.permalink; 82 } else { 83 url = window.location.href; 84 url = url.replace(/#.*/, ''); 98 // size control, clone/override 99 var width = 550; 100 if ( fcn_global_data.width ) { 101 width = fcn_global_data.width; 102 } else { 103 width = $('#commentform').width(); 104 105 // handle resize event 106 jQuery(window).resize(function() { 107 if ( $('.fb_ltr')[0] ) { 108 var width = $('#commentform').width(); 109 $('.fb_ltr').width( width ); 110 } 111 }); 112 } 113 html += 'width="' + fcn_htmlencode(width) + '"'; 114 115 html += '></fb:comments>' ; 116 $('#commentform').html(html); 117 $('#commentform').show(); 118 119 // add listener 120 FB.Event.subscribe("comment.create", function(response){ 121 122 if ( ! response || ! response.commentID ) { 123 fcn_log( 'fcn: no response' ); 124 return; 85 125 } 86 126 87 // comment form 88 var html = ''; 89 if ( ! $('#fb-root')[0] ) { 90 html += '<div id="fb-root"></div>'; 91 } 92 html += '<fb:comments id="fbcomments" class="fbcomments" notify="true" href="' + fcn_htmlencode(url) + '" migrated="1"'; 127 var href = response.href; 128 var commentID = response.commentID; 129 var parentCommentID = response.parentCommentID; // if reply 93 130 94 // size control, clone/override 95 var width = 550; 96 if ( fcn_global_data.width ) { 97 width = fcn_global_data.width; 98 } else { 99 width = $('#commentform').width(); 131 // get comments/reply text 132 var fbsqlComment = "SELECT text, fromid FROM comment WHERE post_fbid='"+fcn_addslashes(commentID)+"' AND ( object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"') or object_id in (select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"')))"; 100 133 101 // handle resize event 102 jQuery(window).resize(function() { 103 if ( $('.fb_ltr')[0] ) { 104 var width = $('#commentform').width(); 105 $('.fb_ltr').width( width ); 134 //fcn_log(fbsqlComment); 135 136 // get user 137 var commentQuery = FB.Data.query(fbsqlComment);; 138 var fbsqlUser = "SELECT name FROM user WHERE uid in (select fromid from {0})"; 139 var userQuery = FB.Data.query(fbsqlUser, commentQuery); 140 141 FB.Data.waitOn([commentQuery, userQuery], function() { 142 143 var commentText = ''; 144 var userName = ''; 145 146 if ( commentQuery.value && commentQuery.value[0] ) { 147 var commentRow = commentQuery.value[0]; 148 if ( commentRow ) { 149 commentText = commentRow.text; 150 } 151 } 152 153 if ( userQuery.value && userQuery.value[0] ) { 154 var userRow = userQuery.value[0]; 155 if ( userRow.name ) { 156 userName = userRow.name; 157 } 158 } 159 160 // post to ajax service 161 var data = { 162 "action": "fcn_comment_created", 163 "href": href, 164 "commentID": commentID, 165 "parentCommentID": parentCommentID, 166 "commentText": commentText, 167 "userName": userName 168 }; 169 170 $.post( fcn_global_data.ajaxurl, data , function(jsonstr){ 171 var response = $.parseJSON(jsonstr); 172 if ( response ) { 173 if ( ! response.status ) { 174 fcn_log( response ); 175 } 106 176 } 107 177 }); 108 } 109 html += 'width="' + fcn_htmlencode(width) + '"';178 }); 179 }); 110 180 111 html += '></fb:comments>' ;112 $('#commentform').html(html);113 $('#commentform').show();114 115 // add listener116 FB.Event.subscribe("comment.create", function(response){117 118 if ( ! response || ! response.commentID ) {119 return;120 }121 122 var href = response.href;123 var commentID = response.commentID;124 var parentCommentID = response.parentCommentID; // if reply125 126 // both comments and replies127 var fbsqlComment = "SELECT text, fromid FROM comment WHERE post_fbid='"+fcn_addslashes(commentID)+"' AND ( object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"') or object_id in (select post_fbid from comment where object_id in (select comments_fbid from link_stat where url ='"+fcn_addslashes(href)+"')))";128 129 //fcn_log(fbsqlComment);130 131 var commentQuery = FB.Data.query(fbsqlComment);;132 133 var fbsqlUser = "SELECT name FROM user WHERE uid in (select fromid from {0})";134 var userQuery = FB.Data.query(fbsqlUser, commentQuery);135 136 FB.Data.waitOn([commentQuery, userQuery], function() {137 138 var commentText = '';139 var userName = '';140 141 if ( commentQuery.value && commentQuery.value[0] ) {142 var commentRow = commentQuery.value[0];143 if ( commentRow ) {144 commentText = commentRow.text;145 }146 }147 148 if ( userQuery.value && userQuery.value[0] ) {149 var userRow = userQuery.value[0];150 if ( userRow.name ) {151 userName = userRow.name;152 }153 }154 155 // post to ajax service156 var data = {157 "action": "fcn_comment_created",158 "href": href,159 "commentID": commentID,160 "parentCommentID": parentCommentID,161 "commentText": commentText,162 "userName": userName163 };164 165 $.post( fcn_global_data.ajaxurl, data , function(jsonstr){166 var response = $.parseJSON(jsonstr);167 if ( response ) {168 if ( ! response.status ) {169 fcn_log( response );170 }171 }172 });173 });174 });175 176 }177 181 178 182 });
Note: See TracChangeset
for help on using the changeset viewer.