-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
config.html
1027 lines (927 loc) · 40.7 KB
/
config.html
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
<html>
<head>
<link rel="stylesheet" type="text/css" href="res/style.css" />
<link rel="stylesheet" type="text/css" href="res/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="res/jquery-ui.structure.min.css" />
<link rel="stylesheet" type="text/css" href="res/jquery-ui.theme.min.css" />
<script>if (typeof module === 'object') {
window.module = module;
module = undefined;
}</script>
<!-- normal script imports etc -->
<script src="res/jquery-3.3.1.min.js"></script>
<script src="res/jquery.tablesorter.js"></script>
<script src="res/jquery.lazy.js"></script>
<script src="res/jquery-ui.min.js"></script>
<script src="res/utils.js"></script>
<script src="res/debug.js"></script>
<script src="res/page-utils.js"></script>
<!-- Insert this line after script imports -->
<script>if (window.module)
module = window.module;</script>
<style type="text/css">
.tooltipStyle, .ui-tooltip-content {
font-size: medium !important;
font-family: Fontin !important;
background: rgba(0, 0, 0, 0.9) !important;
}
</style>
<script>
const https = require('https');
const {dialog, app} = require('electron').remote;
const path = require('path');
const {ipcRenderer} = require('electron');
const fs = require('fs');
const logger = require('./modules/Log').getLogger(__filename);
const Utils = require('./modules/Utils');
const configKeys = ["accountName", "poesessid", "clientTxt", "screenshotDir", "overlayEnabled", "minimizeToTray", "autoSwitch", "getLowConfidence"];
var settings = {};
var disabledTabsArray = [ 1 ];
var tabsLoaded = false;
var filterData = null;
var requiresRestart = false;
const itemFilterCategories = [
{ id: "nonunique", desc: "Non-unique equipment", hint: "Normal, magic and rare gear (weapons, armour, jewellery)" },
{ id: "unique", desc: "Unique equipment", hint: "Weapons, armour, jewellery, flasks and jewels" },
{ id: "gem", desc: "Skill Gems" },
{ id: "map", desc: "Maps", hint: "Also includes unique maps" },
{
id: "divcard",
desc: "Divination cards",
opts: {
"card" : "per Card",
"fullStack" : "per Full Stack"
}
},
{ id: "prophecy", desc: "Prophecies" },
{ id: "oil", desc: "Oils" },
{ id: "fragment", desc: "Fragments", hint: "Also includes Offering to the Goddess and Maven's Invitation" },
{ id: "delve", desc: "Fossils and resonators" },
{ id: "catalyst", desc: "Catalysts" },
{ id: "essence", desc: "Essences" },
{ id: "incubator", desc: "Incubators" },
{ id: "currency", desc: "Currency", hint: "Includes all other currency items not specifically listed above" }
];
$(document).ready(async function () {
$(document).tooltip({
position: {
at: "top left",
collision: "flipfit"
},
classes: {
"ui-tooltip" : "tooltipStyle"
},
show: false,
hide: false,
track: true
});
var settingsPath = path.join(app.getPath("userData"), "settings.json");
if(fs.existsSync(settingsPath)) {
try {
settings = require(settingsPath);
} catch(err) {
disabledTabsArray = [ 1, 2, 3 ];
// if settings file contains invalid JSON, ignore and prompt for fresh setup
}
} else {
disabledTabsArray = [ 1, 2, 3 ];
}
$("#sidenav").load("sidenav.html", () => {
if(JSON.stringify(settings) === "{}") {
$("#sidenav-items").hide();
} else {
$("#sidenav-main").removeAttr("href");
$("#sidenav-main").click(backToMain);
}
});
$("#messages").load("messages.html");
$(document).keydown(e => {
if(e.key === ")" && e.ctrlKey && e.altKey && e.shiftKey && $('#tabs').tabs('option','active') === 3) {
$("#debugsql").css("display", "flex");
$("#debugOutput").val("");
$("#debugOutput").removeAttr("readonly");
}
});
for(const cat of itemFilterCategories) {
let d = $("<div style='margin: 4px 0'>");
let valueHint = cat.valueHint || 'If no value is specified, ALL items of the selected category will be ignored';
let dropdown = cat.opts ? getDropdown() : "";
d.append($(`<input type='checkbox' id='${cat.id}Checkbox' class='itemtypecheckbox' style='width:25px;height:25px;vertical-align:middle' title="${cat.hint || ""}"/>`));
d.append($(`<span class='itemtypeicon'><img src='res/img/itemtypeicons/${cat.id}.png' class='itemtypeicon' style='height:35px;padding:0 8px;vertical-align:middle;'/>${cat.desc}</span>`));
d.append($(`
<span class='itemvaluefilter'>
less than
<input type='number' min='0' max='999' step='0.1' maxlength='5' style='margin:0!important;width:50px' id='${cat.id}MinValue' title='${valueHint}'/>
<img src='res/img/c.png' style='height:25px;vertical-align:middle;' />
in value
${dropdown}
</span>
`));
$("#itemFilterCategories").append(d);
function getDropdown() {
let select = `<select class='ui-text' style='font-family:FontinSmallCaps;' id='${cat.id}Dropdown'>`;
for(let val in cat.opts) {
select += `<option value='${val}'>${cat.opts[val]}</option>`;
}
select += `</select>`;
return select;
}
}
await loadSettings();
$("#clientTxt").click(() => {
let win = require('electron').remote.getCurrentWindow();
let opts = { properties: ['openFile'] };
dialog.showOpenDialog(win, opts).then( r => {
let filepath = r.filePaths;
if (filepath && filepath.length === 1 && typeof (filepath[0]) === "string" && filepath[0].endsWith("Client.txt")) {
$("#clientTxt").val(filepath[0]);
}
});
});
$("#uploadFilter").click(() => {
let win = require('electron').remote.getCurrentWindow();
let opts = {
properties: ['openFile']
};
dialog.showOpenDialog(win, opts).then( r => {
let filepath = r.filePaths;
if (filepath && filepath.length === 1 && typeof (filepath[0]) === "string") {
processFilter(filepath[0]);
}
});
});
$("#screenshotDir").click(() => {
if($("#screenshotDirDisable").prop("checked")) {
return;
}
let win = require('electron').remote.getCurrentWindow();
let opts = { properties: ['openDirectory'] };
dialog.showOpenDialog(win, opts).then( r => {
let filepath = r.filePaths;
if (filepath && filepath.length === 1 && typeof (filepath[0]) === "string") {
$("#screenshotDir").val(filepath[0]);
}
});
});
$("#screenshotDirDisable").change(() => {
var d = $("#screenshotDir");
var checked = $("#screenshotDirDisable").prop("checked");
if(checked) {
d.data("oldValue", d.val());
d.val("");
d.prop("disabled", true);
} else {
d.prop("disabled", false);
d.val(d.data("oldValue"));
d.removeData();
}
});
$("#stashCheckUnits").change(() => {
switch($("#stashCheckUnits").val()) {
case "hours":
$("#stashCheckMaps").hide();
$("#stashCheckHours").show();
break;
case "maps":
$("#stashCheckHours").hide();
$("#stashCheckMaps").show();
break;
}
});
$("#tabs").tabs({
active: 0,
disabled: disabledTabsArray,
activate: function(event) {
if(event.currentTarget && event.currentTarget.id === "debugLink") {
$("#buttonsDiv").hide();
} else {
$("#buttonsDiv").show();
}
}
});
$("#body").show();
});
async function loadSettings() {
configKeys.forEach((key) => {
if(["overlayEnabled", "minimizeToTray", "autoSwitch", "getLowConfidence"].includes(key)) {
$("#" + key).prop("checked", settings[key]);
} else {
$("#" + key).val(settings[key]);
}
});
if(settings.screenshotDir === "disabled") {
$("#screenshotDir").val("");
$("#screenshotDir").prop("disabled", true);
$("#screenshotDirDisable").prop("checked", true);
}
if(settings.activeProfile && settings.activeProfile.characterName) {
$("#activeProfile").html(`${settings.activeProfile.characterName} (${settings.activeProfile.league} league)`);
$("#selectedName").val(settings.activeProfile.characterName);
$("#selectedLeague").val(settings.activeProfile.league);
$("#uploadFilter").attr('placeholder', `Click to upload new item filter for ${settings.activeProfile.characterName}`);
$("#overrideSSF").prop("checked", settings.activeProfile.overrideSSF);
$("#noGearCheck").prop("checked", settings.activeProfile.noGearCheck);
// private league handling
if(Utils.isPrivateLeague(settings.activeProfile.league)) {
let leagueList = await getLeagueList();
let selectedLeague = null;
if(settings.privateLeaguePriceMaps && settings.privateLeaguePriceMaps[settings.activeProfile.league]) {
selectedLeague = settings.privateLeaguePriceMaps[settings.activeProfile.league];
} else {
$("#privateLeaguePriceList").append($(`<option hidden disabled selected></option>`));
}
leagueList.forEach(league => {
$("#privateLeaguePriceList").append($(`<option value="${league}" ${league === selectedLeague ? "selected" : ""}>${league}</option>`));
})
$("#privateLeagueRow").show();
} else {
$("#privateLeagueRow").empty();
}
getTabList();
} else {
$("#activeProfile").html(`None`);
$("#uploadFilter").hide();
$("#privateLeagueRow").empty();
$("#autoSwitchRow").hide();
}
if(settings.stashCheck) {
var value = settings.stashCheck.interval;
var units = settings.stashCheck.units;
var enabled = true;
if(settings.stashCheck.hasOwnProperty("enabled")) {
enabled = settings.stashCheck.enabled;
}
$("#stashCheckCheckbox").prop("checked", enabled);
$("#stashCheckUnits").val(units);
switch(units) {
case "hours":
$("#stashCheckMaps").hide();
$("#stashCheckHours").show();
$("#stashCheckHours").val(value);
break;
case "maps":
$("#stashCheckHours").hide();
$("#stashCheckMaps").show();
$("#stashCheckMaps").val(value);
break;
}
} else {
$("#stashCheckHours").hide();
$("#stashCheckMaps").val(20);
$("#stashCheckUnits").val("maps");
$("#stashCheckCheckbox").prop("checked", true);
}
if(settings.netWorthCheck) {
$("#netWorthCheckInterval").val(settings.netWorthCheck.interval);
$("#netWorthCheckbox").prop("checked", settings.netWorthCheck.enabled);
} else {
$("#netWorthCheckInterval").val(300);
$("#netWorthCheckbox").prop("checked", true);
}
// backward compatibility, preserve old minItemValue if present
if(settings.minItemValue && !settings.itemFilter) {
["nonunique", "unique", "gem"].forEach(cat => {
$(`#${cat}Checkbox`).prop("checked", true);
$(`#${cat}MinValue`).val(settings.minItemValue);
})
} else if(settings.itemFilter) {
for(let key in settings.itemFilter) {
let cat = settings.itemFilter[key];
if(cat.ignore) {
$(`#${key}Checkbox`).prop("checked", true);
if(cat.minValue) {
$(`#${key}MinValue`).val(cat.minValue);
}
if(cat.option) {
$(`#${key}Dropdown`).val(cat.option);
}
}
};
}
updateManualSwitch();
}
function getLeagueList() {
return new Promise((resolve, reject) => {
let params = {
hostname: 'api.pathofexile.com',
path: '/leagues',
method: 'GET',
headers: {
"User-Agent": `exile-diary/${app.getVersion()}`,
"Referer": 'http://www.pathofexile.com/'
}
};
var request = require('https').request(params, (response) => {
var body = '';
response.setEncoding('utf8');
response.on('data', (chunk) => {
body += chunk;
});
response.on('end', async () => {
try {
let list = [];
var data = JSON.parse(body);
data.forEach(d => {
if(!d.id.includes("SSF")) {
list.push(d.id);
}
});
// list temp leagues first
list = list.slice(2).concat(list.slice(0, 2));
resolve(list);
} catch (err) {
logger.info(`Error getting public league list: ${err}`);
resolve(null);
}
});
response.on('error', (err) => {
logger.info(`Error getting public league list: ${err}`);
resolve(null);
});
});
request.on('error', (err) => {
logger.info(`Error getting public league list: ${err}`);
resolve(null);
});
request.end();
});
}
function processFilter(path) {
logger.info("Getting filter file " + path);
var stats = fs.statSync(path);
if(stats.size > 2097152) {
$("#uploadFilter").val("Maximum file size (2MB) exceeded");
return;
}
var data = fs.readFileSync(path, "utf8");
var filter = require('./modules/FilterParser').test(data.toString());
if(JSON.stringify(filter.errors) !== "[]") {
$("#uploadFilter").val("Errors found while parsing filter");
logger.info(filter.errors);
} else {
$("#uploadFilter").val(`[${path}] will be uploaded on save`);
filterData = data;
return;
}
}
function saveSettings() {
var valid = true;
configKeys.forEach((key) => {
var inputField = $("#" + key);
if(["overlayEnabled", "minimizeToTray", "autoSwitch", "getLowConfidence"].includes(key)) {
settings[key] = inputField.is(':checked');
} else if(inputField.val()) {
settings[key] = inputField.val();
inputField.removeClass("invalid");
} else if(key === 'screenshotDir') {
if($("#screenshotDirDisable").prop("checked")) {
inputField.removeClass("invalid");
} else {
inputField.addClass("invalid");
valid = false;
}
} else {
inputField.addClass("invalid");
valid = false;
}
});
if(!$("#selectedName").val()) {
$("#characterList").addClass("invalid");
valid = false;
} else {
$("#characterList").removeClass("invalid");
}
if($("#privateLeaguePriceList").length > 0) {
if(!$("#privateLeaguePriceList").val()) {
$("#privateLeaguePriceList").addClass("invalid");
valid = false;
} else {
settings.privateLeaguePriceMaps = settings.privateLeaguePriceMaps || {};
settings.privateLeaguePriceMaps[settings.activeProfile.league] = $("#privateLeaguePriceList").val();
$("#privateLeaguePriceList").removeClass("invalid");
}
}
if(!valid) {
$("#saveError").show();
return;
}
$("#saveError").hide();
if($("#screenshotDirDisable").prop("checked")) {
settings.screenshotDir = "disabled";
}
settings.activeProfile = {
characterName: $("#selectedName").val(),
league: $("#selectedLeague").val()
};
if($("#overrideSSF").is(":checked")) {
settings.activeProfile.overrideSSF = true;
}
if($("#noGearCheck").is(":checked")) {
settings.activeProfile.noGearCheck = true;
}
var stashCheckUnits = $("#stashCheckUnits").val();
var stashCheckInterval;
switch(stashCheckUnits) {
case "hours":
stashCheckInterval = $("#stashCheckHours").val() || 1;
break;
case "maps":
stashCheckInterval = $("#stashCheckMaps").val() || 20;
break;
default:
stashCheckInterval = 1;
stashCheckUnits = "hours";
break;
}
settings.stashCheck = {
interval: stashCheckInterval,
units: stashCheckUnits,
enabled: $("#stashCheckCheckbox").prop("checked")
};
settings.netWorthCheck = {
interval: $("#netWorthCheckInterval").val() || 300,
enabled: $("#netWorthCheckbox").prop("checked")
};
let itemFilter = {};
itemFilterCategories.forEach(cat => {
itemFilter[cat.id] = {};
if($(`#${cat.id}Checkbox`).prop("checked")) {
itemFilter[cat.id].ignore = true;
let v = Number.parseFloat($(`#${cat.id}MinValue`).val());
if(v) {
itemFilter[cat.id].minValue = v;
if($(`#${cat.id}Dropdown`)) {
itemFilter[cat.id].option = $(`#${cat.id}Dropdown`).val();
}
}
}
});
settings.itemFilter = itemFilter;
if(!requiresRestart && tabsLoaded) {
var tabs = [];
$("input[name='tabList']:checked").each((i, elem) => {
tabs.push($(elem).val());
})
if(!settings.tabs) {
settings.tabs = {};
}
settings.tabs[settings.activeProfile.league] = tabs;
}
var filename = path.join(app.getPath("userData"), "settings.json");
fs.writeFile(filename, JSON.stringify(settings), (err) => {
if (err) throw err;
$("#saveSettings").html('Saving . . . ');
$("#saveSettings").prop('disabled', true);
if(requiresRestart) {
logger.info("Requires restart");
ipcRenderer.once("done-initializing", () => {
window.location = "index.html";
});
ipcRenderer.send("reinitialize");
} else {
if(filterData) {
var DB = require('./modules/DB').getDB();
var moment = require('moment');
DB.run(
"insert into filters(timestamp, text) values(?, ?)",
[moment().format('YYYYMMDDHHmmss'), filterData],
(err) => {
if(err) {
logger.info("Error inserting filter: " + err.message);
} else {
$("#uploadFilter").val(`Item filter uploaded successfully!`);
ipcRenderer.once("done-initializing", () => {
window.location.reload();
});
ipcRenderer.send("reinitialize");
}
}
);
} else {
ipcRenderer.once("done-initializing", () => {
window.location.reload();
});
ipcRenderer.send("reinitialize");
}
}
});
}
function getTabList() {
var path = `/character-window/get-stash-items?accountName=${encodeURIComponent(settings.accountName)}&league=${encodeURIComponent(settings.activeProfile.league)}&tabs=1`;
var poesessid = $("#poesessid").val();
var requestParams = Utils.getRequestParams(path, poesessid);
var request = https.request(requestParams, (response) => {
var body = '';
response.setEncoding('utf8');
response.on('data', (chunk) => {
body += chunk;
});
response.on('end', () => {
try {
var data = JSON.parse(body);
listTabs(data);
} catch (err) {
tabListError(err);
}
});
response.on('error', (err) => {
tabListError(err);
});
});
request.on('error', tabListError);
request.end();
function tabListError(err) {
logger.info(`Failed to get tab list: ${err.message}`);
alert(`Failed to get tab list for ${$("#accountName").val()}. Have you entered your account name and POESESSID correctly?`);
}
}
function listTabs(data) {
var div = $("#tabList");
data.tabs.forEach(tab => {
let unsupported = (tab.type === "MapStash" || tab.type === "UniqueStash");
var color = `#${toHex(tab.colour.r)}${toHex(tab.colour.g)}${toHex(tab.colour.b)}`;
var checked = settings.tabs && settings.tabs[settings.activeProfile.league] && settings.tabs[settings.activeProfile.league].includes(tab.id);
div.append(`
<div onclick='selectTab("${tab.id}");' class='stashTab' style='background-color:${color};${unsupported ? "opacity:0.5;" : ""}'>
${unsupported ? "<input type='checkbox' style='visibility:hidden;'/>" : `<input type='checkbox' onclick='selectTab("${tab.id}")' name='tabList' class='stashTabCheckbox' ${checked ? "checked='checked'" : ""} id='${tab.id}' value='${tab.id}'>`}
<img style='margin-bottom:-8px;margin-right:8px' src="res/img/tabicons/${tab.type}.png"/>
<span>${tab.n}</span>
</div>
`);
});
tabsLoaded = true;
$("#tabs").tabs("enable", 1);
var params = require('./modules/Utils').getParams(window.location.toString());
if(params['loadStash']) {
$("#tabs").tabs({ active: 1 });
}
function toHex(c) {
var hex = c.toString(16);
return hex.length === 1 ? "0" + hex : hex;
}
}
function selectTab(id) {
$(`#${id}`).prop("checked", !$(`#${id}`).prop("checked"));
}
function toggleTabs() {
let select = ($('#toggleTabs').data("mode") === "select");
$('#toggleTabs').data("mode", (select ? "unselect" : "select"));
$('#toggleTabs').html(`Click here to ${select ? "unselect" : "select"} all`);
$(`.stashTabCheckbox`).each( function() {
if( (!$(this).prop("checked") && select) || ($(this).prop("checked") && !select) ) {
$(this).click();
}
});
}
function getCharacters() {
if(!$("#accountName").val() || !$("#poesessid").val()) {
return;
}
$("#characterList").val(`Loading characters for ${$("#accountName").val()} . . .`);
var path = `/character-window/get-characters?accountName=${encodeURIComponent($("#accountName").val())}`;
var poesessid = $("#poesessid").val();
var requestParams = Utils.getRequestParams(path, poesessid);
var request = https.request(requestParams, (response) => {
var body = '';
response.setEncoding('utf8');
response.on('data', (chunk) => {
body += chunk;
});
response.on('end', () => {
try {
logger.info(body);
var data = JSON.parse(body);
listCharacters(data);
} catch (err) {
characterListError(err);
}
});
response.on('error', (err) => {
characterListError(err);
});
});
request.on('error', characterListError);
request.end();
function characterListError(err) {
alert(`Failed to get character list for ${$("#accountName").val()}. Have you entered your account name and POESESSID correctly?`);
$("#characterList").val("");
}
}
function listCharacters(data) {
var charList = [];
data.forEach( char => {
var obj = {
label: `${char.name} (Level ${char.level} ${char.class} in ${char.league})`,
name: char.name,
league: char.league
};
charList.push(obj);
try {
if(char.name === settings.activeProfile.characterName) {
$("#characterList").val(obj.label);
$("#selectedName").val(obj.name);
$("#selectedLeague").val(obj.league);
}
} catch(err) {
// active profile not found - do nothing
}
});
$("#characterList").prop("onclick", null);
$("#characterList").autocomplete({
delay: 0,
minLength: 0,
source: charList,
focus: function(event, ui) {
$("#characterList").val(ui.item.label);
return false;
},
select: function( event, ui ) {
$("#characterList").val(ui.item.label);
$("#selectedName").val(ui.item.name);
$("#selectedLeague").val(ui.item.league);
if(settings.activeProfile && ($("#selectedName").val() !== settings.activeProfile.characterName || $("#selectedLeague").val() !== settings.activeProfile.league)) {
requiresRestart = true;
filterData = null;
$("#uploadFilter").hide();
$("#saveSettings").html("Save and Restart");
} else {
requiresRestart = false;
filterData = null;
if(settings.activeProfile && settings.activeProfile.characterName) {
$("#uploadFilter").attr('placeholder', `Click to upload new item filter for ${settings.activeProfile.characterName}`);
$("#uploadFilter").show();
}
$("#saveSettings").html("Save");
}
return false;
}
});
$("#characterList").focus(function () {
$(this).autocomplete('search', '');
});
$("#characterList").click(function () {
$(this).autocomplete('search', '');
});
$("#characterList").click();
}
function setActiveCharacter() {
settings.activeProfile = {
characterName: $("#selectedName").val(),
league: $("#selectedLeague").val()
};
}
function backToMain() {
ipcRenderer.once("done-initializing", () => {
window.location.href = "index.html";
});
ipcRenderer.send("reinitialize");
}
function updateManualSwitch() {
$("#characterList").prop("disabled", $("#autoSwitch").is(":checked"));
$("#characterList").css("display", $("#autoSwitch").is(":checked") ? "none" : "");
}
function toggleStashCheckboxes(e) {
let id = e.target.id;
if(id === "netWorthCheckbox" && $(`#${id}`).prop("checked") === false) {
$("#stashCheckCheckbox").prop("checked", false);
} else if(id === "stashCheckCheckbox" && $(`#${id}`).prop("checked") === true) {
$("#netWorthCheckbox").prop("checked", true);
}
}
</script>
</head>
<body id='body' style='display:none'>
<div class='sidenav' id='sidenav'></div>
<div id="tabs">
<ul>
<li><a id="accountLink" href="#account">Account</a></li>
<li><a id="stashLink" href="#stash">Stash</a></li>
<li><a id="filterLink" href="#filter">Filter</a></li>
<li><a id="debugLink" href="#debug">Debug</a></li>
</ul>
<div id="account">
<table id='mapFilters'>
<tr>
<td><div class='configLabel ui-text'>Account Name</div></td>
<td><input class='configInput' name='accountName' id='accountName' type='text' maxlength='50' size='80' /></td>
</tr>
<tr>
<td><div class='configLabel ui-text'>POESESSID</div></td>
<td><input class='configInput' name='poesessid' id='poesessid' type='password' maxlength='50' size='80' /></td>
</tr>
<tr>
<td style='vertical-align:middle;'>
</td>
</tr>
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<tr>
<td colspan="2">
Currently active character: <span class='eventText' id='activeProfile'/>
</td>
</tr>
<tr>
<td id='privateLeagueRow' colspan="2" style="white-space:nowrap">
<img src='res/img/!.png' style='height:1em;width:1em;vertical-align:middle;'/> Private leagues are not listed on Poe.ninja -
item prices for <select class='ui-text' style='margin:0px;font-family:FontinSmallCaps;' id="privateLeaguePriceList"></select> league will be used instead
</td>
</tr>
<tr>
<td colspan="2">
<input class='configInput' readonly name='uploadFilter' id='uploadFilter' type='text' style='width:100%'/>
</td>
</tr>
<tr>
<td colspan="2">
<input class='configInput' onclick='getCharacters()' name='characterList' id='characterList' type='text' style='width:100%' placeholder='Click to change active character' />
<input type='hidden' id='selectedName' />
<input type='hidden' id='selectedLeague' />
</td>
</tr>
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<tr>
<td><div class='configLabel ui-text'>Client.txt Location</div></td>
<td><input class='configInput' name='clientTxt' id='clientTxt' readonly type='text' maxlength='50' size='80' /></td>
</tr>
<tr>
<td><div class='configLabel ui-text'>Screenshot Directory</div></td>
<td title="Only used for extracting map mod info from in-game screenshots. Disable if you don't need this">
<input class='configInput' name='screenshotDir' id='screenshotDir' readonly type='text' maxlength='50' size='80' />
<input type="checkbox" style='margin-left:20px;' id='screenshotDirDisable'/> Disable
</td>
</tr>
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<tr>
<td colspan="2">
<div class='configLabel ui-text'>
<input style='margin:0 16px;' name='minimizeToTray' id='minimizeToTray' type='checkbox'/>
<label for='minimizeToTray'>Minimize to Tray</label>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class='configLabel ui-text' title="Displays notifications about completed maps and net worth updates as an overlay in your PoE window. WARNING: may cause FPS drops">
<input style='margin:0 16px;' name='overlayEnabled' id='overlayEnabled' type='checkbox'/>
<label for='overlayEnabled'>Enable overlay popup messages</label>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class='configLabel ui-text'>
<input style='margin:0 16px;' name='overrideSSF' id='overrideSSF' type='checkbox'/>
<label for='overrideSSF'>Get item prices even in SSF mode</label>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class='configLabel ui-text' title="Retrieve prices for items with very few listings from poe.ninja. WARNING: use at your own risk, may result in very skewed item values">
<input style='margin:0 16px;' name='getLowConfidence' id='getLowConfidence' type='checkbox'/>
<label for='getLowConfidence'>Get low-confidence pricing data from poe.ninja</label>
</div>
</td>
</tr>
<tr id='autoSwitchRow'>
<td colspan="2">
<div class='configLabel ui-text' title="If checked, whenever you switch characters in-game, Exile Diary will automatically track stats for that character">
<input style='margin:0 16px;' name='autoSwitch' id='autoSwitch' type='checkbox' onchange='updateManualSwitch();'/>
<label for='autoSwitch'>Enable automatic character switching</label>
</div>
</td>
</tr>
<tr id='noGearCheckRow'>
<td colspan="2">
<div class='configLabel ui-text' title="If checked, equipment history will no longer be tracked. For fully-geared characters that swap gems or equipment frequently">
<input style='margin:0 16px;' name='noGearCheck' id='noGearCheck' type='checkbox'/>
<label for='noGearCheck'>Disable gear tracking</label>
</div>
</td>
</tr>
</table>
</div>
<div id="stash">
<div style='display:inline-block;' title="How often to check the total value of your stash.">
<input type='checkbox' id='netWorthCheckbox' onchange="toggleStashCheckboxes(event)" class='spanCheckbox'/>
<span id='netWorthSpan'>Check net worth</span>
<span class='togglable'> every <input type='number' value='300' min='0' max='86400' step='1' maxlength='8' style='margin:0 4px;width:60px' id='netWorthCheckInterval' /> seconds</span>
</div>
<br/>
<div style='display:inline-block;' title="How often to save the entire contents of your stash for later viewing. If you're not interested in this, disabling it can save disk space">
<input type='checkbox' id='stashCheckCheckbox' onchange="toggleStashCheckboxes(event)" class='spanCheckbox'/>
<span id='stashCheckSpan'>
Retrieve full stash contents
</span>
<span class='togglable'>
every
<select class='ui-text' style='margin-left:4px;font-family:FontinSmallCaps;' id="stashCheckHours">
<option value="0.25">1/4</option>
<option value="0.5">1/2</option>
<option value="1">1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='6'>6</option>
<option value='8'>8</option>
<option value='12'>12</option>
<option value='24'>24</option>
</select>
<select class='ui-text' style='margin-left:10px;font-family:FontinSmallCaps;' id="stashCheckMaps">
<option value="5">5</option>
<option value="10">10</option>
<option value='20'>20</option>
<option value='50'>50</option>
<option value='100'>100</option>
</select>
<select class='ui-text' style='font-family:FontinSmallCaps;' id="stashCheckUnits">
<option value="hours">hours</option>
<option value="maps">maps</option>
</select>
</span>
</div>
<div>
<hr>
<div id="note">Select Stash Tabs to Monitor (Map and unique tabs not yet supported). <a id='toggleTabs' data-mode='select' style='color:#66f;' onclick='toggleTabs()'>Click here to select all</a></div>
<div id="tabList" style="max-height:65%;overflow-y:auto;"></div>
</div>
</div>
<div id="filter">
<div style='display:flex;align-items:center'>
<img src="res/img/novalue.png" style='height:100px;margin-right:10px'/>
<span>
Items you pick up which are in the categories selected below will be <b class='eventText'>ignored.</b><br/>
No value will be calculated for them, and they will be excluded from map summary and net worth.
</span>
</div>
<hr style='clear:left;'>
<div id='itemFilterCategories'></div>
</div>
<div id="debug">
<div style='display:flex;align-items:center'>
<img src="res/img/howa.png" style='height:100px;margin-right:10px'/>
<span>
Tools for fixing bugged data.<br/>
Please do not use unless specifically instructed
</span>
</div>
<hr style='clear:left;'>
<div style="display: flex; flex-direction: row;">
<button class='debugButton' id="recheckGainedButton" style="width:320px;margin:0 16px;" onclick="debugClear();recheckGained();">Recheck Map Profit</button>
<div style='line-height: 200%;vertical-align: middle;'>
Recalculates the value of items picked up for all map runs since
<input id="recheckGainedStartValue" type="number" style="width:10ch;" value="20210115" title='Default value is the start of the current league. Enter a date, or leave blank to recheck all map runs in the database (warning: slow)'/>
</div>
</div>
<div style="display: flex; flex-direction: row; padding-top:10px;">
<button class='debugButton' id="recheckGainedButton" style="width:320px;margin:0 16px;" onclick="debugClear();updateUltimatum();">Update Ultimatum Info</button>
<div style='line-height: 200%;vertical-align: middle;'>
Adds Ultimatum info (rounds, mods picked, completion) to each map run.
</div>
</div>
<!--
<div style="display: flex; flex-direction: row; padding-top:10px;">
<button class='debugButton' id="recheckGearButton" style="width:320px;margin:0 16px;" onclick="debugClear();checkGearDuplicates();">Recheck Gear Changes</button>
<div style='line-height: 200%; vertical-align: middle;'>
Removes gear changes for which the item was not actually changed.
</div>
</div>
<div style="display: flex; flex-direction: row; padding-top:10px;">