From 626bb8efb0c825f332c937ffaaadc9b402079539 Mon Sep 17 00:00:00 2001
From: Derrell Lipman <derrell@samba.org>
Date: Wed, 3 Jan 2007 20:17:37 +0000
Subject: r20517: re-add cleaned-up webapps (This used to be commit
 5a3d6ad0b7cf0ecf8b57b4088b19f7d4291c990b)

---
 webapps/scripting/client/js_scripts.js | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 webapps/scripting/client/js_scripts.js

(limited to 'webapps/scripting/client/js_scripts.js')

diff --git a/webapps/scripting/client/js_scripts.js b/webapps/scripting/client/js_scripts.js
new file mode 100644
index 0000000000..1c6e5806f4
--- /dev/null
+++ b/webapps/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;
+
-- 
cgit