Module: check_mk
Branch: master
Commit: 6d91d0058e39e4c01c2c9d10a0997830d8e6cf06
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6d91d0058e39e4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 10 14:03:31 2012 +0200
FIX: Fixed editing of ListOf in valuespec editors (e.g. used in logwatch pattern editor)
---
ChangeLog | 2 ++
web/htdocs/js/checkmk.js | 38 +++++++++++++++++++++++++-------------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 176376f..dbee015 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@
on hosts with more than 500 services.
* FIX: make config options directly active after resetting them
to their defaults (didn't work for start_url, etc.
+ * FIX: Fixed editing of ListOf in valuespec editors (e.g. used in logwatch
+ pattern editor)
Multisite:
* FIX: fixed filter of recent event views (4 hours didn't catch)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 5f66f93..6cc7ca7 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1490,17 +1490,20 @@ function valuespec_listof_add(varprefix, magic) {
var htmlcode = oPrototype.innerHTML;
htmlcode = replace_all(htmlcode, magic, strcount);
var oTable = document.getElementById(varprefix + "_table");
- if (count == 0) { // first: no <tbody> present!
- oTable.innerHTML = "<tbody><tr>" + htmlcode +
"</tr></tbody>";
- valuespec_listof_fixarrows(oTable.childNodes[0]);
- }
- else {
- var oTbody = oTable.childNodes[0];
- var oTr = document.createElement("tr")
- oTr.innerHTML = htmlcode;
- oTbody.appendChild(oTr);
- valuespec_listof_fixarrows(oTbody);
+
+ var oTbody = oTable.childNodes[0];
+ if(oTbody == undefined) { // no row -> no <tbody> present!
+ oTbody = document.createElement('tbody');
+ oTable.appendChild(oTbody);
}
+
+ // Hack for IE. innerHTML does not work on tbody/tr correctly.
+ var container = document.createElement('div');
+ container.innerHTML = '<table><tbody><tr>' + htmlcode +
'</tr></tbody></tr>';
+ var oTr = container.childNodes[0].childNodes[0].childNodes[0] // TR
+ oTbody.appendChild(oTr);
+
+ valuespec_listof_fixarrows(oTbody);
}
// When deleting we do not fix up indices but simply
@@ -1522,6 +1525,7 @@ function valuespec_listof_delete(oA, varprefix, nr) {
function valuespec_listof_move(oA, varprefix, nr, where) {
var oTr = oA.parentNode.parentNode; // TR to move
var oTbody = oTr.parentNode;
+ var oTable = oTbody.parentNode;
if (where == "up") {
var sib = oTr.previousSibling;
@@ -1541,8 +1545,16 @@ function valuespec_listof_move(oA, varprefix, nr, where) {
function valuespec_listof_fixarrows(oTbody) {
- for (var i in oTbody.childNodes) {
- var oTd = oTbody.childNodes[i].childNodes[0]; /* TD with buttons */
+ if(!oTbody || typeof(oTbody.rows) == undefined) {
+ return;
+ }
+
+ for(var i = 0, row; row = oTbody.rows[i]; i++) {
+ if(row.cells.length == 0)
+ continue;
+ var oTd = row.cells[0]; /* TD with buttons */
+ if(row.cells[0].childNodes.length == 0)
+ continue;
var oIndex = oTd.childNodes[0];
oIndex.value = "" + (parseInt(i) + 1);
if (oTd.childNodes.length > 4) { /* movable */
@@ -1558,7 +1570,7 @@ function valuespec_listof_fixarrows(oTbody) {
}
var oDownTrans = oTd.childNodes[4];
var oDown = oTd.childNodes[5];
- if (i >= oTbody.childNodes.length - 1) {
+ if (i >= oTbody.rows.length - 1) {
oDownTrans.style.display = "";
oDown.style.display = "none";
}