Browse Source

rewrite appendPostToContainer() and rename to appendPostToElem()

readme-update
Simon Grim 9 years ago
parent
commit
0d902c1ea6
  1. 21
      js/twister_actions.js

21
js/twister_actions.js

@ -156,18 +156,13 @@ function requestRTs(postLi)
} }
} }
function appendPostToContainer(postFromJson, containerToAppend) function appendPostToElem(postFromJson, elem) {
{ // posts without 'msg' and 'rt' may be used for metadata like 'url' and are not meant to be displayed
// posts without 'msg' may be used for metadata like 'url' if (!postFromJson.userpost.msg && !postFromJson.userpost.rt)
// and are not meant to be displayed.
if (typeof(postFromJson['userpost']['msg']) === 'undefined' &&
typeof(postFromJson['userpost']['rt']) === 'undefined' )
return; return;
var newStreamPost = postToElem(postFromJson, "original"); postToElem(postFromJson, 'original').hide().appendTo(elem).slideDown('fast');
newStreamPost.hide();
containerToAppend.append( newStreamPost );
newStreamPost.slideDown("fast");
$.MAL.postboardLoaded(); $.MAL.postboardLoaded();
} }
@ -183,7 +178,7 @@ function requestPost(containerToAppend,username,resource,cbFunc,cbArgs){
//console.log(postFromJson); //console.log(postFromJson);
appendPostToContainer(postFromJson,args.containerToAppend); appendPostToElem(postFromJson, args.containerToAppend);
if(args.cbFunc!=undefined) args.cbFunc(args.cbArgs); if(args.cbFunc!=undefined) args.cbFunc(args.cbArgs);
@ -217,7 +212,7 @@ function requestPostRecursively(containerToAppend,username,resource,count,useGet
twisterRpc("getposts", [count,[req]], twisterRpc("getposts", [count,[req]],
function(args, posts) { function(args, posts) {
for( var i = 0; i < posts.length; i++ ) { for( var i = 0; i < posts.length; i++ ) {
appendPostToContainer(posts[i],args.containerToAppend); appendPostToElem(posts[i], args.containerToAppend);
} }
profilePostsLoading = false; profilePostsLoading = false;
}, {containerToAppend:containerToAppend}, }, {containerToAppend:containerToAppend},
@ -228,7 +223,7 @@ function requestPostRecursively(containerToAppend,username,resource,count,useGet
dhtget( username, resource, "s", dhtget( username, resource, "s",
function(args, postFromJson) { function(args, postFromJson) {
if( postFromJson ) { if( postFromJson ) {
appendPostToContainer(postFromJson,args.containerToAppend); appendPostToElem(postFromJson, args.containerToAppend);
if( args.count > 1 ) { if( args.count > 1 ) {
var userpost = postFromJson["userpost"]; var userpost = postFromJson["userpost"];

Loading…
Cancel
Save