Skip to content

Commit 957de40

Browse files
committed
perf(optimization): code tweaks
reorganized code, made it modular BREAKING CHANGE: we now moved to GitHub
1 parent beeb727 commit 957de40

File tree

7 files changed

+294
-173
lines changed

7 files changed

+294
-173
lines changed

GRCRTMain.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ function _GRCRTMain(){
401401
ga('create', 'UA-6635454-10', 'auto');
402402
ga('send', 'pageview');
403403
}
404+
this.sChbxs = {};
404405
this.init = function() {
405406
if (typeof Game != 'object' && typeof MousePopup != 'function' && typeof GameEvents != 'object') {
406407
setTimeout(function(){RepConv.init();},1000);
@@ -432,7 +433,7 @@ function _GRCRTMain(){
432433
this.CookieStatsGRC2 = this._cookie + "_statsGRC2",
433434
this.CookieStatsGRCL = this._cookie + "_statsGRCL",
434435
this.CookieUnitsCost = this._cookie + "_unitsCost",
435-
this.CookieOceanNumber = this._cookie + "_oceanNumber",
436+
// this.CookieOceanNumber = this._cookie + "_oceanNumber",
436437
this.CookieReportFormat = this._cookie + "_repFormat",
437438
this.CookieUnitsRecr = this._cookie + "_unitsRecr",
438439
this.CookieUnitsABH = this._cookie + "_unitsRecrABH",
@@ -441,6 +442,16 @@ function _GRCRTMain(){
441442
this.CookieWall = this._cookie + "_wall",
442443
this.hash = $.md5(this._cookie);
443444

445+
this.sChbxs[RepConv.CookiePower] = { label : 'CHKPOWERNAME' , default : true},
446+
this.sChbxs[RepConv.CookieForumTabs] = { label : 'CHKFORUMTABS' , default : true},
447+
this.sChbxs[RepConv.CookieUnitsCost] = { label : 'CHKUNITSCOST' , default : true},
448+
this.sChbxs[RepConv.CookieReportFormat] = { label : 'CHKREPORTFORMAT' , default : true},
449+
this.sChbxs[RepConv.Cookie+'_idle'] = { label : 'STATS.CHKINACTIVE' , default : true},
450+
this.sChbxs[RepConv.Cookie+'_wonder_trade'] = { label : 'CHKWONDERTRADE' , default : true},
451+
this.sChbxs[RepConv.Cookie+'_town_popup'] = { label : 'CHKTOWNPOPUP' , default : true},
452+
this.sChbxs[RepConv.Cookie+'_mcol'] = { label : 'CHKMCOL' , default : true},
453+
this.sChbxs[RepConv.Cookie+'_bupo'] = { label : 'CHKBUPO' , default : true},
454+
444455
RepConvLangArray = new _GRCRTRepConvLangArray()
445456

446457
if (RepConvLangArray[Game.locale_lang.substring(0,2)] == undefined) {

bin/build.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ try {
9191
function write2file(fileNameIn, fileNameOut, append){
9292
var data = fs.readFileSync(fileNameIn, 'utf8');
9393
var result = data
94-
.replace(/{GRCRT_VERSION}/g, GRCRT_VERSION)
9594
.replace(/{GRCRT_NAME}/g, GRCRT_NAME)
9695
.replace(/{GRCRT_URL}/g, GRCRT_URL)
9796
.replace(/\r\n/g,'\n')

common/RepConvTool.js

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,24 @@ function _RepConvTool() {
66
this.checkSettings = function(){
77
var defData = {}, setOK = true;
88
defData[RepConv.CookieCmdImg] = true,
9-
defData[RepConv.CookiePower] = true,
10-
defData[RepConv.CookieForumTabs] = true,
119
defData[RepConv.CookieStatsGRCL] = 'potusek',
12-
defData[RepConv.CookieUnitsCost] = true,
13-
defData[RepConv.CookieOceanNumber] = true,
14-
defData[RepConv.CookieReportFormat] = true,
1510
defData[RepConv.CookieSounds] = { mute: false, volume: 100, url:'', loop:true};
1611

1712
RepConv.settings = RepConv.settings || {}
1813

19-
if(RepConv.settings[RepConv.CookiePower] == undefined){
20-
RepConv.settings[RepConv.CookiePower] = JSON.parse(RepConvTool.getSettings(RepConv.CookiePower, defData[RepConv.CookiePower])),
21-
setOK = false;
22-
RepConv.Debug && console.log(RepConv.CookiePower)
23-
}
24-
if(RepConv.settings[RepConv.CookieForumTabs] == undefined){
25-
RepConv.settings[RepConv.CookieForumTabs] = JSON.parse(RepConvTool.getSettings(RepConv.CookieForumTabs, defData[RepConv.CookieForumTabs])),
26-
setOK = false;
27-
RepConv.Debug && console.log(RepConv.CookieForumTabs)
28-
}
14+
$.each(RepConv.sChbxs, function(opt, optData){
15+
if(RepConv.settings[opt] == undefined){
16+
RepConv.settings[opt] = JSON.parse(RepConvTool.getSettings(opt, optData.default)),
17+
setOK = false;
18+
RepConv.Debug && console.log(RepConv.CookieReportFormat)
19+
}
20+
})
21+
2922
if(RepConv.settings[RepConv.CookieStatsGRCL] == undefined){
3023
RepConv.settings[RepConv.CookieStatsGRCL] = RepConvTool.getSettings(RepConv.CookieStatsGRCL, defData[RepConv.CookieStatsGRCL]),
3124
setOK = false;
3225
RepConv.Debug && console.log(RepConv.CookieStatsGRCL)
3326
}
34-
if(RepConv.settings[RepConv.CookieUnitsCost] == undefined){
35-
RepConv.settings[RepConv.CookieUnitsCost] = JSON.parse(RepConvTool.getSettings(RepConv.CookieUnitsCost,defData[RepConv.CookieUnitsCost])),
36-
setOK = false;
37-
RepConv.Debug && console.log(RepConv.CookieUnitsCost)
38-
}
39-
if(RepConv.settings[RepConv.CookieOceanNumber] == undefined){
40-
RepConv.settings[RepConv.CookieOceanNumber] = JSON.parse(RepConvTool.getSettings(RepConv.CookieOceanNumber, defData[RepConv.CookieOceanNumber])),
41-
setOK = false;
42-
RepConv.Debug && console.log(RepConv.CookieOceanNumber)
43-
}
44-
if(RepConv.settings[RepConv.CookieReportFormat] == undefined){
45-
RepConv.settings[RepConv.CookieReportFormat] = JSON.parse(RepConvTool.getSettings(RepConv.CookieReportFormat, defData[RepConv.CookieReportFormat])),
46-
setOK = false;
47-
RepConv.Debug && console.log(RepConv.CookieReportFormat)
48-
}
4927
if(RepConv.settings[RepConv.CookieUnitsABH] == undefined){
5028
RepConv.settings[RepConv.CookieUnitsABH] = RepConvTool.getSettings(RepConv.CookieUnitsABH, "{}"),
5129
setOK = false;
@@ -76,41 +54,11 @@ function _RepConvTool() {
7654
setOK = false;
7755
RepConv.Debug && console.log(RepConv.CookieEmots)
7856
}
79-
if(RepConv.settings[RepConv.Cookie+'_idle'] == undefined){
80-
RepConv.settings[RepConv.Cookie+'_idle'] = true;//!(typeof QT_saveValue == 'function')
81-
setOK = false;
82-
RepConv.Debug && console.log(RepConv.Cookie+'_idle')
83-
}
8457
if(RepConv.settings[RepConv.CookieSounds] == undefined){
8558
RepConv.settings[RepConv.CookieSounds] = JSON.parse(RepConvTool.getSettings(RepConv.CookieSounds, JSON.stringify(defData[RepConv.CookieSounds]))),
8659
setOK = false;
8760
RepConv.Debug && console.log(RepConv.CookieSounds)
8861
}
89-
if(RepConv.settings[RepConv.Cookie+'_wonder_trade'] == undefined){
90-
RepConv.settings[RepConv.Cookie+'_wonder_trade'] = (RepConv.settings[RepConv.Cookie+'_wonder_trade']==undefined)?true:RepConv.settings[RepConv.Cookie+'_wonder_trade'],
91-
setOK = false;
92-
RepConv.Debug && console.log(RepConv.Cookie+'_wonder_trade')
93-
}
94-
if(RepConv.settings[RepConv.Cookie+'_town_popup'] == undefined){
95-
RepConv.settings[RepConv.Cookie+'_town_popup'] = (RepConv.settings[RepConv.Cookie+'_town_popup']==undefined)?true:RepConv.settings[RepConv.Cookie+'_town_popup'],
96-
setOK = false;
97-
RepConv.Debug && console.log(RepConv.Cookie+'_town_popup')
98-
}
99-
if(RepConv.settings[RepConv.Cookie+'_tacl'] == undefined){
100-
RepConv.settings[RepConv.Cookie+'_tacl'] = (RepConv.settings[RepConv.Cookie+'_tacl']==undefined)?true:RepConv.settings[RepConv.Cookie+'_tacl'],
101-
setOK = false;
102-
RepConv.Debug && console.log(RepConv.Cookie+'_tacl')
103-
}
104-
if(RepConv.settings[RepConv.Cookie+'_mcol'] == undefined){
105-
RepConv.settings[RepConv.Cookie+'_mcol'] = (RepConv.settings[RepConv.Cookie+'_mcol']==undefined)?true:RepConv.settings[RepConv.Cookie+'_mcol'],
106-
setOK = false;
107-
RepConv.Debug && console.log(RepConv.Cookie+'_mcol')
108-
}
109-
if(RepConv.settings[RepConv.Cookie+'_bupo'] == undefined){
110-
RepConv.settings[RepConv.Cookie+'_bupo'] = (RepConv.settings[RepConv.Cookie+'_bupo']==undefined)?true:RepConv.settings[RepConv.Cookie+'_bupo'],
111-
setOK = false;
112-
RepConv.Debug && console.log(RepConv.Cookie+'_bupo')
113-
}
11462

11563
if(!setOK){
11664
RepConv.Debug && console.log(_saveCount);
@@ -132,7 +80,7 @@ function _RepConvTool() {
13280
RepConv.active.ftabs = RepConv.settings[RepConv.CookieForumTabs],//, defData[RepConv.CookieForumTabs]),
13381
RepConv.active.statsGRCL = RepConv.settings[RepConv.CookieStatsGRCL],//, defData[RepConv.CookieStatsGRCL]),
13482
RepConv.active.unitsCost = RepConv.settings[RepConv.CookieUnitsCost],//,defData[RepConv.CookieUnitsCost]),
135-
RepConv.active.oceanNumber = RepConv.settings[RepConv.CookieOceanNumber],//, defData[RepConv.CookieOceanNumber]),
83+
// RepConv.active.oceanNumber = RepConv.settings[RepConv.CookieOceanNumber],//, defData[RepConv.CookieOceanNumber]),
13684
RepConv.active.reportFormat = RepConv.settings[RepConv.CookieReportFormat],//, defData[RepConv.CookieReportFormat]);
13785
RepConv.audioSupport && (RepConv.active.sounds = RepConv.settings[RepConv.CookieSounds]),
13886
this.useSettings()

modules/GRCRTMovedFrames.js

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
function _GRCRTMovedFrames(){
2+
"use strict";
3+
4+
function activity_commands_list(){
5+
if($('#toolbar_activity_commands_list').length==0){
6+
setTimeout(function(){
7+
activity_commands_list()
8+
},500);
9+
return;
10+
}
11+
// command list
12+
if($('#grcrt_taclWrap').length==0){
13+
$('#toolbar_activity_commands_list').wrap($('<div/>',{'class':'grcrt_taclWrap', 'id':'grcrt_taclWrap'}))
14+
if(RepConv.settings[RepConv.Cookie+'_tacl']){
15+
$('#toolbar_activity_commands_list').addClass('grcrt_tacl')
16+
$('#grcrt_taclWrap').draggable().draggable('enable')
17+
} else {
18+
$('#toolbar_activity_commands_list').removeClass('grcrt_tacl')
19+
$('#grcrt_taclWrap').draggable().draggable('disable').removeAttr('style')
20+
}
21+
}
22+
23+
var
24+
tacl_id = '#toolbar_activity_commands_list',
25+
tacl_clk = '.activity.commands',
26+
target_tacl = document.querySelector(tacl_id),
27+
observer_tacl = new MutationObserver(function(mutations) {
28+
mutations.forEach(function(mutation) {
29+
if($(target_tacl).hasClass('grcrt_tacl') && ($('#grcrt_taclWrap').attr('style') && $(target_tacl).css('display')=="none")){
30+
$(tacl_clk).trigger('mouseenter')
31+
}
32+
});
33+
});
34+
if($(tacl_id+">.js-dropdown-list>a.cancel").length == 0){
35+
$(tacl_id+">.js-dropdown-list")
36+
.append(
37+
$('<a/>',{'href':'#n','class':'cancel', 'style':'display:none;'})
38+
.click(function(){
39+
$('#grcrt_taclWrap').removeAttr('style')
40+
})
41+
)
42+
}
43+
observer_tacl.observe(target_tacl, { attributes: true, childList: false, characterData: false });
44+
}
45+
46+
// function activity_trades_list(){
47+
// if($('#toolbar_activity_trades_list').length==0){
48+
// setTimeout(function(){
49+
// activity_trades_list()
50+
// },500);
51+
// return;
52+
// }
53+
// var
54+
// tatl_id = '#toolbar_activity_trades_list',
55+
// tatl_clk = '.activity.trades'
56+
// if($('#grcrt_tatlWrap').length==0){
57+
// $('#toolbar_activity_trades_list').wrap($('<div/>',{'class':'grcrt_tatlWrap', 'id':'grcrt_tatlWrap'}))
58+
// if(RepConv.settings[RepConv.Cookie+'_tatl']){
59+
// $('#toolbar_activity_trades_list').addClass('grcrt_tatl')
60+
// $('#grcrt_tatlWrap').draggable().draggable('enable')
61+
// } else {
62+
// $('#toolbar_activity_trades_list').removeClass('grcrt_tatl')
63+
// $('#grcrt_tatlWrap').draggable().draggable('disable').removeAttr('style')
64+
// }
65+
// }
66+
67+
// if($(tatl_clk).hasClass('active')){
68+
// $(tatl_id)
69+
// .append(
70+
// $('<a/>',{'href':'#n','class':'cancel', 'style':'display:none;'})
71+
// .click(function(){
72+
// $('#grcrt_tatlWrap').removeAttr('style')
73+
// })
74+
// )
75+
// } else {
76+
// var
77+
// target_tatl = document.querySelector(tatl_id),
78+
// observer_tatl = new MutationObserver(function(mutations) {
79+
// mutations.forEach(function(mutation) {
80+
// if($(target_tatl).hasClass('grcrt_tatl') && ($('#grcrt_tatlWrap').attr('style') && $(target_tatl).css('display')=="none")){
81+
// $(tatl_clk).trigger('mouseenter')
82+
// }
83+
// });
84+
// });
85+
// $(tatl_id+">.js-dropdown-list")
86+
// .append(
87+
// $('<a/>',{'href':'#n','class':'cancel', 'style':'display:none;'})
88+
// .click(function(){
89+
// $('#grcrt_tatlWrap').removeAttr('style')
90+
// })
91+
// )
92+
// observer_tatl.observe(target_tatl, { attributes: true, childList: false, characterData: false });
93+
// }
94+
// }
95+
96+
$('head')
97+
.append(
98+
$('<style/>')
99+
.append( // frozen lists
100+
$('<style/>')
101+
.append('.showImportant { bisplay: block !important}')
102+
103+
.append('#grcrt_taclWrap { left:312px; position: absolute; top: 29px;}')
104+
.append('#grcrt_taclWrap>#toolbar_activity_commands_list { left: 0 !important; top: 0 !important;}')
105+
.append('.grcrt_tacl { z-index:5000 !important;}')
106+
.append('.grcrt_tacl>.js-dropdown-list>a.cancel { position: relative; float: right; margin-bottom: 11px;display:none; opacity: 0; visibility: hidden; transition: visibility 0s, opacity 0.5s linear;}')
107+
.append('.grcrt_tacl>.js-dropdown-list:hover>a.cancel { display: block !important; visibility: visible; opacity: 0.5;}')
108+
.append('.grcrt_tacl>.js-dropdown-list>a.cancel:hover { opacity: 1;}')
109+
110+
// .append('#grcrt_tatlWrap { left:340px; position: absolute; top: 29px;}')
111+
// .append('#grcrt_tatlWrap>#toolbar_activity_trades_list { left: 0 !important; top: 0 !important;}')
112+
// .append('.grcrt_tatl { z-index:5000 !important;}')
113+
// .append('.grcrt_tatl>a.cancel { position: relative; float: right; margin-bottom: 11px;display:none; opacity: 0; visibility: hidden; transition: visibility 0s, opacity 0.5s linear;}')
114+
// .append('.grcrt_tatl:hover>a.cancel { display: block !important; visibility: visible; opacity: 0.5;}')
115+
// .append('.grcrt_tatl>a.cancel:hover { opacity: 1;}')
116+
// .append('.grcrt_tatl>.js-dropdown-list>a.cancel { position: relative; float: right; margin-bottom: 11px;display:none; opacity: 0; visibility: hidden; transition: visibility 0s, opacity 0.5s linear;}')
117+
// .append('.grcrt_tatl>.js-dropdown-list:hover>a.cancel { display: block !important; visibility: visible; opacity: 0.5;}')
118+
// .append('.grcrt_tatl>.js-dropdown-list>a.cancel:hover { opacity: 1;}')
119+
120+
121+
// .append('.grcrt_tarl>a.cancel,.grcrt_tacl>a.cancel,.grcrt_tatl>a.cancel { position: relative; float: right; margin-bottom: 0px;display:none; opacity: 0; visibility: hidden; transition: visibility 0s, opacity 0.5s linear;}')
122+
// .append('.grcrt_tarl:hover>a.cancel,.grcrt_tacl:hover>a.cancel,.grcrt_tatl:hover>a.cancel { display: block !important; visibility: visible; opacity: 0.5;}')
123+
// .append('.grcrt_tarl>a.cancel:hover,.grcrt_tacl>a.cancel:hover,.grcrt_tatl>a.cancel:hover { opacity: 1;}')
124+
// .append('.grcrt_tacl>.js-dropdown-list:after {content: "___"; float: right; height: 30px; background: transparent url(https://cdn1.iconfinder.com/data/icons/interface-4/96/Cursor-Move-16.png) no-repeat top right; color: transparent;position:relative}')
125+
// .append('.grcrt_tacl>.js-dropdown-list:after:hover {height: 30px;}')
126+
// .append('.grcrt_tacl>.js-dropdown-item-list:after {content: "___"; float: right; height: 19px; background: transparent url(https://cdn1.iconfinder.com/data/icons/interface-4/96/Cursor-Move-16.png) no-repeat top right; color: transparent;position:relative}')
127+
// .append('.grcrt_tacl>.js-dropdown-item-list:after:hover {height: 30px;}')
128+
)
129+
);
130+
131+
RepConv.sChbxs[RepConv.Cookie+'_tacl'] = { label : 'CHKTACL', default : true}
132+
// RepConv.sChbxs[RepConv.Cookie+'_tatl'] = { label : 'CHKTATL', default : true}
133+
134+
$.Observer(GameEvents.grcrt.settings.load)
135+
.subscribe('GRCRTMovedFrames_settings_load', function() {
136+
activity_commands_list();
137+
// activity_trades_list();
138+
});
139+
}

modules/GRCRTOceanNumbers.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
function _GRCRTOceanNumbers(){
2+
var _cookie = RepConv._cookie + "_oceanNumber";
23
function oceanNumbers(){
34
if ($('#map_move_container').length == 0) {
45
setTimeout(function(){
56
oceanNumbers();
67
}, 100);
78
} else {
8-
if (!RepConv.active.oceanNumber) {
9+
if (!RepConv.settings[_cookie]) {
910
$('div#grcrt_oceanNumbers').remove()
1011
} else {
1112
if ($('div#grcrt_oceanNumbers').length == 0) {
@@ -25,6 +26,12 @@ function _GRCRTOceanNumbers(){
2526
}
2627
}
2728
}
29+
30+
RepConv.sChbxs[_cookie] = {
31+
label : 'CHKOCEANNUMBER',
32+
default : true
33+
}
34+
2835
$.Observer(GameEvents.grcrt.settings.load)
2936
.subscribe('GRCRTOceanNumbers_settings_load', function() {
3037
oceanNumbers();

0 commit comments

Comments
 (0)