@ -10,7 +10,8 @@
// global variables
// global variables
var postsPerRefresh = 10 ;
var postsPerRefresh = 10 ;
var maxExpandPost = 20 ;
var maxExpandPost = 8 ;
var maxExpandPostTop = 4 ;
var _hashtagProcessedMap = { } ;
var _hashtagProcessedMap = { } ;
var _hashtagPendingPosts = [ ] ;
var _hashtagPendingPosts = [ ] ;
var autoUpdateHashtag = false ;
var autoUpdateHashtag = false ;
@ -19,7 +20,7 @@ var autoUpdateHashtag = false;
function requestRepliedBefore ( postLi )
function requestRepliedBefore ( postLi )
{
{
if ( postLi . siblings ( ) . length >= maxExpandPost )
if ( postLi . siblings ( ) . length >= maxExpandPostTop )
return ;
return ;
var originalPost = postLi . find ( ".post-data" ) ;
var originalPost = postLi . find ( ".post-data" ) ;
@ -41,7 +42,7 @@ function requestRepliedBefore(postLi)
function requestRepliesAfter ( postLi )
function requestRepliesAfter ( postLi )
{
{
if ( postLi . siblings ( ) . length >= maxExpandPost )
if ( postLi . parents ( '.module.post.original.open' ) . find ( '.post.related' ) . length >= maxExpandPost )
return ;
return ;
var originalPost = postLi . find ( ".post-data" ) ;
var originalPost = postLi . find ( ".post-data" ) ;
@ -49,16 +50,56 @@ function requestRepliesAfter(postLi)
var original _k = originalPost . attr ( 'data-id' ) ;
var original _k = originalPost . attr ( 'data-id' ) ;
if ( original _n != undefined && original _k != undefined ) {
if ( original _n != undefined && original _k != undefined ) {
dhtget ( original _n , "replies" + original _k , "m" ,
dhtget ( original _n , "replies" + original _k , "m" , $ . MAL . reqRepAfterCB , postLi ) ;
function ( postLi , postsFromJson ) {
}
for ( var i = 0 ; i < postsFromJson . length ; i ++ ) {
}
var newStreamPost = postToElem ( postsFromJson [ i ] , "related" ) ;
function getTopPostOfConversation ( postLi , post , postboard ) {
var reply _n ;
var reply _k ;
if ( post && typeof ( post ) !== 'undefined' && "reply" in post [ "userpost" ] ) {
reply _k = post [ "userpost" ] [ "reply" ] [ "k" ] ;
reply _n = post [ "userpost" ] [ "reply" ] [ "n" ] ;
} else if ( postLi && typeof ( postLi ) !== 'undefined' ) {
var originalPost = postLi . find ( ".post-data" ) ;
reply _n = originalPost . attr ( 'data-replied-to-screen-name' ) ;
reply _k = originalPost . attr ( 'data-replied-to-id' ) ;
}
if ( reply _n != undefined && reply _k != undefined ) {
dhtget ( reply _n , "post" + reply _k , "s" ,
function ( postLi , postFromJson ) {
getTopPostOfConversation ( null , postFromJson , postboard ) ;
} , postLi ) ;
} else {
var newStreamPost ;
if ( post )
newStreamPost = postToElem ( post , "related" ) ;
else {
newStreamPost = postLi . clone ( true ) ;
newStreamPost . removeClass ( 'original' ) ;
newStreamPost . addClass ( 'related' ) ;
newStreamPost . find ( '.expanded-content' ) . hide ( ) ;
newStreamPost . find ( '.show-more' ) . hide ( ) ;
}
requestRepliesAfterAll ( newStreamPost ) ;
newStreamPost . find ( '.post-expand' ) . remove ( ) ;
newStreamPost . unbind ( 'click' ) ;
newStreamPost . hide ( ) ;
newStreamPost . hide ( ) ;
postLi . after ( newStreamPost ) ;
postboard . append ( newStreamPost ) ;
newStreamPost . slideDown ( "fast" ) ;
newStreamPost . slideDown ( "fast" ) ;
}
}
$ . MAL . relatedPostLoaded ( ) ;
}
} , postLi ) ;
function requestRepliesAfterAll ( postLi )
{
var originalPost = postLi . find ( ".post-data" ) ;
var original _n = originalPost . attr ( 'data-screen-name' ) ;
var original _k = originalPost . attr ( 'data-id' ) ;
if ( original _n != undefined && original _k != undefined ) {
dhtget ( original _n , "replies" + original _k , "m" , $ . MAL . reqRepAfterCB , postLi ) ;
}
}
}
}