dh_ackergaul
vor 3 Tagen 5bbf43c1b146439ab882815c12ed6292f1d7b4df
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
1001
1002
1003
1004
1005
1006
function ModuleStandard(options) {
    // this.filter = this.filter.bind(this);
    this.forceFilter = this.forceFilter.bind(this);
    this.categoryValueButton = {};
    //this.dimensionValueButton = {};
    //this.dimensions = [];
    this.dimMapping = options.DimensionsMapping || [];
    this.constructionTypeListDistinctDimensions = {};
    this.defaultConfiguratorArt = undefined;
    this.pdfFile = undefined;
    this.manuCat = dh_TempGetJSONData("currentManuCat", "");
    this.modProg = "";
    this.modManu = "";
 
    /* GS [2026|06|09] Performance: Session-Cache fuer die statischen Katalog-Lookups.
    GetDynEquipment (Kategorie/Sortierung je ArtNr) und GetArtPropByArt (Vars je ArtNr)
    liefern fuer ein gegebenes (manu, prog, artNr[, progGroup]) immer dasselbe Ergebnis -
    das sind Katalog-Metadaten, die sich innerhalb einer Sitzung nicht aendern.
    Jeder dieser Aufrufe ist ein teurer synchroner FPS/COM-Roundtrip (JSON-Serialisierung
    hin und zurueck). buildEquipment ruft sie einmal PRO Zubehoer-Element auf und laeuft
    ueber onEquipmentChangeListeners bei JEDER Equipment-Aenderung komplett neu - das Cachen
    eliminiert die Roundtrips bei Wiederholung und bei doppelten ArtNrn vollstaendig.
    Die Ergebnisse werden nur gelesen, nie mutiert -> ein gemeinsam genutztes Objekt ist sicher. */
    this.dynEquipmentCache = {};
    this.artPropByArtCache = {};
    this.equipmentArtNumbersOnPage = [];
 
}
 
ModuleStandard.prototype.setEquipmentCache = function () {
    var self = this;
    var sqlResult = FurnplanCommunicationService.GetDynEquipment(this.modManu, this.modProg, this.equipmentArtNumbersOnPage, this.manuCat);
    if (sqlResult && sqlResult.rows && sqlResult.rows.length > 0) {
        sqlResult.rows.forEach(function (row) {
            var key = "KEY" + row.ArtNr;
            if (!self.dynEquipmentCache.hasOwnProperty(key)) {
                self.dynEquipmentCache[key] = [];
            }
            self.dynEquipmentCache[key].push(row);
        })
    }
    
    this.artPropByArtCache = FurnplanCommunicationService.GetArtPropByArt(this.modManu, this.modProg, this.equipmentArtNumbersOnPage);    
}
 
ModuleStandard.prototype.getConstructionTypeListDistinctDimensionsFromArticles = function (articles) {
    var self = this;
    var constructionTypeList = {};
    articles.forEach(function (art) {
        if (art.contructionType !== "") {
            if (!constructionTypeList.hasOwnProperty(art.contructionType)) {
                constructionTypeList[art.contructionType] = {
                    Z: [art.zMax],
                    X: [art.xMax],
                    Y: [art.yMax]
                };
            } else {
                if (constructionTypeList[art.contructionType]["Z"].indexOf(art.zMax) === -1) {
                    constructionTypeList[art.contructionType]["Z"].push(art.zMax);
                }
                if (constructionTypeList[art.contructionType]["X"].indexOf(art.xMax) === -1) {
                    constructionTypeList[art.contructionType]["X"].push(art.xMax);
                }
                if (constructionTypeList[art.contructionType]["Y"].indexOf(art.yMax) === -1) {
                    constructionTypeList[art.contructionType]["Y"].push(art.yMax);
                }
            }
        }
    });
    return constructionTypeList;
};
 
ModuleStandard.prototype.build = function () {
    var self = this;
    var moduleElement = $("<div></div>");
    moduleElement.addClass("module");
    moduleElement.addClass("standard");
    moduleElement.addClass(this.id);
 
    self.constructionTypeListDistinctDimensions = this.getConstructionTypeListDistinctDimensionsFromArticles(self.articles);
 
    if (this.moduleFilterCategories.length > 0 && !this.cfg["hideCategorieFilter"]) {
        if (this.articles.length > 1) {
            moduleElement.append(this.buildCategories());
        }
    }
 
    if (!this.cfg["hideDimensionFilter"] && !self.defaultConfiguratorArt) {
        var filter = this.buildFilter();
        if (filter.children().length > 0) {
            moduleElement.append(filter);
        }
    }
 
    if (this.infoText.length > 0) {
        var infoTextContainer = $('<div class="infoText"></div>');
        infoTextContainer.html(this.infoText);
        moduleElement.append(infoTextContainer);
    }
 
    if (self.catConfigGlobal.length > 0) {
        var contextId = dh_manufacturer_get() + "#" + dh_programmname_get_current() + "#" + (++propContextIndex);
        AusfCenter.createHeader(this.cfg["ausfCenterShowBgButton"], undefined, undefined, moduleElement[0], contextId);
        ArticleListBuilder.getProgPropertiesContainer(self.catConfigGlobal, moduleElement, contextId);
        // for (i = 0; i < self.catConfigGlobal.length; i++) {
        //     var propProperty = self.catConfigGlobal[i];
        //     //Bisherige Logik
        //     //-------------------------------------
        //     // var propId = "dhIdent" + propProperty.attribute;
        //     // var prop   = window[propId] = new dhprop(propId, ypos, "", "", "", +propProperty.attribute, "", "");
        //     // prop.targetElement = moduleElement[0];
        //     // prop.dhpropgen(0);
        //
        //
        //     //Zukünftige Logik
        //     //-------------------------------------
        //     DhCreateProperty(propProperty.attribute, moduleElement[0]);
        // }
    }
 
    if (self.defaultConfiguratorArt) {
        var defautArtDummyList = [];
        defautArtDummyList.push(self.defaultConfiguratorArt);
        moduleElement.append(this.buildArticles(defautArtDummyList));
    } else if (this.articles.length > 0 || this.id === "mod_search") {
        moduleElement.append(this.buildArticles(this.articles));
    }
    $(window).on("forceFilter", function (event, modId, dataDimension, dataValue, dataGroupIdent) {
        console.log(modId + "\n" + dataDimension + "\n" + dataValue + "\n" + dataGroupIdent);
 
        if (modId !== self.id) {
            if (self.dimensionValueButton[dataDimension]) {
                self.dimensionValueButton[dataDimension].forEach(function (btn) {
                    if (btn.attr("data-value") === dataValue) {
                        btn.trigger("click", ["simulated"]);
                    }
                })
            }
        }
    });
 
    return moduleElement;
};
 
var prioLoaded = [];
ModuleStandard.prototype.buildCategories = function () {
    var self = this;
    var categoriesElement = $("<div></div>");
    categoriesElement.addClass("categories");
    categoriesElement.addClass(this.id);
    self.distinctPriorities.forEach(function (prio, index) {
 
        if (self.cfg["CategoriePriosToHide"].indexOf(prio) < 0) {
            self.categoryValueButton[prio] = [];
            var firstCat = true;
            var group = $("<div></div>");
            var groupIdent = getUniqueIdentifier();
            group.addClass("categoryPrioGroup");
            group.attr("data-priority", prio);
            self.moduleFilterCategories.forEach(function (category) {
                if (prio === category.priority) {
                    if (firstCat) {
                        group.append(getCategorieElement("*", "_", prio, true, groupIdent));
                    }
                    group.append(getCategorieElement(category.id, category.name, prio, false, groupIdent));
                    firstCat = false;
                }
            });
 
            group.addClass("spacer");
            categoriesElement.append(group);
 
            if (self.cfg["lastVisiblePrioWithoutActivation"] !== 0) {
                if (prio > self.cfg["lastVisiblePrioWithoutActivation"]) {
                    //Kategoriegruppe höher Grenzwert nicht anzeigen
                    group.hide();
                }
            }
        }
    });
 
    function getCategorieElement(value, text, prio, checked, groupIdent) {
        var btn = $("<div></div>");
        btn.addClass("categoryPrioControl");
        if (value === "*") {
            btn.addClass("wildCard");
        }
        btn.attr("data-priority", prio);
        btn.attr("data-value", value);
        btn.attr("data-groupIdent", groupIdent);
        btn.html(text);
        btn.on("click", function (event) {
            // Wenn Einstellungswert "lastVisiblePrioWithoutActivation" gesetzt, dann die nächst höhere Priorität anzeigen
            if (self.cfg["lastVisiblePrioWithoutActivation"] > 0) {
                //Wenn Index vorhanden, also wenn es eine höhere KategoriePrio gibt
                if (prioLoaded.indexOf(nextPrio) < 0) {
                    var clickedPrioIndex = self.distinctPriorities.indexOf(prio);
                    var nextPrio = self.distinctPriorities[clickedPrioIndex + 1];
                    if (nextPrio) {
                        $(".categories").find(".categoryPrioGroup").each(function (index) {
                            var group = $(this);
                            if (group.attr("data-priority") == nextPrio) {
                                //Kategoriegruppe anhand von Prio raussuchen und auf Visible setzen
                                group.show();
                            }
                        })
                    }
                    prioLoaded.push(nextPrio);
                }
            }
            self.preFilter(this);
        });
        // btn.on("dblclick", function () {
        //     self.filterReset(this);
        // });
        if (checked) {
            btn.addClass("checked");
        }
        self.categoryValueButton[prio].push(btn);
        return btn;
    }
 
    //Textselektion deaktivieren
    categoriesElement.on("selectstart", function () {
        return false;
    });
 
    var line = $("<hr>");
    line.addClass("last");
    categoriesElement.append(line);
 
    return categoriesElement;
};
 
ModuleStandard.prototype.buildFilter = function () {
    var self = this;
 
    var filterElement = $("<div></div>");
    filterElement.addClass("filter");
    filterElement.addClass(self.id);
 
    var appendLine = false;
    var first = true;
    self.dimensions.forEach(function (dimension) {
        if (dimension.show) {
            if (!first) {
                var line = $("<hr>");
                line.addClass("spacer");
                filterElement.append(line);
            }
            first = false;
 
            var dimValues = self.distinctDimensionValues(dimension.id, self.articles);
            self.dimensionValueButton[dimension.id] = [];
            var filterTop = $("<div></div>");
            var label = $("<div></div>");
            label.html(dimension.name);
            label.addClass("caption");
 
            var filter = $("<div></div>");
            filter.addClass(dimension.id);
            var groupIdent = getUniqueIdentifier();
            filterTop.append(getValueElement("*", dimension.id, true, false, groupIdent, "_"));
 
 
            filterTop.append(label);
 
            var valueCountLimit = self.cfg["valueCountLimit"];
            var valueGroupSize = self.cfg["valueGroupSize"];
            var valueGroupBtnHide = self.cfg["valueGroupBtnHide"];
 
            var groupItems = [];
            //Hier wird entschiende ob gruppiert werden soll
            var showGroupedButton = dimValues.length > valueCountLimit;
            //"dimvalues" ist ein Array das alle distinktiven Maße der Dimension enthält
            dimValues.forEach(function (value) {
                var numVal = +value.replace(",", ".");
                var group = (numVal - (numVal % valueGroupSize)) / valueGroupSize;
                if (groupItems.indexOf(group) === -1) {
                    groupItems.push(group);
                }
            });
 
            dimValues.forEach(function (value) {
                var dimmap = self.dimMapping.find(function (dm) {
                    return dm.dimValue === value && dm.dim === dimension.idShort && dm.cat === self.id.replace("mod", "dhcat");
                });
                if (dimmap) {
                    filter.append(getValueElement(value, dimension.id, false, true, groupIdent, dimmap.dimText, showGroupedButton));
                } else {
                    filter.append(getValueElement(value, dimension.id, false, true, groupIdent, value, showGroupedButton));
                }
            });
 
            if (showGroupedButton) {
                groupItems.forEach(function (groupItem) {
                    //"filterGroupBtn" ist die Schaltfläche die die einzelnen Maßfilter gruppiert, z.B. mit dem Text "0 - 100"
                    var filterGroupBtn = $("<div></div>");
                    filterGroupBtn.text(groupItem * valueGroupSize + "-" + (groupItem + 1) * valueGroupSize);
                    filterGroupBtn.addClass("dimensionValueControl");
                    filterGroupBtn.addClass("grouped");
                    //"dimensionValueButtonGrouped" hat für jede Dimension ein Property-Key, dessen Property-Value ein Array ist,
                    //welches die Gruppierungsbuttons der Dimension enthält
                    if (self.dimensionValueButtonGrouped[dimension.id] === undefined) {
                        //Objekt mit den Key für die Dimensionen versorgen
                        self.dimensionValueButtonGrouped[dimension.id] = [];
                    }
                    //"filterGroupBtn.dimValues"-Array wird gebraucht um die voreingestellte Filterung per "preSelectedFilter" zu realisieren   
                    filterGroupBtn.dimValues = [];
 
                    self.dimensionValueButton[dimension.id].forEach(function (btn) {
                        //Alle Button der Dimension durchlaufen und in Gruppen einsortieren
                        var btnValue = +btn.attr("data-value").replace(",", ".");
                        //filterGroupBtn.dimValues.push(btn.attr("data-value"));
                        if (btnValue >= (valueGroupSize * groupItem) && btnValue < (valueGroupSize * (groupItem + 1))) {
                            //"filterGroupBtn.dimValues" mit allen Dimensionswerten befüllen die diesem Gruppierungsbutton zugeordnet werden,
                            //siehe filterGroupBtn.on("click", function (event) {....} 
                            filterGroupBtn.dimValues.push(btn.attr("data-value"));
                        }
                    })
                    //Gruppierungsbutton für Verarbeitung in katapage.js("KataPage.prototype.build") befüllen
                    self.dimensionValueButtonGrouped[dimension.id].push(filterGroupBtn);
 
                    filterGroupBtn.on("click", function (event) {
                        filterGroupBtn.toggleClass("checked");
                        if (filterGroupBtn.hasClass("checked")) {
                            self.dimensionValueButton[dimension.id].forEach(function (btn) {
                                var btnValue = +btn.attr("data-value").replace(",", ".");
                                if (btnValue >= (valueGroupSize * groupItem) && btnValue < (valueGroupSize * (groupItem + 1))) {
                                    btn.show();
                                }
                            })
                        } else {
                            self.dimensionValueButton[dimension.id].forEach(function (btn) {
                                var btnValue = +btn.attr("data-value").replace(",", ".");
                                if (btnValue >= (valueGroupSize * groupItem) && btnValue < (valueGroupSize * (groupItem + 1))) {
                                    btn.hide();
                                }
                            })
                        }
                        if (valueGroupBtnHide) {
                            filterGroupBtn.hide();
                        }
                    });
                    filterTop.append(filterGroupBtn);
                });
            }
 
 
 
 
            filterElement.append(filterTop);
            filterElement.append(filter);
            appendLine = true;
        }
    });
 
    filterElement.on("selectstart", function () {
        return false;
    });
 
    if (appendLine) {
        var line = $("<hr>");
        line.addClass("last");
        filterElement.append(line);
    }
 
    return filterElement;
 
    function getValueElement(value, dimension, checked, linked, groupIdent, text, hidden) {
        var btn = $("<div></div>");
        btn.addClass("dimensionValueControl");
        if (value === "*") {
            btn.addClass("wildCard");
        } else if (value !== text) {
            //Dimensionstext vorhanden
            if (!self.cfg["singleRowDimText"]) {
                btn.addClass("dimText2rows");
            }
            if (self.cfg["threeRowDimText"]) {
                btn.removeClass("dimText2rows");
                btn.addClass("dimText3rows");
            }
        }
        btn.attr("data-dimension", dimension);
        btn.attr("data-value", value);
        btn.attr("data-groupIdent", groupIdent);
        btn.text(text);
        if (checked) {
            btn.addClass("checked");
        }
        btn.on("click", function (event, simulated) {
            self.preFilter(this);
            if (self.cfg["handleGlobalDimensionFilter"] === true && !simulated) {
                $(window).trigger("forceFilter", [self.id, dimension, value, groupIdent]);
            }
        });
        // btn.on("dblclick", function () {
        //     self.filterReset(this);
        // });
        self.dimensionValueButton[dimension].push(btn);
 
        if (hidden) {
            // btn.hide();
            btn.css("display", "none");
        }
        return btn;
    }
};
 
ModuleStandard.prototype.forceFilter = function (e) {
    this.preFilter($(e.currentTarget).data("value"), $(e.currentTarget).data("dimension"));
};
 
ModuleStandard.prototype.preFilter = function (clickEle) {
    var self = this;
    var clickedElement = $(clickEle);
 
    // Wird im Original IMMER zurückgesetzt -- auch bei Klicks auf disabled/Wildcard.
    $(".hiddenByHideDimValuesByCategories").removeClass("hiddenByHideDimValuesByCategories");
 
    // Deaktivierte Buttons ignorieren
    if (clickedElement.hasClass("disabled")) {
        return;
    }
 
    // --- Click-Metadaten einmalig auslesen ---
    var clickedValue = clickedElement.attr("data-value");
    var clickedGroupIdent = clickedElement.attr("data-groupIdent");
    var clickedDimension = clickedElement.attr("data-dimension");
    var clickedPriority = clickedElement.attr("data-priority");
    var clickedIsWildCard = clickedValue === "*";
    var clickedIsChecked = clickedElement.hasClass("checked");
    var hideHigherPrio = !!self.cfg["hideDisabledCategoriesInHigherPrio"];
 
    // Bereits aktive Wildcard erneut geklickt -> nichts zu tun
    if (clickedIsWildCard && clickedIsChecked) {
        return;
    }
 
    // --- Selektion in der Gruppe aktualisieren ---
    var groupContainer = clickedElement.parent().parent();
    var groupAttr = "[data-groupIdent='" + clickedGroupIdent + "']";
 
    if (clickedIsWildCard) {
        // Wildcard auswählen: alle Geschwister abwählen, Wildcard markieren
        groupContainer.find(".checked" + groupAttr).removeClass("checked");
        clickedElement.addClass("checked");
    } else {
        // Status togglen, Wildcard der Gruppe abwählen
        clickedElement.toggleClass("checked");
        groupContainer.find(".checked.wildCard" + groupAttr).removeClass("checked");
 
        // Wenn nach dem Klick nichts mehr in der Gruppe gewählt ist -> Wildcard aktivieren
        if (groupContainer.find(".checked" + groupAttr).length === 0) {
            groupContainer.find(".wildCard" + groupAttr).addClass("checked");
        }
    }
 
    // --- Selektierte Kategorien einsammeln ---
    var selectedCategories = {};
    var distinctCategoryList = {};
    var onlyCatWildCards = true;
 
    self.distinctPriorities.forEach(function (prio) {
        if (prio < 1000) return;
        selectedCategories[prio] = [];
        distinctCategoryList[prio] = [];
        var buttons = self.categoryValueButton[prio];
        if (!buttons) return;
        buttons.forEach(function (jEle) {
            if (jEle.attr("data-value") !== "*" && jEle.hasClass("checked")) {
                selectedCategories[prio].push(jEle.attr("data-value"));
                onlyCatWildCards = false;
            }
        });
    });
 
    // --- Selektierte Maße einsammeln ---
    var selectedValues = {};
    var distinctValueList = { xMax: [], yMax: [], zMax: [] };
 
    Object.keys(self.dimensionValueButton).forEach(function (key) {
        selectedValues[key] = [];
        self.dimensionValueButton[key].forEach(function (jEle) {
            if (jEle.hasClass("checked") && jEle.attr("data-value") !== "*") {
                selectedValues[jEle.attr("data-dimension")].push(jEle.attr("data-value"));
            }
        });
    });
 
    // --- Anzahl gefüllter Filtergruppen + Merken der letzten Gruppe ---
    var selectedGroupCount = 0;
    var selectedGroup = { Prio: "", Dim: "" };
 
    Object.keys(selectedCategories).forEach(function (prio) {
        if (selectedCategories[prio].length > 0) {
            selectedGroupCount += 1;
            selectedGroup.Prio = prio;
        }
    });
    Object.keys(selectedValues).forEach(function (dimension) {
        if (selectedValues[dimension].length > 0) {
            selectedGroupCount += 1;
            selectedGroup.Dim = dimension;
        }
    });
 
    var selectedValueKeys = Object.keys(selectedValues);
    var distinctValueKeys = Object.keys(distinctValueList);
 
    // --- Artikelliste filtern und distinkte Maße/Kategorien aufbauen ---
    self.filteredArticles = self.articles.filter(function (art) {
        // Maße prüfen
        for (var d = 0; d < selectedValueKeys.length; d++) {
            var dim = selectedValueKeys[d];
            if (selectedValues[dim].length > 0 && selectedValues[dim].indexOf(art[dim]) === -1) {
                return false;
            }
        }
 
        // Kategorien prüfen: mindestens ein Treffer in einer der gewählten Prioritäten
        if (!onlyCatWildCards) {
            var matched = false;
            for (var c = 0; c < art.artCategories.length; c++) {
                var cat = art.artCategories[c];
                var sel = selectedCategories[cat.priority];
                if (sel && sel.length > 0 && sel.indexOf(cat.id) > -1) {
                    matched = true;
                    break;
                }
            }
            if (!matched) {
                return false;
            }
        }
 
        // Distinkte Maßlisten aufbauen
        distinctValueKeys.forEach(function (dimension) {
            if (distinctValueList[dimension].indexOf(art[dimension]) === -1) {
                distinctValueList[dimension].push(art[dimension]);
            }
        });
 
        // Distinkte Kategorielisten aufbauen
        art.artCategories.forEach(function (cat) {
            if (cat.priority >= 1000 && distinctCategoryList[cat.priority] && distinctCategoryList[cat.priority].indexOf(cat.id) === -1) {
                distinctCategoryList[cat.priority].push(cat.id);
            }
        });
        return true;
    });
 
    // --- Maß-Buttons disable-/enable-Zustand aktualisieren ---
    var dimensionShouldDisable = function (jEle) {
        return distinctValueList[jEle.attr("data-dimension")].indexOf(jEle.attr("data-value")) === -1;
    };
 
    Object.keys(self.dimensionValueButton).forEach(function (key) {
        self.dimensionValueButton[key].forEach(function (jEle) {
            if (jEle.attr("data-value") === "*") return;
            if (clickedDimension) {
                // Auf der geklickten Achse nur deaktivierte Buttons anfassen,
                // auf den anderen Achsen nur nicht-gecheckte.
                var actOnThis = (key === clickedDimension)
                    ? jEle.hasClass("disabled")
                    : !jEle.hasClass("checked");
                if (!actOnThis) return;
            }
            jEle.toggleClass("disabled", dimensionShouldDisable(jEle));
        });
    });
 
    // --- Kategorie-Buttons disable-/enable-Zustand aktualisieren ---
    Object.keys(self.categoryValueButton).forEach(function (prio) {
        var buttons = self.categoryValueButton[prio];
        if (!buttons) return;
 
        var prioHidesHigher = hideHigherPrio && (prio > clickedPriority);
 
        buttons.forEach(function (jEle) {
            if (jEle.attr("data-value") === "*") return;
 
            // Auf der geklickten Priorität wurde original *nichts* getan (siehe alter Code).
            if (clickedPriority && prio === clickedPriority) return;
 
            // Auf anderen Prioritäten nur die nicht-gecheckten Buttons anfassen
            if (clickedPriority && jEle.hasClass("checked")) return;
 
            var shouldDisable = distinctCategoryList[prio].indexOf(jEle.attr("data-value")) === -1;
            jEle.toggleClass("disabled", shouldDisable);
 
            if (prioHidesHigher) {
                if (shouldDisable) jEle.hide();
                else jEle.show();
            } else if (!clickedPriority && hideHigherPrio && shouldDisable) {
                // Fallback ohne Click-Priorität: deaktivierte Buttons ausblenden
                jEle.hide();
            }
        });
    });
 
    // --- hideDimValuesByCategories: Maße ausblenden, deren Kategorie-Set passt ---
    if (self.cfg["hideDimValuesByCategories"].length > 0) {
        var flatCats = [];
        Object.keys(selectedCategories).forEach(function (prio) {
            flatCats = flatCats.concat(selectedCategories[prio]);
        });
 
        self.cfg["hideDimValuesByCategories"].forEach(function (obj) {
            if (!isStrArrayEqual(flatCats, obj.categories)) return;
            Object.keys(self.dimensionValueButton).forEach(function (key) {
                var rule = obj.values[key];
                if (!rule) return;
                self.dimensionValueButton[key].forEach(function (jEle) {
                    if (rule.indexOf(jEle.attr("data-value")) > -1) {
                        jEle.addClass("hiddenByHideDimValuesByCategories");
                    }
                });
            });
        });
    }
 
    // --- Bei genau einer aktiven Filtergruppe alles in dieser Gruppe aktivieren ---
    if (selectedGroupCount === 1) {
        if (selectedGroup.Dim !== "") {
            self.dimensionValueButton[selectedGroup.Dim].forEach(function (jEle) {
                jEle.removeClass("disabled");
            });
        }
        if (selectedGroup.Prio !== "") {
            var showHigher = hideHigherPrio && (selectedGroup.Prio > clickedPriority);
            self.categoryValueButton[selectedGroup.Prio].forEach(function (jEle) {
                jEle.removeClass("disabled");
                if (showHigher) jEle.show();
            });
        }
    }
 
    // --- Wildcard ausblenden, wenn in der Prio-Ebene keine echten Buttons mehr sichtbar sind ---
    if (hideHigherPrio) {
        Object.keys(self.categoryValueButton).forEach(function (prio) {
            var buttons = self.categoryValueButton[prio];
            if (!buttons) return;
 
            var hiddenNonWild = 0;
            var wildcardBtn = null;
            buttons.forEach(function (jEle) {
                if (jEle.attr("data-value") === "*") {
                    wildcardBtn = jEle;
                } else if (jEle.css("display") === "none") {
                    hiddenNonWild += 1;
                }
            });
 
            if (!wildcardBtn) return;
            if (hiddenNonWild === buttons.length - 1) {
                wildcardBtn.hide();
            } else {
                wildcardBtn.show();
            }
        });
    }
 
    // --- Artikel in "alle Kategorien getroffen" / "nur einige getroffen" sortieren ---
    var flatSelectedCategories = [];
    Object.keys(selectedCategories).forEach(function (prio) {
        flatSelectedCategories = flatSelectedCategories.concat(selectedCategories[prio]);
    });
 
    var filterArticlesAllCats = [];
    var filterArticlesSomeCats = [];
 
    self.filteredArticles.forEach(function (art) {
        art.isCategorySpacer = false;
        var hasAll = flatSelectedCategories.every(function (selectedCat) {
            return !!art.artCategories.find(function (cat) {
                return cat.id === selectedCat;
            });
        });
        if (hasAll) {
            filterArticlesAllCats.push(art);
        } else {
            filterArticlesSomeCats.push(art);
        }
    });
 
    // Spacer vor dem ersten "nur teilweise getroffenen" Artikel setzen
    if (filterArticlesSomeCats.length > 0) {
        filterArticlesSomeCats[0].isCategorySpacer = true;
    }
 
    var newAllArticles = filterArticlesAllCats.concat(filterArticlesSomeCats);
 
    var artContainer = $("." + self.id + ".articles");
    artContainer.empty();
 
    self.constructionTypeListDistinctDimensions = self.getConstructionTypeListDistinctDimensionsFromArticles(newAllArticles);
 
    artContainer.append(self.buildArticles(newAllArticles));
};
 
ModuleStandard.prototype.showDimension = function (dimension, articles) {
    return this.distinctDimensionValues(dimension, articles).length > 1;
};
 
ModuleStandard.prototype.distinctDimensionValues = function (dimension, articles) {
    var ret = [];
    articles.forEach(function (article) {
        var val = article[dimension + "Raw"];
        if (ret.indexOf(val) < 0) ret.push(val);
    });
    ret.sort(function (a, b) {
        return a - b;
    });
    return ret.map(function (value) {
        return (value / 10).toFixed(1).replace(".", ",");
    });
};
 
ModuleStandard.prototype.addScrollContent = function () {
    if (this.articlesToShow.length - 1 >= this.currentScrollIndex) {
        $("." + this.id + ".articleList").append(ArticleListBuilder.buildArticle(this.cfg, this.articlesToShow[this.currentScrollIndex], this.dimensions));
    }
    this.currentScrollIndex++;
};
 
ModuleStandard.prototype.buildArticles = function (filteredArticles) {
    var self = this;
    var articleListContainer = $("<div></div>");
    articleListContainer.addClass("articles");
    articleListContainer.addClass(this.id);
 
    var progLogoContainer = $('<div class="logoContainer"></div>');
    var progLogoImg = $("<img/>");
    progLogoImg.attr("src", "../../../../../" + currentManu + "/" + currentProg + "/html/kata-images/" + currentProg + ".png");
    progLogoContainer.append(progLogoImg);
    articleListContainer.append(progLogoContainer);
 
    progLogoImg.on("error", function () {
        $(".logoContainer").hide();
    });
 
    var articleCountText = dh_text_global("fv.generickatatree.articles") + " (" + filteredArticles.length + ")";
    if (self.cfg["articleView"] === "horizontal") {
        self.dimensions.forEach(function (dimension) {
            if (!dimension.show) {
                articleCountText += " " + dimension.label + ":" + filteredArticles[0][dimension.property];
            }
        });
    }
 
    var labelContainer = $('<span class="artInfoContainer"></span>');
 
    var label1 = $('<span class="artInfoContainerItem"></span>');
    label1.text(dh_text_global("fv.generickatatree.articles"));
 
    var label2 = $('<span class="artInfoContainerItem"></span>');
    label2.text(" (");
 
    var label3 = $('<span class="artInfoContainerItem"></span>');
    label3.text(filteredArticles.length);
 
    var label4 = $('<span class="artInfoContainerItem"></span>');
    label4.text(")");
 
    var label5 = $('<span class="artInfoContainerItem"></span>');
    var label5img = $("<img/>").attr("src", "../../h/generic-katatree/img/openerShowRoom.png");
    label5.append(label5img);
    label5.addClass("openerShowRoom");
    label5.on("click", function () {
        var dialog = new CDialog();
        dialog.showGenericArticleView(ArticleListBuilder.buildShowRoom(filteredArticles, self.titel, self.cfg, self.dimensions));
    });
 
    var label6 = $('<span class="artInfoContainerItem"></span>');
    var label6img = $("<img/>");
    label6img.attr("src", "../../../../../" + currentManu + "/_global/images/pdfInfo.png");
 
    // JM [2026|05|05] Im HTML5 fuehrt dies offenbar mit jedem set src zu erneutem error, wenn "../../h/generic-katatree/img/pdfInfo.png" nicht existiert.
    function label6imgErrHandler() {
        label6img.attr("src", "../../h/generic-katatree/img/pdfInfo.png");
        label6img.off("error", label6imgErrHandler);
    }
    label6img.on("error", label6imgErrHandler);
    label6.on("click", function () {
        ShowPdf(getCurrentManu(), "1882", "app", "_global/pdf", self.pdfFile, 0);
    });
    label6.addClass("openerInfo");
    label6.append(label6img);
 
    labelContainer.append(label1);
    labelContainer.append(label2);
    labelContainer.append(label3);
    labelContainer.append(label4);
    labelContainer.append(label5);
    if (self.pdfFile !== undefined) {
        labelContainer.append(label6);
    }
 
    articleListContainer.append(labelContainer);
 
    var label = $("<div></div>");
    label.addClass("articleCount");
    label.addClass(this.id);
    label.text(articleCountText);
 
 
    var openerShowRoom = $("<div></div>");
    openerShowRoom.addClass("openerShowRoom");
 
 
    if (self.cfg["hideArticleCount"]) {
        labelContainer.hide();
    }
 
    var articleList = $("<div></div>");
    articleList.addClass("articleList");
    // articleList.addClass(self.cfg["articleView"]);
 
    articleList.addClass(this.id);
 
    if (filteredArticles.length === 0) {
        dh_text_global("fv.generickatatree.nothingFound");
    }
    var modHasProgProperties = false;
    if (self.catConfigGlobal.length > 0) {
        modHasProgProperties = true;
    }
    //Endless scroll nur wenn es keine Konstruktionstypen gibt
    if (this.endLessScroll && Object.keys(self.constructionTypeListDistinctDimensions).length === 0) {
        this.currentScrollIndex = 20;
        this.articlesToShow = filteredArticles;
        filteredArticles.slice(0, this.currentScrollIndex).forEach(function (article) {
            articleList.append(ArticleListBuilder.buildArticle(self.cfg, article, self.dimensions));
            if (article.progProperties && article.progProperties.length > 0) {
                modHasProgProperties = true;
            }
        });
    } else {
        //Durchlauf erst alle Artikel und exkludiere die Artikel die keinen Konstruktiuonstyp habe in seperates Array
        var filteredArticlesWithCTyp = {};
        var filteredArticlesWithoutCTyp = [];
        filteredArticles.forEach(function (article) {
            if (article.progProperties && article.progProperties.length > 0) {
                modHasProgProperties = true;
            }
            if (article.contructionType !== "") {
                if (!filteredArticlesWithCTyp.hasOwnProperty(article.contructionType)) {
                    filteredArticlesWithCTyp[article.contructionType] = [{
                        z: article.zMax,
                        x: article.xMax,
                        y: article.yMax,
                        art: article,
                        isFirst: true
                    }]
                } else {
                    filteredArticlesWithCTyp[article.contructionType].push({
                        z: article.zMax,
                        x: article.xMax,
                        y: article.yMax,
                        art: article,
                        isFirst: false
                    });
                }
            } else {
                filteredArticlesWithoutCTyp.push(article);
            }
        });
 
        Object.keys(filteredArticlesWithCTyp).forEach(function (ctyp) {
            var container = $('<div class="ctypArticle"></div>');
            var artContainer = $('<div></div>');
            var constructionTypContainer = $('<div class="constructionTypContainer" style="display: none;" id="ctyp_' + ctyp + '"></div>');
            if (self.constructionTypeListDistinctDimensions[ctyp].Z.length > 1) {
                var constructionTypContainerZ = $('<div><span class="ctypDimLabel">Höhe:</span></div>');
                self.constructionTypeListDistinctDimensions[ctyp].Z.forEach(function (value) {
                    var btn = $("<div></div>");
                    btn.addClass("cTypControl");
                    if (value === "*") {
                        btn.addClass("wildCard");
                    }
                    btn.attr("data-value", value);
                    btn.attr("data-dimension", "z");
                    btn.attr("data-ctyp", ctyp);
                    btn.text(value);
                    btn.click(function () {
                        self.switchCTypArticle(constructionTypContainer, constructionTypContainerZ, btn, filteredArticlesWithCTyp[ctyp], artContainer)
                    });
                    constructionTypContainerZ.append(btn);
                })
                constructionTypContainer.append(constructionTypContainerZ);
            }
            if (self.constructionTypeListDistinctDimensions[ctyp].X.length > 1) {
                var constructionTypContainerX = $('<div><span class="ctypDimLabel">Breite:</span></div>');
                self.constructionTypeListDistinctDimensions[ctyp].X.forEach(function (value) {
                    var btn = $("<div></div>");
                    btn.addClass("cTypControl");
                    if (value === "*") {
                        btn.addClass("wildCard");
                    }
                    btn.attr("data-value", value);
                    btn.attr("data-dimension", "x");
                    btn.attr("data-ctyp", ctyp);
                    btn.text(value);
                    btn.click(function () {
                        self.switchCTypArticle(constructionTypContainer, constructionTypContainerX, btn, filteredArticlesWithCTyp[ctyp], artContainer)
                    });
                    constructionTypContainerX.append(btn);
                })
                constructionTypContainer.append(constructionTypContainerX);
            }
            if (self.constructionTypeListDistinctDimensions[ctyp].Y.length > 1) {
                var constructionTypContainerY = $('<div><span class="ctypDimLabel">Tiefe:</span></div>');
                self.constructionTypeListDistinctDimensions[ctyp].Y.forEach(function (value) {
                    var btn = $("<div></div>");
                    btn.addClass("cTypControl");
                    if (value === "*") {
                        btn.addClass("wildCard");
                    }
                    btn.attr("data-value", value);
                    btn.attr("data-dimension", "y");
                    btn.attr("data-ctyp", ctyp);
                    btn.text(value);
                    btn.click(function () {
                        self.switchCTypArticle(constructionTypContainer, constructionTypContainerY, btn, filteredArticlesWithCTyp[ctyp], artContainer)
                    });
                    constructionTypContainerY.append(btn);
                })
                constructionTypContainer.append(constructionTypContainerY);
            }
            container.append(constructionTypContainer);
            filteredArticlesWithCTyp[ctyp].forEach(function (artItem) {
                if (artItem.isFirst) {
                    artContainer.append(ArticleListBuilder.buildArticle(self.cfg, artItem.art, self.dimensions));
                    constructionTypContainer.find('[data-dimension="z"][data-value="' + artItem.art.zMax + '"]').addClass("checked");
                    constructionTypContainer.find('[data-dimension="y"][data-value="' + artItem.art.yMax + '"]').addClass("checked");
                    constructionTypContainer.find('[data-dimension="x"][data-value="' + artItem.art.xMax + '"]').addClass("checked");
                }
            });
            container.append(artContainer);
            articleList.append(container);
        });
 
        //Rendere bzw füge unten alle Artikel ohne Konstruktionstyp
        filteredArticlesWithoutCTyp.forEach(function (article) {
            articleList.append(ArticleListBuilder.buildArticle(self.cfg, article, self.dimensions));
        });
    }
 
 
    articleListContainer.append(articleList);
 
    return articleListContainer;
};
 
ModuleStandard.prototype.switchCTypArticle = function (ctypContainer, buttonContainer, clickedButton, ctypArtItems, articleContainer) {
    var self = this;
    buttonContainer.children().removeClass("checked");
    clickedButton.addClass("checked");
 
    var selectedX = ctypContainer.find('.checked[data-dimension="x"]').attr("data-value");
    var selectedY = ctypContainer.find('.checked[data-dimension="y"]').attr("data-value");
    var selectedZ = ctypContainer.find('.checked[data-dimension="z"]').attr("data-value");
 
 
    articleContainer.empty();
 
    ctypArtItems.forEach(function (artItem) {
        var add = true;
        if (selectedX) {
            if (artItem.art.xMax !== selectedX) {
                add = false;
            }
        }
        if (selectedY) {
            if (artItem.art.yMax !== selectedY) {
                add = false;
            }
        }
        if (selectedZ) {
            if (artItem.art.zMax !== selectedZ) {
                add = false;
            }
        }
        if (add) {
            articleContainer.append(ArticleListBuilder.buildArticle(self.cfg, artItem.art, self.dimensions));
        }
    })
 
 
};
 
ModuleStandard.prototype.openArtProp = function () {
    $("." + this.id + " .toggleArtProps").trigger("click");
};
 
ModuleStandard.prototype.openArtProgProperties = function () {
    $("." + this.id + " .toggleProgProperties").trigger("click");
};