From 7611e826aa2be305e2bfcc22361deb4d03d76c8d Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 18 Mar 2019 00:12:51 +0100 Subject: History redesign --- js/Utils.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'js') diff --git a/js/Utils.js b/js/Utils.js index f02303c5..ec3a6851 100644 --- a/js/Utils.js +++ b/js/Utils.js @@ -125,4 +125,31 @@ function isUpperLock(shift, letter){ else return true; } + +function qmlEach(item, properties, ignoredObjectNames, arr){ + // Traverse QML object tree and return components that match + // via property names. Similar to jQuery("myclass").each(... + // item: root QML object + // properties: list of strings + // ignoredObjectNames: list of strings + if(typeof(arr) == 'undefined') arr = []; + if(item.hasOwnProperty('data') && item['data'].length > 0){ + for(var i = 0; i < item['data'].length; i += 1){ + arr = qmlEach(item['data'][i], properties, ignoredObjectNames, arr); + } + } + + // ignore QML objects on .objectName + for(var a = 0; a < ignoredObjectNames.length; a += 1){ + if(item.objectName === ignoredObjectNames[a]){ + return arr; + } + } + + for(var u = 0; u < properties.length; u += 1){ + if(item.hasOwnProperty(properties[u])) arr.push(item); + else break; + } + + return arr; } -- cgit v1.2.3