[Pkg-javascript-commits] [sockjs-client] 42/434: Make jsonp work on ie7

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:00 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 b7018722067b57496be09a0fd5b06116f1367b9b
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue Aug 2 17:38:32 2011 +0100

    Make jsonp work on ie7
---
 lib/trans-jsonp-sender.js | 10 ++++++----
 lib/utils.js              | 15 +++++++++------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/trans-jsonp-sender.js b/lib/trans-jsonp-sender.js
index 5843b45..77c37a4 100644
--- a/lib/trans-jsonp-sender.js
+++ b/lib/trans-jsonp-sender.js
@@ -12,7 +12,7 @@ BufferedSender.prototype.doSend = function(message) {
     }
 };
 
-BufferedSender.prototype.send_schedule = function(message) {
+BufferedSender.prototype.send_schedule = function() {
     var that = this;
     if (that.send_buffer.length > 0) {
         var payload = '[' + that.send_buffer.join(',') + ']';
@@ -38,7 +38,7 @@ var jsonPGenericSender = function(url, payload, callback) {
     var that = this;
     if (!('_send_form' in that)) {
         var form = that._send_form = _document.createElement('form');
-        var area = _document.createElement('textarea');
+        var area = that._send_area = _document.createElement('textarea');
         area.name = 'd';
         form.style.display = 'none';
         form.style.position = 'absolute';
@@ -49,6 +49,7 @@ var jsonPGenericSender = function(url, payload, callback) {
         _document.body.appendChild(form);
     }
     var form = that._send_form;
+    var area = that._send_area;
     var id = 'a' + utils.random_string(8);
     form.target = id;
     form.action = url + '/jsonp_send?i=' + id;
@@ -63,14 +64,15 @@ var jsonPGenericSender = function(url, payload, callback) {
     }
     iframe.id = id;
     form.appendChild(iframe);
-    form.d.value = payload;
+    iframe.style.display = 'none';
+    area.value = payload;
     form.submit();
 
     var completed = function() {
         form.removeChild(iframe);
         iframe.onreadystatechange = iframe.onerror = iframe.onload = null;
         iframe = undefined;
-        form.d.value = undefined;
+        area.value = undefined;
         form.target = undefined;
         form.reset();
         callback();
diff --git a/lib/utils.js b/lib/utils.js
index 245f2e2..9d6b4ba 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -1,10 +1,13 @@
 var utils = {};
+var random_string_chars = ['a','b','c','d','e','f','g','h','i','j',
+                           'k','l','m','n','o','p','q','r','s','t',
+                           'u','v','w','x','y','z',
+                           '0','1','2','3','4','5','6','7','8','9','_'];
 utils.random_string = function(letters, max) {
-    var chars = 'abcdefghijklmnopqrstuvwxyz0123456789_';
-    max = max || chars.length;
+    max = max || random_string_chars.length;
     var i, ret = [];
-    for(i=0; i < letters;i++) {
-        ret.push( chars[Math.floor(Math.random() * max)] );
+    for(i=0; i < letters; i++) {
+        ret.push( random_string_chars[Math.floor(Math.random() * max)] );
     }
     return ret.join('');
 };
@@ -86,8 +89,8 @@ if (navigator &&
 utils.createXDR = function(method, url, payload, callback) {
     var mock_xhr = {status: null, responseText:'', readyState:1};
     var xdr = new XDomainRequest();
-    // IE caches POSTs
-    url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);
+    // IE caches even POSTs
+    url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+utils.random_string(8);
     var cleanup = function() {
         onerror = xdr.onerror = xdr.ontimeout = xdr.onprogress =
             xdr.onload = null;

-- 
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