aboutsummaryrefslogtreecommitdiffstats
path: root/lib/util.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-08-05 07:09:15 -0400
committerMatěj Cepl <mcepl@redhat.com>2010-08-05 08:54:13 -0400
commit70c60b518c8017156c452d8ce689c791b17a8b77 (patch)
treead8967da325e7ee4bd0da3986daeb43dbf755c85 /lib/util.js
parent2aabaeb3efb7419f400f639ab75a98a48bf1fd81 (diff)
downloadbugzilla-triage-70c60b518c8017156c452d8ce689c791b17a8b77.tar.gz
Remove elements based on the configuration JSON file (configData.killNodes
object).
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index 0ab44ce..54af598 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -175,6 +175,30 @@ var filterByRegexp = exports.filterByRegexp =
}
};
+/**
+ * remove elements from the page based on their IDs
+ *
+ * @param doc Document object
+ * @param target String/Array with ID(s)
+ * @param remove Boolean indicating whether the node should be
+ * actually removed or just hidden.
+ * @return none
+ * TODO remove parameter could be replaced by function which would
+ * do actual activity.
+ */
+exports.killNodes = function killNodes(doc, target, remove) {
+ target = target.trim();
+ var targetArr = target instanceof Array ? target : target.split(/,\s*/);
+ targetArr.forEach(function(x) {
+ if (remove) {
+ var targetNode = doc.getElementById(x);
+ targetNode.parentNode.removeChild(targetNode);
+ } else {
+ x.style.display = "none";
+ }
+ });
+};
+
exports.getObjectKeys = function getObjectKeys(obj) {
var keys = [];
for (var key in obj) {