Always use document.write to output script tags, regardless of useragent.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 21 Jun 2010 15:43:35 +0000 (11:43 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 21 Jun 2010 15:45:45 +0000 (11:45 -0400)
inserting scripts into the dom breaks things when using horde's static javascript
caching.

horde/js/hordemap/map.js

index a51169a..65f6503 100644 (file)
@@ -72,25 +72,14 @@ HordeMap = {
     _includeScripts: function()
     {
         var files = this._includes;
-        var agent = navigator.userAgent;
-        var docWrite = (agent.match("MSIE") || agent.match("Safari"));
+
+        // Need to use document.write instead of inserting into DOM directly
+        // to play nice with horde's javascript caching/loading
         var writeFiles = [];
         for (var i = 0, len = files.length; i < len; i++) {
-            if (docWrite) {
-                writeFiles.push('<script src="' + files[i] + '"></script>');
-            } else {
-                var s = document.createElement("script");
-                s.src = files[i];
-                var h = document.getElementsByTagName("head").length ?
-                           document.getElementsByTagName("head")[0] :
-                           document.body;
-                h.appendChild(s);
-            }
-        }
-
-        if (docWrite) {
-            document.write(writeFiles.join(""));
+            writeFiles.push('<script src="' + files[i] + '"></script>');
         }
+        document.write(writeFiles.join(""));
     },
 
     _addScript: function(s)