This repository has been archived by the owner on Aug 25, 2022. It is now read-only.
forked from sephizack/sephiogame
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSephiOgame.user.js
5900 lines (5897 loc) · 441 KB
/
SephiOgame.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name SephiOGame
// @namespace http://www.sephiogame.com
// @version 3.10.11
// @description Script Ogame
// @author Sephizack,I2T,Chewbaka
//
// @exclude /^(http|https)://s.*\.ogame\.gameforge\.com/feed/.*$/
// @exclude /^(http|https)://s.*\.ogame\.gameforge\.com/board/.*$/
// @exclude /^(http|https)://www\.sephiogame\.com/.*$/
// @exclude /^(http|https)://www.*$/
// @exclude /^(http|https)://.*ajax=1.*$/
// @include /^(http|https)://s.*\.ogame\.gameforge\.com/game/index.php.*$/
// @include /^(http|https)://fr\.ogame\.gameforge\.com/$/
//
// @copyright 2012+, You
// @require http://code.jquery.com/jquery-1.9.1.min.js
// @grant GM_xmlhttpRequest
// @connect sephiogame.com
// ==/UserScript==
//
var _b, _c, _d, _e, _f, _g;
try {
var debug = false;
var antiBugTimeout = setTimeout(function () { location.href = location.href; }, 5 * 60 * 1000);
var cur_version = '3.10.11';
var univers = window.location.href.split('/')[2];
var PersistedData = /** @class */ (function () {
function PersistedData() {
}
return PersistedData;
}());
// Multi langues
var isFR = univers.match('fr');
var LANG_programm = isFR ? "Programmer" : "Add to list";
var LANG_added = isFR ? "Ajouté" : "Added";
var LANG_started = isFR ? "Lancé" : "Started";
var LANG_done = isFR ? "Terminé" : "Done";
var LANG_noLocalStorage = isFR ? "Votre navigateur ne supporte pas le système de localStorage, mettez le à jour ou désinstallez le script."
: "Your browser does not support localStorage feature, please update to latest Chrome version or unistall SephiOGame.";
var LANG_nouveaute_update = ' - Fix premium button break programmation number';
//get userid
var userid = ($('head').find('meta[name="ogame-player-id"]') != null && $('head').find('meta[name="ogame-player-id"]').length > 0) ? $('head').find('meta[name="ogame-player-id"]').attr("content") : tabID;
//get allianceid
var allianceid = ($('head').find('meta[name="ogame-alliance-id"]') != null && $('head').find('meta[name="ogame-alliance-id"]').length > 0) ? $('head').find('meta[name="ogame-alliance-id"]').attr("content") : "";
//get username
var username = ($('head').find('meta[name="ogame-player-name"]') != null && $('head').find('meta[name="ogame-player-name"]').length > 0) ? $('head').find('meta[name="ogame-player-name"]').attr("content") : "unloged";
//get current token
var cur_token = ($(document.body).find("#planet input[name='token']") != null && $(document.body).find("#planet input[name='token']").length > 0) ? $(document.body).find("#planet input[name='token']").val() : "";
//Compatibility Antigame
var AGO_actif = ($(document).find("#ago_global_data").length > 0);
if ($('#banner_skyscraper'))
$('#banner_skyscraper').html('');
if (localStorage == null) {
alert("SephiOGame : " + LANG_noLocalStorage);
exit(0);
}
var clock = $('#ago_clock');
if (clock.length >= 1)
clock.css({ display: "none" });
//##############################################
// Fonctions de base
//##############################################
function exit(i) { throw new Error('This is not an error. This is just to abort javascript'); }
function time() { var mytime = new Date(); return mytime.getTime(); }
function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds) {
break;
}
} }
function checkmail(mailteste) { var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i'); return (reg.test(mailteste)); }
function storeData(name, value, name_prefix) {
if (name_prefix == 'all')
name = userid + '_' + name;
else
name = GLOB_cur_planet + '_' + name_prefix + '_' + name;
localStorage.setItem(name, value);
}
function readData(name, name_prefix) {
if (name_prefix == 'all' && localStorage.getItem(name_prefix + '_' + name) != null && localStorage.getItem(name_prefix + '_' + name) != "") {
if (localStorage.getItem(userid + '_' + name) == null || localStorage.getItem(userid + '_' + name) == "")
localStorage.setItem(userid + '_' + name, localStorage.getItem(name_prefix + '_' + name));
localStorage.removeItem(name_prefix + '_' + name);
}
if (name_prefix == 'all')
name = userid + '_' + name;
else
name = GLOB_cur_planet + '_' + name_prefix + '_' + name;
//retrocompatibility
return localStorage.getItem(name);
}
function removeData(name, name_prefix) {
if (name_prefix == 'all')
name = userid + '_' + name;
else
name = GLOB_cur_planet + '_' + name_prefix + '_' + name;
localStorage.removeItem(name);
}
function storeSessionData(name, value, name_prefix) {
if (name_prefix == 'all')
name = name_prefix + '_' + name;
else
name = GLOB_cur_planet + '_' + name_prefix + '_' + name;
sessionStorage.setItem(name, value);
}
function readSessionData(name, name_prefix) {
if (name_prefix == 'all') {
name = name_prefix + '_' + name;
}
else {
name = GLOB_cur_planet + '_' + name_prefix + '_' + name;
}
return sessionStorage.getItem(name);
}
function removeSessionData(name, name_prefix) {
if (name_prefix == 'all')
name = name_prefix + '_' + name;
else
name = GLOB_cur_planet + '_' + name_prefix + '_' + name;
sessionStorage.removeItem(name);
}
function gup(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null)
return "";
else
return results[1];
}
function rand(a, b) { return Math.floor((Math.random() * (b - a)) + a); }
function blit_message(message) {
blit_message_time(message, 7000);
}
function blit_message_time(message, time) {
$("#fadeBox").fadeTo(0, 0);
$('#fadeBox').css({ display: 'block' });
$('#fadeBoxStyle').css({
height: "46px",
width: "90px",
margin: "3px 0 0 12px",
backgroundImage: "url(http://www.sephiogame.com/script/icon_ecchi2.png)"
});
$('#fadeBoxContent').css({ width: "120px" });
$('#fadeBoxContent').html(message);
$("#fadeBox").fadeTo(400, 0.85);
setTimeout(function () { $("#fadeBox").fadeTo(400, 0); }, time);
}
//######################################################################################
// ALL Functions
//######################################################################################
/**
* Auth, Save and Load gmail api
*
* @param {authResult} result of the Auth request
*/
function Auth_Load_Save_info(authResult) {
if (authResult && !authResult.error) {
storeData('gapi_auth', time().toString(), 'all');
storeData('gapi_token', authResult.access_token, 'all');
storeData('gapi_expires_in', authResult.expires_in, 'all');
storeData('gapi_clientid', authResult.client_id, 'all');
storeData('gapi_scope', authResult.scope, 'all');
if (gup('sephiScript')) {
$('#authorize-div').css({ display: 'none' });
$('#alertmail-div').css({ display: 'inline' });
appendResults($('#output'), (isFR) ? 'Vous avez autorisé google à envoyer des mails en votre nom. Merci pour votre confiance.' : 'You have authorized google to send email for you. Thanks to trust us.');
}
blit_message((isFR) ? 'Vous êtes maintenant authentifié auprés de Google gmail!' : 'You are now authenticated on Google gmail!');
loadGmailApi();
}
else {
storeData('gapi_auth', '0', 'all');
storeData('gapi_token', '0', 'all');
storeData('gapi_expires_in', '0', 'all');
storeData('gapi_clientid', '0', 'all');
storeData('gapi_scope', '0', 'all');
if (gup('sephiScript')) {
$('#authorize-div').css({ display: 'inline' });
$('#authorize-div').css({ display: 'none' });
}
blit_message('Perte de l\'authentification Google gmail! Cliquer sur le bouton pour vous authentifier.');
}
}
function make_important_vars_data() {
return JSON.stringify(GLOB_persistedData, null, 2);
}
function init_vars() {
save_important_vars('');
blit_message('Vos données de cette planète <span style="float: none; margin: 0; color:#109E18">ont bien été réinitialisées</span>.');
setTimeout(function () {
window.location.href = window.location.href;
}, 1000);
}
function save_important_vars(data_cloud) {
var aSerializedData;
if (!data_cloud)
aSerializedData = make_important_vars_data();
else
aSerializedData = data_cloud;
storeData("saved_vars_v2", aSerializedData, 'dump');
return;
}
function load_important_vars() {
var aSerializedData = readData("saved_vars_v2", 'dump');
if (aSerializedData !== null) {
// Migrated
try {
GLOB_persistedData = JSON.parse(aSerializedData);
}
catch (e) {
blit_message('<span style="color:red">Unable to load saved data</span>');
if (debug)
console.log('e1:' + e);
throw e;
}
if (debug)
console.log('JSON persisted data retrieved');
return;
}
// Not migrated
aSerializedData = readData("saved_vars", 'dump');
if (aSerializedData !== null && aSerializedData !== 'que dalle') {
try {
GLOB_persistedData = JSON.parse(aSerializedData);
}
catch (e) {
if (debug)
console.log('No JSON found, using old algorithm');
try {
// Must support old format for compatibility reasons. Can be removed after a long time :/
GLOB_persistedData = load_persisted_data_deprecated(aSerializedData);
}
catch (e) {
blit_message('<span style="color:red">Unable to load saved data</span>');
if (debug)
console.log('e2:' + e);
throw e;
}
}
}
}
function load_persisted_data_deprecated(iSerializedData) {
var result = { "listPrev": null, "prods": null, "frigos": null, "eject": null };
iSerializedData = iSerializedData.replace(/_Ar1_/g, '\n');
var aSerializedDataParts = iSerializedData.split('/_/_/');
for (var i = 0; i < aSerializedDataParts.length - 1; i++) {
if (aSerializedDataParts[i] !== null && aSerializedDataParts[i].replace('\n', '') !== aSerializedDataParts[i]) {
aSerializedDataParts[i] = aSerializedDataParts[i].split('\n');
aSerializedDataParts[i] = aSerializedDataParts[i].slice(0, aSerializedDataParts[i].length - 1);
for (var j = 0; j < aSerializedDataParts[i].length; j++) {
if (aSerializedDataParts[i][j] !== null && aSerializedDataParts[i][j].replace('_Ar2_', '') !== aSerializedDataParts[i][j]) {
aSerializedDataParts[i][j] = aSerializedDataParts[i][j].split('_Ar2_');
aSerializedDataParts[i][j] = aSerializedDataParts[i][j].slice(0, aSerializedDataParts[i][j].length - 1);
if (aSerializedDataParts[i][j] == 'null' || aSerializedDataParts[i][j] == 'undefined')
aSerializedDataParts[i][j] = null;
for (var k = 0; k < aSerializedDataParts[i][j].length; k++)
if (aSerializedDataParts[i][j][k] == 'null' || aSerializedDataParts[i][j][k] == 'undefined')
aSerializedDataParts[i][j][k] = null;
}
}
}
}
for (var i = 0; i < 4; i++) {
if (i == 0)
result['listPrev'] = aSerializedDataParts[i];
if (i == 1)
result['prods'] = aSerializedDataParts[i];
if (i == 2)
result['frigos'] = aSerializedDataParts[i];
if (i == 3)
result['eject'] = aSerializedDataParts[i];
}
for (i = 0; i < result.listPrev.length; i++) {
set_prev_data('original_id', i, i.toString());
}
return result;
}
function save_important_vars_in_cloud() {
var blob = new Blob([make_important_vars_data()], { type: "text/plain;charset=utf-8" });
var month = ((new Date()).getUTCMonth() + 1);
var monthStr = month < 10 ? "0" + month : month.toString();
var day = ((new Date()).getUTCDate());
var dayStr = day < 10 ? "0" + day : day.toString();
saveAs(blob, GLOB_cur_planet_name.replace(/\W/g, '') + "_" + (new Date()).getUTCFullYear() + "_" + month + "_" + day + ".sephiOGame");
}
function load_important_vars_in_cloud() {
try {
var files = $('#fileupload')[0].files;
if (!files.length || !files[0].name.match('.sephiOGame')) {
alert('Merci de selectionner un fichier *.sephiOGame');
return;
}
var file = files[0];
var start = 0;
var stop = file.size - 1;
var reader = new FileReader();
// If we use onloadend, we need to check the readyState.
reader.onloadend = function (evt) {
if (evt.target.readyState == FileReader.DONE) {
// Test the data with a JSON.parse()
try {
JSON.parse(evt.target.result);
}
catch (e) {
blit_message('<span style="float: none;margin: 0;color:red">Erreur lors de la lecture des données</span>. Arret de la restauration.');
return;
}
save_important_vars(evt.target.result);
blit_message('Vos données de cette planète <span style="float: none;margin: 0;color:#109E18">ont bien été chargées</span>. Patientez...');
$('#load_button').on("click", function () { });
setTimeout(function () {
window.location.href = window.location.href;
}, 2000);
}
};
var blob = file.slice(start, stop + 1);
reader.readAsText(blob);
}
catch (e) {
blit_message('<span style="float: none;margin: 0;color:red">Impossible de lire le fichier</span>.');
return;
}
}
function get_prev_data(name, id) {
clock = (GLOB_persistedData["listPrev"][id] == null) ? 'undefined' : GLOB_persistedData["listPrev"][id][cookies_list.indexOf(name)];
//I2T: Correction between undifinied par undefined (why do not use 'undefined' ?)
if (clock == 'undefined')
return null;
else
return clock;
}
function set_prev_data(name, id, val) {
GLOB_persistedData["listPrev"][id][cookies_list.indexOf(name)] = val;
}
function bruit_alert(url) {
$('#div_for_sound').html('<audio controls autoplay="true"><source src="' + url + '" type="audio/mpeg" volume="0.5"></audio>');
}
function get_cool_title(cost_met, cost_crys, cost_deut, color1, color2, color3) {
cool_title = 'Ressources:| <table class="resourceTooltip">';
if (cost_met > 0)
cool_title += '<tr> <th>Metal:</th> <td><span style="color:' + color1 + ';" class="">' + cost_met + '</span></td> </tr>';
if (cost_crys > 0)
cool_title += '<tr> <th>Cristal:</th> <td><span style="color:' + color2 + ';" class="">' + cost_crys + '</span></td> </tr>';
if (cost_deut > 0)
cool_title += '<tr> <th>Deuterium:</th> <td><span style="color:' + color3 + ';" class="">' + cost_deut + '</span></td> </tr>';
cool_title += '</table>';
return cool_title;
}
function get_cool_time(boss) {
temps_string = '';
if (Math.floor(boss / 60 / 60) > 0) //!== 0)
temps_string += Math.floor(boss / 60 / 60) + 'h';
tmp = Math.floor(boss / 60 - Math.floor(boss / 60 / 60) * 60);
sup_chiffre = '';
if (tmp < 10)
sup_chiffre = '0';
temps_string += sup_chiffre + tmp;
sup_chiffre = '';
if (Math.floor(boss % 60) < 10)
sup_chiffre = '0';
temps_string += '<span style="font-size:0.8em;float: none;margin: 0;">.' + sup_chiffre + Math.floor(boss % 60) + '</span>';
return temps_string;
}
function get_cool_digit(i) {
i = i.toString();
data = '';
while (i.length > 3) {
data = '.' + i.substr(i.length - 3, 3) + data;
i = i.substr(0, i.length - 3);
}
return i + data;
}
function get_prevision_bar_html(i, textSupp, textSupp2, infotitle, color, cost_met, cost_crys, cost_deut, ress_metal, ress_crystal, ress_deuterium, cur_progs_count) {
var color1 = '#109E18';
var color2 = '#109E18';
var color3 = '#109E18';
if (parseInt(cost_met) > parseInt(ress_metal))
color1 = '#d43635';
if (parseInt(cost_crys) > parseInt(ress_crystal))
color2 = '#d43635';
if (parseInt(cost_deut) > parseInt(ress_deuterium))
color3 = '#d43635';
if (textSupp == '[' + LANG_started + '] ')
cool_title = LANG_done;
else
var cool_title = get_cool_title(cost_met, cost_crys, cost_deut, color1, color2, color3);
data = "\n" + '<div id="block_prog_' + i + '" style="height:0px;position:relative;top:' + (27 * (cur_progs_count - 1)) + 'px;"><span style="display:none" id="prog_cur_place_' + i + '">' + i + '</span><div class="tooltipHTML" title="' + cool_title + '" id="info_prog_' + i + '" style="cursor:default;word-wrap: normal;height:20px;font: 700 12px Verdana,Arial,Helvetica,sans-serif;position:relative;left:-8px;padding-top:7px;background: url(http://www.sephiogame.com/images/barre_fond.gif) no-repeat;background-position:0px -1px;width:640px;margin-bottom:0px;color:' + color + ';padding-left:40px;font-weight:normal;">';
data += '<p style="width:600px;height:20px;white-space: nowrap">' + textSupp + ' <b>' + infotitle + '</b>';
data += ' <i><span style="font-size:11px" id="info_prog_time_' + i + '"></span></i></p></div>';
data += "\n" + '<div id="dragdrop_prev_' + i + '" style="position:relative;height:0px;width:16px;left:585px;top:-21px;"><img style="cursor:move;width:18px;height:auto;-moz-user-select: none;" draggable="false" src="http://www.sephiogame.com/script/dragdrop.png" title="Déplacer"/></div>';
data += "\n" + '<div id="del_button_' + i + '" style="position:relative;height:0px;width:16px;left:610px;top:-20px;"><img style="cursor:pointer;width:16px;height:auto;" src="http://www.sephiogame.com/script/newsletter-close-button.png" title="Retirer cette construction de la liste" onclick="localStorage.setItem(\'' + userid + '_delete_id\', \'' + i + '\');"/></div>';
data += '</div>';
return data;
}
function get_cost(data, type) {
//if (data.match('energy')) return 0;
tmp = data.split('<li class="resource ' + type);
if (tmp[0] !== data) {
data = tmp[1].split("</")[0].split('">')[1];
if (!data.match(','))
return parseInt(data.replace('M', '.000.000').match(/\d/g).join(""));
else
return parseInt(parseInt(data.split(',')[0].match(/\d/g).join("")) * 1000000 + parseInt(data.split(',')[1].match(/\d/g).join("")) * 100000 / Math.pow(10, data.split(',')[1].match(/\d/g).length - 1));
}
else {
return 0;
}
}
function add_programmation_button() {
if (gup('page') !== 'premium' && gup('page') !== 'shop' && $("#pageContent #middle header").length > 0 && $("#pageContent #middle header").children()[0].tagName == 'H2') {
var title = $("#pageContent #middle #technologydetails .content").length > 0 ? $("#pageContent #middle #technologydetails .content").children()[1].innerText : null;
if (title !== null && title !== cur_title) {
if (document.querySelectorAll('#prev_ok, #havetoprev, #cur_met_prev, #cur_met_prev, #cur_crys_prev, #cur_deut_prev, #title_prev, #form_type_prev, #form_modus_prev, #form_number_prev, #is_ok_prev') !== null)
document.querySelectorAll('#prev_ok, #havetoprev, #cur_met_prev, #cur_met_prev, #cur_crys_prev, #cur_deut_prev, #title_prev, #form_type_prev, #form_modus_prev, #form_number_prev, #is_ok_prev').forEach(function (el) { return el.remove(); });
var ress_metal = $("span#resources_metal").html().replace(/\./g, "");
var ress_crystal = $("span#resources_crystal").html().replace(/\./g, "");
var ress_deuterium = $("span#resources_deuterium").html().replace(/\./g, "");
cur_title = title;
title = title.replace(/ /g, '_esp_');
cur_content = $("#pageContent #middle .maincontent").html();
var cost_metal = get_cost(cur_content, "metal");
var cost_crystal = get_cost(cur_content, "crystal");
var cost_deuterium = get_cost(cur_content, "deuterium");
var max_nb = Math.floor(parseInt(ress_metal) / parseInt(cost_metal));
tmp = Math.floor(parseInt(ress_crystal) / parseInt(cost_crystal));
if (tmp < max_nb)
max_nb = tmp;
tmp = Math.floor(parseInt(ress_deuterium) / parseInt(cost_deuterium));
if (tmp < max_nb)
max_nb = tmp;
var max_text = '';
if (max_nb > 0)
max_text = max_nb; //max_text = '[max. '+max_nb+']';
var det = $("div#detail").html();
var url_1 = new URL(upgradeEndpoint);
var form_modus = url_1.searchParams.get('modus');
var form_type = $('[data-technology-id]').data('technology-id');
var form_number = ($('#build_amount').length > 0) ? parseInt($('#build_amount').val()) : 0;
// Program button
//I2T: Pour compatibilité AGO
//var ori_build_button = $("#content").find('a').last();
var hasPremiumButton = ($("#pageContent").find('.build-it_premium').length == 1);
var ori_build_button = hasPremiumButton ? $("#pageContent").find('.build-it_premium') : ($("#pageContent").find('.build-it_wrap button.upgrade').is(':disabled')) ? $("#pageContent").find('.build-it_wrap button.upgrade') : $("#pageContent").find('.build-it_wrap .upgrade');
!hasPremiumButton ? ori_build_button.css('position', 'absolute') : null; //'relative');
//ori_build_button.css('right', '5px');
var build_button = ori_build_button.clone();
(AGO_actif) ? ori_build_button.css('top', '-100px') : ori_build_button.css('top', '-45px'); //'-16px');//'-85px')
hasPremiumButton ? build_button.css('z-index', 10) : null;
if(build_button.is('[data-title]')) {
build_button.removeAttr('data-title');
build_button.removeAttr('data-url');
build_button.removeAttr('data-question');
build_button.removeAttr('title');
build_button.removeAttr('style');
build_button.removeAttr('id');
}
build_button.attr('class', 'upgrade');
build_button.attr('href', '#');
build_button.attr('disabled', false);
build_button.css('background-image', 'url(http://www.sephiogame.com/script/d99a48dc0f072590fbf110ad2a3ef5.png)');
if (build_button.children()[0] !== undefined) {
build_button.children()[0].innerHTML = LANG_programm;
build_button.children()[0].title = LANG_programm;
}
(AGO_actif) ? build_button.css('top', '-16px') : (hasPremiumButton ? build_button.css('top', '-40px') : (ori_build_button.is(':disabled') ? build_button.css('top', '-100px') : (ori_build_button.is('[id="missingResource"]') ? build_button.css('top', '-55px') : build_button.css('top', '-100px'))));
(ori_build_button.is(':disabled') || (!ori_build_button.is('[id="missingResource"]') && !hasPremiumButton)) ? build_button.css('height', '53px') : build_button.css('height', '50px');
ori_build_button.is('[id="missingResource"]') ? build_button.css('right', '0px') : null;
build_button.click(function (e) {
$(e.currentTarget).css('backgroundImage', 'url(http://www.sephiogame.com/script/sfdgdfshsdhg.png)');
$(e.currentTarget).prop('disabled', true);
$('#havetoprev').html('yes');
$('#prev_ok').css('display', 'block');
$('#is_ok_prev').html('no');
if (typeof $(e.currentTarget).children()[0] != 'undefined')
$(e.currentTarget).children()[0].innerHTML = LANG_added;
e.stopPropagation();
e.preventDefault();
return false;
});
ori_build_button.parent().prepend(build_button);
// Data
var first = $("#middle .maincontent");
first.append('<span id="prev_ok" style="display:none;">'
+ '<b>Construction programmée</b><br/>'
+ '<span style="font-size:9px;position:relative;top:-5px;">Ne quittez pas cette page.</span><br/>'
+ '</span>'
+ '<div style="display:none" id="havetoprev">no</div>'
+ '<div style="display:none" id="cur_met_prev">' + cost_metal + '</div>'
+ '<div style="display:none" id="cur_crys_prev">' + cost_crystal + '</div>'
+ '<div style="display:none" id="cur_deut_prev">' + cost_deuterium + '</div>'
+ '<div style="display:none" id="title_prev">' + title + '</div>'
+ '<div style="display:none" id="form_type_prev">' + form_type + '</div>'
+ '<div style="display:none" id="form_modus_prev">' + form_modus + '</div>'
+ '<div style="display:none" id="form_number_prev">' + form_number + '</div>'
+ '<div style="display:none" id="is_ok_prev">no</div>');
// Max number
var p_amount = $("#content").find('p.amount');
var div_enter = $("#content").find('div.enter');
if (p_amount.length > 0) {
p_amount.html(p_amount.html().replace(":", " max:"));
p_amount.first().append(' <span style="color:#ffffff">' + max_text + '</span>');
p_amount.css('display', 'block');
}
div_enter.css('top', '125px');
(AGO_actif) ? div_enter.css('right', '16px') : div_enter.css('right', '-110px');
$("#content").find('a#close').on("click", function () {
$('div#detail').css("display", 'none');
});
$('div#detail').css({ display: 'block' });
//$("#planet [name='form']")[0].id = 'form_finished';
$('#form_finished').onsubmit = function () {
dontAddToCookies = true;
return true;
};
$('#form_finished').onkeyup = null;
if ($('#number').length > 0) {
$('#number').onkeyup = null;
$('#number').onkeydown = null;
$('#number').onkeypress = null;
//I2T- Force the focus on number input to improve ergonomy
$('#number').focus();
}
}
//set down info_prog
//$('#info_prog').css("top",parseInt(($("div#detail").css('display') !== 'none')?$('#detail').height():$('#detail').height()-30)+'px');
}
setTimeout(add_programmation_button, 200);
}
/***************************************
***** Change message actions tab
****************************************
* Input: action_tab object
* Output: Object changed
****************************************/
function change_actions_tab(action_tab) {
//Change APIKey from <div> to <a> tag
action_tab.find("span.icon_apikey").each(function (index) {
var parent = $(this).parent();
if (!parent.attr("href")) {
var title = $(this).attr("title");
var api_num = $(this).attr("title").replace(/^.*input value='(.*)' readonly.*$/m, '$1');
if (api_num.match(/^sr-.*$/))
api_param = "SR_KEY=".concat(api_num);
if (api_num.match(/^cr-.*$/))
api_param = "CR_KEY=".concat(api_num);
if (api_num.match(/^rr-.*$/))
api_param = "RR_KEY=".concat(api_num);
if (api_param != "" && api_param != null)
parent.replaceWith(function () {
return $('<a/>', {
href: "http://topraider.eu/index.php?langue=fr&simulator=speedsim&".concat(api_param),
target: '_blank',
"class": "icon_nf_link fleft",
html: this.innerHTML
});
});
}
var parent = null;
});
// Change attack url allowing to auto attack target
action_tab.find("span.icon_attack").each(function (index) {
var parent = $(this).parent();
if (!parent.attr("href").match("auto=yes")) {
//Get information about butin (sum of metal, cristal and deut) * type_multifactor (50%, 75%, 100%, ...)
if (parent.parent().parent().find("span.ctn4 .resspan").length > 0) {
process_espionnage_data(parent.parent().parent().find("span.ctn4 .resspan"));
var butin = Math.floor(type_multip * (met + cri + deu));
url_parent = parent.attr("href");
url_pt = url_parent.replace("mission=1", "mission=1&auto=yes&ID=0&am202=" + (1 + Math.floor(butin / 5000)) + "&Referer=" + (encodeURIComponent($(location).attr('href').replace(/.*\?(.*)/g, "$1"))));
url_gt = url_parent.replace("mission=1", "mission=1&auto=yes&ID=0&am203=" + (1 + Math.floor(butin / 25000)) + "&Referer=" + (encodeURIComponent($(location).attr('href').replace(/.*\?(.*)/g, "$1"))));
title = "Butin :" + butin + "<br><a href='" + url_pt + "'>P.Transp :" + (1 + Math.floor(butin / 5000)) + "</a><br><a href='" + url_gt + "'>G.Transp :" + (1 + Math.floor(butin / 25000)) + "</a>";
$(this).addClass("tooltipCustom tooltip-width:400");
$(this).attr("title", title);
var url_parent = null;
var url_pt = null;
var url_gt = null;
var title = null;
}
}
var parent = null;
});
if (action_tab.find("span#icon_frigo").length == 0) {
action_tab.parent().each(function (index) {
var _b, _c, _d, _e, _f, _g;
if ($(this).find('.msg_head .msg_title').length > 0) {
var planame = null, coord = null;
// dans message rapport de combat
if ($(this).find('.msg_head .msg_title').html().match(/Rapport de combat/)) {
// dans message Rapport de combat
if ($(this).find('.msg_head .msg_title').html().match(/middlemark/))
_b = $(this).find('.msg_head .msg_title span.middlemark').html().match(/Rapport de combat (.*) <figure.* class="txt_link">(.*)<\/a>.*$/), planame = _b[1], coord = _b[2];
if ($(this).find('.msg_head .msg_title').html().match(/undermark/)) // Successfull fight
_c = $(this).find('.msg_head .msg_title span.undermark').html().match(/Rapport de combat (.*) <figure.*<a.*>(.*)<\/a>/), planame = _c[1], coord = _c[2];
if ($(this).find('.msg_head .msg_title').html().match(/overmark/)) // Failled fight
_d = $(this).find('.msg_head .msg_title span.overmark').html().match(/Rapport de combat (.*) <figure.*<a.*>(.*)<\/a>/), planame = _d[1], coord = _d[2];
//I2T: Prévision de correction
//[, planame, coord] = $(this).find('.msg_head .msg_title span.overmark').html().match(/Rapport de combat (.*) <figure.* class="txt_link">(.*)<\/a>.*$/);
}
// dans message rapport d'espionnage
if ($(this).find('.msg_head .msg_title').html().match(/Rapport d`espionnage/)) {
if ($(this).find('.msg_head .msg_title').html().match(/figure/))
_e = $(this).find('.msg_head .msg_title .txt_link').html().match(/<\/figure>(.*) (.*)$/), planame = _e[1], coord = _e[2];
//DETECTION DEF/FLOTTE
var flottes = null, flottesActive = false, defense = null, defenseActive = false, flottesDetected = false, defenseDetected = false;
if ($(this).find('.msg_content div.compacting:eq(3) span:eq(0):contains("Flottes:")').length > 0) {
flottesDetected = true;
flottes = parseInt($(this).find('.msg_content div.compacting:eq(3) span:eq(0):contains("Flottes:")').html().match(/\d/g).join(""));
if ($(this).find('.msg_content div.compacting:eq(3) span:eq(0):contains("Flottes:")').html().match('M'))
flottes *= 1000000;
if ($(this).find('.msg_content div.compacting:eq(3) span:eq(0):contains("Flottes:")').html().match(','))
flottes /= 100;
(flottes > 0) ? flottesActive = true : flottesActive = false;
}
if ($(this).find('.msg_content div.compacting:eq(3) span:eq(1):contains("Défense:")').length > 0) {
defenseDetected = true;
defense = parseInt($(this).find('.msg_content div.compacting:eq(3) span:eq(1):contains("Défense:")').html().match(/\d/g).join(""));
if ($(this).find('.msg_content div.compacting:eq(3) span:eq(1):contains("Défense:")').html().match('M'))
defense *= 1000000;
if ($(this).find('.msg_content div.compacting:eq(3) span:eq(1):contains("Défense:")').html().match(','))
defense /= 100;
(defense > 0) ? defenseActive = true : defenseActive = false;
}
//END DETECTION
}
//Detection type frigo
var typeFrigo = ($(this).find('.msg_head .msg_title figure.moon').length > 0) ? "moon" : "planet";
coord += (typeFrigo === "moon") ? "Lune" : "";
if (planame && coord) {
var galaxy, system, planet;
_f = coord.match(/\[(.*):(.*):(.*)\]/), galaxy = _f[1], system = _f[2], planet = _f[3];
// Recherche d'un frigo avec ces coordonnées
//I2T- Factorize with is_frigo fonction
var num_frigo = is_frigo(GLOB_persistedData["frigos"], coord);
var infrig = (num_frigo >= 0) ? 'yes' : 'no';
//If coord is ours return
if ($.inArray(coord, planet_list_coords) >= 0)
return;
////
//nb sonde config dans option
var nb_sonde_default = parseInt(readData("nb_sondes", "all"));
(nb_sonde_default === 0 || nb_sonde_default === "undefined" || nb_sonde_default === "NaN") ? nb_sonde_default = 1 : nb_sonde_default;
var frigo_status = "", img_surcharge = "";
frigo_status = (flottesDetected == "undefined" || !(flottesDetected && flottesActive)) ? "" : " avec une flotte active";
frigo_status = frigo_status + ((frigo_status !== "") ? " et " : "") + ((defenseDetected === "undefined" || !(defenseDetected && defenseActive)) ? "" : " avec une defense active");
if ($(this).find('.msg_head .msg_title').html().match(/Rapport d`espionnage/) //in spy message only
&& infrig == 'no' //if not a frigo yet
&& readData('Prog_AF', 'all') == "true" // If autofrigo prog
) {
var ressources = parseInt($(this).find('.msg_content div.compacting:eq(2) span:eq(4):contains("Ressources:")').html().replace('M', '000').match(/\d/g).join(""));
var cur_planet_GAL = parseInt(cur_planet_coords.replace(/\[|\]/, '').split(/:/)[0]);
if ((readData('SameGAL_AF', 'all') != "true" || (readData('SameGAL_AF', 'all') == "true" && galaxy == cur_planet_GAL))
&& (readData('WithoutFLEET_DEF_AF', 'all') != "true" || (readData('WithoutFLEET_DEF_AF', 'all') == "true" && flottesActive == false && defenseActive == false))
&& (readData('Seuil_Auto_ADD_AF', 'all') != "true" || (readData('Seuil_Auto_ADD_AF', 'all') == "true" && readData('Seuil_Auto_ADD_VAL_AF', 'all') <= (ressources / 2))))
add_frigo({ 'nom': planame, 'galaxy': galaxy, 'system': system, 'position': planet, 'sondes': nb_sonde_default, 'flottes': flottes, 'defenses': defense, 'type': typeFrigo });
}
if (infrig == 'no') {
var info = 'Je ne suis pas encore un de vos frigos !';
var style = 'cursor:pointer;color:#A52592;padding:5px;text-decoration:none;padding-bottom:15px;';
var style_rep = 'cursor: "default";color: "#10E010";';
var message_res_action = 'Bienvenue dans les frigos !';
var action = 'localStorage.setItem("' + userid + '_add_racc", "' + (index + 1) + '");this.onclick=null;$($(this).find("#res_action")).html("' + message_res_action + '");';
var text_action = "</span>Integration de \'" + coord + " " + planame + "\' dans " + GLOB_cur_planet_name + "?<hr/><u>Status:</u> Frigo potentiel" + frigo_status + "<br><u>Actions:</u> <a href=\'javascript:void(0)\' onclick=\'" + (action) + "\'>Ajouter ce frigos</a>";
var img = 'http://www.sephiogame.com/images/frigoOff.png';
// dans message espionnage
if ($(this).find('.msg_head .msg_title').html().match(/Rapport d`espionnage/)) {
var message_res_action = ((flottesDetected && !flottesActive) || (defenseDetected && !defenseActive)) ? 'Bienvenue dans les frigos !' : 'Bienvenue dans les frigos ! <b>Attention</b>, il faudra prévoir une flotte personnalisée adaptée.';
var text_action = "</span>Integration de \'" + coord + " " + planame + "\' dans " + GLOB_cur_planet_name + "?<hr/><u>Status:</u> Frigo libre" + (frigo_status) + "<br><u>Actions:</u> <a href=\'javascript:void(0)\' onclick=\'" + (action) + "\'>Ajouter ce frigos</a>";
var img_addon = ((flottesDetected && !flottesActive) && (defenseDetected && !defenseActive)) ? 'http://www.sephiogame.com/images/data-ok.png' : 'http://www.sephiogame.com/images/no-data.png';
var img_surcharge = (img_addon != null) ? '<img src="' + (img_addon) + '" style="height:10px;width:10px;position:relative;top:-3px;left: -17px" />' : '';
}
}
else {
//Get DEF/FLOTTE from frigo information
var message_res_action = 'Retiré des frigos !';
var info = 'J\'ai l\'honneur d\'être un de vos frigos ! Je le retire?';
var action = "localStorage.setItem("'+userid+'_del_racc", "" + coord + "");this.onclick=null;$(this).find("#res_action").html("" + message_res_action + "");";
var text_action = "</span>Frigo \'" + coord + " " + planame + "\' de " + GLOB_cur_planet_name + "<hr/><u>Status:</u> Frigo actif" + (frigo_status) + "<br><u>Actions:</u> <a href=\'javascript:void(0)\' onclick=\'" + (action) + "\'>Retirer ce frigos</a>";
var img = 'http://www.sephiogame.com/images/frigoOn.png';
var style = 'cursor:pointer;color:#A52592;padding:5px;text-decoration:none;padding-bottom:15px;';
var style_rep = 'cursor: "default";color: "#10E010";';
// dans message espionnage
if ($(this).find('.msg_head .msg_title').html().match(/Rapport d`espionnage/)) {
_g = get_frigo_data(num_frigo), frigo_name = _g[0], frigo_galaxy = _g[1], frigo_system = _g[2], frigo_position = _g[3], frigo_sonde = _g[4], frigo_flotte_perso = _g[5], frigo_ignore = _g[6], frigo_flotte = _g[7], frigo_defense = _g[8], frigo_sonde = _g[9], frigo_cur_flotte = _g[10], frigo_cur_def = _g[11], frigo_sonde = _g[12], frigo_type = _g[13];
//if flotte detected ==> update frigo with current flottes
if (flottesDetected)
GLOB_persistedData["frigos"][num_frigo][9] = flottes;
//if frigo_flotte null or undefined
if ((frigo_flotte === null || frigo_flotte === "undefined" || frigo_flotte === "") && flottes !== null)
GLOB_persistedData["frigos"][num_frigo][7] = flottes;
//if defense detected ==> update frigo with current defense
if (defenseDetected)
GLOB_persistedData["frigos"][num_frigo][10] = defense;
//if frigo_defense null or undefined or defense_saved > defense
if ((frigo_defense === null || frigo_defense === "undefined" || frigo_defense == "" || parseInt(frigo_defense) > defense) && defense !== null)
GLOB_persistedData["frigos"][num_frigo][8] = defense;
if (frigo_type === null || frigo_type === "undefined" || frigo_type === "")
GLOB_persistedData["frigos"][num_frigo][12] = typeFrigo;
img_addon = ((!flottesDetected || (flottesDetected && flottesActive && parseInt(frigo_flotte) < flottes)) || (!defenseDetected || (defenseDetected && defenseActive && parseInt(frigo_defense) < defense))) ? 'http://www.sephiogame.com/images/warning.png' : null;
var img_surcharge = (img_addon != null) ? '<img src="' + (img_addon) + '" style="height:10px;width:10px;position:relative;top:-3px;left: -17px" />' : '';
save_important_vars();
var text_action = "</span>Frigo \'" + coord + " " + planame + "\' de " + GLOB_cur_planet_name + "<hr/><u>Status:</u> Frigo actif" + (frigo_status) + "<br><u>Actions:</u> <a href=\'javascript:void(0)\' onclick=\'" + (action) + "\'>Retirer ce frigos</a><br><u>Options:</u> Utiliser <input style=\'width:10px;height:10px;\' type=\'text\' value=\'" + ((parseInt(GLOB_persistedData["frigos"][num_frigo][11]) > 0) ? parseInt(GLOB_persistedData["frigos"][num_frigo][11]) : nb_sonde_default) + "\' onchange=\'$("#sondes" + (index + 1) + "").val(this.value);localStorage.setItem("" + userid + "_updt_racc", "" + (index + 1) + "," + num_frigo + "");\'> sondes sur ce frigo.";
}
}
frigData = '<a id="name_sep' + (index + 1) + '" href="javascript:void(0)" >';
frigData += '<span id="icon_frigo" class="js_hideTipOnMobile tooltipCustom tooltip-width:400" title="' + text_action + '"><img id="img' + (index + 1) + '" src="' + (img) + '" height="26px" width="26px" />' + (img_surcharge);
frigData += '<input type="hidden" id="raccourcis_name_sep' + (index + 1) + '" value="' + planame + '">';
frigData += '<input type="hidden" id="galaxy' + (index + 1) + '" value="' + (galaxy) + '">';
frigData += '<input type="hidden" id="system' + (index + 1) + '" value="' + (system) + '">';
frigData += '<input type="hidden" id="position' + (index + 1) + '" value="' + (planet) + '">';
frigData += '<input type="hidden" id="flottes' + (index + 1) + '" value="' + (flottes) + '">';
frigData += '<input type="hidden" id="defense' + (index + 1) + '" value="' + (defense) + '">';
frigData += '<input type="hidden" id="sondes' + (index + 1) + '" value="' + ((num_frigo > 0 && parseInt(GLOB_persistedData["frigos"][num_frigo][11]) > 0) ? parseInt(GLOB_persistedData["frigos"][num_frigo][11]) : nb_sonde_default) + '">';
//frigData +='<input type="hidden" id="sondes'+(index+1)+'" value="'+((num_frigo>0&&parseInt(GLOB_persistedData["frigos"][num_frigo][11])>0)?GLOB_persistedData["frigos"][num_frigo][11]:nb_sonde_default)+'">';
frigData += '<input type="hidden" id="type' + (index + 1) + '" value="' + (typeFrigo) + '">';
frigData += '</span></a>';
//Add the object built
$($(this).find('.msg_action_link.overlay')).before(frigData);
var frigData = null;
var message_res_action = null;
var info = null;
var text_action = null;
var img = null;
var action = null;
var style = null;
var style_rep = null;
}
}
});
}
}
function change_message_actiontab() {
var subtabs_fleets = $('#ui-id-2 .tab_ctn .js_subtabs_fleets');
var Overlay_Detail = $('.ui-dialog .overlayDiv');
if (subtabs_fleets.length == 1) { // Message Fleet Tab
if (subtabs_fleets.find('#ui-id-14 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleet20 - Espionnage
change_actions_tab(subtabs_fleets.find('#ui-id-14 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-16 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleet21 - Rapports de combat
change_actions_tab(subtabs_fleets.find('#ui-id-16 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-18 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleet22 - Expeditions
change_actions_tab(subtabs_fleets.find('#ui-id-18 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-20 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleet23 - Groupes/transport
change_actions_tab(subtabs_fleets.find('#ui-id-20 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-22 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleet24 - Divers
change_actions_tab(subtabs_fleets.find('#ui-id-22 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-24 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleetTrash - Corbeille
change_actions_tab(subtabs_fleets.find('#ui-id-24 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-26 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleetTrash - Corbeille
change_actions_tab(subtabs_fleets.find('#ui-id-26 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-28 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleetTrash - Corbeille
change_actions_tab(subtabs_fleets.find('#ui-id-28 .tab_inner li.msg div.msg_actions'));
}
if (subtabs_fleets.find('#ui-id-30 .tab_inner li.msg').length > 0) { // Tab subtabs-nfFleetTrash - Corbeille
change_actions_tab(subtabs_fleets.find('#ui-id-30 .tab_inner li.msg div.msg_actions'));
}
}
if (Overlay_Detail.length == 1) { // Message detail overlay
change_actions_tab(Overlay_Detail.find('.detail_msg .detail_msg_head .msg_actions'));
}
}
function get_prevID_from_place(place) {
ID = -1;
for (var tmpi = 0; tmpi < GLOB_persistedData["listPrev"].length; tmpi++) {
if ($('#prog_cur_place_' + tmpi).length > 0 && parseInt($('#prog_cur_place_' + tmpi).html()) == place) {
ID = tmpi;
break;
}
}
return ID;
}
function apply_move_prev(fromID, fromPlace, toPlace) {
if (fromPlace === toPlace)
return;
toID = -1;
if (Math.abs(fromPlace - toPlace) == 1) {
toID = get_prevID_from_place(toPlace);
tmp = GLOB_persistedData["listPrev"][fromPlace];
GLOB_persistedData["listPrev"][fromPlace] = GLOB_persistedData["listPrev"][toPlace];
GLOB_persistedData["listPrev"][toPlace] = tmp;
if (fromPlace < toPlace) {
prev_positions[fromID] = (fromPlace + 1 + GLOB_nb_special_bars) * 27;
prev_positions[toID] = (toPlace - 1 + GLOB_nb_special_bars) * 27;
$('#prog_cur_place_' + fromID).html(fromPlace + 1);
$('#prog_cur_place_' + toID).html(toPlace - 1);
}
else {
prev_positions[fromID] = (fromPlace - 1 + GLOB_nb_special_bars) * 27;
prev_positions[toID] = (toPlace + 1 + GLOB_nb_special_bars) * 27;
$('#prog_cur_place_' + fromID).html(fromPlace - 1);
$('#prog_cur_place_' + toID).html(toPlace + 1);
}
}
else {
if (fromPlace < toPlace) {
apply_move_prev(fromID, fromPlace, fromPlace + 1);
toID = apply_move_prev(fromID, fromPlace + 1, toPlace);
}
else {
apply_move_prev(fromID, fromPlace, fromPlace - 1);
toID = apply_move_prev(fromID, fromPlace - 1, toPlace);
}
}
return toID;
}
function save_list_in_cookies() {
var _b;
//add prev
if (!dontAddToCookies && $('#is_ok_prev').length > 0 && $('#is_ok_prev').html() == "no"
&& $('#havetoprev').length > 0 && $('#havetoprev').html() === "yes") {
var aNextAvailableId = GLOB_persistedData["listPrev"].length;
form_number = '';
if ($('#number').length > 0) {
form_number = $('#number').val();
}
page = gup("component");
if ($('#title_prev').html().match('Satellite'))
page = 'shipyard';
GLOB_persistedData["listPrev"][aNextAvailableId] = new Array();
set_prev_data("havetoprev", aNextAvailableId, "yes");
set_prev_data("donned", aNextAvailableId, "no");
set_prev_data("cur_met_prev", aNextAvailableId, $('#cur_met_prev').html());
set_prev_data("cur_crys_prev", aNextAvailableId, $('#cur_crys_prev').html());
set_prev_data("cur_deut_prev", aNextAvailableId, $('#cur_deut_prev').html());
set_prev_data("component", aNextAvailableId, page);
set_prev_data("form_modus", aNextAvailableId, $('#form_modus_prev').html());
set_prev_data("form_type", aNextAvailableId, $('#form_type_prev').html());
set_prev_data("form_number", aNextAvailableId, form_number);
set_prev_data("form_initial_number", aNextAvailableId, form_number);
set_prev_data("title", aNextAvailableId, $('#title_prev').html());
GLOB_persistedData["listPrev"][aNextAvailableId]["original_id"] = aNextAvailableId;
prev_positions[aNextAvailableId] = (aNextAvailableId + GLOB_nb_special_bars) * 27;
$('#is_ok_prev').html('yes');
multip = '';
factor = 1;
if (get_prev_data("form_number", aNextAvailableId) !== null && get_prev_data("form_number", aNextAvailableId) !== "") {
multip = " (x" + get_prev_data("form_number", aNextAvailableId) + ")";
factor = parseInt(get_prev_data("form_number", aNextAvailableId));
}
count_progs++;
blit_message('Cette action a été <span style="float: none;margin: 0;color:#109E18">ajoutée dans votre liste de programmation</span> !');
var ress_metal = $(document.body).find('#resources_metal').html().match(/\d/g).join("");
var ress_crystal = $(document.body).find('#resources_crystal').html().match(/\d/g).join("");
var ress_deuterium = $(document.body).find('#resources_deuterium').html().match(/\d/g).join("");
$('#info_prog').html($('#info_prog').html() + get_prevision_bar_html(aNextAvailableId, ' ', titles_cat[categories.indexOf(gup('component'))], get_prev_data("title", aNextAvailableId).replace(/_esp_/g, ' ') + multip, "#6f9fc8", parseInt(get_prev_data("cur_met_prev", aNextAvailableId)) * factor, parseInt(get_prev_data("cur_crys_prev", aNextAvailableId)) * factor, parseInt(get_prev_data("cur_deut_prev", aNextAvailableId)) * factor, ress_metal, ress_crystal, ress_deuterium, count_progs));
$('#' + id_prev).height($('#' + id_prev).height() + 27 + "px");
save_important_vars();
// Drag & Drop des constructions
if (gup('sephiScript') != '1')
for (var i = 0; i < GLOB_persistedData["listPrev"].length && GLOB_persistedData["listPrev"][i]; i++) {
$('#dragdrop_prev_' + i).mousedown(drag_prev);
}
verif = setTimeout(gestion_cook, 2000);
}
// Delete Prevs
if (readData("delete_id", 'all') !== null && readData("delete_id", 'all') !== "-1") {
blockID = readData("delete_id", 'all');
var prevIdToDelete = parseInt($('#prog_cur_place_' + blockID).html());
GLOB_persistedData["listPrev"].splice(prevIdToDelete, 1);
count_progs--;
cur_progs_count = count_progs;
storeData("delete_id", '-1', "all");
save_important_vars();
blit_message('Cette action a été <span style="float: none;margin: 0;color:#109E18">supprimée de votre liste de programmation</span> !');
setTimeout(function () {
location.href = location.href;
}, 200);
}
// Ajout de frigo
//I2T- Retrait de Frigo
if ((gup('component') == "fleet2" || gup('page') == 'messages' || gup('component') == 'galaxy')
&& ((readData('add_racc', 'all') != null && parseInt(readData('add_racc', 'all')) > 0)
|| (readData('updt_racc', 'all') != null && parseInt(readData('updt_racc', 'all')) > 0)
|| (readData('del_racc', 'all') != null && readData('del_racc', 'all').match(':')))) {
if (readData('add_racc', 'all') != null && parseInt(readData('add_racc', 'all')) > 0) {
var messageID = readData('add_racc', 'all');
storeData('add_racc', '0', 'all');
$('#raccourcis_name_sep' + messageID).focus();
var cur_nb = GLOB_persistedData["frigos"].length;
GLOB_persistedData["frigos"][cur_nb] = new Array();
//Nom du frigo
GLOB_persistedData["frigos"][cur_nb][0] = $('#raccourcis_name_sep' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
//Galaxy
GLOB_persistedData["frigos"][cur_nb][1] = $('#galaxy' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
//System
GLOB_persistedData["frigos"][cur_nb][2] = $('#system' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
//Position
GLOB_persistedData["frigos"][cur_nb][3] = $('#position' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
//Checked or not checked
GLOB_persistedData["frigos"][cur_nb][4] = '1';
//Flotte_Perso
GLOB_persistedData["frigos"][cur_nb][5] = '';
//Ignore
GLOB_persistedData["frigos"][cur_nb][6] = '0';
if (gup('page') == 'messages') {
//Flottes
($('#flottes' + messageID).length > 0) ? GLOB_persistedData["frigos"][cur_nb][7] = $('#flottes' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '') : null;
//Defenses
($('#defenses' + messageID).length > 0) ? GLOB_persistedData["frigos"][cur_nb][8] = $('#defense' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '') : null;
}
//Flotte en cours
GLOB_persistedData["frigos"][cur_nb][9] = '0';
//defense en cours
GLOB_persistedData["frigos"][cur_nb][10] = '0';
//Nb sonde
GLOB_persistedData["frigos"][cur_nb][11] = parseInt(readData("nb_sondes", "all"));
//Type frigo
GLOB_persistedData["frigos"][cur_nb][12] = $('#type' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
save_important_vars();
blit_message(GLOB_persistedData["frigos"][cur_nb][0] + '(' + GLOB_persistedData["frigos"][cur_nb][12] + ') a été <span style="float: none;margin: 0;color:#109E18">ajouté à vos frigos</span> !');
messageID = null;
if (gup('page') == 'messages')
setTimeout(function () { window.location.href = window.location.href; }, 500);
if (gup('component') == 'galaxy')
$("div.btn_blue[onclick^='submitForm()']").trigger("click");
}
//I2T- Ajout de la suppression d'un frigo
if (readData('del_racc', 'all') != null && readData('del_racc', 'all').match(':')) {
//all_del_racc contents coord
var delid = is_frigo(GLOB_persistedData["frigos"], readData('del_racc', 'all'));
storeData('del_racc', '0', 'all');
var frig_name = GLOB_persistedData["frigos"][delid][0];
GLOB_persistedData["frigos"].splice(delid, 1);
save_important_vars();
blit_message(frig_name + ' a été <span style="float: none;margin: 0;color:#109E18">supprimé de vos frigos</span> !');
delid = null;
frig_name = null;
if (gup('page') == 'messages')
setTimeout(function () { window.location.href = window.location.href; }, 500);
if (gup('component') == 'galaxy')
$("div.btn_blue[onclick^='submitForm()']").trigger("click");
}
if (readData('updt_racc', 'all') != null && parseInt(readData('updt_racc', 'all')) > 0) {
_b = readData('updt_racc', 'all').match(/(.*),(.*)/), messageID = _b[1], num_frigo = _b[2];
storeData('updt_racc', '0', 'all');
$('#raccourcis_name_sep' + messageID).focus();
GLOB_persistedData["frigos"][num_frigo][11] = $('#sondes' + messageID).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
save_important_vars();
blit_message(GLOB_persistedData["frigos"][num_frigo][0] + ' a été <span style="float: none;margin: 0;color:#109E18">mis à jour.</span> !');
messageID = null;
num_frigo = null;
if (gup('page') == 'messages')
setTimeout(function () { window.location.href = window.location.href; }, 500);
if (gup('component') == 'galaxy')
$("div.btn_blue[onclick^='submitForm()']").trigger("click");
}
}
/* Affichage des raccourcis */
dropelems = document.getElementsByClassName('dropdown dropdownList initialized');
if (gup('component') === "fleetdispatch" && $('#fleet2').css('display') !== 'none' && dropelems.length > 0 && have_to_change_dropid) {
have_to_change_dropid = false;
data_racc_dropdown = '<li><a class="undefined" style="text-align:center;color:#80C080"><figure class="planetIcon planet tooltip js_hideTipOnMobile" title="Planète"></figure>------ Mes frigos ------</a></li>';
for (var i = 0; i < GLOB_persistedData["frigos"].length && GLOB_persistedData["frigos"][i]; i++)
data_racc_dropdown += '<li><a class="undefined" style="color:#80C080;" data-value="' + GLOB_persistedData["frigos"][i][1] + '#' + GLOB_persistedData["frigos"][i][2] + '#' + GLOB_persistedData["frigos"][i][3] + '#' + GLOB_persistedData["frigos"][i][4] + '#' + GLOB_persistedData["frigos"][i][0] + '" onClick="$(\'#targetPlanetName\').html(\'' + GLOB_persistedData["frigos"][i][0] + '\');$(\'#galaxy\').val(\'' + GLOB_persistedData["frigos"][i][1] + '\');$(\'#system\').val(\'' + GLOB_persistedData["frigos"][i][2] + '\');$(\'#position\').val(\'' + GLOB_persistedData["frigos"][i][3] + '\');"><figure class="planetIcon planet tooltip js_hideTipOnMobile" title="Planète"></figure>' + GLOB_persistedData["frigos"][i][0] + ' [' + GLOB_persistedData["frigos"][i][1] + ':' + GLOB_persistedData["frigos"][i][2] + ':' + GLOB_persistedData["frigos"][i][3] + ']</a></li>';
dropelems[0].innerHTML += data_racc_dropdown;
}
setTimeout(save_list_in_cookies, 200);
}
function delete_frigo() {
delid = parseInt(this.id.replace('del_button_', ''));
GLOB_persistedData["frigos"].splice(delid, 1);
save_important_vars();
delid = null;
window.location.href = window.location.href;
}
function edit_frigo() {
for (var editid = 0; editid < GLOB_persistedData["frigos"].length && GLOB_persistedData["frigos"][editid]; editid++) {
GLOB_persistedData["frigos"][editid][0] = $('#frig_name_' + editid).val().replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
GLOB_persistedData["frigos"][editid][4] = $('#frig_sondes_' + editid).val().match(/\d/g).join("").toString();
GLOB_persistedData["frigos"][editid][5] = $('#frig_flotte_perso_' + editid).val();
GLOB_persistedData["frigos"][editid][6] = ($('#frig_ignore_' + editid).prop("checked")) ? '1' : '0';
GLOB_persistedData["frigos"][editid][7] = $('#frig_flotte_' + editid).val();
GLOB_persistedData["frigos"][editid][8] = $('#frig_defense_' + editid).val();
}
save_important_vars();
blit_message_time('Modifications <span style="float: none;margin: 0;color:#109E18">enregistrées avec succès</span> !', 1000);
}
function add_frigo(infos_frigo_to_add) {
var cur_nb = GLOB_persistedData["frigos"].length;
GLOB_persistedData["frigos"][cur_nb] = new Array();
//Nom du frigo
GLOB_persistedData["frigos"][cur_nb][0] = infos_frigo_to_add['nom'].replace(/__/g, '').replace(/'/g, '').replace(/"/g, '');
//Galaxy,System,Position
GLOB_persistedData["frigos"][cur_nb][1] = infos_frigo_to_add['galaxy'];
GLOB_persistedData["frigos"][cur_nb][2] = infos_frigo_to_add['system'];
GLOB_persistedData["frigos"][cur_nb][3] = infos_frigo_to_add['position'];
//Checked or not checked
GLOB_persistedData["frigos"][cur_nb][4] = '1';
//Flotte_Perso
GLOB_persistedData["frigos"][cur_nb][5] = '';
//Ignore
GLOB_persistedData["frigos"][cur_nb][6] = '0';