-
Notifications
You must be signed in to change notification settings - Fork 6
/
WME Wide-Angle Lens Places.user.js
1562 lines (1562 loc) · 77.9 KB
/
WME Wide-Angle Lens Places.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
/// <reference path="../typescript-typings/globals/openlayers/index.d.ts" />
/// <reference path="../typescript-typings/I18n.d.ts" />
/// <reference path="../typescript-typings/waze.d.ts" />
/// <reference path="../typescript-typings/globals/jquery/index.d.ts" />
/// <reference path="WME Wide-Angle Lens.user.ts" />
/// <reference path="../typescript-typings/greasyfork.d.ts" />
// ==UserScript==
// @name WME Wide-Angle Lens Places
// @namespace https://greasyfork.org/en/users/19861-vtpearce
// @description Find place that match filter criteria
// @author vtpearce and crazycaveman
// @match https://*.waze.com/*editor*
// @exclude https://*.waze.com/user/editor*
// @exclude https://www.waze.com/discuss/*
// @version 2024.10.07.001
// @grant GM_xmlhttpRequest
// @copyright 2020 vtpearce
// @license CC BY-SA 4.0
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @updateURL https://greasyfork.org/scripts/40645-wme-wide-angle-lens-places/code/WME%20Wide-Angle%20Lens%20Places.meta.js
// @downloadURL https://greasyfork.org/scripts/40645-wme-wide-angle-lens-places/code/WME%20Wide-Angle%20Lens%20Places.user.js
// @connect greasyfork.org
// ==/UserScript==
// @updateURL https://greasyfork.org/scripts/418293-wme-wide-angle-lens-places-beta/code/WME%20Wide-Angle%20Lens%20Places.meta.js
// @downloadURL https://greasyfork.org/scripts/418293-wme-wide-angle-lens-places-beta/code/WME%20Wide-Angle%20Lens%20Places.user.js
/*global W, OL, I18n, $, WazeWrap, WMEWAL, OpenLayers */
var WMEWAL_Places;
(function (WMEWAL_Places) {
const SCRIPT_NAME = GM_info.script.name;
const SCRIPT_VERSION = GM_info.script.version.toString();
const DOWNLOAD_URL = GM_info.script.downloadURL;
const updateText = '<ul>'
+ '<li>Fixes for latest WME release</li>'
+ '</ul>';
const greasyForkPage = 'https://greasyfork.org/scripts/40645';
const wazeForumThread = 'https://www.waze.com/forum/viewtopic.php?t=206376';
const ctlPrefix = "_wmewalPlaces";
const minimumWALVersionRequired = "2023.09.18.001";
let Operation;
(function (Operation) {
Operation[Operation["Equal"] = 1] = "Equal";
Operation[Operation["NotEqual"] = 2] = "NotEqual";
Operation[Operation["LessThan"] = 3] = "LessThan";
Operation[Operation["LessThanOrEqual"] = 4] = "LessThanOrEqual";
Operation[Operation["GreaterThan"] = 5] = "GreaterThan";
Operation[Operation["GreaterThanOrEqual"] = 6] = "GreaterThanOrEqual";
})(Operation || (Operation = {}));
let Issue;
(function (Issue) {
Issue[Issue["MissingHouseNumber"] = 1] = "MissingHouseNumber";
Issue[Issue["MissingStreet"] = 2] = "MissingStreet";
Issue[Issue["AdLocked"] = 4] = "AdLocked";
Issue[Issue["HasUpdateRequests"] = 8] = "HasUpdateRequests";
Issue[Issue["PendingApproval"] = 16] = "PendingApproval";
Issue[Issue["UndefStreet"] = 32] = "UndefStreet";
Issue[Issue["NoExternalProviders"] = 64] = "NoExternalProviders";
Issue[Issue["NoHours"] = 128] = "NoHours";
Issue[Issue["NoEntryExitPoints"] = 256] = "NoEntryExitPoints";
Issue[Issue["MissingBrand"] = 512] = "MissingBrand";
Issue[Issue["NoPhoneNumber"] = 1024] = "NoPhoneNumber";
Issue[Issue["BadPhoneNumberFormat"] = 2048] = "BadPhoneNumberFormat";
Issue[Issue["NoWebsite"] = 4096] = "NoWebsite";
Issue[Issue["NoCity"] = 8192] = "NoCity";
Issue[Issue["NoName"] = 16384] = "NoName";
})(Issue || (Issue = {}));
const pluginName = "WMEWAL-Places";
WMEWAL_Places.Title = "Places";
WMEWAL_Places.MinimumZoomLevel = 17;
WMEWAL_Places.SupportsSegments = false;
WMEWAL_Places.SupportsVenues = true;
const settingsKey = "WMEWALPlacesSettings";
const savedSettingsKey = "WMEWALPlacesSavedSettings";
let settings = null;
let savedSettings = [];
let places;
let nameRegex = null;
let cityRegex = null;
let websiteRegex = null;
let streetRegex = null;
let state;
let stateName;
let lastModifiedBy;
let lastModifiedByName;
let createdBy;
let createdByName;
let initCount = 0;
let detectIssues = false;
let savedVenues;
function onWmeReady() {
initCount++;
if (WazeWrap && WazeWrap.Ready && typeof (WMEWAL) !== 'undefined' && WMEWAL && WMEWAL.RegisterPlugIn) {
log('debug', 'WazeWrap and WMEWAL ready.');
init();
}
else {
if (initCount < 60) {
log('debug', 'WazeWrap or WMEWAL not ready. Trying again...');
setTimeout(onWmeReady, 1000);
}
else {
log('error', 'WazeWrap or WMEWAL not ready. Giving up.');
}
}
}
function bootstrap() {
if (W?.userscripts?.state.isReady) {
onWmeReady();
}
else {
document.addEventListener('wme-ready', onWmeReady, { once: true });
}
}
async function init() {
// Check to see if WAL is at the minimum verson needed
if (!(typeof WMEWAL.IsAtMinimumVersion === "function" && WMEWAL.IsAtMinimumVersion(minimumWALVersionRequired))) {
log('log', "WAL not at required minimum version.");
WazeWrap.Alerts.info(GM_info.script.name, "Cannot load plugin because WAL is not at the required minimum version. " +
"You might need to manually update it from <a href='https://greasyfork.org/scripts/40641' target='_blank'>Greasy Fork</a>.", true, false);
return;
}
if (typeof Storage !== "undefined") {
if (localStorage[settingsKey]) {
settings = JSON.parse(localStorage[settingsKey]);
}
if (localStorage[savedSettingsKey]) {
try {
savedSettings = JSON.parse(WMEWAL.LZString.decompressFromUTF16(localStorage[savedSettingsKey]));
}
catch (e) { }
if (typeof savedSettings === "undefined" || savedSettings === null || savedSettings.length === 0) {
log('debug', "decompressFromUTF16 failed, attempting decompress");
localStorage[savedSettingsKey + "Backup"] = localStorage[savedSettingsKey];
try {
savedSettings = JSON.parse(WMEWAL.LZString.decompress(localStorage[savedSettingsKey]));
}
catch (e) { }
if (typeof savedSettings === "undefined" || savedSettings === null) {
log('warn', "decompress failed, savedSettings unrecoverable. Using blank");
savedSettings = [];
}
updateSavedSettings();
}
}
}
if (settings == null) {
initSettings();
}
else {
if (updateProperties()) {
updateSettings();
}
}
log('log', "Initialized");
WazeWrap.Interface.ShowScriptUpdate(SCRIPT_NAME, SCRIPT_VERSION, updateText, greasyForkPage, wazeForumThread);
WMEWAL.RegisterPlugIn(WMEWAL_Places);
}
function GetTab() {
const rpp = "RESIDENCE_HOME";
let html = "<table style='border-collapse:separate;border-spacing:0px 1px;'>";
html += "<tbody>";
html += "<tr><td class='wal-heading'><b>Saved Filters</b></td></tr>";
html += "<tr><td class='wal-indent' style='padding-bottom: 8px'>" +
`<select id='${ctlPrefix}SavedSettings'></select><br/>` +
`<button class='btn btn-primary' id='${ctlPrefix}LoadSetting' title='Load'>Load</button>` +
`<button class='btn btn-primary' style='margin-left: 4px;' id='${ctlPrefix}SaveSetting' title='Save'>Save</button>` +
`<button class='btn btn-primary' style='margin-left: 4px;' id='${ctlPrefix}DeleteSetting' title='Delete'>Delete</button></td></tr>`;
html += `<tr><td style='border-top: 1px solid'><button class='btn btn-primary' style='margin-top: 6px;margin-bottom: 6px' id='${ctlPrefix}Reset' title='Reset'>Reset</button></td></tr>`;
html += "<tr><td class='wal-heading' style='border-top: 1px solid'>Output Options</td></tr>";
html += `<tr><td class='wal-indent'><input type='checkbox' id='${ctlPrefix}IncludeAlt' class='wal-check' name='${ctlPrefix}IncludeAlt'>` +
`<label for='${ctlPrefix}IncludeAlt' class='wal-label'>Include Alt Names</label></td></tr>`;
html += "<tr><td class='wal-heading' style='border-top: 1px solid; padding-top: 4px'><b>Filters (All of these)</b></td></tr>";
html += "<tr><td><b>Category:</b></td></tr>";
html += `<tr><td class='wal-indent'><select id='${ctlPrefix}CategoryOp'>` +
"<option value='" + Operation.Equal.toString() + "' selected='selected'>=</option>" +
"<option value='" + Operation.NotEqual.toString() + "'><></option>" +
"</select>";
html += `<select id='${ctlPrefix}Category'>` +
"<option value=''></option>";
for (let topIx = 0; topIx < W.Config.venues.categories.length; topIx++) {
const topCategory = W.Config.venues.categories[topIx];
html += ("<option value='" + topCategory + "'>" + I18n.t("venues.categories." + topCategory) + "</option>");
const subCategories = W.Config.venues.subcategories[topCategory];
for (let subIx = 0; subIx < subCategories.length; subIx++) {
const subCategory = W.Config.venues.subcategories[topCategory][subIx];
html += ("<option value='" + subCategory + "'>--" + I18n.t("venues.categories." + subCategory) + "</option>");
}
}
html += "<option value='" + rpp + "'>" + I18n.t("venues.categories." + rpp) + "</option>";
html += "</select></td></tr>";
html += "<tr><td><b>Lock Level:</b></td></tr>" +
"<tr><td class='wal-indent'>" +
`<select id='${ctlPrefix}LockLevelOp'>` +
"<option value='" + Operation.Equal.toString() + "' selected='selected'>=</option>" +
"<option value='" + Operation.NotEqual.toString() + "'><></option></select>" +
`<select id='${ctlPrefix}LockLevel'>` +
"<option value=''></option>" +
"<option value='1'>1</option>" +
"<option value='2'>2</option>" +
"<option value='3'>3</option>" +
"<option value='4'>4</option>" +
"<option value='5'>5</option>" +
"<option value='6'>6</option>" +
"<option value='7'>7</option>" +
"</select></td></tr>";
html += "<tr><td><b>Name RegEx</b></td></tr>";
html += "<tr><td class='wal-indent'>" +
`<input type='text' id='${ctlPrefix}Name' class='wal-textbox'/><br/>` +
`<input id='${ctlPrefix}IgnoreCase' class='wal-check' type='checkbox'/>` +
`<label for='${ctlPrefix}IgnoreCase' class='wal-indent'>Ignore case</label></td>`;
html += "<tr><td><b>Street RegEx</b></td></tr>";
html += "<tr><td class='wal-indent'>" +
`<input type='text' id='${ctlPrefix}Street' class='wal-textbox'/><br/>` +
`<input id='${ctlPrefix}StreetIgnoreCase' class='wal-check' type='checkbox'/>` +
`<label for='${ctlPrefix}StreetIgnoreCase' class='wal-indent'>Ignore case</label></td>`;
html += "<tr><td><b>City RegEx:</b></td></tr>";
html += `<tr><td class='wal-indent'><input type='text' id='${ctlPrefix}City' class='wal-textbox'/><br/>` +
`<input id='${ctlPrefix}CityIgnoreCase' class='wal-check' type='checkbox'/>` +
`<label for='${ctlPrefix}CityIgnoreCase' style='margin-left: 8px'>Ignore case</label></td></tr>`;
html += "<tr><td><b>Website RegEx:</b></td></tr>";
html += `<tr><td class='wal-indent'><input type='text' id='${ctlPrefix}Website' class='wal-textbox'/><br/>` +
`<input id='${ctlPrefix}WebsiteIgnoreCase' class='wal-check' type='checkbox'/>` +
`<label for='${ctlPrefix}WebsiteIgnoreCase' style='margin-left: 8px'>Ignore case</label></td></tr>`;
html += "<tr><td><b>State:</b></td></tr>";
html += "<tr><td style='padding-left:20px'>" +
`<select id='${ctlPrefix}StateOp'>` +
"<option value='" + Operation.Equal.toString() + "' selected='selected'>=</option>" +
"<option value='" + Operation.NotEqual.toString() + "'><></option></select>" +
`<select id='${ctlPrefix}State'></select>`;
html += "<tr><td><b>Type:</b></td></tr>" +
`<tr><td class='wal-indent'><select id='${ctlPrefix}Type'>` +
"<option value=''></option>" +
"<option value='area'>" + I18n.t("edit.venue.type.area") + "</option>" +
"<option value='point'>" + I18n.t("edit.venue.type.point") + "</option>" +
"</select></td></tr>";
html += "<tr><td><b>Created By:</b></td></tr>";
html += "<tr><td class='wal-indent'>" +
`<select id='${ctlPrefix}CreatedBy'></select></td></tr>`;
html += `<tr><td><input id='${ctlPrefix}Created' class='wal-check' type='checkbox' />` +
`<label for=${ctlPrefix}Created' class='wal-label'>Date Created:</label> ` +
`<select id='${ctlPrefix}CreatedOp'>` +
`<option value='${Operation.LessThan}'><</option>` +
`<option value='${Operation.LessThanOrEqual}'><=</option>` +
`<option value='${Operation.GreaterThanOrEqual}' selected='selected'>>=</option>` +
`<option value='${Operation.GreaterThan}'>></option></select>` +
"</td></tr>";
html += "<tr><td class='wal-indent'>" +
`<input id='${ctlPrefix}CreatedDate' type='date'/> <input id='${ctlPrefix}CreatedTime' type='time'/></td></tr>`;
html += "<tr><td><b>Last Updated By:</b></td></tr>";
html += "<tr><td class='wal-indent'>" +
`<select id='${ctlPrefix}LastModifiedBy'></select></td></tr>`;
html += `<tr><td><input id='${ctlPrefix}Updated' class='wal-check' type='checkbox' />` +
`<label for=${ctlPrefix}Updated' class='wal-label'>Date Updated:</label> ` +
`<select id='${ctlPrefix}UpdatedOp'>` +
`<option value='${Operation.LessThan}'><</option>` +
`<option value='${Operation.LessThanOrEqual}'><=</option>` +
`<option value='${Operation.GreaterThanOrEqual}' selected='selected'>>=</option>` +
`<option value='${Operation.GreaterThan}'>></option></select>` +
"</td></tr>";
html += "<tr><td class='wal-indent'>" +
`<input id='${ctlPrefix}UpdatedDate' type='date'/> <input id='${ctlPrefix}UpdatedTime' type='time'/></td></tr>`;
html += `<tr><td><input id='${ctlPrefix}Editable' class='wal-check' type='checkbox'/>` +
`<label for='${ctlPrefix}Editable' class='wal-label'>Editable by me</label></td></tr>`;
html += `<tr><td><input id='${ctlPrefix}ParkingLotType' class='wal-check' type='checkbox'/>` +
`<label for='${ctlPrefix}ParkingLotType' class='wal-label'>`;
html += `Parking Lot Type: <select id='${ctlPrefix}ParkingLotTypeFilter'>` +
"<option value='PRIVATE'>" + I18n.t("edit.venue.parking.types.parkingType.PRIVATE") + "</option>" +
"<option value='PUBLIC'>" + I18n.t("edit.venue.parking.types.parkingType.PUBLIC") + "</option>" +
"<option value='RESTRICTED'>" + I18n.t("edit.venue.parking.types.parkingType.RESTRICTED") + "</option>" +
"</select></label></td></tr>";
html += "<tr><td class='wal-heading' style='border-top: 1px solid; padding-top: 4px'>Issues (Any of these)</td></tr>";
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoName'/>` +
`<label for='${ctlPrefix}NoName' class='wal-label'>No Name</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoHouseNumber'/>` +
`<label for='${ctlPrefix}NoHouseNumber' class='wal-label'>Missing House Number</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoStreet'/>` +
`<label for='${ctlPrefix}NoStreet' class='wal-label'>Missing Street</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoCity'/>` +
`<label for='${ctlPrefix}NoCity' class='wal-label'>Missing City</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}AdLocked'/>` +
`<label for='${ctlPrefix}AdLocked' class='wal-label'>Ad Locked</label></td></tr>`;
html += `<tr><td ><input class='wal-check' type='checkbox' id='${ctlPrefix}UpdateRequests'/>` +
`<label for='${ctlPrefix}UpdateRequests' class='wal-label'>Has Update Requests</label></td></tr>`;
html += `<tr><td ><input class='wal-check' type='checkbox' id='${ctlPrefix}PendingApproval'/>` +
`<label for='${ctlPrefix}PendingApproval' class='wal-label'>Pending Approval</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}UndefStreet' />` +
`<label for='${ctlPrefix}UndefStreet' class='wal-label' title='Street ID not found in W.model.streets.objects, possibly as a result of a cities form Merge or Delete'>Undefined Street ID</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoExternalProviders' />` +
`<label for='${ctlPrefix}NoExternalProviders' class='wal-label'>No External Provider Links</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoHours' />` +
`<label for='${ctlPrefix}NoHours' class='wal-label'>No Hours</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoWebsite' />` +
`<label for='${ctlPrefix}NoWebsite' class='wal-label'>No Website</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoPhoneNumber' />` +
`<label for='${ctlPrefix}NoPhoneNumber' class='wal-label'>No Phone Number</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}BadPhoneNumberFormat' />` +
`<label for='${ctlPrefix}BadPhoneNumberFormat' class='wal-label'>Bad Phone Number Format</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}NoEntryExitPoints' />` +
`<label for='${ctlPrefix}NoEntryExitPoints' class='wal-label'>No Entry/Exit Points</label></td></tr>`;
html += `<tr><td><input class='wal-check' type='checkbox' id='${ctlPrefix}MissingBrand' />` +
`<label for='${ctlPrefix}MissingBrand' class='wal-label'>Missing Brand (GS)</label></td></tr>`;
html += "</tbody></table>";
return html;
}
WMEWAL_Places.GetTab = GetTab;
function TabLoaded() {
loadScriptUpdateMonitor();
updateStates();
updateUsers($(`#${ctlPrefix}LastModifiedBy`));
updateUsers($(`#${ctlPrefix}CreatedBy`));
updateUI();
updateSavedSettingsList();
$(`#${ctlPrefix}State`).on("focus", updateStates);
$(`#${ctlPrefix}LastModifiedBy`).on("focus", function () {
updateUsers($(`#${ctlPrefix}LastModifiedBy`));
});
$(`#${ctlPrefix}CreatedBy`).on("focus", function () {
updateUsers($(`#${ctlPrefix}CreatedBy`));
});
$(`#${ctlPrefix}LoadSetting`).on("click", loadSetting);
$(`#${ctlPrefix}SaveSetting`).on("click", saveSetting);
$(`#${ctlPrefix}DeleteSetting`).on("click", deleteSetting);
$(`#${ctlPrefix}Reset`).on('click', reset);
}
WMEWAL_Places.TabLoaded = TabLoaded;
function reset() {
initSettings();
updateUI();
}
function updateStates() {
const selectState = $(`#${ctlPrefix}State`);
// Preserve current selection
const currentId = parseInt(selectState.val());
selectState.empty();
const stateObjs = [];
stateObjs.push({ id: null, name: "" });
for (let s in W.model.states.objects) {
if (W.model.states.objects.hasOwnProperty(s)) {
const st = W.model.states.getObjectById(parseInt(s));
if (st.getAttribute('id') !== 1 && st.getAttribute('name').length !== 0) {
stateObjs.push({ id: st.getAttribute('id'), name: st.getAttribute('name') });
}
}
}
stateObjs.sort(function (a, b) {
if (a.id == null) {
return -1;
}
else {
return a.name.localeCompare(b.name);
}
});
for (let ix = 0; ix < stateObjs.length; ix++) {
const so = stateObjs[ix];
const stateOption = $("<option/>").text(so.name).attr("value", so.id ?? "");
if (currentId != null && so.id === currentId) {
stateOption.attr("selected", "selected");
}
selectState.append(stateOption);
}
}
function updateUsers(selectUsernameList) {
// Preserve current selection
const currentId = parseInt(selectUsernameList.val());
selectUsernameList.empty();
const userObjs = [];
userObjs.push({ id: null, name: "" });
for (let uo in W.model.users.objects) {
if (W.model.users.objects.hasOwnProperty(uo)) {
const u = W.model.users.getObjectById(parseInt(uo));
if (u.type === "user" && u.getAttribute('userName') !== null && typeof u.getAttribute('userName') !== "undefined") {
userObjs.push({ id: u.getAttribute('id'), name: u.getAttribute('userName') });
}
}
}
userObjs.sort(function (a, b) {
if (a.id == null) {
return -1;
}
else {
return a.name.localeCompare(b.name);
}
});
for (let ix = 0; ix < userObjs.length; ix++) {
const o = userObjs[ix];
const userOption = $("<option/>").text(o.name).attr("value", o.id);
if (currentId != null && o.id == null) {
userOption.attr("selected", "selected");
}
selectUsernameList.append(userOption);
}
}
function updateSavedSettingsList() {
const s = $(`#${ctlPrefix}SavedSettings`);
s.empty();
for (let ixSaved = 0; ixSaved < savedSettings.length; ixSaved++) {
let opt = $("<option/>").attr("value", ixSaved).text(savedSettings[ixSaved].Name);
s.append(opt);
}
}
function updateUI() {
// $(`#${ctlPrefix}OutputTo`).val(settings.OutputTo);
$(`#${ctlPrefix}CategoryOp`).val(settings.CategoryOperation || Operation.Equal);
$(`#${ctlPrefix}Category`).val(settings.Category);
$(`#${ctlPrefix}LockLevel`).val(settings.LockLevel);
$(`#${ctlPrefix}LockLevelOp`).val(settings.LockLevelOperation || Operation.Equal);
$(`#${ctlPrefix}NoName`).prop("checked", settings.NoName);
$(`#${ctlPrefix}Name`).val(settings.Regex || "");
$(`#${ctlPrefix}IgnoreCase`).prop("checked", settings.RegexIgnoreCase);
$(`#${ctlPrefix}City`).val(settings.CityRegex || "");
$(`#${ctlPrefix}CityIgnoreCase`).prop("checked", settings.CityRegexIgnoreCase);
$(`#${ctlPrefix}State`).val(settings.State);
$(`#${ctlPrefix}StateOp`).val(settings.StateOperation || Operation.Equal);
$(`#${ctlPrefix}Type`).val(settings.PlaceType);
$(`#${ctlPrefix}Editable`).prop("checked", settings.EditableByMe);
$(`#${ctlPrefix}NoHouseNumber`).prop("checked", settings.NoHouseNumber);
$(`#${ctlPrefix}UndefStreet`).prop("checked", settings.UndefStreet);
$(`#${ctlPrefix}AdLocked`).prop("checked", settings.AdLocked);
$(`#${ctlPrefix}UpdateRequests`).prop("checked", settings.UpdateRequests);
$(`#${ctlPrefix}PendingApproval`).prop("checked", settings.PendingApproval);
$(`#${ctlPrefix}NoStreet`).prop("checked", settings.NoStreet);
$(`#${ctlPrefix}NoCity`).prop("checked", settings.NoCity);
$(`#${ctlPrefix}LastModifiedBy`).val(settings.LastModifiedBy);
$(`#${ctlPrefix}CreatedBy`).val(settings.CreatedBy);
$(`#${ctlPrefix}NoExternalProviders`).prop("checked", settings.NoExternalProviders);
$(`#${ctlPrefix}NoHours`).prop("checked", settings.NoHours);
$(`#${ctlPrefix}NoPhoneNumber`).prop("checked", settings.NoPhoneNumber);
$(`#${ctlPrefix}BadPhoneNumberFormat`).prop("checked", settings.BadPhoneNumberFormat);
$(`#${ctlPrefix}NoWebsite`).prop("checked", settings.NoWebsite);
$(`#${ctlPrefix}NoEntryExitPoints`).prop("checked", settings.NoEntryExitPoints);
$(`#${ctlPrefix}ParkingLotType`).prop("checked", settings.ParkingLotType);
$(`#${ctlPrefix}ParkingLotTypeFilter`).val(settings.ParkingLotTypeFilter);
$(`#${ctlPrefix}MissingBrand`).prop("checked", settings.MissingBrand);
$(`#${ctlPrefix}IncludeAlt`).prop("checked", settings.IncludeAlt);
$(`#${ctlPrefix}Created`).prop("checked", settings.Created);
$(`#${ctlPrefix}CreatedOp`).val(settings.CreatedOperation);
if (settings.CreatedDate != null) {
const createdDateTime = new Date(settings.CreatedDate);
$(`#${ctlPrefix}CreatedDate`).val(createdDateTime.getFullYear().toString().padStart(4, "0") + "-" +
(createdDateTime.getMonth() + 1).toString().padStart(2, "0") + "-" + createdDateTime.getDate().toString().padStart(2, "0"));
$(`#${ctlPrefix}CreatedTime`).val(createdDateTime.getHours().toString().padStart(2, "0") + ":" +
createdDateTime.getMinutes().toString().padStart(2, "0"));
}
else {
$(`#${ctlPrefix}CreatedDate`).val("");
$(`#${ctlPrefix}CreatedTime`).val("");
}
$(`#${ctlPrefix}Updated`).prop("checked", settings.Updated);
$(`#${ctlPrefix}UpdatedOp`).val(settings.UpdatedOperation);
if (settings.UpdatedDate != null) {
const updatedDateTime = new Date(settings.UpdatedDate);
$(`#${ctlPrefix}UpdatedDate`).val(updatedDateTime.getFullYear().toString().padStart(4, "0") + "-" +
(updatedDateTime.getMonth() + 1).toString().padStart(2, "0") + "-" + updatedDateTime.getDate().toString().padStart(2, "0"));
$(`#${ctlPrefix}UpdatedTime`).val(updatedDateTime.getHours().toString().padStart(2, "0") + ":" +
updatedDateTime.getMinutes().toString().padStart(2, "0"));
}
else {
$(`#${ctlPrefix}UpdatedDate`).val("");
$(`#${ctlPrefix}UpdatedTime`).val("");
}
$(`#${ctlPrefix}Website`).val(settings.WebsiteRegex || "");
$(`#${ctlPrefix}WebsiteIgnoreCase`).prop("checked", settings.WebsiteRegexIgnoreCase);
$(`#${ctlPrefix}Street`).val(settings.StreetRegex || "");
$(`#${ctlPrefix}StreetIgnoreCase`).prop("checked", settings.StreetRegexIgnoreCase);
}
function loadSetting() {
const selectedSetting = parseInt($(`#${ctlPrefix}SavedSettings`).val());
if (selectedSetting == null || isNaN(selectedSetting) || selectedSetting < 0 || selectedSetting > savedSettings.length) {
return;
}
initSettings();
const savedSetting = savedSettings[selectedSetting].Setting;
for (let name in savedSetting) {
if (settings.hasOwnProperty(name)) {
settings[name] = savedSetting[name];
}
}
updateUI();
}
function validateSettings() {
function addMessage(error) {
message += ((message.length > 0 ? "\n" : "") + error);
}
let message = "";
const s = getSettings();
const cat = $(`#${ctlPrefix}Category`).val();
let r;
if (nullif(s.Regex, "") !== null) {
try {
r = (s.RegexIgnoreCase ? new RegExp(s.Regex, "i") : new RegExp(s.Regex));
}
catch (error) {
addMessage("Name RegEx is invalid");
}
}
if (nullif(s.CityRegex, "") !== null) {
try {
r = (s.CityRegexIgnoreCase ? new RegExp(s.CityRegex, "i") : new RegExp(s.CityRegex));
}
catch (error) {
addMessage("City RegEx is invalid");
}
}
if (nullif(s.WebsiteRegex, "") !== null) {
try {
r = (s.WebsiteRegexIgnoreCase ? new RegExp(s.WebsiteRegex, "i") : new RegExp(s.WebsiteRegex));
}
catch (error) {
addMessage("Website RegEx is invalid");
}
}
if (nullif(s.StreetRegex, "") !== null) {
try {
r = (s.StreetRegexIgnoreCase ? new RegExp(s.StreetRegex, "i") : new RegExp(s.StreetRegex));
}
catch (error) {
addMessage("Street RegEx is invalid");
}
}
const selectedState = $(`#${ctlPrefix}State`).val();
if (nullif(selectedState, "") !== null && s.State === null) {
addMessage("Invalid state selection");
}
const selectedModifiedUser = $(`#${ctlPrefix}LastModifiedBy`).val();
if (nullif(selectedModifiedUser, "") !== null && s.LastModifiedBy === null) {
addMessage("Invalid last modified user");
}
const selectedCreatedUser = $(`#${ctlPrefix}CreatedBy`).val();
if (nullif(selectedCreatedUser, "") !== null && s.CreatedBy === null) {
addMessage("Invalid created user");
}
if (s.ParkingLotType) {
if (nullif(s.ParkingLotTypeFilter, "") === null) {
addMessage("Please select a parking lot type");
}
if (cat !== "" && cat !== "PARKING_LOT") {
addMessage("When filtering on parking lot type, category must be parking lot.");
}
}
if (s.MissingBrand && cat !== "" && cat !== "GAS_STATION" && cat !== "CAR_SERVICES") {
addMessage("Invalid category selected if checking for missing gas station brand");
}
if (s.Created && s.CreatedDate === null) {
addMessage("Select a created date on which to filter.");
}
if (s.Updated && s.UpdatedDate === null) {
addMessage("Select an updated date on which to filter.");
}
if (message.length > 0) {
alert(pluginName + ": " + message);
return false;
}
return true;
}
function saveSetting() {
if (validateSettings()) {
const s = getSettings();
const sName = prompt("Enter a name for this setting");
if (sName == null) {
return;
}
// Check to see if there is already a name that matches this
for (let ixSetting = 0; ixSetting < savedSettings.length; ixSetting++) {
if (savedSettings[ixSetting].Name === sName) {
if (confirm("A setting with this name already exists. Overwrite?")) {
savedSettings[ixSetting].Setting = s;
updateSavedSettings();
}
else {
alert("Please pick a new name.");
}
return;
}
}
const savedSetting = {
Name: sName,
Setting: s
};
savedSettings.push(savedSetting);
updateSavedSettings();
}
}
function getSettings() {
const s = {
NoName: $(`#${ctlPrefix}NoName`).prop("checked"),
Regex: null,
RegexIgnoreCase: $(`#${ctlPrefix}IgnoreCase`).prop("checked"),
CategoryOperation: parseInt($(`#${ctlPrefix}CategoryOp`).val()),
Category: null,
NoHouseNumber: $(`#${ctlPrefix}NoHouseNumber`).prop("checked"),
State: null,
StateOperation: parseInt($(`#${ctlPrefix}StateOp`).val()),
LockLevel: null,
LockLevelOperation: parseInt($(`#${ctlPrefix}LockLevelOp`).val()),
EditableByMe: $(`#${ctlPrefix}Editable`).prop("checked"),
AdLocked: $(`#${ctlPrefix}AdLocked`).prop("checked"),
UndefStreet: $(`#${ctlPrefix}UndefStreet`).prop("checked"),
UpdateRequests: $(`#${ctlPrefix}UpdateRequests`).prop("checked"),
PlaceType: null,
PendingApproval: $(`#${ctlPrefix}PendingApproval`).prop("checked"),
CityRegex: null,
CityRegexIgnoreCase: $(`#${ctlPrefix}CityIgnoreCase`).prop("checked"),
NoStreet: $(`#${ctlPrefix}NoStreet`).prop("checked"),
NoCity: $(`#${ctlPrefix}NoCity`).prop("checked"),
LastModifiedBy: null,
CreatedBy: null,
NoExternalProviders: $(`#${ctlPrefix}NoExternalProviders`).prop("checked"),
NoHours: $(`#${ctlPrefix}NoHours`).prop("checked"),
NoPhoneNumber: $(`#${ctlPrefix}NoPhoneNumber`).prop("checked"),
BadPhoneNumberFormat: $(`#${ctlPrefix}BadPhoneNumberFormat`).prop("checked"),
NoWebsite: $(`#${ctlPrefix}NoWebsite`).prop("checked"),
NoEntryExitPoints: $(`#${ctlPrefix}NoEntryExitPoints`).prop("checked"),
ParkingLotType: $(`#${ctlPrefix}ParkingLotType`).prop("checked"),
ParkingLotTypeFilter: $(`#${ctlPrefix}ParkingLotTypeFilter`).val(),
MissingBrand: $(`#${ctlPrefix}MissingBrand`).prop("checked"),
IncludeAlt: $(`#${ctlPrefix}IncludeAlt`).prop("checked"),
Created: $(`#${ctlPrefix}Created`).prop("checked"),
CreatedOperation: parseInt($(`#${ctlPrefix}CreatedOp`).val()),
CreatedDate: null,
Updated: $(`#${ctlPrefix}Updated`).prop("checked"),
UpdatedOperation: parseInt($(`#${ctlPrefix}UpdatedOp`).val()),
UpdatedDate: null,
WebsiteRegex: null,
WebsiteRegexIgnoreCase: $(`#${ctlPrefix}WebsiteIgnoreCase`).prop("checked"),
StreetRegex: null,
StreetRegexIgnoreCase: $(`#${ctlPrefix}StreetIgnoreCase`).prop("checked")
};
s.Regex = nullif($(`#${ctlPrefix}Name`).val(), "");
s.CityRegex = nullif($(`#${ctlPrefix}City`).val(), "");
s.WebsiteRegex = nullif($(`#${ctlPrefix}Website`).val(), "");
s.StreetRegex = nullif($(`#${ctlPrefix}Street`).val(), "");
const selectedState = $(`#${ctlPrefix}State`).val();
if (nullif(selectedState, "") !== null) {
const state = W.model.states.getObjectById(parseInt(selectedState));
if (state !== null) {
s.State = state.getAttribute('id');
}
}
const selectedModifiedUser = $(`#${ctlPrefix}LastModifiedBy`).val();
if (nullif(selectedModifiedUser, "") !== null) {
const u = W.model.users.getObjectById(selectedModifiedUser);
if (u !== null) {
s.LastModifiedBy = u.getAttribute('id');
}
}
const selectedCreatedUser = $(`#${ctlPrefix}CreatedBy`).val();
if (nullif(selectedCreatedUser, "") !== null) {
const u = W.model.users.getObjectById(selectedCreatedUser);
if (u !== null) {
s.CreatedBy = u.getAttribute('id');
}
}
const selectedLockLevel = $(`#${ctlPrefix}LockLevel`).val();
if (selectedLockLevel != null && selectedLockLevel.length > 0) {
s.LockLevel = parseInt(selectedLockLevel);
}
s.PlaceType = nullif($(`#${ctlPrefix}Type`).val(), "");
s.Category = nullif($(`#${ctlPrefix}Category`).val(), "");
let createdDate = $(`#${ctlPrefix}CreatedDate`).val();
if (createdDate && createdDate.length > 0) {
const createdTime = $(`#${ctlPrefix}CreatedTime`).val();
if (createdTime && createdTime.length > 0) {
createdDate += ` ${createdTime}`;
}
else {
createdDate += ' 00:00';
}
s.CreatedDate = (new Date(createdDate)).getTime();
}
let updatedDate = $(`#${ctlPrefix}UpdatedDate`).val();
if (updatedDate && updatedDate.length > 0) {
const updatedTime = $(`#${ctlPrefix}UpdatedTime`).val();
if (updatedTime && updatedTime.length > 0) {
updatedDate += ` ${updatedTime}`;
}
else {
updatedDate += ' 00:00';
}
s.UpdatedDate = (new Date(updatedDate)).getTime();
}
return s;
}
function deleteSetting() {
const selectedSetting = parseInt($(`#${ctlPrefix}SavedSettings`).val());
if (selectedSetting == null || isNaN(selectedSetting) || selectedSetting < 0 || selectedSetting > savedSettings.length) {
return;
}
if (confirm("Are you sure you want to delete this saved setting?")) {
savedSettings.splice(selectedSetting, 1);
updateSavedSettings();
}
}
function ScanStarted() {
let allOk = validateSettings();
places = [];
savedVenues = [];
if (allOk) {
settings = getSettings();
if (nullif(settings.Regex, "") !== null) {
nameRegex = (settings.RegexIgnoreCase ? new RegExp(settings.Regex, "i") : new RegExp(settings.Regex));
}
else {
nameRegex = null;
}
if (nullif(settings.CityRegex, "") !== null) {
cityRegex = (settings.CityRegexIgnoreCase ? new RegExp(settings.CityRegex, "i") : new RegExp(settings.CityRegex));
}
else {
cityRegex = null;
}
if (nullif(settings.WebsiteRegex, "") !== null) {
websiteRegex = (settings.WebsiteRegexIgnoreCase ? new RegExp(settings.WebsiteRegex, "i") : new RegExp(settings.WebsiteRegex));
}
else {
websiteRegex = null;
}
if (nullif(settings.StreetRegex, "") !== null) {
streetRegex = (settings.StreetRegexIgnoreCase ? new RegExp(settings.StreetRegex, "i") : new RegExp(settings.StreetRegex));
}
else {
streetRegex = null;
}
if (settings.State !== null) {
state = W.model.states.getObjectById(settings.State);
stateName = state.getAttribute('name');
}
else {
state = null;
stateName = null;
}
if (settings.LastModifiedBy !== null) {
lastModifiedBy = W.model.users.getObjectById(settings.LastModifiedBy);
lastModifiedByName = lastModifiedBy.getAttribute('userName');
}
else {
lastModifiedBy = null;
lastModifiedByName = null;
}
if (settings.CreatedBy !== null) {
createdBy = W.model.users.getObjectById(settings.CreatedBy);
createdByName = createdBy.getAttribute('userName');
}
else {
createdBy = null;
createdByName = null;
}
detectIssues = settings.NoName ||
settings.NoHouseNumber ||
settings.NoStreet ||
settings.NoCity ||
settings.AdLocked ||
settings.UpdateRequests ||
settings.PendingApproval ||
settings.UndefStreet ||
settings.NoExternalProviders ||
settings.NoHours ||
settings.NoPhoneNumber ||
settings.BadPhoneNumberFormat ||
settings.NoWebsite ||
settings.NoEntryExitPoints ||
settings.MissingBrand;
updateSettings();
}
return allOk;
}
WMEWAL_Places.ScanStarted = ScanStarted;
function ScanExtent(segments, venues) {
return new Promise(resolve => {
setTimeout(function () {
const count = scan(segments, venues);
resolve({ Streets: null, Places: count, MapComments: null });
});
});
}
WMEWAL_Places.ScanExtent = ScanExtent;
function scan(segments, venues) {
function checkCategory(categories, category, operation) {
const match = categories.find(function (e) {
return e.localeCompare(category) === 0;
});
if (typeof match === "undefined" || match == null || match.length === 0) {
return operation === Operation.NotEqual;
}
return operation === Operation.Equal;
}
const validPhoneRegex = new RegExp("\\(\\d\\d\\d\\) \\d\\d\\d-\\d\\d\\d\\d");
for (let ix = 0; ix < venues.length; ix++) {
const venue = venues[ix];
if (venue != null) {
const categories = venue.getAttribute('categories');
const address = venue.getAddress(W.model);
if (venue.getAttribute('streetID') && address && address.getCountry() == null) {
log("warn", "no address for streetID " + venue.getAttribute('streetID') + ", venue " + venue.getAttribute('name') + " " + venue.getID());
}
const houseNum = venue.getAttribute('houseNumber') ?? "";
if ((settings.LockLevel == null ||
(settings.LockLevelOperation === Operation.Equal && (venue.getAttribute('lockRank') || 0) + 1 === settings.LockLevel) ||
(settings.LockLevelOperation === Operation.NotEqual && (venue.getAttribute('lockRank') || 0) + 1 !== settings.LockLevel)) &&
(!settings.EditableByMe || venue.arePropertiesEditable() || venue.areUpdateRequestsEditable()) &&
(settings.PlaceType == null || (settings.PlaceType === "point" && venue.isPoint() && !venue.is2D()) || (settings.PlaceType === "area" && !venue.isPoint() && venue.is2D())) &&
(nameRegex == null || nameRegex.test(venue.getAttribute('name'))) &&
(!settings.Created ||
(settings.CreatedOperation === Operation.LessThan && venue.getAttribute('createdOn') < settings.CreatedDate) ||
(settings.CreatedOperation === Operation.LessThanOrEqual && venue.getAttribute('createdOn') <= settings.CreatedDate) ||
(settings.CreatedOperation === Operation.GreaterThanOrEqual && venue.getAttribute('createdOn') >= settings.CreatedDate) ||
(settings.CreatedOperation === Operation.GreaterThan && venue.getAttribute('createdOn') > settings.CreatedDate)) &&
(!settings.Updated ||
(settings.UpdatedOperation === Operation.LessThan && (venue.getAttribute('updatedOn') || venue.getAttribute('createdOn')) < settings.UpdatedDate) ||
(settings.UpdatedOperation === Operation.LessThanOrEqual && (venue.getAttribute('updatedOn') || venue.getAttribute('createdOn')) <= settings.UpdatedDate) ||
(settings.UpdatedOperation === Operation.GreaterThanOrEqual && (venue.getAttribute('updatedOn') || venue.getAttribute('createdOn')) >= settings.UpdatedDate) ||
(settings.UpdatedOperation === Operation.GreaterThan && (venue.getAttribute('updatedOn') || venue.getAttribute('createdOn')) > settings.UpdatedDate)) &&
((settings.CreatedBy === null) ||
(venue.getCreatedBy() === settings.CreatedBy)) &&
((settings.LastModifiedBy === null) ||
((venue.getUpdatedBy() ?? venue.getCreatedBy()) === settings.LastModifiedBy)) &&
(websiteRegex === null ||
websiteRegex.test(venue.getAttribute('url')))) {
let issues = 0;
if (state != null) {
if (address && !address.isEmpty() && address.attributes.state) {
if (settings.StateOperation === Operation.Equal && address.attributes.state.getAttribute('id') !== state.getAttribute('id') ||
settings.StateOperation === Operation.NotEqual && address.attributes.state.getAttribute('id') === state.getAttribute('id')) {
continue;
}
}
else if (settings.StateOperation === Operation.Equal) {
continue;
}
}
// if (settings.LastModifiedBy != null) {
// if (venue.getAttribute('updatedBy') != null) {
// if (venue.getAttribute('updatedBy') !== settings.LastModifiedBy) {
// continue;
// }
// } else if (venue.getAttribute('createdBy') !== settings.LastModifiedBy) {
// continue;
// }
// }
// if (settings.CreatedBy != null) {
// if (venue.getAttribute('createdBy') !== settings.CreatedBy) {
// continue;
// }
// }
if (settings.Category != null) {
if (!checkCategory(categories, settings.Category, settings.CategoryOperation)) {
continue;
}
}
let regExMatched = false;
if (cityRegex != null) {
regExMatched = false;
if (address && !address.isEmpty() && address.attributes.city && !address.attributes.city.isEmpty() && address.attributes.city.hasName()) {
regExMatched = cityRegex.test(address.attributes.city.getAttribute('name'));
}
if (!regExMatched) {
continue;
}
}
if (streetRegex != null) {
regExMatched = false;
if (address && !address.isEmpty() && !address.isEmptyStreet()) {
regExMatched = streetRegex.test(address.attributes.street.getAttribute('name'));
}
if (!regExMatched) {
continue;
}
}
if (settings.ParkingLotType) {
// Don't pay attention if we don't have a parking lot type
if (!venue.getAttribute('categoryAttributes').PARKING_LOT ||
venue.getAttribute('categoryAttributes').PARKING_LOT.parkingType !== settings.ParkingLotTypeFilter) {
continue;
}
}
if (settings.NoName && !venue.getAttribute('name')) {
issues |= Issue.NoName;
}
if (settings.NoHouseNumber && houseNum == '') {
issues |= Issue.MissingHouseNumber;
}
if (settings.AdLocked && venue.getAttribute('adLocked')) {
issues |= Issue.AdLocked;
}
if (settings.UndefStreet && typeof W.model.streets.objects[venue.getAttribute('streetID')] === 'undefined') {
issues |= Issue.UndefStreet;
}
if (settings.UpdateRequests && venue.hasOpenUpdateRequests()) {
issues |= Issue.HasUpdateRequests;
}
if (settings.PendingApproval && !venue.isApproved()) {
issues |= Issue.PendingApproval;
}
if (settings.NoStreet && (!address || address.isEmpty() || address.isEmptyStreet())) {
issues |= Issue.MissingStreet;
}
if (settings.NoCity && (!address || address.isEmpty() || !address.getCity() || address.getCity().isEmpty())) {
issues |= Issue.NoCity;
}
if (settings.NoExternalProviders && (!venue.getAttribute('externalProviderIDs') || venue.getAttribute('externalProviderIDs').length === 0)) {
issues |= Issue.NoExternalProviders;
}
if (settings.NoHours && (!venue.getAttribute('openingHours') || venue.getAttribute('openingHours').length === 0)) {
issues |= Issue.NoHours;
}
if (settings.NoPhoneNumber && !venue.getAttribute('phone')) {
issues |= Issue.NoPhoneNumber;
}
if (settings.BadPhoneNumberFormat && (venue.getAttribute('phone') && !validPhoneRegex.test(venue.getAttribute('phone')))) {
issues |= Issue.BadPhoneNumberFormat;
}
if (settings.NoWebsite && !venue.getAttribute('url')) {
issues |= Issue.NoWebsite;
}
if (settings.NoEntryExitPoints && (!venue.getAttribute('entryExitPoints') || venue.getAttribute('entryExitPoints').length === 0)) {
issues |= Issue.NoEntryExitPoints;
}
if (settings.MissingBrand && checkCategory(categories, "GAS_STATION", Operation.Equal) && venue.getAttribute('brand') === null) {
issues |= Issue.MissingBrand;
}
if (detectIssues && issues === 0) {
// If at least one issue was chosen and this segment doesn't have any issues, then skip it
continue;
}
if (!WMEWAL.IsVenueInArea(venue)) {
continue;
}
// Don't add it if we've already done so
if (savedVenues.indexOf(venue.getID()) === -1) {
savedVenues.push(venue.getID());
const lastEditorID = venue.getUpdatedBy() ?? venue.getCreatedBy();
const lastEditor = W.model.users.getObjectById(lastEditorID);
const createdByID = venue.getCreatedBy();
const createdBy = W.model.users.getObjectById(createdByID);
const place = {
id: venue.getAttribute('id'),
mainCategory: venue.getMainCategory(),
name: venue.getAttribute('name'),
lockLevel: venue.getLockRank() + 1,
pointGeometry: venue.getOLGeometry().getCentroid(),
// navigationPoint: venue.getNavigationPoint(),
categories: categories,
streetID: venue.getAttribute('streetID'),
placeType: ((venue.isPoint() && !venue.is2D()) ? I18n.t("edit.venue.type.point") : I18n.t("edit.venue.type.area")),
isApproved: venue.isApproved(),
city: ((address && !address.isEmpty() && address.attributes.city && !address.attributes.city.isEmpty() && address.attributes.city.hasName()) ? address.attributes.city.getAttribute('name') : "No City"),
state: ((address && !address.isEmpty() && address.attributes.state) ? address.attributes.state.getAttribute('name') : "No State"),
houseNumber: houseNum,
streetName: ((address && !address.isEmpty() && !address.isEmptyStreet()) ? address.attributes.street.getAttribute('name') : "") || "",
lastEditor: lastEditor?.getAttribute('userName') ?? '',
createdBy: createdBy?.getAttribute('userName') ?? '',
url: venue.getAttribute('url') ?? "",
phone: venue.getAttribute('phone') ?? "",
issues: issues,
parkingLotType: (venue.getAttribute('categoryAttributes').PARKING_LOT && venue.getAttribute('categoryAttributes').PARKING_LOT.parkingType && I18n.t("edit.venue.parking.types.parkingType." + venue.getAttribute('categoryAttributes').PARKING_LOT.parkingType)) || "",
altNames: [...venue.getAttribute('aliases')]
};
places.push(place);
}
}
}
}
return places.length;
}
function ScanComplete() {
if (places.length === 0) {
alert(pluginName + ": No places found.");
}
else {
places.sort(function (a, b) {
return a.name.localeCompare(b.name);
});
const isCSV = (WMEWAL.outputTo & WMEWAL.OutputTo.CSV);
const isTab = (WMEWAL.outputTo & WMEWAL.OutputTo.Tab);
const addBOM = WMEWAL.addBOM ?? false;
const outputFields = WMEWAL.outputFields ?? ['CreatedEditor', 'LastEditor', 'LockLevel', 'Lat', 'Lon'];
const includeCreatedBy = outputFields.indexOf('CreatedEditor') > -1 || settings.CreatedBy !== null;
const includeLastUpdatedBy = outputFields.indexOf('LastEditor') > -1 || settings.LastModifiedBy !== null;
const includeLockLevel = outputFields.indexOf('LockLevel') > -1 || settings.LockLevel !== null;
const includeLat = outputFields.indexOf('Lat') > -1;
const includeLon = outputFields.indexOf('Lon') > -1;
let lineArray;
let columnArray;
let w;
let fileName;
if (isCSV) {
lineArray = [];
// (settings.undefStreet ? "Street ID," : "")
columnArray = ["Name"];
if (settings.IncludeAlt) {
columnArray.push("Alt Names");
}
columnArray.push("Categories", "City", "State");
if (includeLockLevel) {
columnArray.push("Lock Level");
}
columnArray.push("Type", "Street", "House Number");
if (detectIssues) {
columnArray.push("Issues");
}
columnArray.push("Website", "Phone Number", "Parking Lot Type");
if (includeCreatedBy) {