[Pkg-javascript-commits] [sockjs-client] 96/434: Activex IE version of htmlfile transport

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:06 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit a442a6e48d06549d6e0316c02852e5f25783b8e5
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue Aug 23 16:27:16 2011 +0100

    Activex IE version of htmlfile transport
---
 lib/trans-iframe-htmlfile.js | 11 ++++++-----
 lib/utils.js                 | 46 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/lib/trans-iframe-htmlfile.js b/lib/trans-iframe-htmlfile.js
index 2c436c6..5b7c025 100644
--- a/lib/trans-iframe-htmlfile.js
+++ b/lib/trans-iframe-htmlfile.js
@@ -49,10 +49,11 @@ var HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function (ri, trans_url)
     };
     _window[WPrefix][that.id] = callback;
 
-    that.iframeObj = utils.createIframe(iframe_url, function(e) {
-                                            that.doCleanup();
-                                            that.ri._didClose(1001, "Can't load htmlfile iframe (" + e + ")");
-                                        });
+    var constructor = that.ie ? utils.createHtmlfile : utils.createIframe;
+    that.iframeObj = constructor(iframe_url, function(e) {
+                                     that.doCleanup();
+                                     that.ri._didClose(1001, "Can't load htmlfile iframe (" + e + ")");
+                                 });
 };
 
 // Inheritnace
@@ -65,4 +66,4 @@ HtmlFileTransport.prototype.doCleanup = function() {
         delete _window[WPrefix][that.id];
     }
     that.send_destructor();
-};
\ No newline at end of file
+};
diff --git a/lib/utils.js b/lib/utils.js
index a0131ec..ab9f54c 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -243,6 +243,52 @@ utils.createIframe = function (iframe_url, error_callback) {
     };
 };
 
+utils.createHtmlfile = function (iframe_url, error_callback) {
+    var doc = new ActiveXObject('htmlfile');
+    var tref;
+    var iframe;
+    var unattach = function() {
+        clearTimeout(tref);
+    };
+    var cleanup = function() {
+        if (doc) {
+            unattach();
+            utils.detachEvent('unload', cleanup);
+            try {
+                iframe.src = "about:blank";
+            } catch (x) {}
+            iframe.parentNode.removeChild(iframe);
+            iframe = doc = null;
+            CollectGarbage();
+        }
+    };
+    var onerror = function(r)  {
+        if (doc) {
+            cleanup();
+            error_callback(r);
+        }
+    };
+
+    doc.open();
+    doc.write('<html><script>' +
+              'document.domain="' + document.domain + '";' +
+              '</script></html>');
+    doc.close();
+    doc.parentWindow[WPrefix] = _window[WPrefix];
+    var c = doc.createElement('div');
+    doc.body.appendChild(c);
+    iframe = doc.createElement('iframe');
+    c.appendChild(iframe);
+    iframe.src = iframe_url;
+    tref = setTimeout(function(){onerror('timeout');}, 5000);
+    utils.attachEvent('unload', cleanup);
+    return {
+        iframe: iframe,
+        cleanup: cleanup,
+        loaded: unattach
+    };
+};
+
 utils.closeFrame = function (status, reason) {
     return 'c'+JSON.stringify([status, reason]);
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list