From a6b89ce2713433f7133309f7b12ffd1eaa756387 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sat, 9 Jan 2016 00:00:40 +0500 Subject: [PATCH] rename some vars and restyle a bit in js/twister_directmsg.js --- js/twister_directmsg.js | 62 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/js/twister_directmsg.js b/js/twister_directmsg.js index 19b7592..6f52793 100644 --- a/js/twister_directmsg.js +++ b/js/twister_directmsg.js @@ -8,9 +8,9 @@ var _groupMsgInviteToGroupQueue = []; function requestDMsnippetList(dmThreadList, forGroup) { var followList = []; for (var i = 0; i < followingUsers.length; i++) - followList.push({username:followingUsers[i]}); + followList.push({username: followingUsers[i]}); for (var i = 0; i < groupChatAliases.length; i++) - followList.push({username:groupChatAliases[i]}); + followList.push({username: groupChatAliases[i]}); twisterRpc('getdirectmsgs', [defaultScreenName, 1, followList], function(req, ret) {processDMsnippet(ret, req.dmThreadList, req.forGroup);}, @@ -49,33 +49,33 @@ function processDMsnippet(dmUsers, dmThreadList, forGroup) { $.MAL.dmThreadListLoaded(); } -function requestDmConversationModal(postboard, dm_screenname) { +function requestDmConversationModal(postboard, peerAlias) { if (!isModalWithElemExists(postboard)) return; - requestDmConversation(postboard, dm_screenname); - setTimeout(requestDmConversationModal, 1000, postboard, dm_screenname); + requestDmConversation(postboard, peerAlias); + setTimeout(requestDmConversationModal, 1000, postboard, peerAlias); } -function requestDmConversation(postboard, dm_screenname) { +function requestDmConversation(postboard, peerAlias) { var since_id = undefined; var oldItems = postboard.children(); if (oldItems.length) since_id = parseInt(oldItems.eq(oldItems.length - 1).attr('data-id')); - var userDmReq = [{username: dm_screenname}]; + var userDmReq = [{username: peerAlias}]; if (typeof since_id !== 'undefined') userDmReq[0].since_id = since_id; var count = 100; twisterRpc('getdirectmsgs', [defaultScreenName, count, userDmReq], - function(args, ret) {processDmConversation(args.postboard, args.dm_screenname, ret);}, - {postboard: postboard, dm_screenname: dm_screenname}, - function(arg, ret) { + function(req, ret) {processDmConversation(req.postboard, req.peerAlias, ret);}, + {postboard: postboard, peerAlias: peerAlias}, + function(req, ret) { var msg = (ret.message) ? ret.message : ret; alert(polyglot.t('ajax_error', {error: msg})); - }, null + } ); } @@ -117,25 +117,25 @@ function directMsgSubmit(e) { replyText.val(''); } -function newDirectMsg(msg, dm_screenname) { +function newDirectMsg(msg, peerAlias) { if (typeof lastPostId !== 'undefined') { - var paramsOrig = [defaultScreenName, lastPostId + 1, dm_screenname, msg]; + var paramsOrig = [defaultScreenName, lastPostId + 1, peerAlias, msg]; var paramsOpt = paramsOrig; var copySelf = $.Options.dmCopySelf.val === 'enable'; - if (copySelf && dm_screenname[0] !== '*') + if (copySelf && peerAlias[0] !== '*') paramsOpt = paramsOrig.concat(true) twisterRpc('newdirectmsg', paramsOpt, - function(arg, ret) { + function(req, ret) { incLastPostId(); - if (arg.copySelf) + if (req.copySelf) incLastPostId(); }, {copySelf: copySelf}, - function(arg, ret) { + function(req, ret) { // fallback for older twisterd (error: no copy_self parameter) - twisterRpc('newdirectmsg', arg.paramsOrig, - function(arg, ret) {incLastPostId();}, null, - function(arg, ret) { + twisterRpc('newdirectmsg', req.paramsOrig, + function(req, ret) {incLastPostId();}, null, + function(req, ret) { var msg = (ret.message) ? ret.message : ret; alert('Ajax error: ' + msg); }, null @@ -175,7 +175,7 @@ function directMessagesPopup() { ; } -function openDmWithUserModal(dm_screenname) { +function openDmWithUserModal(peerAlias) { if (!defaultScreenName) { alert(polyglot.t('You have to log in to use direct messages.')); return; @@ -184,17 +184,17 @@ function openDmWithUserModal(dm_screenname) { var modal = openModal({ classAdd: 'directMessages', content: $('.messages-thread-template').children().clone(true), - title: polyglot.t('direct_messages_with', {username: '' + dm_screenname + ''}) + title: polyglot.t('direct_messages_with', {username: '' + peerAlias + ''}) }); - modal.self.attr('data-screen-name', dm_screenname); + modal.self.attr('data-screen-name', peerAlias); - if (dm_screenname.length && dm_screenname[0] === '*') - getGroupChatName(dm_screenname, modal.self.find('.modal-header h3 span')); + if (peerAlias.length && peerAlias[0] === '*') + getGroupChatName(peerAlias, modal.self.find('.modal-header h3 span')); else - getFullname(dm_screenname, modal.self.find('.modal-header h3 span')); + getFullname(peerAlias, modal.self.find('.modal-header h3 span')); - requestDmConversationModal(modal.self.find('.direct-messages-thread').empty(), dm_screenname); + requestDmConversationModal(modal.self.find('.direct-messages-thread').empty(), peerAlias); $('.dm-form-template').children().clone(true) .addClass('open').appendTo(modal.content).fadeIn('fast'); @@ -356,7 +356,7 @@ function openGroupMessagesJoinGroupModal() { }, {groupAlias: groupAlias}, function(req, ret) { alert(polyglot.t('Error in \'importprivkey\'', {rpc: ret.message})); - }, null + } ); }); } @@ -371,7 +371,7 @@ function groupMsgCreateGroup(description, peersToInvite) { }, peersToInvite, function(req, ret) { alert(polyglot.t('error', {error: 'can\'t create group — ' + ret.message})); - }, null + } ); } @@ -450,9 +450,7 @@ function groupMsgInviteFormInputSetTextcompleteReq() { })); }, index: 1, - replace: function (mention) { - return '@'+mention+' '; - } + replace: function (mention) {return '@' + mention + ' ';} }] }