diff options
author | Deryck Hodge <deryck@samba.org> | 2005-08-26 05:25:29 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:34:36 -0500 |
commit | c6b592a5b79bd8449a675012192c5654ddc4442c (patch) | |
tree | b7f193ddd8d393133ffba26aed91728422c5008f /swat | |
parent | a45c4fd5e24c8ae50bd86c6c84d1a3278e1bdab6 (diff) | |
download | samba-c6b592a5b79bd8449a675012192c5654ddc4442c.tar.gz samba-c6b592a5b79bd8449a675012192c5654ddc4442c.tar.bz2 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')
-rw-r--r-- | swat/desktop/index.esp | 32 | ||||
-rw-r--r-- | swat/esptest/registry.esp | 15 | ||||
-rw-r--r-- | swat/scripting/client/js_scripts.js | 53 | ||||
-rw-r--r-- | swat/scripting/client/regedit.js | 31 | ||||
-rw-r--r-- | swat/scripting/client/status.js | 9 |
5 files changed, 101 insertions, 39 deletions
diff --git a/swat/desktop/index.esp b/swat/desktop/index.esp index 424f848e44..f688850851 100644 --- a/swat/desktop/index.esp +++ b/swat/desktop/index.esp @@ -4,8 +4,8 @@ libinclude("base.js"); %> <script type="text/javascript" src="/scripting/client/encoder.js"></script> -<script type="text/javascript" src="/scripting/client/regedit.js"></script> -<script type="text/javascript" src="/scripting/client/status.js"></script> +<script type="text/javascript" src="/scripting/client/call.js"></script> +<script type="text/javascript" src="/scripting/client/js_scripts.js"></script> <script type="text/javascript"> @@ -91,6 +91,7 @@ function showContextMenu(e) } /*** init the page for qooxdoo ***/ +document.js.add('/scripting/client/status.js'); window.application.main = function() { var doc = this.getClientWindow().getClientDocument(); @@ -108,6 +109,12 @@ window.application.main = function() // Always open with stats var win = new QxWindow(); + win._onclosebuttonclick = function(e) + { + this.close(); + e.stopPropagation(); + document.js.remove('/scripting/client/status.js'); + }; with(win) { setTop(50); setRight(50); @@ -126,9 +133,26 @@ window.onresize = function() function showReg() { + document.js.add('/scripting/client/regedit.js'); + + var regWin = new QxWindow("Registry Editor"); + regWin._onclosebuttonclick = function(e) + { + this.close(); + e.stopPropagation(); + document.js.remove('/scripting/client/regedit.js'); + }; + with(regWin) { + setTop(100); + setLeft(100); + setMinWidth(450); + setMinHeight(450); + } + var regedit = regedit_widget("ncalrpc:"); - w.add(regedit); - regedit.startup(); + regWin.add(regedit); + w.add(regWin); + regWin.setVisible('true'); } function startSwat() diff --git a/swat/esptest/registry.esp b/swat/esptest/registry.esp index b65b5d1b24..efdfefc37e 100644 --- a/swat/esptest/registry.esp +++ b/swat/esptest/registry.esp @@ -23,9 +23,20 @@ window.application.main = function() var btn1 = new QxButton("Registry Editor"); btn1.set({ top: 20, left : 30 }); btn1.addEventListener("click", function() { + var regWindow = new QxWindow("Registry Editor"); + with(regWindow) { + setTop(50); + setLeft(50); + setMinWidth(600); + setMinHeight(600); + setResizeMethod("frame"); + } + var regedit = regedit_widget("ncalrpc:"); - qwidget.add(regedit); - regedit.startup(); + regWindow.add(regedit); + qwidget.add(regWindow); + regWindow.setVisible(true); + }); qwidget.add(btn1); inlineWidget.add(qwidget); diff --git a/swat/scripting/client/js_scripts.js b/swat/scripting/client/js_scripts.js new file mode 100644 index 0000000000..776e5e4ded --- /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 5942f25991..9175017c2e 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 fa2c3b57e7..9be85aca58 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", |