summaryrefslogtreecommitdiff
path: root/swat/scripting
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-31 02:57:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:20 -0500
commit580b5bb8ef24f950581545425b4fee23a6e1c6ab (patch)
tree27556d261de98263b6e585acd008e14662afa311 /swat/scripting
parentb8b680f3aaa84d61d3ac008cf7a121c29f9edddb (diff)
downloadsamba-580b5bb8ef24f950581545425b4fee23a6e1c6ab.tar.gz
samba-580b5bb8ef24f950581545425b4fee23a6e1c6ab.tar.bz2
samba-580b5bb8ef24f950581545425b4fee23a6e1c6ab.zip
r7132: - start a convention of making object constructors end in Obj, so we
now have FormObj(). This follows the style in the ejs manual - make a new MenuObj object type, with a display_menu() to display it. This will make it easier to make different types of menus. Currently only veritical simple menus are supported. (This used to be commit ac978d4124f773d872dd15205d90a41dcec8a38f)
Diffstat (limited to 'swat/scripting')
-rw-r--r--swat/scripting/common.js44
1 files changed, 36 insertions, 8 deletions
diff --git a/swat/scripting/common.js b/swat/scripting/common.js
index 8df419bc60..d087f0d2a6 100644
--- a/swat/scripting/common.js
+++ b/swat/scripting/common.js
@@ -69,17 +69,45 @@ function always_allowed(uri) {
}
/*
- display a simple menu. First argument is menu title, followed by
- pairs of menu item name and link
+ create a menu object with the defaults filled in, ready for display_menu()
+ */
+function MenuObj(name, num_elements)
+{
+ var o = new Object();
+ o.name = name;
+ o.class = "menu";
+ o.style = "simple";
+ o.orientation = "vertical"
+ o.element = new Array(num_elements);
+ for (i in o.element) {
+ o.element[i] = new Object();
+ }
+ return o;
+}
+
+/*
+ display a menu object. Currently only the "simple", "vertical" menu style
+ is supported
*/
-function simple_menu() {
- write("<i>" + arguments[0] + "</i><br /><ul>\n");
- for (i = 1; i < arguments.length; i = i + 2) {
- write("<li><a href=\"" + arguments[i+1] + "\">" + arguments[i] + "</a></li>\n");
+function display_menu(m) {
+ assert(m.style == "simple" && m.orientation == "vertical");
+ write('<div class="' + m.class + '">\n');
+ write("<i>" + m.name + "</i><br /><ul>\n");
+ for (i = 0; i < m.element.length; i++) {
+ var e = m.element[i];
+ write("<li><a href=\"" + e.link + "\">" + e.label + "</a></li>\n");
}
- write("</ul>\n");
+ write("</ul></div>\n");
}
+function simple_menu() {
+ var m = MenuObj(arguments[0], (arguments.length-1)/2);
+ for (i=0;i<m.element.length;i++) {
+ m.element[i].label = arguments[1+(i*2)];
+ m.element[i].link = arguments[2+(i*2)];
+ }
+ display_menu(m);
+}
/*
display a table element
@@ -133,7 +161,7 @@ function multi_table(array, header) {
/*
create a Form object with the defaults filled in, ready for display_form()
*/
-function Form(name, num_elements, num_submits)
+function FormObj(name, num_elements, num_submits)
{
var f = new Object();
f.name = name;