From c6b592a5b79bd8449a675012192c5654ddc4442c Mon Sep 17 00:00:00 2001 From: Deryck Hodge Date: Fri, 26 Aug 2005 05:25:29 +0000 Subject: 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) --- swat/scripting/client/js_scripts.js | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 swat/scripting/client/js_scripts.js (limited to 'swat/scripting/client/js_scripts.js') 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 -1) { + return true; + } else { + return false; + } + } +} + +function __get_js_script(file) +{ + var i; + for (i=0; i -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; + -- cgit