From adb7fd18e5e58bc466bdd31d68423e5f958a1d5d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Jul 2005 11:46:34 +0000 Subject: r8372: - split out provisioning logic into a separate ejs library - added a provisioning web page (This used to be commit 7476cb94132cf2849ec19360468904ca6fe8de2c) --- swat/scripting/common.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'swat/scripting/common.js') diff --git a/swat/scripting/common.js b/swat/scripting/common.js index 2e90c1b469..0e297d7d99 100644 --- a/swat/scripting/common.js +++ b/swat/scripting/common.js @@ -23,6 +23,22 @@ function session_uri(uri) { return uri + global.SESSIONURI; } +/* + like printf, but to the web page +*/ +function writef() +{ + write(vsprintf(arguments)); +} + +/* + like writef with a
+*/ +function writefln() +{ + write(vsprintf(arguments)); + write("
\n"); +} /* if the browser was too dumb to set the HOST header, then @@ -196,6 +212,7 @@ function FormObj(name, num_elements, num_submits) f.element[i].value = current value (optional, defaults to "") */ function display_form(f) { + var i, size = 20; write('
\n'); @@ -210,6 +227,12 @@ function display_form(f) { if (e.value == undefined) { e.value = ""; } + if (strlen(e.value) > size) { + size = strlen(e.value) + 4; + } + } + for (i in f.element) { + var e = f.element[i]; write(""); write("" + e.label + ""); if (e.type == "select") { @@ -223,8 +246,12 @@ function display_form(f) { } write('\n'); } else { - write('\n'); + var sizestr = ""; + if (e.type == "text" || e.type == "password") { + sizestr = sprintf('size="%d"', size); + } + writef('\n', + e.name, e.type, e.value, sizestr); } write(""); } -- cgit