mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-12 16:07:59 +00:00
rewrite newPostMsg()
This commit is contained in:
parent
b440cb2600
commit
3180a04de4
@ -2472,7 +2472,7 @@ function postSubmit(e, oldLastPostId) {
|
||||
}
|
||||
|
||||
var doSubmitPost = function (postText, postData) {
|
||||
newPostMsg(postText, postData);
|
||||
newPostMsg(postText, postData.attr('data-screen-name'), parseInt(postData.attr('data-id')));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ function installSubmitClick() {
|
||||
var $postOrig = $("#newmsg .reply-original-post .post-data");
|
||||
|
||||
var s = encode_utf8($replyText.val());
|
||||
newPostMsg(s, $postOrig);
|
||||
newPostMsg(s, $postOrig.attr('data-screen-name'), parseInt($postOrig.attr('data-id')));
|
||||
|
||||
$replyText.val("");
|
||||
$replyText.attr("placeholder", polyglot.t("Your message was sent!"));
|
||||
|
@ -243,23 +243,44 @@ function requestPostRecursively(containerToAppend,username,resource,count,useGet
|
||||
}
|
||||
}
|
||||
|
||||
function newPostMsg(msg, $postOrig) {
|
||||
if( lastPostId != undefined ) {
|
||||
if ( typeof _sendedPostIDs !== 'undefined' )
|
||||
_sendedPostIDs.push(lastPostId + 1);
|
||||
|
||||
var params = [defaultScreenName, lastPostId + 1, msg]
|
||||
if( $postOrig.length ) {
|
||||
params.push($postOrig.attr('data-screen-name'));
|
||||
params.push(parseInt($postOrig.attr('data-id')));
|
||||
}
|
||||
twisterRpc("newpostmsg", 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!)"));
|
||||
function newPostMsg(msg, reply_n, reply_k, cbFunc, cbReq) {
|
||||
if (typeof lastPostId === 'undefined') {
|
||||
alertPopup({
|
||||
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
|
||||
txtMessage: 'Can\'t handle the twisting of a new twist —\n'
|
||||
+ polyglot.t('Internal error: lastPostId unknown (following yourself may fix!)')
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeof _sendedPostIDs !== 'object') {
|
||||
alertPopup({
|
||||
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
|
||||
txtMessage: 'Can\'t handle the twisting of a new twist —\n'
|
||||
+ polyglot.t('this is undefined', {'this': '_sendedPostIDs'})
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
_sendedPostIDs.push(lastPostId + 1);
|
||||
|
||||
var req = [defaultScreenName, lastPostId + 1, msg];
|
||||
if (reply_n)
|
||||
req.push(reply_n, reply_k);
|
||||
|
||||
twisterRpc('newpostmsg', req,
|
||||
function(req, ret) {
|
||||
incLastPostId();
|
||||
if (typeof req.cbFunc === 'function')
|
||||
req.cbFunc(req.cbReq, ret);
|
||||
}, {cbFunc: cbFunc, cbReq: cbReq},
|
||||
function(req, ret) {
|
||||
alertPopup({
|
||||
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
|
||||
txtMessage: 'Can\'t handle the twisting of a new twist —\n'
|
||||
+ polyglot.t('ajax_error', {error: (ret.message) ? ret.message : ret})
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function newRtMsg(postData, msg) {
|
||||
|
Loading…
Reference in New Issue
Block a user