r7131: support sub-object arrays when displaying objects. This allows the ldb test to
authorAndrew Tridgell <tridge@samba.org>
Tue, 31 May 2005 02:24:50 +0000 (02:24 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:20 +0000 (13:17 -0500)
correctly display multi-value attributes like objectClass
(This used to be commit 134f42655ed2e5e13dee25921b8cd4e1ca9a1396)

swat/scripting/common.js

index 13ed343..8df419b 100644 (file)
@@ -82,12 +82,32 @@ function simple_menu() {
 
 
 /*
-  display a ejs object as a table
+  display a table element
+*/
+function table_element(i, o) {
+       write("<tr><td>" + i + "</td><td>");
+       if (typeof(o[i]) == "object") {
+               var first;
+               first = true;
+               for (j in o[i]) {
+                       if (first == false) {
+                               write("<br />");
+                       }
+                       write(o[i][j]);
+                       first = false;
+               }
+       } else {
+               write(o[i]);
+       }
+       write("</td></tr>\n");
+}
+/*
+  display a ejs object as a table. The header is optional
 */
 function simple_table(v) {
        write("<table class=\"data\">\n");
        for (r in v) {
-               write("<tr><td>" + r + "</td><td>" + v[r] + "</td></tr>\n");
+               table_element(r, v);
        }
        write("</table>\n");
 }
@@ -103,8 +123,7 @@ function multi_table(array, header) {
                write("<tr><th colspan=2>" + v[header] + "</th></tr>\n");
                for (r in v) {
                        if (r != header) {
-                               write("<tr><td align=left>" + r + 
-                                     "</td><td align=left>" + v[r] + "</td></tr>\n");
+                           table_element(r, v);
                        }
                }
        }