console.log("mod loaded");
var pageName = "thing";
var tokenString = '?access_token=EAAE0sjJPIAABAETw4ayrpAid5lpLd56EhoHstDyUtA5XJ9YZBreoz8jDqcysKnEdPqWT7pENFaa3A77ORUtf6SH1dZABErzwYq7zn9OLhpgGGUMXqgq7Q3m5w2iTfULUNsPSiDjb0NpQiqBGxP7SaZCZCyglBLiUNxfQZCRLxJxEZBjaZA9tT4gMbpp9EzjbBcZD';
var auth_status_change_callback = function(response) {
console.log("auth_status_change_callback: " + response.status);
if (response.status == "connected") {
console.log("facebook api connected OK");
}
}
function initPage() {
console.log("init page");
buildPageNavN();
}
function setPage(id, token)
{
//var att = $(this).attr("data-id");
//console.log("setPageObject");
//console.log(id);
//console.log(token);
//displayMessage("Select a post to view comments");
//clearCommentCount();
// fetch posts
pageID = id;
pageToken = token;
//tokenString = '?access_token=' + token;
console.log("set pageid " + id);
//setCookie("pageid", id);
getPagePosts();
buildBreadcrumb("home");
}
function getPagePosts() {
var thePageID = pageID;//319034668130985;
console.log(" load posts: " + thePageID);
//wboc
//thePageID = 219252434538;
//219252434538
var fieldFilter = "&fields=admin_creator,id,name,message,from,source,created_time";
console.log(thePageID + "/feed" + tokenString + fieldFilter);
//showActivity();
//console.log(pageToken);
FB.api(
'/' + thePageID + '/feed' + tokenString + fieldFilter,
'GET', {
order: 'reverse_chronological',
limit: 20
},
function(response) {
//hideActivity();
// console.log("post response");
// console.log(response.data);
var postCounter = 0;
// var theDropDown = 'Select Post ';
var postListNav = '
';
//console.log(response.data);
$.each(response.data, function(index, value) {
//suppress posts from users, we only want posts from the main page!!!!!!!
try {
//console.log(value);
//postListNav = postListNav +value.name +" / "+value.message+ "
";
var theTitle = "";
var theIcon = "";
var extraClass="";
// var cleanPost = buildPostItem(value);
// if(cleanPost.islive == true)
// {
//
// theIcon = '
Live ';
// //extraClass = " list-group-item-warning";
// console.log("live "+theTitle);
// preloadVideoPost(cleanPost);
// // theDropDown = theDropDown + '
' + theTitle + ' ';
//
// }
// else
// {
// theIcon = '';
// // theDropDown = theDropDown + '
' + theTitle + ' ';
//
// }
//
//
var theURL = " onClick=setPostLink('"+ value.id.toString()+"')";
// postListNav = postListNav + '
'+value.name+' ';
//
// //
Dapibus ac facilisis in
//
postCounter++;
// var theListIcon = '';//
';
postListNav = postListNav + '';
//
// var theListIcon = '';//
';
// postListNav = postListNav + '';
// console.log("updated post list");
} catch (e) {
console.log(e);
//$("#tableData").html(e);
} finally {
}
//theDropDown = theDropDown + '
' + value.message.substring(0, 100) + ' ';
});
// console.log("posts: " + postCounter);
//theDropDown = theDropDown + '';
// postListNav = postListNav + "
";
// if(preloadPostIDFound == false)
// {
$("#postNav").html(postListNav);
// }
}
);
//$("#postNav").html(postListNav);
//console.log("clean array");
//console.log(cleanPostArray);
//setReloadInterval();
//dataInterval = setInterval(loadComments, refreshInterval);
//buildPostNav();
}
function setPostLink(id)
{
//console.log("setPost "+id);
//theID = $("#postSelector").val();
//setPostID(id);
//setCookie("postid", id);
console.log("set post id "+id);
loadSinglePostComments(id);
$("#menuNav").html("");
$("#postNav").html("");
}
function buildPostCommentsTable(commentArray)
{
var commentTable = "";
$.each(commentArray, function(index, value) {
console.log(value);
commentTable = commentTable + renderComment(value);
});
$("#postNav").html(commentTable);
}
function loadSinglePostComments(postID) {
try {
buildBreadcrumb("posts");
//console.log("passed postid "+postID);
//displayDebugMessage("loading comments");
// var tempID = getPostID();
//console.log("id retrieved from var: " + tempID);
// var theID = $("#pageSelector").val();
var theID = postID;
// setCookie("postid", theID);
//console.log("loadComments fired: " + theID);
//Video1.play();
if (theID != "null") {
//console.log("load comments: " + theID);
//displayErrorMessage("loading comments...");
if (theID) {
$("#blurMaker").focus();
// getPostReactions(theID);
//showActivity();
FB.api(
'/' + theID + '/comments' + tokenString + '&fields=id,message,comments{message,id,comments,from,created_time},comment_count,from,created_time',
'GET', {
order: 'reverse_chronological',
limit: 20
},
function(response) {
// console.log(response);
var comments = response.data;
// Insert your code here
//makeMediaObject(response);
console.log("update");
console.log(comments);
buildPostCommentsTable(comments);
//hideActivity();
//updateDisplayTime(convertTime(Date()));
try {
if (response.data && response.data.length > 0) {
// if (haveNewComments(response)) {
// //console.log("new comments " + totalCommentCount);
// //console.log("new data");
// // playAlert();
// // buildTableData(response);
// } else {
// //playAlert();
// //buildTableData(response);
// console.log("no new comments");
// // updateTableDataTimes(response);
// }
// if (lastID != response.data[0].id) {
// console.log("new data");
// playAlert();
// buildTableData(response);
// } else {
// //buildTableData(response);
// updateTableDataTimes(response);
// }
} else {
try {
if (response.error) {
inError = true;
displayErrorMessage("Unable to load comments, will retry.");
} else {
//var theInfo = 'Live Video Post Detected:
';
//var currentInfo = $('#theTable').html();
//$('#theTable').html(theInfo +currentInfo);
noCommentsMessage("No comments yet", ""+currentPostName+" ");
clearCommentCount();
}
} catch (e) {
} finally {
}
//console.log(response.error);
}
} catch (e) {
//displayErrorMessage("Error loading reactions...");
//console.log(response);
console.log(e);
} finally {
//console.log("finally");
}
}
);
} else {
console.log("Load comments: no post id set");
//loop through our list of posts and see if we have a live one to preset!!!!
//getPostListData();
}
} else {
console.log("do it");
// getPostListData();
}
} catch (e) {
//displayErrorMessage("Error loading comments...");
} finally {
}
}
function renderComment(theComment) {
//console.log(theComment);
var theCommentHTML = "";
var displayName = theComment.from.name;
var userMessage = theComment.message;
var createdTime = theComment.created_time;
getThumbnailID(theComment.from.id, theComment.id);
var milliseconds = (new Date(createdTime)).getTime();
//console.log("post " + milliseconds + " | " + lastTime);
// if (milliseconds > lastTime) {
// theCommentHTML = '
' + displayName + '
'; theCommentHTML = theCommentHTML + userMessage; theCommentHTML = theCommentHTML + "" + convertTime(createdTime, true) + ""; theCommentHTML = theCommentHTML + '