diff --git a/home.html b/home.html
index f72edc6..4e96142 100644
--- a/home.html
+++ b/home.html
@@ -48,7 +48,8 @@
- Direct Messages
+
+
diff --git a/interface_home.js b/interface_home.js
index 41c1f5b..96fe19d 100644
--- a/interface_home.js
+++ b/interface_home.js
@@ -3,6 +3,8 @@
//
// Specific interface functions for home.html
+var promotedPostsOnly = false;
+
//***********************************************
//******************* DECLARATIONS **************
//***********************************************
@@ -12,8 +14,15 @@ var InterfaceFunctions = function()
this.init = function()
{
$( ".wrapper .postboard-news").click(function() {
- requestTimelineUpdate("latest",postsPerRefresh,followingUsers);});
-
+ requestTimelineUpdate("latest",postsPerRefresh,followingUsers,promotedPostsOnly);});
+ $( ".promoted-posts-only").click(function() {
+ promotedPostsOnly = !promotedPostsOnly;
+ $(this).text( promotedPostsOnly ? "Switch to Normal posts" : "Switch to Promoted posts" );
+ timelineChangedUser();
+ $.MAL.getStreamPostsParent().empty();
+ requestTimelineUpdate("latestFirstTime",postsPerRefresh,followingUsers,promotedPostsOnly);
+ });
+
initInterfaceCommon();
initUserSearch();
initInterfaceDirectMsg();
@@ -45,13 +54,13 @@ var InterfaceFunctions = function()
setInterval("requestLastHave()", 1000);
initMentionsCount();
initDMsCount();
- requestTimelineUpdate("latestFirstTime",postsPerRefresh,followingUsers);
+ requestTimelineUpdate("latestFirstTime",postsPerRefresh,followingUsers,promotedPostsOnly);
// install scrollbottom handler to load more posts as needed
$(window).scroll(function(){
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 20){
if( timelineLoaded ) {
- requestTimelineUpdate("older", postsPerRefresh, followingUsers);
+ requestTimelineUpdate("older", postsPerRefresh, followingUsers, promotedPostsOnly);
}
}
});
diff --git a/twister_timeline.js b/twister_timeline.js
index 94a1648..cf78957 100644
--- a/twister_timeline.js
+++ b/twister_timeline.js
@@ -9,6 +9,7 @@
var _idTrackerMap = {};
+var _idTrackerSpam = new idTrackerObj();
var _lastHaveMap = {};
var _refreshInProgress = false;
var _newPostsPending = 0;
@@ -72,17 +73,21 @@ function idTrackerObj()
/* object to maintain a request state for several users.
* each user is tracked by idTrackerObj in global _idTrackerMap.
*/
-function requestObj(users, mode, count)
+function requestObj(users, mode, count, getspam)
{
this.users = users;
this.mode = mode; // 'latest', 'latestFirstTime' or 'older'
this.count = count;
+ this.getspam = getspam;
// getRequest method returns the list parameter expected by getposts rpc
this.getRequest = function() {
var req = [];
if( this.mode == 'done')
return req;
+ if( this.getspam ) {
+ return _idTrackerSpam.getRequest(this.mode);
+ }
for( var i = 0; i < this.users.length; i++ ) {
var user = this.users[i];
if( !(user in _idTrackerMap) )
@@ -96,6 +101,9 @@ function requestObj(users, mode, count)
// receiveId method notifies that a post was received (and possibly shown)
this.reportProcessedPost = function(user, id, shown) {
+ if( this.getspam ) {
+ _idTrackerSpam.receivedId(this.mode, id, shown);
+ }
if( this.users.indexOf(user) >= 0 ) {
_idTrackerMap[user].receivedId(this.mode, id, shown);
}
@@ -115,10 +123,16 @@ function requestObj(users, mode, count)
function requestGetposts(req)
{
var r = req.getRequest();
- if( r.length ) {
- twisterRpc("getposts", [req.count,r],
- function(req, posts) {processReceivedPosts(req, posts);}, req,
- function(req, ret) {console.log("ajax error:" + ret);}, req);
+ if( !req.getspam ) {
+ if( r.length ) {
+ twisterRpc("getposts", [req.count,r],
+ function(req, posts) {processReceivedPosts(req, posts);}, req,
+ function(req, ret) {console.log("ajax error:" + ret);}, req);
+ }
+ } else {
+ twisterRpc("getspamposts", [req.count,r.max_id?r.max_id:-1,r.since_id?r.since_id:-1],
+ function(req, posts) {processReceivedPosts(req, posts);}, req,
+ function(req, ret) {console.log("ajax error:" + ret);}, req);
}
}
@@ -189,14 +203,14 @@ function processReceivedPosts(req, posts)
}
// request timeline update for a given list of users
-function requestTimelineUpdate(mode, count, timelineUsers)
+function requestTimelineUpdate(mode, count, timelineUsers, getspam)
{
if( _refreshInProgress )
return;
$.MAL.postboardLoading();
_refreshInProgress = true;
if( timelineUsers.length ) {
- var req = new requestObj(timelineUsers, mode, count);
+ var req = new requestObj(timelineUsers, mode, count, getspam);
requestGetposts(req);
} else {
console.log("requestTimelineUpdate: not following any users");
@@ -269,6 +283,7 @@ function processNewPostsConfirmation(expected, posts)
function timelineChangedUser()
{
_idTrackerMap = {};
+ _idTrackerSpam = new idTrackerObj();
_lastHaveMap = {};
_refreshInProgress = false;
_newPostsPending = 0;