@ -49,27 +49,26 @@ function postToElem( post, kind, promoted ) {
}
}
"sig_userpost" : signature by userpost . n
"sig_userpost" : signature by userpost . n
* /
* /
var username , k , t , msg , rt , content _to _rt , content _to _sigrt , retweeted _by ;
// Obtain data from userpost
// Obtain data from userpost
var postJson = $ . toJSON ( post ) ;
var userpost = post . userpost ;
var userpost = post [ "userpost" ] ;
if ( userpost . rt ) {
if ( "rt" in userpost ) {
rt = userpost . rt ;
var rt = userpost [ "rt" ] ;
username = rt . n ;
var n = rt [ "n" ] ;
k = rt . k ;
var k = rt [ "k" ] ;
t = rt . time ;
var t = rt [ "time" ] ;
msg = rt . msg ;
var msg = rt [ "msg" ] ;
content _to _rt = $ . toJSON ( rt ) ;
var content _to _rt = $ . toJSON ( rt ) ;
content _to _sigrt = userpost . sig _rt ;
var content _to _sigrt = userpost [ "sig_rt" ] ;
retweeted _by = userpost . n ;
var retweeted _by = userpost [ "n" ] ;
} else {
} else {
var n = userpost [ "n" ] ;
username = userpost . n ;
var k = userpost [ "k" ] ;
k = userpost . k ;
var t = userpost [ "time" ] ;
t = userpost . time ;
var msg = userpost [ "msg" ]
msg = userpost . msg ;
var content _to _rt = $ . toJSON ( userpost ) ;
content _to _rt = $ . toJSON ( userpost ) ;
var content _to _sigrt = post [ "sig_userpost" ] ;
content _to _sigrt = post . sig _userpost ;
var retweeted _by = undefined ;
}
}
// Now create the html elements
// Now create the html elements
@ -79,36 +78,36 @@ function postToElem( post, kind, promoted ) {
. attr ( 'data-time' , t )
. attr ( 'data-time' , t )
;
;
if ( post [ 'isNew' ] )
if ( post . isNew )
elem . addClass ( 'new' ) ;
elem . addClass ( 'new' ) ;
var postData = elem . find ( '.post-data' ) ;
var postData = elem . find ( '.post-data' ) ;
postData . addClass ( kind )
postData . addClass ( kind )
. attr ( 'data-userpost' , postJson )
. attr ( 'data-userpost' , $ . toJSON ( post ) )
. attr ( 'data-content_to_rt' , content _to _rt )
. attr ( 'data-content_to_rt' , content _to _rt )
. attr ( 'data-content_to_sigrt' , content _to _sigrt )
. attr ( 'data-content_to_sigrt' , content _to _sigrt )
. attr ( 'data-screen-name' , n )
. attr ( 'data-screen-name' , user name )
. attr ( 'data-id' , k )
. attr ( 'data-id' , k )
. attr ( 'data-lastk' , userpost [ "lastk" ] )
. attr ( 'data-lastk' , userpost [ "lastk" ] )
. attr ( 'data-text' , msg )
. attr ( 'data-text' , msg )
;
;
if ( 'reply' in userpost ) {
if ( userpost . reply ) {
postData . attr ( 'data-replied-to-screen-name' , userpost . reply . n )
postData . attr ( 'data-replied-to-screen-name' , userpost . reply . n )
. attr ( 'data-replied-to-id' , userpost . reply . k )
. attr ( 'data-replied-to-id' , userpost . reply . k )
. find ( '.post-expand' ) . text ( polyglot . t ( 'Show conversation' ) )
. find ( '.post-expand' ) . text ( polyglot . t ( 'Show conversation' ) )
;
;
} else if ( 'rt' in userpost && 'reply' in userpost . rt ) {
} else if ( userpost . rt && userpost . rt . reply ) {
postData . attr ( 'data-replied-to-screen-name' , userpost . rt . reply . n )
postData . attr ( 'data-replied-to-screen-name' , userpost . rt . reply . n )
. attr ( 'data-replied-to-id' , userpost . rt . reply . k )
. attr ( 'data-replied-to-id' , userpost . rt . reply . k )
. find ( '.post-expand' ) . text ( polyglot . t ( 'Show conversation' ) )
. find ( '.post-expand' ) . text ( polyglot . t ( 'Show conversation' ) )
;
;
}
}
var postInfoName = elem . find ( '.post-info-name' ) ;
var postInfoName = elem . find ( '.post-info-name' )
postInfoName . text ( n ) . attr ( 'href' , $ . MAL . userUrl ( n ) ) ;
. text ( user name ) . attr ( 'href' , $ . MAL . userUrl ( user name ) ) ;
getFullname ( n , postInfoName ) ;
getFullname ( user name , postInfoName ) ;
//elem.find('.post-info-tag').text("@" + n);
//elem.find('.post-info-tag').text("@" + user name );
getAvatar ( n , elem . find ( '.avatar' ) ) ;
getAvatar ( user name , elem . find ( '.avatar' ) ) ;
elem . find ( '.post-info-time' ) . text ( timeGmtToText ( t ) ) . attr ( 'title' , timeSincePost ( t ) ) ;
elem . find ( '.post-info-time' ) . text ( timeGmtToText ( t ) ) . attr ( 'title' , timeSincePost ( t ) ) ;
var mentions = [ ] ;
var mentions = [ ] ;
@ -116,10 +115,10 @@ function postToElem( post, kind, promoted ) {
postData . attr ( 'data-text-mentions' , mentions ) ;
postData . attr ( 'data-text-mentions' , mentions ) ;
var replyTo = '' ;
var replyTo = '' ;
if ( n !== defaultScreenName )
if ( user name !== defaultScreenName )
replyTo += '@' + n + ' ' ;
replyTo += '@' + user name + ' ' ;
for ( var i = 0 ; i < mentions . length ; i ++ ) {
for ( var i = 0 ; i < mentions . length ; i ++ ) {
if ( mentions [ i ] !== n && mentions [ i ] !== defaultScreenName )
if ( mentions [ i ] !== user name && mentions [ i ] !== defaultScreenName )
replyTo += '@' + mentions [ i ] + ' ' ;
replyTo += '@' + mentions [ i ] + ' ' ;
}
}
@ -132,7 +131,7 @@ function postToElem( post, kind, promoted ) {
postData . attr ( 'data-reply-to' , replyTo ) ;
postData . attr ( 'data-reply-to' , replyTo ) ;
if ( retweeted _by != undefined ) {
if ( typeof retweeted _by !== 'undefined' ) {
elem . find ( '.post-context' ) . show ( ) ;
elem . find ( '.post-context' ) . show ( ) ;
elem . find ( '.post-retransmited-by' )
elem . find ( '.post-retransmited-by' )
. attr ( 'href' , $ . MAL . userUrl ( retweeted _by ) )
. attr ( 'href' , $ . MAL . userUrl ( retweeted _by ) )
@ -140,25 +139,38 @@ function postToElem( post, kind, promoted ) {
;
;
}
}
if ( typeof ( promoted ) !== 'undefined' && promoted ) {
if ( typeof promoted !== 'undefined' && promoted ) {
elem . find ( '.post-propagate' ) . remove ( ) ;
elem . find ( '.post-propagate' ) . remove ( ) ;
postData . attr ( 'data-promoted' , 1 ) ;
postData . attr ( 'data-promoted' , 1 ) ;
postData . attr ( 'data-screen-name' , '!' + n ) ;
postData . attr ( 'data-screen-name' , '!' + user name ) ;
} else {
} else {
setPostInfoSent ( userpost [ "n" ] , userpost [ "k" ] , elem . find ( '.post-info-sent' ) ) ;
setPostInfoSent ( userpost . n , userpost . k , elem . find ( '.post-info-sent' ) ) ;
if ( $ . Options . filterLang . val !== 'disable' && $ . Options . filterLangSimulate . val ) {
if ( $ . Options . filterLang . val !== 'disable' && $ . Options . filterLangSimulate . val ) {
// FIXME it's must be stuff from template actually
// FIXME it's must be stuff from template actually
if ( typeof ( post [ 'langFilter' ] ) !== 'undefined' ) {
if ( typeof post . langFilter !== 'undefined' ) {
if ( typeof ( post [ 'langFilter' ] [ 'prob' ] [ 0 ] ) !== 'undefined' )
if ( typeof post . langFilter . prob [ 0 ] !== 'undefined' )
var mlm = ' // ' + polyglot . t ( 'Most possible language: this' , { 'this' : '<em>' + post [ 'langFilter' ] [ 'prob' ] [ 0 ] . toString ( ) + '</em>' } ) ;
var mlm = ' // ' + polyglot . t ( 'Most possible language: this' ,
{ 'this' : '<em>' + post . langFilter . prob [ 0 ] . toString ( ) + '</em>' } ) ;
else
else
var mlm = '' ;
var mlm = '' ;
elem . append ( '<div class="langFilterSimData">' + polyglot . t ( 'This post is treated by language filter' , { 'treated' : '<em>' + ( ( post [ 'langFilter' ] [ 'pass' ] ) ? polyglot . t ( 'passed' ) : polyglot . t ( 'blocked' ) ) + '</em>' } ) + '</div>' )
elem . append ( '<div class="langFilterSimData">'
. append ( '<div class="langFilterSimData">' + polyglot . t ( 'Reason: this' , { 'this' : '<em>' + post [ 'langFilter' ] [ 'reason' ] + '</em>' } ) + mlm + '</div>' )
+ polyglot . t ( 'This post is treated by language filter' ,
{ 'treated' : '<em>' + ( post . langFilter . pass ? polyglot . t ( 'passed' ) : polyglot . t ( 'blocked' ) ) + '</em>' } )
+ '</div>'
)
. append ( '<div class="langFilterSimData">'
+ polyglot . t ( 'Reason: this' , { 'this' : '<em>' + post . langFilter . reason + '</em>' } )
+ mlm + '</div>'
)
;
;
} else {
} else {
elem . append ( '<div class="langFilterSimData">' + polyglot . t ( 'This post is treated by language filter' , { 'treated' : '<em>' + polyglot . t ( 'not analyzed' ) + '</em>' } ) + '</div>' ) ;
elem . append ( '<div class="langFilterSimData">'
+ polyglot . t ( 'This post is treated by language filter' ,
{ 'treated' : '<em>' + polyglot . t ( 'not analyzed' ) + '</em>' } )
+ '</div>'
)
;
}
}
}
}
}
}