summaryrefslogtreecommitdiff
path: root/swat/scripting/client/js_scripts.js
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-09-07 03:08:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:05:21 -0500
commitf8573766bc17af0afacc5d44d3c3d8234b426dbf (patch)
tree55dfe87448d6332ff48ba6e74fd3226fdd7422f6 /swat/scripting/client/js_scripts.js
parent8f3ab786f03e1bb5bf73fe9d7264b1b0bbb90a75 (diff)
downloadsamba-f8573766bc17af0afacc5d44d3c3d8234b426dbf.tar.gz
samba-f8573766bc17af0afacc5d44d3c3d8234b426dbf.tar.bz2
samba-f8573766bc17af0afacc5d44d3c3d8234b426dbf.zip
r24985: Start to revert us back to the old-style SWAT, while trying not to
loose some of the fixes in the meantime. Andrew Bartlett (This used to be commit 13acff5ed259e7b5859fd2324ea7740b8f9e5fd7)
Diffstat (limited to 'swat/scripting/client/js_scripts.js')
-rw-r--r--swat/scripting/client/js_scripts.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/swat/scripting/client/js_scripts.js b/swat/scripting/client/js_scripts.js
new file mode 100644
index 0000000000..1c6e5806f4
--- /dev/null
+++ b/swat/scripting/client/js_scripts.js
@@ -0,0 +1,60 @@
+/*
+ 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)
+{
+ // Create a unique ID for this script
+ var srcID = new Date().getTime();
+
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.id = srcID;
+
+ head.appendChild(script);
+
+ // IE works only with the path set after appending to the document
+ document.getElementById(srcID).src = path;
+}
+
+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;
+