mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-27 07:04:24 +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) {
|
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 $postOrig = $("#newmsg .reply-original-post .post-data");
|
||||||
|
|
||||||
var s = encode_utf8($replyText.val());
|
var s = encode_utf8($replyText.val());
|
||||||
newPostMsg(s, $postOrig);
|
newPostMsg(s, $postOrig.attr('data-screen-name'), parseInt($postOrig.attr('data-id')));
|
||||||
|
|
||||||
$replyText.val("");
|
$replyText.val("");
|
||||||
$replyText.attr("placeholder", polyglot.t("Your message was sent!"));
|
$replyText.attr("placeholder", polyglot.t("Your message was sent!"));
|
||||||
|
@ -243,23 +243,44 @@ function requestPostRecursively(containerToAppend,username,resource,count,useGet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newPostMsg(msg, $postOrig) {
|
function newPostMsg(msg, reply_n, reply_k, cbFunc, cbReq) {
|
||||||
if( lastPostId != undefined ) {
|
if (typeof lastPostId === 'undefined') {
|
||||||
if ( typeof _sendedPostIDs !== '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);
|
_sendedPostIDs.push(lastPostId + 1);
|
||||||
|
|
||||||
var params = [defaultScreenName, lastPostId + 1, msg]
|
var req = [defaultScreenName, lastPostId + 1, msg];
|
||||||
if( $postOrig.length ) {
|
if (reply_n)
|
||||||
params.push($postOrig.attr('data-screen-name'));
|
req.push(reply_n, reply_k);
|
||||||
params.push(parseInt($postOrig.attr('data-id')));
|
|
||||||
}
|
twisterRpc('newpostmsg', req,
|
||||||
twisterRpc("newpostmsg", params,
|
function(req, ret) {
|
||||||
function(arg, ret) { incLastPostId(); }, null,
|
incLastPostId();
|
||||||
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
|
if (typeof req.cbFunc === 'function')
|
||||||
alert(polyglot.t("ajax_error", { error: msg })); }, null);
|
req.cbFunc(req.cbReq, ret);
|
||||||
} else {
|
}, {cbFunc: cbFunc, cbReq: cbReq},
|
||||||
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
|
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) {
|
function newRtMsg(postData, msg) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user