blob: 1f1a629924476646cfa81c3858e690e132e7c5ca (
plain)
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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
.pragma library
function findChildByProperty(parent, propertyName, propertyValue, compareCb) {
var obj = null
if (parent === null)
return null
var children = parent.children
for (obj of children) {
if (obj.hasOwnProperty(propertyName)) {
if (compareCb !== null) {
if (compareCb(obj[propertyName], propertyValue))
break
} else if (obj[propertyName] === propertyValue) {
break
}
}
obj = findChildByProperty(obj, propertyName, propertyValue, compareCb)
if (obj)
break
}
return obj
}
function findChild(parent, param, matchCb) {
var obj = null
if (parent === null)
return null
var children = parent.children
for (obj of children) {
if (matchCb(obj, param))
break
obj = findChild(obj, param, matchCb)
if (obj)
break
}
return obj
}
function toUnicodeHex(str) {
var result = ''
for (var i = 0; i < str.length; i++) {
if (result.length > 0)
result += ", "
result += "U+" + ("000" + str.charCodeAt(i).toString(16)).slice(-4)
}
return result
}
|