From d52ad056305c4d966ba67ed1ae4067f30fde0ecc Mon Sep 17 00:00:00 2001 From: Julian Steinwachs Date: Fri, 23 Jan 2015 09:08:52 +0100 Subject: [PATCH] somewhat working hashscheme for conversation modal --- js/interface_common.js | 39 +++++++++++++++++++++++++++------------ js/twister_actions.js | 21 +++++++++++++++++++++ js/twister_io.js | 1 + 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 07c5dfb..5ea5739 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -370,35 +370,46 @@ function openWhoToFollowModal() { $( "." + whoToFollowModalClass + " h3" ).text( polyglot.t("Who to Follow") ); } -function newConversationModal(postLi) { +function newConversationModal(username,resource) { + var hashtagModalContent = $( "#hashtag-modal-template" ).children().clone(true); + + requestPost(hashtagModalContent.find(".postboard-posts"),username,resource, + function(args){ + getTopPostOfConversation(args.hashtagModalContent.find(".postboard-posts").first(), + null, + args.hashtagModalContent.find(".postboard-posts") + ); + },{ hashtagModalContent:hashtagModalContent } + ); + hashtagModalContent.find( ".postboard-news").click(function (){ $(this).hide(); displayHashtagPending($(".conversation-modal .postboard-posts")); }); - getTopPostOfConversation(postLi, null, hashtagModalContent.find(".postboard-posts")); - return hashtagModalContent; } -function openConversationModal(e) +function openConversationModal(username,resource) { - e.stopPropagation(); - e.preventDefault(); + //e.stopPropagation(); + //e.preventDefault(); - var $this = $( this ); - var postLi = $this.parents(".module.post.original.open").find('.module.post.original'); + //var $this = $( this ); + //var postLi = $this.parents(".module.post.original.open").find('.module.post.original'); var conversationModalClass = "conversation-modal"; openModal( conversationModalClass ); //$( "." + threadingModalClass ).attr("data-resource","hashtag"); - var hashtagModalContent = newConversationModal( postLi ); - hashtagModalContent.appendTo("." + conversationModalClass + " .modal-content"); + + + var conversationModalContent = newConversationModal(username,resource); + conversationModalContent.appendTo("." + conversationModalClass + " .modal-content"); //título do modal - $( "." + conversationModalClass + " h3" ).text( polyglot.t('conversation_title', {'username': postLi.find('.post-data').attr('data-screen-name')}) ); + //$( "." + conversationModalClass + " h3" ).text( polyglot.t('conversation_title', {'username': postLi.find('.post-data').attr('data-screen-name')}) ); } @@ -435,7 +446,7 @@ function loadModalFromHash(){ var hashdata = hashstring.split(':'); if (hashdata[0] != '#web+twister') { - hashdata = hashstring.match(/(hashtag|profile|mentions|directmessages|following)\?(?:user|hashtag)=(.+)/); + hashdata = hashstring.match(/(hashtag|profile|mentions|directmessages|following|conversation)\?(?:user|hashtag|post)=(.+)/); } if (hashdata && hashdata[1] != undefined && hashdata[2] != undefined) { @@ -449,6 +460,10 @@ function loadModalFromHash(){ openDmWithUserModal(hashdata[2]); }else if (hashdata[1] == 'following') { openFollowingModal(hashdata[2]); + }else if (hashdata[1] == 'conversation') { + splithashdata2=hashdata[2].split(':') + //console.log('username='+splithashdata2[0]+' resource='+splithashdata2[1]); + openConversationModal(splithashdata2[0],splithashdata2[1]); } } else if (hashstring == '#directmessages') { directMessagesPopup(); diff --git a/js/twister_actions.js b/js/twister_actions.js index fb04b79..bad1d65 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -147,6 +147,27 @@ function appendPostToContainer(postFromJson, containerToAppend) var profilePostsLoading = false; +function requestPost(containerToAppend,username,resource,cbFunc,cbArgs){ + + console.log('dhtget '+username+' '+resource); + + dhtget( username, resource, "s", + function(args, postFromJson) { + if( postFromJson ) { + + console.log(postFromJson); + + appendPostToContainer(postFromJson,args.containerToAppend); + + if(args.cbFunc!=undefined) args.cbFunc(args.cbArgs); + + } + }, + {containerToAppend:containerToAppend,cbFunc:cbFunc,cbArgs:cbArgs} + ); + +} + function requestPostRecursively(containerToAppend,username,resource,count,useGetposts) { var max_id = -1; diff --git a/js/twister_io.js b/js/twister_io.js index dd5882c..9e91c99 100644 --- a/js/twister_io.js +++ b/js/twister_io.js @@ -93,6 +93,7 @@ function _dhtgetAbortPending(locator) // the value ["v"] is extracted from response and returned to callback // null is passed to callback in case of an error function dhtget( username, resource, multi, cbFunc, cbArg, timeoutArgs ) { + //console.log('dhtget '+username+' '+resource+' '+multi); var locator = _dhtgetLocator(username, resource, multi); if( locator in _dhtgetPendingMap) { _dhtgetAddPending(locator, cbFunc, cbArg);