Skip to content

Commit ec1b595

Browse files
committed
refactor(playerId): change how playerId is fetched
1 parent d8eab3b commit ec1b595

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

common/RepConvTool.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,4 +867,15 @@ function _RepConvTool() {
867867
$('<script/>',{'type':"text/template", 'id':"tpl_grcrt_button"})
868868
.text('<div class="left"></div><div class="right"></div><div class="caption js-caption"><% if (icon && icon_position === \'left\') { %><div class="icon"></div><% } %><img src="https://cdn.grcrt.net/img/octopus.png" style="width: 20px;float:left;margin: 0px 5px 0px -6px"><%= caption %><% if (icon && icon_position === \'right\') { %><div class="icon"></div><% } %><div class="effect js-effect"></div></div>')
869869
);
870+
this.getPlayerId4Name = function(pName){
871+
var _ret = undefined;
872+
try{
873+
$.each(RepConv.cachePlayers, function(pId,pData){
874+
if (pData.name == pName)
875+
_ret = pData.id;
876+
})
877+
return _ret;
878+
} catch(e){}
879+
return null;
880+
}
870881
}

modules/RepConvGRC.js

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,10 @@ function _RepConvGRC() {
462462
// statystyki gracza
463463
if ( (RCGP.getJQElement()).find($(WndId+'RepConvStatsPlayer')).length == 0) {
464464
var
465-
__tmp = ((RCGP.getContext().sub == "player_get_profile_html") ? btoa(JSON.stringify({id:RCGP.getOptions().player_id})) : $(elem).nextAll('.gp_player_link').attr('href')).split(/#/),
466-
_player = (RCGP.getType() == Layout.wnd.TYPE_PLAYER_PROFILE_EDIT) ? Game.player_id : (RCGP.getContext().sub == "player_get_profile_html") ? JSON.parse(unescape(RepConv.requests.player.url).match(/({.*})/)[0]).player_id : JSON.parse(atob(__tmp[1] || __tmp[0])).id,
465+
// __tmp = ((RCGP.getContext().sub == "player_get_profile_html") ? btoa(JSON.stringify({id:RCGP.getOptions().player_id})) : $(elem).nextAll('.gp_player_link').attr('href')).split(/#/),
466+
// _player = (RCGP.getType() == Layout.wnd.TYPE_PLAYER_PROFILE_EDIT) ? Game.player_id : (RCGP.getContext().sub == "player_get_profile_html") ? ((RepConv.requests.player && RepConv.requests.player.url) ? JSON.parse(unescape(RepConv.requests.player.url).match(/({.*})/)[0]).player_id : RCGP.getOptions().player_id) : JSON.parse(atob(__tmp[1] || __tmp[0])).id,
467467
_player_name = RCGP.getJQElement().find($('#write_message_form input[name="recipients"]')).val(),
468+
_player = RepConvTool.getPlayerId4Name(_player_name),
468469
_link = $('<a/>',{
469470
'href' : "#n",
470471
'id' : WndName + 'RepConvStatsPlayer',
@@ -491,9 +492,10 @@ function _RepConvGRC() {
491492
// radar dla miast gracza
492493
if ( (RCGP.getJQElement()).find($(WndId+'RepConvRadarPlayer')).length == 0) {
493494
var
494-
__tmp = ((RCGP.getContext().sub == "player_get_profile_html") ? btoa(JSON.stringify({id:RCGP.getOptions().player_id})) : $(elem).nextAll('.gp_player_link').attr('href')).split(/#/),
495-
_player = (RCGP.getType() == Layout.wnd.TYPE_PLAYER_PROFILE_EDIT) ? Game.player_id : (RCGP.getContext().sub == "player_get_profile_html") ? JSON.parse(unescape(RepConv.requests.player.url).match(/({.*})/)[0]).player_id : JSON.parse(atob(__tmp[1] || __tmp[0])).id,
496-
_player_name = RCGP.getJQElement().find($('#write_message_form input[name="recipients"]')).val();
495+
// __tmp = ((RCGP.getContext().sub == "player_get_profile_html") ? btoa(JSON.stringify({id:RCGP.getOptions().player_id})) : $(elem).nextAll('.gp_player_link').attr('href')).split(/#/),
496+
// _player = (RCGP.getType() == Layout.wnd.TYPE_PLAYER_PROFILE_EDIT) ? Game.player_id : (RCGP.getContext().sub == "player_get_profile_html") ? ((RepConv.requests.player && RepConv.requests.player.url) ? JSON.parse(unescape(RepConv.requests.player.url).match(/({.*})/)[0]).player_id : RCGP.getOptions().player_id) : JSON.parse(atob(__tmp[1] || __tmp[0])).id,
497+
_player_name = RCGP.getJQElement().find($('#write_message_form input[name="recipients"]')).val(),
498+
_player = RepConvTool.getPlayerId4Name(_player_name);
497499
RCGP.getJQElement()
498500
.find($('#player_info>h3'))
499501
.before(
@@ -1745,6 +1747,17 @@ function _RepConvGRC() {
17451747
$(_parent).find($('.curr4')).html('');
17461748
}
17471749
});
1750+
if(RCGP.getJQElement().find($('.content div#unit_order_booty')).length == 0){
1751+
RCGP.getJQElement().find($('.content div#duration_container'))
1752+
.before(
1753+
$('<div/>',{'id':'unit_order_booty','style':'position: relative;top: -28px;cursor: pointer;'})
1754+
.click(function(){
1755+
$('#trade_type_wood input').select().val(Math.floor(ITowns.getTown(Game.townId).getAvailableTradeCapacity()/3)).blur()
1756+
$('#trade_type_stone input').select().val(Math.floor(ITowns.getTown(Game.townId).getAvailableTradeCapacity()/3)).blur()
1757+
$('#trade_type_iron input').select().val(Math.floor(ITowns.getTown(Game.townId).getAvailableTradeCapacity()/3)).blur()
1758+
})
1759+
)
1760+
}
17481761
}
17491762
$.each(RCGP.getJQElement().find($('.amounts .curr4')), function(ind, elem){
17501763
var _parent = $(elem).parent();
@@ -2183,7 +2196,7 @@ function _RepConvGRC() {
21832196
}
21842197

21852198
function emotsTabs(wndType, action){//insertArea){
2186-
var content = $('<div/>', {'class': 'gpwindow_content', 'style': 'overflow-y:auto !important; max-height: 185px; min-height: 120px;'}),
2199+
var content = $('<div/>', {'class': 'gpwindow_content', 'style': 'overflow-y:auto !important; max-height: 185px; min-height: 120px; top: 44px !important;'}),
21872200
contentLinks = $('<ul/>', {'class':'menu_inner grcrt_menu_inner', 'style':'padding: 0px;left:0px;'}),
21882201
tabs =
21892202
$('<div/>', {'id': 'emots_popup_' + wndType, 'style': 'display:none; z-index: 5000; min-height: 180px;max-height: 265px;','class':'grcrtbb'})
@@ -2537,8 +2550,19 @@ function _RepConvGRC() {
25372550
function addIdleDays(RCGP){
25382551
$.each(RCGP.getJQElement().find($('.grcrt_idle')), function(ind, elem){
25392552
var
2540-
__tmp = ((RCGP.getContext().sub == "player_get_profile_html") ? btoa(JSON.stringify({id:RCGP.getOptions().player_id})) : $(elem).nextAll('.gp_player_link').attr('href')).split(/#/),
2541-
_player = (RCGP.getType() == Layout.wnd.TYPE_PLAYER_PROFILE_EDIT) ? Game.player_id : (RCGP.getContext().sub == "player_get_profile_html") ? JSON.parse(unescape(RepConv.requests.player.url).match(/({.*})/)[0]).player_id : JSON.parse(atob(__tmp[1] || __tmp[0])).id,
2553+
__tmp = ((RCGP.getContext().sub == "player_get_profile_html")
2554+
?
2555+
btoa(JSON.stringify({id:RCGP.getOptions().player_id}))
2556+
:
2557+
$(elem).nextAll('.gp_player_link').attr('href')).split(/#/),
2558+
_player = (RCGP.getType() == Layout.wnd.TYPE_PLAYER_PROFILE_EDIT)
2559+
? Game.player_id
2560+
:
2561+
(RCGP.getContext().sub == "player_get_profile_html")
2562+
?
2563+
/*((RepConv.requests.player && RepConv.requests.player.url) ? JSON.parse(unescape(RepConv.requests.player.url).match(/({.*})/)[0]).player_id : RCGP.getOptions().player_id)*/
2564+
RepConvTool.getPlayerId4Name(RCGP.getJQElement().find($('#write_message_form input[name="recipients"]')).val())
2565+
: JSON.parse(atob(__tmp[1] || __tmp[0])).id,AQQ
25422566
_days = parseFloat(RepConvGRC.idle.JSON[_player]||'-1');
25432567
$(elem).addClass('grcrt_idle_days'),
25442568
$(elem).addClass('grcrt_idle_dg'),
@@ -3456,6 +3480,9 @@ function _RepConvGRC() {
34563480
'.grcrt_brackets:before { content: "("}\n'+
34573481
'.grcrt_brackets:after { content: ")"}'
34583482
)
3483+
)
3484+
.append(
3485+
$('<style/>', {'id':'grcrt_ft'})
34593486
);
34603487
// obsługa YT
34613488
$('#ui_box')

0 commit comments

Comments
 (0)