summaryrefslogtreecommitdiff
path: root/swat/scripting/client/js_scripts.js
diff options
context:
space:
mode:
Diffstat (limited to 'swat/scripting/client/js_scripts.js')
-rw-r--r--swat/scripting/client/js_scripts.js53
1 files changed, 53 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..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;
+