2 js functions and code common to all pages
5 /* define some global variables for this request */
6 global.page = new Object();
8 /* fill in some defaults */
9 global.page.title = "Samba Web Administration Tool";
11 libinclude("base.js");
13 /* to cope with browsers that don't support cookies we append the sessionid
15 global.SESSIONURI = "";
16 if (request['COOKIE_SUPPORT'] != "True") {
17 global.SESSIONURI="?SwatSessionId=" + request['SESSION_ID'];
21 possibly adjust a local URI to have the session id appended
22 used for browsers that don't support cookies
24 function session_uri(uri) {
25 return uri + global.SESSIONURI;
29 like printf, but to the web page
33 write(vsprintf(arguments));
37 like writef with a <br>
41 write(vsprintf(arguments));
46 /* if the browser was too dumb to set the HOST header, then
48 if (headers['HOST'] == undefined) {
49 headers['HOST'] = server['SERVER_HOST'] + ":" + server['SERVER_PORT'];
53 show the page header. page types include "plain" and "column"
55 function page_header(pagetype, title, menu) {
56 global.page.pagetype = pagetype;
57 global.page.title = title;
58 global.page.menu = menu;
59 include("/scripting/header_" + pagetype + ".esp");
63 show the page footer, getting the page type from page.pagetype
66 function page_footer() {
67 include("/scripting/footer_" + global.page.pagetype + ".esp");
72 check if a uri is one of the 'always allowed' pages, even when not logged in
73 This allows the login page to use the same style sheets and images
75 function always_allowed(uri) {
76 var str = string_init();
78 /* allow jsonrpc-based applications to do their own authentication */
79 var s = str.split('/', uri);
80 if (s[0] == "" && s[1] == 'apps') {
84 var s = str.split('.', uri);
89 var ext = s[s.length-1];
90 var allowed = new Array("ico", "gif", "png","css", "js");
92 if (allowed[i] == ext) {
100 display a table element
102 function table_element(i, o) {
103 write("<tr><td>" + i + "</td><td>");
104 if (typeof(o[i]) == "object") {
108 if (first == false) {
117 write("</td></tr>\n");
121 display a ejs object as a table. The header is optional
123 function simple_table(v) {
127 write("<table class=\"data\">\n");
136 display an array of objects, with the header for each element from the given
139 function multi_table(array, header) {
141 write("<table class=\"data\">\n");
142 for (i=0;i<array.length;i++) {
144 write('<tr><th colspan="2">' + v[header] + "</th></tr>\n");