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
var ArticleType = {
    NORMAL   : 1,
    ACCESS   : 2,
    EQUIPMENT: 3
};
 
function setCurrentManu(manu) {
    dh_manufacturer_to_app(manu);
}
 
function getCurrentManu() {
    return currentManu;
}
 
function getManuPath() {
    return currentPath;
}
 
function getCurrentManuPath() {
    return currentPath + "/" + getCurrentManu();
}
 
function setCurrentProg(prog) {
    dh_programmname_to_app(prog);
}
 
function getCurrentProg() {
    return currentProg;
}
 
function getUniqueIdentifier() {
    return Math.random().toString().split('.')[1];
}
 
function isStrArrayEqual(arr1, arr2) {
    if (arr1.length !== arr2.length) {
        return false;
    }
    var count = {};
    var key;
    var i;
    for (i = 0; i < arr1.length; i++) {
        key = "k_" + arr1[i];
        count[key] = (count[key] || 0) + 1;
    }
    for (i = 0; i < arr2.length; i++) {
        key = "k_" + arr2[i];
        if (!count[key]) {
            return false;
        }
        count[key]--;
    }
    return true;
}
 
function conLog(heading, data) {
    if (dh_reginfo_get('HKCU', '', 'GenKataTreeDebug') == "True") {
        console.log("######################## " + heading.toUpperCase() + " ########################################");
        console.log("----------------------------------------------------------------");
        console.log(data);
        console.log("----------------------------------------------------------------");
    }
}
 
/**
 * Baut (memoisiert) eine Lookup-Map "Schluesselwert -> erstes passendes Element"
 * fuer ein Array auf. Damit lassen sich wiederholte lineare Array.find()-Scans
 * (jeweils O(n)) durch O(1)-Zugriffe ersetzen -- entscheidend, wenn die gleiche
 * Liste fuer sehr viele Artikel durchsucht wird (sonst O(Artikel * Listengroesse)).
 *
 * Die fertige Map wird am Array-Objekt zwischengespeichert (Property
 * "__kataIdx_<prop>") und automatisch verworfen, sobald das Array neu zugewiesen
 * wird (z.B. bei Hersteller-/Sprachwechsel oder neuem KataPage-Aufbau), da das
 * neue Array-Objekt diese Property nicht besitzt.
 *
 * Schluessel werden mit "$" praefixiert, um Kollisionen mit Eigenschaften des
 * Object-Prototyps (z.B. "constructor", "toString") auszuschliessen.
 *
 * IE7-kompatibel: nur for-Schleife und einfache Property-Zugriffe.
 *
 * @param {Array}  arr   Quell-Array (darf null/undefined/leer sein)
 * @param {string} prop  Eigenschaft, nach der indiziert wird
 * @returns {Object}     Map ("$"+Wert -> Element); erstes Vorkommen gewinnt (wie find())
 */
function buildIndexMap(arr, prop) {
    if (!arr) {
        return {};
    }
    var cacheKey = "__kataIdx_" + prop;
    var idx = arr[cacheKey];
    if (idx) {
        return idx;
    }
    idx = {};
    for (var i = 0; i < arr.length; i++) {
        var item = arr[i];
        if (item) {
            var k = "$" + item[prop];
            if (idx[k] === undefined) {
                idx[k] = item; // erstes Vorkommen behalten -> identisch zu Array.find()
            }
        }
    }
    arr[cacheKey] = idx;
    return idx;
}
genKataTreeTimeLine = [];
startDate = Date.now();
 
function timeline(date, text){
    genKataTreeTimeLine.push({date: date - startDate, text: text});
}