mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-13 08:27:51 +00:00
introduce sending posts with citation (retwists with comments)
This commit is contained in:
parent
48a5292249
commit
66431127e6
@ -1787,6 +1787,10 @@ ol.toptrends-list {
|
||||
min-height: 68px;
|
||||
}
|
||||
|
||||
.reTwist .post-area-extras {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
********* REPLY POSTS PROMPT *********
|
||||
**************************************/
|
||||
|
@ -379,13 +379,25 @@ function reTwistPopup(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
openModal({
|
||||
var modal = openModal({
|
||||
classBase: '.prompt-wrapper',
|
||||
classAdd: 'reTwist',
|
||||
title: polyglot.t('retransmit_this')
|
||||
})
|
||||
.content
|
||||
.append(postToElem($.evalJSON($(this).parents('.post-data').attr('data-userpost')), ''));
|
||||
});
|
||||
|
||||
modal.content
|
||||
.append(postToElem($.evalJSON($(this).parents('.post-data').attr('data-userpost')), ''))
|
||||
.append($('#reply-modal-template').children().clone(true)) // FIXME retwist-reply-modal-template
|
||||
;
|
||||
|
||||
var replyArea = modal.content.find('.post-area .post-area-new');
|
||||
var textArea = replyArea.find('textarea');
|
||||
var textAreaPostInline = modal.content.find('.post .post-area-new textarea');
|
||||
$.each(['placeholder', 'data-reply-to'], function(i, attribute) {
|
||||
textArea.attr(attribute, textAreaPostInline.attr(attribute));
|
||||
});
|
||||
|
||||
replyArea.find('.post-submit').addClass('with-reference');
|
||||
}
|
||||
|
||||
// Expande Área do Novo post
|
||||
@ -399,16 +411,16 @@ function replyInitPopup(e, post) {
|
||||
getFullname(post.userpost.n, modal.self.find('h3 .fullname'));
|
||||
|
||||
modal.content
|
||||
.append($('#reply-modal-template').children().clone(true))
|
||||
.append(postToElem(post, ''))
|
||||
.append($('#reply-modal-template').children().clone(true))
|
||||
;
|
||||
|
||||
// FIXME passing data through attributes may result in a mess like following
|
||||
var replyArea = modal.content.find('.post-area .post-area-new').addClass('open');
|
||||
var replyText = replyArea.find('textarea');
|
||||
var postInlineReplyText = modal.content.find('.post .post-area-new textarea');
|
||||
var textArea = replyArea.find('textarea');
|
||||
var textAreaPostInline = modal.content.find('.post .post-area-new textarea');
|
||||
$.each(['placeholder', 'data-reply-to'], function(i, attribute) {
|
||||
replyText.attr(attribute, postInlineReplyText.attr(attribute));
|
||||
textArea.attr(attribute, textAreaPostInline.attr(attribute));
|
||||
});
|
||||
|
||||
composeNewPost(e, replyArea);
|
||||
@ -1202,82 +1214,95 @@ function undoLastUnicode(e) {
|
||||
}
|
||||
|
||||
function postSubmit(e, oldLastPostId) {
|
||||
var btnPostSubmit;
|
||||
|
||||
if (e instanceof $) {
|
||||
var $this = e;
|
||||
btnPostSubmit = e;
|
||||
//check if previous part was sent...
|
||||
if (oldLastPostId === lastPostId) {
|
||||
setTimeout(postSubmit, 1000, $this, oldLastPostId);
|
||||
setTimeout(postSubmit, 1000, btnPostSubmit, oldLastPostId);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
btnPostSubmit = $(this);
|
||||
}
|
||||
$.MAL.disableButton($this);
|
||||
$.MAL.disableButton(btnPostSubmit);
|
||||
|
||||
var $replyText = $this.closest('.post-area-new').find('textarea');
|
||||
var textArea = btnPostSubmit.closest('.post-area-new').find('textarea');
|
||||
|
||||
$replyText.siblings('#post-preview').hide();
|
||||
textArea.siblings('#post-preview').hide();
|
||||
|
||||
var $postOrig = $this.closest('.post-data');
|
||||
if (!$postOrig.length) {
|
||||
$postOrig = $this.closest('.modal-content').find('.post-data');
|
||||
var postData = btnPostSubmit.closest('.post-data');
|
||||
if (!postData.length) {
|
||||
postData = btnPostSubmit.closest('.modal-content').find('.post-data');
|
||||
}
|
||||
|
||||
if (splitedPostsCount > 1) {
|
||||
if ($replyText.length < splitedPostsCount) {
|
||||
//current part will be sent as reply to the previous part...
|
||||
$postOrig = $('<div data-id="' + lastPostId + '" data-screen-name="' + defaultScreenName + '"></div>');
|
||||
if (btnPostSubmit.hasClass('with-reference')) {
|
||||
function doSubmitPost(postText, postData) {
|
||||
newRtMsg(postData, postText);
|
||||
}
|
||||
} else {
|
||||
if (splitedPostsCount > 1) {
|
||||
if (textArea.length < splitedPostsCount) {
|
||||
//current part will be sent as reply to the previous part...
|
||||
postData = $('<div data-id="' + lastPostId + '" data-screen-name="' + defaultScreenName + '"></div>');
|
||||
}
|
||||
}
|
||||
|
||||
function doSubmitPost(postText, postData) {
|
||||
newPostMsg(postText, postData);
|
||||
}
|
||||
}
|
||||
|
||||
if ($replyText.length <= 1) {
|
||||
if (textArea.length <= 1) {
|
||||
if (splitedPostsCount > 1) {
|
||||
var postxt = '';
|
||||
var reply_to = $replyText.attr('data-reply-to');
|
||||
var val = $replyText.val();
|
||||
var postText = '';
|
||||
var reply_to = textArea.attr('data-reply-to');
|
||||
var val = textArea.val();
|
||||
if (typeof reply_to === 'undefined' || checkPostForMentions(val, reply_to, 140))
|
||||
postxt = val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
postText = val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
else
|
||||
postxt = reply_to + val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
postText = reply_to + val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
|
||||
newPostMsg(postxt, $postOrig);
|
||||
doSubmitPost(postText, postData);
|
||||
} else
|
||||
newPostMsg($replyText.val(), $postOrig);
|
||||
doSubmitPost(textArea.val(), postData);
|
||||
|
||||
splitedPostsCount = 1;
|
||||
} else {
|
||||
var postxt = '';
|
||||
var reply_to = $replyText.attr('data-reply-to');
|
||||
var val = $replyText[0].value;
|
||||
var postText = '';
|
||||
var reply_to = textArea.attr('data-reply-to');
|
||||
var val = textArea[0].value;
|
||||
if (typeof reply_to === 'undefined' || checkPostForMentions(val, reply_to, 140))
|
||||
postxt = val + ' (' + (splitedPostsCount - $replyText.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
postText = val + ' (' + (splitedPostsCount - textArea.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
else
|
||||
postxt = reply_to + val + ' (' + (splitedPostsCount - $replyText.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
postText = reply_to + val + ' (' + (splitedPostsCount - textArea.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
||||
|
||||
$($replyText[0]).remove();
|
||||
$(textArea[0]).remove();
|
||||
|
||||
oldLastPostId = lastPostId;
|
||||
newPostMsg(postxt, $postOrig);
|
||||
setTimeout(postSubmit, 1000, $this, oldLastPostId);
|
||||
doSubmitPost(postText, postData);
|
||||
setTimeout(postSubmit, 1000, btnPostSubmit, oldLastPostId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$replyText.val('').attr('placeholder', polyglot.t('Your message was sent!'));
|
||||
var tweetForm = $this.parents('form');
|
||||
var remainingCount = tweetForm.find('.post-area-remaining');
|
||||
remainingCount.text(140);
|
||||
|
||||
if ($this.parents('.prompt-wrapper').length)
|
||||
if (btnPostSubmit.parents('.prompt-wrapper').length)
|
||||
closeModalHandler('.prompt-wrapper');
|
||||
else {
|
||||
textArea.val('').attr('placeholder', polyglot.t('Your message was sent!'));
|
||||
var tweetForm = btnPostSubmit.parents('form');
|
||||
var remainingCount = tweetForm.find('.post-area-remaining');
|
||||
remainingCount.text(140);
|
||||
|
||||
if ($this.closest('.post-area,.post-reply-content')) {
|
||||
$('.post-area-new').removeClass('open').find('textarea').blur();
|
||||
};
|
||||
$replyText.data('unicodeConversionStack', []);
|
||||
$replyText.data('disabledUnicodeRules', []);
|
||||
if (btnPostSubmit.closest('.post-area,.post-reply-content')) {
|
||||
$('.post-area-new').removeClass('open').find('textarea').blur();
|
||||
};
|
||||
textArea.data('unicodeConversionStack', []);
|
||||
textArea.data('disabledUnicodeRules', []);
|
||||
}
|
||||
}
|
||||
|
||||
function retweetSubmit(e) {
|
||||
|
@ -263,30 +263,50 @@ function newPostMsg(msg, $postOrig) {
|
||||
}
|
||||
}
|
||||
|
||||
function newRtMsg($postOrig) {
|
||||
var content_to_rt = $postOrig.attr('data-content_to_rt');
|
||||
var content_to_sigrt = $postOrig.attr('data-content_to_sigrt');
|
||||
function newRtMsg(postData, msg) {
|
||||
var userpost = $.evalJSON(postData.attr('data-content_to_rt'));
|
||||
var sig_userpost;
|
||||
|
||||
var sig_userpost = String(content_to_sigrt);
|
||||
var userpost = $.evalJSON(String(content_to_rt));
|
||||
var rtObj = { sig_userpost :sig_userpost, userpost : userpost };
|
||||
if (userpost.rt) {
|
||||
if (parseInt(twisterVersion) <= 93000) {
|
||||
alert(polyglot.t('error',
|
||||
{error: 'can\'t handle retwisting of commented retwisted twists with daemon version '
|
||||
+ twisterDisplayVersion + ' and below of that. please upgrade it.'}
|
||||
));
|
||||
|
||||
if( lastPostId != undefined ) {
|
||||
if ( typeof _sendedPostIDs !== 'undefined' )
|
||||
return;
|
||||
} else {
|
||||
// dropping of rt to avoid overquoting
|
||||
sig_userpost = userpost.sig_wort;
|
||||
userpost.rt = undefined;
|
||||
userpost.sig_rt = undefined;
|
||||
}
|
||||
} else {
|
||||
sig_userpost = postData.attr('data-content_to_sigrt');
|
||||
}
|
||||
|
||||
var rtObj = {sig_userpost: sig_userpost, userpost: userpost};
|
||||
|
||||
if (typeof lastPostId !== 'undefined') {
|
||||
if (typeof _sendedPostIDs !== 'undefined')
|
||||
_sendedPostIDs.push(lastPostId + 1);
|
||||
|
||||
var params = [defaultScreenName, lastPostId+1, rtObj]
|
||||
var params = [defaultScreenName, lastPostId + 1, rtObj];
|
||||
|
||||
twisterRpc("newrtmsg", params,
|
||||
function(arg, ret) { incLastPostId(); }, null,
|
||||
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
|
||||
alert(polyglot.t("ajax_error", { error: msg })); }, null);
|
||||
if (typeof msg !== 'undefined')
|
||||
params.push(msg);
|
||||
|
||||
twisterRpc('newrtmsg', params,
|
||||
function(arg, ret) {incLastPostId();}, null,
|
||||
function(arg, ret) {var msg = ('message' in ret) ? ret.message : ret;
|
||||
alert(polyglot.t('ajax_error', {error: msg}));
|
||||
}, null
|
||||
);
|
||||
} else {
|
||||
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
|
||||
alert(polyglot.t('Internal error: lastPostId unknown (following yourself may fix!)'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateProfileData(profileModalContent, username) {
|
||||
|
||||
//profileModalContent.find("a").attr("href",$.MAL.userUrl(username));
|
||||
|
@ -4,6 +4,8 @@
|
||||
// Provides functions for periodic network status check
|
||||
// Interface to network.html page.
|
||||
|
||||
var twisterVersion;
|
||||
var twisterDisplayVersion;
|
||||
var twisterdConnections = 0;
|
||||
var twisterdAddrman = 0;
|
||||
var twisterDhtNodes = 0;
|
||||
@ -39,9 +41,9 @@ function requestNetInfo(cbFunc, cbArg) {
|
||||
twisterdBlocks = ret.blocks;
|
||||
twisterDhtNodes = ret.dht_nodes;
|
||||
twisterVersion = ("0000000" + ret.version).slice(-8);
|
||||
twisterDisplayVersion = twisterVersion.slice(0,2) + '.' +
|
||||
twisterVersion.slice(2,4) + '.' +
|
||||
twisterVersion.slice(4,6) + '.' +
|
||||
twisterDisplayVersion = twisterVersion.slice(0,2) + '.' +
|
||||
twisterVersion.slice(2,4) + '.' +
|
||||
twisterVersion.slice(4,6) + '.' +
|
||||
twisterVersion.slice(6,8);
|
||||
|
||||
$(".connection-count").text(twisterdConnections);
|
||||
@ -301,10 +303,10 @@ function initInterfaceNetwork() {
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$(".userMenu-profile > a").text(polyglot.t("Login"));
|
||||
$(".userMenu-profile > a").attr("href","login.html");
|
||||
}
|
||||
{
|
||||
$(".userMenu-profile > a").text(polyglot.t("Login"));
|
||||
$(".userMenu-profile > a").attr("href","login.html");
|
||||
}
|
||||
});
|
||||
networkUpdate();
|
||||
setInterval("networkUpdate()", 2000);
|
||||
|
@ -2183,6 +2183,10 @@ textarea.splited-post {
|
||||
min-height: 68px;
|
||||
}
|
||||
|
||||
.reTwist .post-area-extras {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
********* REPLY POSTS PROMPT *********
|
||||
**************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user