From d1e09e2e6f9db62bbab84abb53e23ee73764178a Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 31 Dec 2006 20:12:12 +0000 Subject: r20446: rename swat directory to swat.obsolete; keeping it around since there is lots of useful info in it. (This used to be commit 5f9f72a9cfab80561b23284001b67c4ea961757b) --- swat/scripting/common.js | 153 ----------------------------------------------- 1 file changed, 153 deletions(-) delete mode 100644 swat/scripting/common.js (limited to 'swat/scripting/common.js') diff --git a/swat/scripting/common.js b/swat/scripting/common.js deleted file mode 100644 index fe25287a74..0000000000 --- a/swat/scripting/common.js +++ /dev/null @@ -1,153 +0,0 @@ -/* - 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"; - -libinclude("base.js"); - -/* to cope with browsers that don't support cookies we append the sessionid - to the URI */ -global.SESSIONURI = ""; -if (request['COOKIE_SUPPORT'] != "True") { - global.SESSIONURI="?SwatSessionId=" + request['SESSION_ID']; -} - -/* - possibly adjust a local URI to have the session id appended - used for browsers that don't support cookies -*/ -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 - 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, menu) { - global.page.pagetype = pagetype; - global.page.title = title; - global.page.menu = menu; - 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 str = string_init(); - - /* allow jsonrpc-based applications to do their own authentication */ - var s = str.split('/', uri); - if (s[0] == "" && s[1] == 'apps') { - return true; - } - - var s = str.split('.', uri); - if (s.length < 2) { - return false; - } - - var ext = s[s.length-1]; - var allowed = new Array("ico", "gif", "png","css", "js"); - for (i in allowed) { - if (allowed[i] == ext) { - return true; - } - } - return false; -} - -/* - display a table element -*/ -function table_element(i, o) { - write("" + i + ""); - if (typeof(o[i]) == "object") { - var j, first; - first = true; - for (j in o[i]) { - if (first == false) { - write("
"); - } - write(o[i][j]); - first = false; - } - } else { - write(o[i]); - } - write("\n"); -} - -/* - display a ejs object as a table. The header is optional -*/ -function simple_table(v) { - if (v.length == 0) { - return; - } - write("\n"); - var r; - for (r in v) { - table_element(r, v); - } - write("
\n"); -} - -/* - display an array of objects, with the header for each element from the given - attribute -*/ -function multi_table(array, header) { - var i, n; - write("\n"); - for (i=0;i\n"); - for (r in v) { - if (r != header) { - table_element(r, v); - } - } - } - write("
' + v[header] + "
\n"); -} - -- cgit