blob: cc3ca55468130dc73902d18d5dc8a2f270491d06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
js functions and code common to all pages
*/
/* define some global variables for this request */
global.page = new Object();
/* fill in some defaults */
global.page.title = "Samba Web Administration Tool";
/* if the browser was too dumb to set the HOST header, then
set it now */
if (headers['HOST'] == undefined) {
headers['HOST'] = server['SERVER_HOST'] + ":" + server['SERVER_PORT'];
}
/*
show the page header. page types include "plain" and "column"
*/
function page_header(pagetype, title) {
global.page.pagetype = pagetype;
global.page.title = title;
include("/scripting/header_" + pagetype + ".esp");
}
/*
show the page footer, getting the page type from page.pagetype
set in page_header()
*/
function page_footer() {
include("/scripting/footer_" + global.page.pagetype + ".esp");
}
/*
check if a uri is one of the 'always allowed' pages, even when not logged in
This allows the login page to use the same style sheets and images
*/
function always_allowed(uri) {
var allowed = new Array("/images/favicon.ico",
"/images/linkpad.gif",
"/images/logo.png",
"/style/main.css",
"/style/common.css");
for (i in allowed) {
if (allowed[i] == uri) {
return true;
}
}
return false;
}
/*
display a simple menu. First argument is menu title, followed by
pairs of menu item name and link
*/
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");
}
write("</ul>\n");
}
/*
display a ejs object as a table
*/
function simple_table(v) {
write("<table class=\"data\">\n");
for (r in v) {
write("<tr><td>" + r + "</td><td>" + v[r] + "</td></tr>\n");
}
write("</table>\n");
}
/*
display an array of objects, with the header for each element from the given
attribute
*/
function multi_table(array, header) {
write("<table class=\"data\">\n");
for (i in array) {
var v = array[i];
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");
}
}
}
write("</table>\n");
}
|