summaryrefslogtreecommitdiffstats
path: root/swat/scripting
diff options
context:
space:
mode:
authorDeryck Hodge <deryck@samba.org>2005-08-26 05:25:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:34:36 -0500
commitc6b592a5b79bd8449a675012192c5654ddc4442c (patch)
treeb7f193ddd8d393133ffba26aed91728422c5008f /swat/scripting
parenta45c4fd5e24c8ae50bd86c6c84d1a3278e1bdab6 (diff)
downloadsamba-c6b592a5b79bd8449a675012192c5654ddc4442c.tar.gz
samba-c6b592a5b79bd8449a675012192c5654ddc4442c.tar.xz
samba-c6b592a5b79bd8449a675012192c5654ddc4442c.zip
r9635: Seperate window logic from registry js file.
This allows for flexibility in display format, which will make more sense when I start working on windows, tabs, etc. Add the beginnings of a document.js object that allows us to add and remove scripts as we use them, which will ensure we only load what we need. A desktop GUI runs from a single page, so we can't load js files by changing pages. deryck (This used to be commit b4f6f81d7bbf87fcb7c7c9bd4a7164aabaeedc1c)
Diffstat (limited to 'swat/scripting')
-rw-r--r--swat/scripting/client/js_scripts.js53
-rw-r--r--swat/scripting/client/regedit.js31
-rw-r--r--swat/scripting/client/status.js9
3 files changed, 60 insertions, 33 deletions
diff --git a/swat/scripting/client/js_scripts.js b/swat/scripting/client/js_scripts.js
new file mode 100644
index 00000000000..776e5e4ded2
--- /dev/null
+++ b/swat/scripting/client/js_scripts.js
@@ -0,0 +1,53 @@
+/*
+ Beginnnigs of a script manager for SWAT.
+
+ Copyright (C) Deryck Hodge 2005
+ released under the GNU GPL Version 2 or later
+*/
+
+var head = document.getElementsByTagName('head')[0];
+var scripts = document.getElementsByTagName('script');
+
+function __has_js_script(file)
+{
+ var i;
+ for (i=0; i<scripts.length; i++) {
+ if (scripts[i].src.indexOf(file) > -1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
+function __get_js_script(file)
+{
+ var i;
+ for (i=0; i<scripts.length; i++) {
+ if (scripts[i].src.indexOf(file) > -1) {
+ return scripts[i];
+ }
+ }
+}
+
+function __add_js_script(path)
+{
+ var script = document.createElement('script');
+ script.setAttribute('type', 'text/javascript');
+ script.setAttribute('src', path);
+ head.appendChild(script);
+}
+
+function __remove_js_script(path)
+{
+ var script = __get_js_script(path);
+ script.parentNode.removeChild(script);
+}
+
+document.js = new Object();
+document.js.scripts = scripts;
+document.js.hasScript = __has_js_script;
+document.js.getScript = __get_js_script;
+document.js.add = __add_js_script;
+document.js.remove = __remove_js_script;
+
diff --git a/swat/scripting/client/regedit.js b/swat/scripting/client/regedit.js
index 5942f25991d..9175017c2ef 100644
--- a/swat/scripting/client/regedit.js
+++ b/swat/scripting/client/regedit.js
@@ -121,12 +121,9 @@ function __values_table()
*/
function regedit_widget(binding)
{
- var regedit = new QxWindow("Registry Editor");
- regedit.setSpace(300, 600, 300, 600);
-
var fieldSet = new QxFieldSet();
- regedit.binding = binding;
+ fieldSet.binding = binding;
with(fieldSet) {
setWidth("100%");
@@ -138,19 +135,17 @@ function regedit_widget(binding)
gl.setCellPaddingTop(3);
gl.setCellPaddingBottom(3);
- regedit.add(fieldSet);
-
- var t = __registry_tree(regedit.binding);
+ var t = __registry_tree(fieldSet.binding);
function change_binding(e) {
- regedit.binding = e.getNewValue();
- srv_printf("changed binding to %s\\n", regedit.binding);
+ fieldSet.binding = e.getNewValue();
+ srv_printf("changed binding to %s\\n", fieldSet.binding);
gl.remove(t);
- t = __registry_tree(regedit.binding);
+ t = __registry_tree(fieldSet.binding);
gl.add(t, { row : 2, col : 1 });
}
- var b = new QxTextField(regedit.binding);
+ var b = new QxTextField(fieldSet.binding);
b.addEventListener("changeText", change_binding);
var values = new __values_table();
@@ -160,18 +155,6 @@ function regedit_widget(binding)
// gl.add(values, { row : 2, col : 2 });
fieldSet.add(gl);
- regedit.add(fieldSet);
-
- /*
- call the startup() method to display the widget
- */
- regedit.startup = function() {
- this.setVisible(true);
- this.setMoveable(true);
- this.setResizeable(true);
- this.setResizeMethod("frame");
- this.setMoveable(true);
- }
- return regedit;
+ return fieldSet;
};
diff --git a/swat/scripting/client/status.js b/swat/scripting/client/status.js
index fa2c3b57e7b..9be85aca587 100644
--- a/swat/scripting/client/status.js
+++ b/swat/scripting/client/status.js
@@ -5,15 +5,6 @@
*/
-/* Ensure we always include the proper libs
- Playing with a way to add/del scripts on the fly...
-*/
-var lib = document.createElement('script');
-lib.setAttribute('type', 'text/javascript');
-lib.setAttribute('src', '/scripting/client/call.js');
-var head = document.getElementsByTagName('head')[0];
-head.appendChild(lib);
-
// Format for a server status table
var s = [
{ id : "server",