Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

applied MAILTO patch for PubNub JavaScript API discovered by Jon Wu @…

…jon_wu today.

added Disconnect and Reconnect events to PubNub JavaScript API.
  • Loading branch information...
commit 27e7025e09cf143e89766b8cac7fb387c9bb7ff7 1 parent 3d39179
Stephen L. Blum stephenlb authored
1  .gitignore
View
@@ -1,5 +1,6 @@
*~
*.swp
*.pyc
+*.class
.DS_Store
node_modules
52 javascript/mailto-fix.html
View
@@ -0,0 +1,52 @@
+<!doctype html>
+<html>
+<head>
+ <title>PubNub JavaScript MailTO Fix</title>
+ <link
+ rel=stylesheet
+ href=http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css
+ >
+</head>
+<body><div class=container>
+
+<!-- NOTICE / TITLE -->
+<div class="alert-message warning">
+ <a class="close" href="#">&#215;</a>
+ <p><strong>PubNub MailTO Test</strong> for JavaScript on Mobile and Desktop Web Browser</p>
+</div>
+
+<!-- BUTTON PANNEL -->
+<div class=well>
+ <a href="mailto:hello@pubnub.com">hello@pubnub.com</a>
+</div>
+<div id=output class=well>0</div>
+
+<div id=pubnub></div>
+<script src=pubnub-3.1.min.js></script>
+<script>(function(){
+
+var msgs = 1
+, out = PUBNUB.$('output');;
+
+PUBNUB.subscribe({
+ channel : 'mailto-testing',
+ disconnect : function() {},
+ connect : function() {startitup()},
+ reconnect : function() {},
+ callback : function(num) {
+ out.innerHTML += ', ' + num;
+ }
+});
+
+function startitup() {
+ setInterval( function() {
+ PUBNUB.publish({
+ channel : 'mailto-testing',
+ message : msgs++
+ });
+ }, 250 );
+}
+
+})();</script>
+</div></body>
+</html>
38 javascript/pubnub-3.1.js
View
@@ -589,8 +589,8 @@ function ajax( setup ) {
new XDomainRequest() ||
new XMLHttpRequest();
- xhr.onerror = function(){ done(1) };
- xhr.onload = finished;
+ xhr.onerror = xhr.onabort = function(){ done(1) };
+ xhr.onload = xhr.onloadend = finished;
xhr.timeout = XHRTME;
xhr.open( 'GET', setup.url.join(URLBIT), true );
@@ -784,14 +784,16 @@ var PDIV = $('pubnub') || {}
*/
'subscribe' : function( args, callback ) {
- var channel = args['channel']
- , callback = callback || args['callback']
- , restore = args['restore']
- , timetoken = 0
- , error = args['error'] || function(){}
- , connected = 0
- , connect = args['connect'] || function(){}
- , origin = nextorigin(ORIGIN);
+ var channel = args['channel']
+ , callback = callback || args['callback']
+ , restore = args['restore']
+ , timetoken = 0
+ , connect = args['connect'] || function(){}
+ , reconnect = args['reconnect'] || function(){}
+ , disconnect = args['error']||args['disconnect']||function(){}
+ , disconnected = 0
+ , connected = 0
+ , origin = nextorigin(ORIGIN);
// Reduce Status Flicker
if (!READY) return READY_BUFFER.push([ args, callback, SELF ]);
@@ -823,19 +825,29 @@ var PDIV = $('pubnub') || {}
jsonp, timetoken
],
fail : function() {
+ // Disconnect
+ if (!disconnected) {
+ disconnected = 1;
+ disconnect();
+ }
+
timeout( pubnub, SECOND );
- SELF['time'](function(success){
- success || error();
- });
},
success : function(messages) {
if (!CHANNELS[channel].connected) return;
+ // Connect
if (!connected) {
connected = 1;
connect();
}
+ // Reconnect
+ if (disconnected) {
+ disconnected = 0;
+ reconnect();
+ }
+
// Restore Previous Connection Point if Needed
// Also Update Timetoken
restore = db.set(
34 javascript/pubnub-3.1.min.js
View
@@ -1,18 +1,18 @@
-function s(){return function(){}}
-window.JSON&&window.JSON.stringify||function(){function y(c){k.lastIndex=0;return k.test(c)?'"'+c.replace(k,function(c){var g=f[c];return typeof g==="string"?g:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+c+'"'}function u(c,f){var g,h,o,m,k=i,l,e=f[c];e&&typeof e==="object"&&typeof e.toJSON==="function"&&(e=e.toJSON(c));typeof p==="function"&&(e=p.call(f,c,e));switch(typeof e){case "string":return y(e);case "number":return isFinite(e)?String(e):"null";case "boolean":case "null":return String(e);
-case "object":if(!e)return"null";i+=t;l=[];if(Object.prototype.toString.apply(e)==="[object Array]"){m=e.length;for(g=0;g<m;g+=1)l[g]=u(g,e)||"null";o=l.length===0?"[]":i?"[\n"+i+l.join(",\n"+i)+"\n"+k+"]":"["+l.join(",")+"]";i=k;return o}if(p&&typeof p==="object"){m=p.length;for(g=0;g<m;g+=1)h=p[g],typeof h==="string"&&(o=u(h,e))&&l.push(y(h)+(i?": ":":")+o)}else for(h in e)Object.hasOwnProperty.call(e,h)&&(o=u(h,e))&&l.push(y(h)+(i?": ":":")+o);o=l.length===0?"{}":i?"{\n"+i+l.join(",\n"+i)+"\n"+
-k+"}":"{"+l.join(",")+"}";i=k;return o}}window.JSON||(window.JSON={});if(typeof String.prototype.toJSON!=="function")String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var k=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,i,t,f={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},p;typeof JSON.stringify!=="function"&&(JSON.stringify=function(c,
-f,g){var h;t=i="";if(typeof g==="number")for(h=0;h<g;h+=1)t+=" ";else typeof g==="string"&&(t=g);if((p=f)&&typeof f!=="function"&&(typeof f!=="object"||typeof f.length!=="number"))throw Error("JSON.stringify");return u("",{"":c})});typeof JSON.parse!=="function"&&(JSON.parse=function(c){return eval("("+c+")")})}();
-window.PUBNUB||function(){function y(a){var b={},d=a.publish_key||"demo",q=a.subscribe_key||"demo",r=a.ssl?"s":"",v="http"+r+"://"+(a.origin||"pubsub.pubnub.com"),n={history:function(a,b){var b=a.callback||b,d=a.limit||100,j=a.channel,c=e();if(!j)return f("Missing Channel");if(!b)return f("Missing Callback");w({c:c,url:[v,"history",q,z(j),c,d],b:function(a){b(a)},a:function(a){f(a)}})},time:function(a){var b=e();w({c:b,url:[v,"time",b],b:function(b){a(b[0])},a:function(){a(0)}})},uuid:function(a){var b=
-e();w({c:b,url:["http"+r+"://pubnub-prod.appspot.com/uuid?callback="+b],b:function(b){a(b[0])},a:function(){a(0)}})},analytics:function(a){var b=e(),c=a.limit||100,j=a.ago||0,f=a.duration||100,v=a.callback;w({c:b,b:function(a){v(a)},a:function(){v(0)},url:[["http"+r+"://pubnub-prod.appspot.com/analytics-channel?callback="+b,"sub-key="+q,"pub-key="+d,"channel="+z(a.channel||""),"limit="+c,"ago="+j,"duration="+f].join("&")]})},publish:function(a,b){var b=b||a.callback||s(),c=a.message,j=a.channel,r=
-e();if(!c)return f("Missing Message");if(!j)return f("Missing Channel");if(!d)return f("Missing Publish Key");c=JSON.stringify(c);c=[v,"publish",d,q,0,z(j),r,z(c)];if(c.join().length>1800)return f("Message Too Big");w({c:r,b:function(a){b(a)},a:function(){b([0,"Disconnected"])},url:c})},unsubscribe:function(a){a=a.channel;if(a in b)b[a].d=0,b[a].e&&b[a].e(0)},subscribe:function(a,d){function r(){var a=e();if(b[j].d)b[j].e=w({c:a,url:[m,"subscribe",q,z(j),a,h],a:function(){setTimeout(r,A);n.time(function(a){a||
-i()})},b:function(a){b[j].d&&(k||(k=1,l()),g=C.set(q+j,h=g&&C.get(q+j)||a[1]),c(a[0],function(b){d(b,a)}),setTimeout(r,10))}})}var j=a.channel,d=d||a.callback,g=a.restore,h=0,i=a.error||s(),k=0,l=a.connect||s(),m=N(v);if(!D)return I.push([a,d,n]);if(!j)return f("Missing Channel");if(!d)return f("Missing Callback");if(!q)return f("Missing Subscribe Key");j in b||(b[j]={});if(b[j].d)return f("Already Connected");b[j].d=1;r()},db:C,each:c,map:G,css:H,$:t,create:l,bind:h,supplant:g,head:o,search:p,attr:m,
-now:k,unique:u,events:B,updater:i,init:y};return n}function u(){return"x"+ ++O+""+ +new Date}function k(){return+new Date}function i(a,b){function d(){c+b>k()?(clearTimeout(q),q=setTimeout(d,b)):(c=k(),a())}var q,c=0;return d}function t(a){return document.getElementById(a)}function f(a){console.log(a)}function p(a,b){var d=[];c(a.split(/\s+/),function(a){c((b||document).getElementsByTagName(a),function(a){d.push(a)})});return d}function c(a,b){if(a&&b)if(typeof a[0]!="undefined")for(var d=0,c=a.length;d<
-c;)b.call(a[d],a[d],d++);else for(d in a)a.hasOwnProperty&&a.hasOwnProperty(d)&&b.call(a[d],d,a[d])}function G(a,b){var d=[];c(a||[],function(a,c){d.push(b(a,c))});return d}function g(a,b){return a.replace(P,function(a,c){return b[c]||a})}function h(a,b,d){c(a.split(","),function(a){function c(a){if(!a)a=window.event;if(!d(a))a.cancelBubble=true,a.returnValue=false,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation()}b.addEventListener?b.addEventListener(a,c,false):b.attachEvent?
-b.attachEvent("on"+a,c):b["on"+a]=c})}function o(){return p("head")[0]}function m(a,b,d){if(d)a.setAttribute(b,d);else return a&&a.getAttribute&&a.getAttribute(b)}function H(a,b){for(var d in b)if(b.hasOwnProperty(d))try{a.style[d]=b[d]+("|width|height|top|left|".indexOf(d)>0&&typeof b[d]=="number"?"px":"")}catch(c){}}function l(a){return document.createElement(a)}function e(){return E||n()?0:u()}function z(a){return G(encodeURIComponent(a).split(""),function(a){return"-_.!~*'()".indexOf(a)<0?a:"%"+
-a.charCodeAt(0).toString(16).toUpperCase()}).join("")}function w(a){function b(a,b){if(!f)f=1,a||i(b),d.onerror=null,clearTimeout(g),setTimeout(function(){a&&h();var b=t(e),d=b&&b.parentNode;d&&d.removeChild(b)},A)}if(E||n())return Q(a);var d=l("script"),c=a.c,e=u(),f=0,g=setTimeout(function(){b(1)},F),h=a.a||s(),i=a.b||s();window[c]=function(a){b(0,a)};d[J]=J;d.onerror=function(){b(1)};d.src=a.url.join(K);m(d,"id",e);o().appendChild(d);return b}function Q(a){function b(a){if(!e){e=1;clearTimeout(g);
-if(c)c.onerror=c.onload=null,c.abort&&c.abort(),c=null;a&&h()}}function d(){if(!f){f=1;clearTimeout(g);try{response=JSON.parse(c.responseText)}catch(a){return b(1)}i(response)}}var c,e=0,f=0,g=setTimeout(function(){b(1)},F),h=a.a||s(),i=a.b||s();try{c=n()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest,c.onerror=function(){b(1)},c.onload=d,c.timeout=F,c.open("GET",a.url.join(K),true),c.send()}catch(k){return b(0),E=0,w(a)}return b}function L(){PUBNUB.time(k);PUBNUB.time(function(){setTimeout(function(){D||
-(D=1,c(I,function(a){a[2].subscribe(a[0],a[1])}))},A)})}function n(){if(!M.get)return 0;var a={id:n.id++,send:s(),abort:function(){a.id={}},open:function(b,c){n[a.id]=a;M.get(a.id,c)}};return a}window.console||(window.console=window.console||{});console.log||(console.log=(window.opera||{}).postError||s());var C=function(){var a=window.localStorage;return{get:function(b){return a?a.getItem(b):document.cookie.indexOf(b)==-1?null:((document.cookie||"").match(RegExp(b+"=([^;]+)"))||[])[1]||null},set:function(b,
+function q(){return function(){}}
+window.JSON&&window.JSON.stringify||function(){function y(c){l.lastIndex=0;return l.test(c)?'"'+c.replace(l,function(c){var g=f[c];return typeof g==="string"?g:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+c+'"'}function u(c,f){var g,h,n,k,l=i,m,e=f[c];e&&typeof e==="object"&&typeof e.toJSON==="function"&&(e=e.toJSON(c));typeof o==="function"&&(e=o.call(f,c,e));switch(typeof e){case "string":return y(e);case "number":return isFinite(e)?String(e):"null";case "boolean":case "null":return String(e);
+case "object":if(!e)return"null";i+=t;m=[];if(Object.prototype.toString.apply(e)==="[object Array]"){k=e.length;for(g=0;g<k;g+=1)m[g]=u(g,e)||"null";n=m.length===0?"[]":i?"[\n"+i+m.join(",\n"+i)+"\n"+l+"]":"["+m.join(",")+"]";i=l;return n}if(o&&typeof o==="object"){k=o.length;for(g=0;g<k;g+=1)h=o[g],typeof h==="string"&&(n=u(h,e))&&m.push(y(h)+(i?": ":":")+n)}else for(h in e)Object.hasOwnProperty.call(e,h)&&(n=u(h,e))&&m.push(y(h)+(i?": ":":")+n);n=m.length===0?"{}":i?"{\n"+i+m.join(",\n"+i)+"\n"+
+l+"}":"{"+m.join(",")+"}";i=l;return n}}window.JSON||(window.JSON={});if(typeof String.prototype.toJSON!=="function")String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var l=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,i,t,f={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},o;typeof JSON.stringify!=="function"&&(JSON.stringify=function(c,
+f,g){var h;t=i="";if(typeof g==="number")for(h=0;h<g;h+=1)t+=" ";else typeof g==="string"&&(t=g);if((o=f)&&typeof f!=="function"&&(typeof f!=="object"||typeof f.length!=="number"))throw Error("JSON.stringify");return u("",{"":c})});typeof JSON.parse!=="function"&&(JSON.parse=function(c){return eval("("+c+")")})}();
+window.PUBNUB||function(){function y(a){var b={},d=a.publish_key||"demo",r=a.subscribe_key||"demo",s=a.ssl?"s":"",v="http"+s+"://"+(a.origin||"pubsub.pubnub.com"),p={history:function(a,b){var b=a.callback||b,d=a.limit||100,j=a.channel,c=e();if(!j)return f("Missing Channel");if(!b)return f("Missing Callback");w({c:c,url:[v,"history",r,z(j),c,d],b:function(a){b(a)},a:function(a){f(a)}})},time:function(a){var b=e();w({c:b,url:[v,"time",b],b:function(b){a(b[0])},a:function(){a(0)}})},uuid:function(a){var b=
+e();w({c:b,url:["http"+s+"://pubnub-prod.appspot.com/uuid?callback="+b],b:function(b){a(b[0])},a:function(){a(0)}})},analytics:function(a){var b=e(),c=a.limit||100,j=a.ago||0,f=a.duration||100,v=a.callback;w({c:b,b:function(a){v(a)},a:function(){v(0)},url:[["http"+s+"://pubnub-prod.appspot.com/analytics-channel?callback="+b,"sub-key="+r,"pub-key="+d,"channel="+z(a.channel||""),"limit="+c,"ago="+j,"duration="+f].join("&")]})},publish:function(a,b){var b=b||a.callback||q(),c=a.message,j=a.channel,s=
+e();if(!c)return f("Missing Message");if(!j)return f("Missing Channel");if(!d)return f("Missing Publish Key");c=JSON.stringify(c);c=[v,"publish",d,r,0,z(j),s,z(c)];if(c.join().length>1800)return f("Message Too Big");w({c:s,b:function(a){b(a)},a:function(){b([0,"Disconnected"])},url:c})},unsubscribe:function(a){a=a.channel;if(a in b)b[a].d=0,b[a].e&&b[a].e(0)},subscribe:function(a,d){function s(){var a=e();if(b[j].d)b[j].e=w({c:a,url:[o,"subscribe",r,z(j),a,h],a:function(){k||(k=1,m());setTimeout(s,
+A)},b:function(a){b[j].d&&(n||(n=1,i()),k&&(k=0,l()),g=C.set(r+j,h=g&&C.get(r+j)||a[1]),c(a[0],function(b){d(b,a)}),setTimeout(s,10))}})}var j=a.channel,d=d||a.callback,g=a.restore,h=0,i=a.connect||q(),l=a.reconnect||q(),m=a.error||a.disconnect||q(),k=0,n=0,o=N(v);if(!D)return I.push([a,d,p]);if(!j)return f("Missing Channel");if(!d)return f("Missing Callback");if(!r)return f("Missing Subscribe Key");j in b||(b[j]={});if(b[j].d)return f("Already Connected");b[j].d=1;s()},db:C,each:c,map:G,css:H,$:t,
+create:m,bind:h,supplant:g,head:n,search:o,attr:k,now:l,unique:u,events:B,updater:i,init:y};return p}function u(){return"x"+ ++O+""+ +new Date}function l(){return+new Date}function i(a,b){function d(){c+b>l()?(clearTimeout(r),r=setTimeout(d,b)):(c=l(),a())}var r,c=0;return d}function t(a){return document.getElementById(a)}function f(a){console.log(a)}function o(a,b){var d=[];c(a.split(/\s+/),function(a){c((b||document).getElementsByTagName(a),function(a){d.push(a)})});return d}function c(a,b){if(a&&
+b)if(typeof a[0]!="undefined")for(var d=0,c=a.length;d<c;)b.call(a[d],a[d],d++);else for(d in a)a.hasOwnProperty&&a.hasOwnProperty(d)&&b.call(a[d],d,a[d])}function G(a,b){var d=[];c(a||[],function(a,c){d.push(b(a,c))});return d}function g(a,b){return a.replace(P,function(a,c){return b[c]||a})}function h(a,b,d){c(a.split(","),function(a){function c(a){if(!a)a=window.event;if(!d(a))a.cancelBubble=true,a.returnValue=false,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation()}b.addEventListener?
+b.addEventListener(a,c,false):b.attachEvent?b.attachEvent("on"+a,c):b["on"+a]=c})}function n(){return o("head")[0]}function k(a,b,d){if(d)a.setAttribute(b,d);else return a&&a.getAttribute&&a.getAttribute(b)}function H(a,b){for(var d in b)if(b.hasOwnProperty(d))try{a.style[d]=b[d]+("|width|height|top|left|".indexOf(d)>0&&typeof b[d]=="number"?"px":"")}catch(c){}}function m(a){return document.createElement(a)}function e(){return E||p()?0:u()}function z(a){return G(encodeURIComponent(a).split(""),function(a){return"-_.!~*'()".indexOf(a)<
+0?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")}function w(a){function b(a,b){if(!f)f=1,a||i(b),d.onerror=null,clearTimeout(g),setTimeout(function(){a&&h();var b=t(e),d=b&&b.parentNode;d&&d.removeChild(b)},A)}if(E||p())return Q(a);var d=m("script"),c=a.c,e=u(),f=0,g=setTimeout(function(){b(1)},F),h=a.a||q(),i=a.b||q();window[c]=function(a){b(0,a)};d[J]=J;d.onerror=function(){b(1)};d.src=a.url.join(K);k(d,"id",e);n().appendChild(d);return b}function Q(a){function b(a){if(!e){e=1;clearTimeout(g);
+if(c)c.onerror=c.onload=null,c.abort&&c.abort(),c=null;a&&h()}}function d(){if(!f){f=1;clearTimeout(g);try{response=JSON.parse(c.responseText)}catch(a){return b(1)}i(response)}}var c,e=0,f=0,g=setTimeout(function(){b(1)},F),h=a.a||q(),i=a.b||q();try{c=p()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest,c.onerror=c.onabort=function(){b(1)},c.onload=c.onloadend=d,c.timeout=F,c.open("GET",a.url.join(K),true),c.send()}catch(k){return b(0),E=0,w(a)}return b}function L(){PUBNUB.time(l);PUBNUB.time(function(){setTimeout(function(){D||
+(D=1,c(I,function(a){a[2].subscribe(a[0],a[1])}))},A)})}function p(){if(!M.get)return 0;var a={id:p.id++,send:q(),abort:function(){a.id={}},open:function(b,c){p[a.id]=a;M.get(a.id,c)}};return a}window.console||(window.console=window.console||{});console.log||(console.log=(window.opera||{}).postError||q());var C=function(){var a=window.localStorage;return{get:function(b){return a?a.getItem(b):document.cookie.indexOf(b)==-1?null:((document.cookie||"").match(RegExp(b+"=([^;]+)"))||[])[1]||null},set:function(b,
c){if(a)return a.setItem(b,c)&&0;document.cookie=b+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}}}(),O=1,P=/{([\w\-]+)}/g,J="async",K="/",F=14E4,A=1E3,E=navigator.userAgent.indexOf("MSIE 6")==-1,N=function(){var a=Math.floor(Math.random()*9)+1;return function(b){return b.indexOf("pubsub")>0&&b.replace("pubsub","ps"+(++a<10?a:a=1))||b}}(),B={list:{},unbind:function(a){B.list[a]=[]},bind:function(a,b){(B.list[a]=B.list[a]||[]).push(b)},fire:function(a,b){c(B.list[a]||[],function(a){a(b)})}},
-x=t("pubnub")||{},D=0,I=[];PUBNUB=y({publish_key:m(x,"pub-key"),subscribe_key:m(x,"sub-key"),ssl:m(x,"ssl")=="on",origin:m(x,"origin")});H(x,{position:"absolute",top:-A});if("opera"in window||m(x,"flash"))x.innerHTML="<object id=pubnubs type=application/x-shockwave-flash width=1 height=1 data=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=movie value=https://dh15atwfs066y.cloudfront.net/pubnub.swf /><param name=allowscriptaccess value=always /></object>";var M=t("pubnubs")||{};h("load",
-window,function(){setTimeout(L,0)});PUBNUB.rdx=function(a,b){if(!b)return n[a].onerror();n[a].responseText=unescape(b);n[a].onload()};n.id=A;window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);typeof module!=="undefined"&&(module.f=PUBNUB)&&L()}();
+x=t("pubnub")||{},D=0,I=[];PUBNUB=y({publish_key:k(x,"pub-key"),subscribe_key:k(x,"sub-key"),ssl:k(x,"ssl")=="on",origin:k(x,"origin")});H(x,{position:"absolute",top:-A});if("opera"in window||k(x,"flash"))x.innerHTML="<object id=pubnubs type=application/x-shockwave-flash width=1 height=1 data=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=movie value=https://dh15atwfs066y.cloudfront.net/pubnub.swf /><param name=allowscriptaccess value=always /></object>";var M=t("pubnubs")||{};h("load",
+window,function(){setTimeout(L,0)});PUBNUB.rdx=function(a,b){if(!b)return p[a].onerror();p[a].responseText=unescape(b);p[a].onload()};p.id=A;window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);typeof module!=="undefined"&&(module.f=PUBNUB)&&L()}();
11 javascript/unit-test.html
View
@@ -225,6 +225,17 @@
}
});
+
+ /*
+ restore : true,
+ disconnect : function() {
+ },
+ reconnect : function() {
+ },
+ connect : function() {
+ },
+ */
+
}
start_test();
BIN  socket.io/bootstrap-mobile/.DS_Store
View
Binary file not shown
35 socket.io/socket.io.min.js
View
@@ -1,20 +1,21 @@
-function n(){return function(){}}
-window.JSON&&window.JSON.stringify||function(){function u(c){x.lastIndex=0;return x.test(c)?'"'+c.replace(x,function(c){var d=B[c];return typeof d==="string"?d:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+c+'"'}function q(p,l){var d,k,i,r,s=c,h,f=l[p];f&&typeof f==="object"&&typeof f.toJSON==="function"&&(f=f.toJSON(p));typeof g==="function"&&(f=g.call(l,p,f));switch(typeof f){case "string":return u(f);case "number":return isFinite(f)?String(f):"null";case "boolean":case "null":return String(f);
-case "object":if(!f)return"null";c+=j;h=[];if(Object.prototype.toString.apply(f)==="[object Array]"){r=f.length;for(d=0;d<r;d+=1)h[d]=q(d,f)||"null";i=h.length===0?"[]":c?"[\n"+c+h.join(",\n"+c)+"\n"+s+"]":"["+h.join(",")+"]";c=s;return i}if(g&&typeof g==="object"){r=g.length;for(d=0;d<r;d+=1)k=g[d],typeof k==="string"&&(i=q(k,f))&&h.push(u(k)+(c?": ":":")+i)}else for(k in f)Object.hasOwnProperty.call(f,k)&&(i=q(k,f))&&h.push(u(k)+(c?": ":":")+i);i=h.length===0?"{}":c?"{\n"+c+h.join(",\n"+c)+"\n"+
-s+"}":"{"+h.join(",")+"}";c=s;return i}}window.JSON||(window.JSON={});if(typeof String.prototype.toJSON!=="function")String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var x=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,c,j,B={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},g;typeof JSON.stringify!=="function"&&(JSON.stringify=function(p,
-l,d){var k;j=c="";if(typeof d==="number")for(k=0;k<d;k+=1)j+=" ";else typeof d==="string"&&(j=d);if((g=l)&&typeof l!=="function"&&(typeof l!=="object"||typeof l.length!=="number"))throw Error("JSON.stringify");return q("",{"":p})});typeof JSON.parse!=="function"&&(JSON.parse=function(c){return eval("("+c+")")})}();
-window.PUBNUB||function(){function u(a){var b={},e=a.publish_key||"demo",y=a.subscribe_key||"demo",o=a.ssl?"s":"",v="http"+o+"://"+(a.origin||"pubsub.pubnub.com"),m={history:function(a,b){var b=a.callback||b,e=a.limit||100,c=a.channel,d=h();if(!c)return j("Missing Channel");if(!b)return j("Missing Callback");t({c:d,url:[v,"history",y,f(c),d,e],b:function(a){b(a)},a:function(a){j(a)}})},time:function(a){var b=h();t({c:b,url:[v,"time",b],b:function(b){a(b[0])},a:function(){a(0)}})},uuid:function(a){var b=
-h();t({c:b,url:["http"+o+"://pubnub-prod.appspot.com/uuid?callback="+b],b:function(b){a(b[0])},a:function(){a(0)}})},analytics:function(a){var b=h(),c=a.limit||100,d=a.ago||0,v=a.duration||100,g=a.callback;t({c:b,b:function(a){g(a)},a:function(){g(0)},url:[["http"+o+"://pubnub-prod.appspot.com/analytics-channel?callback="+b,"sub-key="+y,"pub-key="+e,"channel="+f(a.channel||""),"limit="+c,"ago="+d,"duration="+v].join("&")]})},publish:function(a,b){var b=b||a.callback||n(),c=a.message,d=a.channel,o=
-h();if(!c)return j("Missing Message");if(!d)return j("Missing Channel");if(!e)return j("Missing Publish Key");c=JSON.stringify(c);c=[v,"publish",e,y,0,f(d),o,f(c)];if(c.join().length>1800)return j("Message Too Big");t({c:o,b:function(a){b(a)},a:function(){b([0,"Disconnected"])},url:c})},unsubscribe:function(a){a=a.channel;if(a in b)b[a].d=0,b[a].e&&b[a].e(0)},subscribe:function(a,e){function c(){var a=h();if(b[d].d)b[d].e=t({c:a,url:[v,"subscribe",y,f(d),a,o],a:function(){setTimeout(c,1E3);m.time(function(a){a||
-k()})},b:function(a){b[d].d&&(i||(i=1,l()),o=a[1],setTimeout(c,10),g(a[0],function(a){e(a)}))}})}var d=a.channel,e=e||a.callback,o=0,k=a.error||n(),i=0,l=a.connect||n();if(!D)return I.push([a,e,m]);if(!d)return j("Missing Channel");if(!e)return j("Missing Callback");if(!y)return j("Missing Subscribe Key");d in b||(b[d]={});if(b[d].d)return j("Already Connected");b[d].d=1;c()},each:g,map:p,css:r,$:c,create:s,bind:d,supplant:l,head:k,search:B,attr:i,now:q,events:z,updater:x,init:u};return m}function q(){return"x"+
-++M+""+ +new Date}function x(a,b){function e(){d+b>+new Date?(clearTimeout(c),c=setTimeout(e,b)):(d=+new Date,a())}var c,d=0;return e}function c(a){return document.getElementById(a)}function j(a){console.log(a)}function B(a,b){var e=[];g(a.split(/\s+/),function(a){g((b||document).getElementsByTagName(a),function(a){e.push(a)})});return e}function g(a,b){if(a&&b)if(typeof a[0]!="undefined")for(var e=0,c=a.length;e<c;)b.call(a[e],a[e],e++);else for(e in a)a.hasOwnProperty&&a.hasOwnProperty(e)&&b.call(a[e],
-e,a[e])}function p(a,b){var e=[];g(a||[],function(a,c){e.push(b(a,c))});return e}function l(a,b){return a.replace(N,function(a,c){return b[c]||a})}function d(a,b,e){g(a.split(","),function(a){function c(a){if(!a)a=window.event;if(!e(a))a.cancelBubble=true,a.returnValue=false,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation()}b.addEventListener?b.addEventListener(a,c,false):b.attachEvent?b.attachEvent("on"+a,c):b["on"+a]=c})}function k(){return B("head")[0]}function i(a,b,
-c){if(c)a.setAttribute(b,c);else return a&&a.getAttribute&&a.getAttribute(b)}function r(a,b){for(var c in b)if(b.hasOwnProperty(c))try{a.style[c]=b[c]+("|width|height|top|left|".indexOf(c)>0&&typeof b[c]=="number"?"px":"")}catch(d){}}function s(a){return document.createElement(a)}function h(){return E||m()?0:q()}function f(a){return p(encodeURIComponent(a).split(""),function(a){return"-_.!~*'()".indexOf(a)<0?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")}function t(a){function b(a,b){if(!g)g=
-1,a||l(b),e.onerror=null,clearTimeout(h),setTimeout(function(){a&&j();var b=c(f),e=b&&b.parentNode;e&&e.removeChild(b)},1E3)}if(E||m())return O(a);var e=s("script"),d=a.c,f=q(),g=0,h=setTimeout(function(){b(1)},F),j=a.a||n(),l=a.b||n();window[d]=function(a){b(0,a)};e[J]=J;e.onerror=function(){b(1)};e.src=a.url.join(K);i(e,"id",f);k().appendChild(e);return b}function O(a){function b(a){if(!f){f=1;clearTimeout(h);if(d)d.onerror=d.onload=null,d.abort&&d.abort(),d=null;a&&i()}}function c(){if(!g){g=1;
-clearTimeout(h);try{response=JSON.parse(d.responseText)}catch(a){return b(1)}j(response)}}var d,f=0,g=0,h=setTimeout(function(){b(1)},F),i=a.a||n(),j=a.b||n();try{d=m()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest,d.onerror=function(){b(1)},d.onload=c,d.timeout=F,d.open("GET",a.url.join(K),true),d.send()}catch(k){return b(0),E=0,t(a)}return b}function G(){clearInterval(P);D||(D=1,g(I,function(a){a[2].subscribe(a[0],a[1])}))}function m(){if(!H.get)return 0;var a={id:m.id++,send:n(),
-abort:function(){a.id={}},open:function(b,c){m[a.id]=a;H.get(a.id,c)}};return a}window.console||(window.console=window.console||{});console.log||(console.log=(window.opera||{}).postError||n());var M=1,N=/{([\w\-]+)}/g,J="async",K="/",F=14E4,A=navigator.userAgent,E=A.indexOf("MSIE 6")==-1,z={list:{},unbind:function(a){z.list[a]=[]},bind:function(a,b){(z.list[a]=z.list[a]||[]).push(b)},fire:function(a,b){g(z.list[a]||[],function(a){a(b)})}},w=c("pubnub")||{},D=0,I=[],C=u({publish_key:i(w,"pub-key"),
-subscribe_key:i(w,"sub-key"),ssl:i(w,"ssl")=="on",origin:i(w,"origin")}),L=!location.href.indexOf("https")?"https://dh15atwfs066y.cloudfront.net/pubnub.swf":"http://cdn.pubnub.com/pubnub.swf";r(w,{position:"absolute",top:-1E3});A.indexOf("Firefox")>0||A.indexOf("MSIE 9")>0||A.indexOf("WebKit")>0||A.indexOf("MSIE 6")>0||(w.innerHTML="<object id=pubnubs type=application/x-shockwave-flash width=1 height=1 data="+L+"><param name=movie value="+L+" /><param name=allowscriptaccess value=always /></object>");
-var H=c("pubnubs")||{},P=setInterval(function(){!("chrome"in window)&&H.get&&G()},100);d("load",window,function(){setTimeout(G,1E3)});C.rdx=function(a,b){if(!b)return m[a].onerror();m[a].responseText=unescape(b);m[a].onload()};m.id=1E3;window.jQuery&&(window.jQuery.PUBNUB=C);window.PUBNUB=C;typeof module!=="undefined"&&(module.f=C)&&G()}();
+function q(){return function(){}}
+window.JSON&&window.JSON.stringify||function(){function y(c){l.lastIndex=0;return l.test(c)?'"'+c.replace(l,function(c){var g=f[c];return typeof g==="string"?g:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+c+'"'}function u(c,f){var g,h,n,k,l=i,m,e=f[c];e&&typeof e==="object"&&typeof e.toJSON==="function"&&(e=e.toJSON(c));typeof o==="function"&&(e=o.call(f,c,e));switch(typeof e){case "string":return y(e);case "number":return isFinite(e)?String(e):"null";case "boolean":case "null":return String(e);
+case "object":if(!e)return"null";i+=t;m=[];if(Object.prototype.toString.apply(e)==="[object Array]"){k=e.length;for(g=0;g<k;g+=1)m[g]=u(g,e)||"null";n=m.length===0?"[]":i?"[\n"+i+m.join(",\n"+i)+"\n"+l+"]":"["+m.join(",")+"]";i=l;return n}if(o&&typeof o==="object"){k=o.length;for(g=0;g<k;g+=1)h=o[g],typeof h==="string"&&(n=u(h,e))&&m.push(y(h)+(i?": ":":")+n)}else for(h in e)Object.hasOwnProperty.call(e,h)&&(n=u(h,e))&&m.push(y(h)+(i?": ":":")+n);n=m.length===0?"{}":i?"{\n"+i+m.join(",\n"+i)+"\n"+
+l+"}":"{"+m.join(",")+"}";i=l;return n}}window.JSON||(window.JSON={});if(typeof String.prototype.toJSON!=="function")String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var l=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,i,t,f={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},o;typeof JSON.stringify!=="function"&&(JSON.stringify=function(c,
+f,g){var h;t=i="";if(typeof g==="number")for(h=0;h<g;h+=1)t+=" ";else typeof g==="string"&&(t=g);if((o=f)&&typeof f!=="function"&&(typeof f!=="object"||typeof f.length!=="number"))throw Error("JSON.stringify");return u("",{"":c})});typeof JSON.parse!=="function"&&(JSON.parse=function(c){return eval("("+c+")")})}();
+window.PUBNUB||function(){function y(a){var b={},d=a.publish_key||"demo",r=a.subscribe_key||"demo",s=a.ssl?"s":"",v="http"+s+"://"+(a.origin||"pubsub.pubnub.com"),p={history:function(a,b){var b=a.callback||b,d=a.limit||100,j=a.channel,c=e();if(!j)return f("Missing Channel");if(!b)return f("Missing Callback");w({c:c,url:[v,"history",r,z(j),c,d],b:function(a){b(a)},a:function(a){f(a)}})},time:function(a){var b=e();w({c:b,url:[v,"time",b],b:function(b){a(b[0])},a:function(){a(0)}})},uuid:function(a){var b=
+e();w({c:b,url:["http"+s+"://pubnub-prod.appspot.com/uuid?callback="+b],b:function(b){a(b[0])},a:function(){a(0)}})},analytics:function(a){var b=e(),c=a.limit||100,j=a.ago||0,f=a.duration||100,v=a.callback;w({c:b,b:function(a){v(a)},a:function(){v(0)},url:[["http"+s+"://pubnub-prod.appspot.com/analytics-channel?callback="+b,"sub-key="+r,"pub-key="+d,"channel="+z(a.channel||""),"limit="+c,"ago="+j,"duration="+f].join("&")]})},publish:function(a,b){var b=b||a.callback||q(),c=a.message,j=a.channel,s=
+e();if(!c)return f("Missing Message");if(!j)return f("Missing Channel");if(!d)return f("Missing Publish Key");c=JSON.stringify(c);c=[v,"publish",d,r,0,z(j),s,z(c)];if(c.join().length>1800)return f("Message Too Big");w({c:s,b:function(a){b(a)},a:function(){b([0,"Disconnected"])},url:c})},unsubscribe:function(a){a=a.channel;if(a in b)b[a].d=0,b[a].e&&b[a].e(0)},subscribe:function(a,d){function s(){var a=e();if(b[j].d)b[j].e=w({c:a,url:[o,"subscribe",r,z(j),a,h],a:function(){k||(k=1,m());setTimeout(s,
+A)},b:function(a){b[j].d&&(n||(n=1,i()),k&&(k=0,l()),g=C.set(r+j,h=g&&C.get(r+j)||a[1]),c(a[0],function(b){d(b,a)}),setTimeout(s,10))}})}var j=a.channel,d=d||a.callback,g=a.restore,h=0,i=a.connect||q(),l=a.reconnect||q(),m=a.error||a.disconnect||q(),k=0,n=0,o=N(v);if(!D)return I.push([a,d,p]);if(!j)return f("Missing Channel");if(!d)return f("Missing Callback");if(!r)return f("Missing Subscribe Key");j in b||(b[j]={});if(b[j].d)return f("Already Connected");b[j].d=1;s()},db:C,each:c,map:G,css:H,$:t,
+create:m,bind:h,supplant:g,head:n,search:o,attr:k,now:l,unique:u,events:B,updater:i,init:y};return p}function u(){return"x"+ ++O+""+ +new Date}function l(){return+new Date}function i(a,b){function d(){c+b>l()?(clearTimeout(r),r=setTimeout(d,b)):(c=l(),a())}var r,c=0;return d}function t(a){return document.getElementById(a)}function f(a){console.log(a)}function o(a,b){var d=[];c(a.split(/\s+/),function(a){c((b||document).getElementsByTagName(a),function(a){d.push(a)})});return d}function c(a,b){if(a&&
+b)if(typeof a[0]!="undefined")for(var d=0,c=a.length;d<c;)b.call(a[d],a[d],d++);else for(d in a)a.hasOwnProperty&&a.hasOwnProperty(d)&&b.call(a[d],d,a[d])}function G(a,b){var d=[];c(a||[],function(a,c){d.push(b(a,c))});return d}function g(a,b){return a.replace(P,function(a,c){return b[c]||a})}function h(a,b,d){c(a.split(","),function(a){function c(a){if(!a)a=window.event;if(!d(a))a.cancelBubble=true,a.returnValue=false,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation()}b.addEventListener?
+b.addEventListener(a,c,false):b.attachEvent?b.attachEvent("on"+a,c):b["on"+a]=c})}function n(){return o("head")[0]}function k(a,b,d){if(d)a.setAttribute(b,d);else return a&&a.getAttribute&&a.getAttribute(b)}function H(a,b){for(var d in b)if(b.hasOwnProperty(d))try{a.style[d]=b[d]+("|width|height|top|left|".indexOf(d)>0&&typeof b[d]=="number"?"px":"")}catch(c){}}function m(a){return document.createElement(a)}function e(){return E||p()?0:u()}function z(a){return G(encodeURIComponent(a).split(""),function(a){return"-_.!~*'()".indexOf(a)<
+0?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")}function w(a){function b(a,b){if(!f)f=1,a||i(b),d.onerror=null,clearTimeout(g),setTimeout(function(){a&&h();var b=t(e),d=b&&b.parentNode;d&&d.removeChild(b)},A)}if(E||p())return Q(a);var d=m("script"),c=a.c,e=u(),f=0,g=setTimeout(function(){b(1)},F),h=a.a||q(),i=a.b||q();window[c]=function(a){b(0,a)};d[J]=J;d.onerror=function(){b(1)};d.src=a.url.join(K);k(d,"id",e);n().appendChild(d);return b}function Q(a){function b(a){if(!e){e=1;clearTimeout(g);
+if(c)c.onerror=c.onload=null,c.abort&&c.abort(),c=null;a&&h()}}function d(){if(!f){f=1;clearTimeout(g);try{response=JSON.parse(c.responseText)}catch(a){return b(1)}i(response)}}var c,e=0,f=0,g=setTimeout(function(){b(1)},F),h=a.a||q(),i=a.b||q();try{c=p()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest,c.onerror=c.onabort=function(){b(1)},c.onload=c.onloadend=d,c.timeout=F,c.open("GET",a.url.join(K),true),c.send()}catch(k){return b(0),E=0,w(a)}return b}function L(){PUBNUB.time(l);PUBNUB.time(function(){setTimeout(function(){D||
+(D=1,c(I,function(a){a[2].subscribe(a[0],a[1])}))},A)})}function p(){if(!M.get)return 0;var a={id:p.id++,send:q(),abort:function(){a.id={}},open:function(b,c){p[a.id]=a;M.get(a.id,c)}};return a}window.console||(window.console=window.console||{});console.log||(console.log=(window.opera||{}).postError||q());var C=function(){var a=window.localStorage;return{get:function(b){return a?a.getItem(b):document.cookie.indexOf(b)==-1?null:((document.cookie||"").match(RegExp(b+"=([^;]+)"))||[])[1]||null},set:function(b,
+c){if(a)return a.setItem(b,c)&&0;document.cookie=b+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}}}(),O=1,P=/{([\w\-]+)}/g,J="async",K="/",F=14E4,A=1E3,E=navigator.userAgent.indexOf("MSIE 6")==-1,N=function(){var a=Math.floor(Math.random()*9)+1;return function(b){return b.indexOf("pubsub")>0&&b.replace("pubsub","ps"+(++a<10?a:a=1))||b}}(),B={list:{},unbind:function(a){B.list[a]=[]},bind:function(a,b){(B.list[a]=B.list[a]||[]).push(b)},fire:function(a,b){c(B.list[a]||[],function(a){a(b)})}},
+x=t("pubnub")||{},D=0,I=[];PUBNUB=y({publish_key:k(x,"pub-key"),subscribe_key:k(x,"sub-key"),ssl:k(x,"ssl")=="on",origin:k(x,"origin")});H(x,{position:"absolute",top:-A});if("opera"in window||k(x,"flash"))x.innerHTML="<object id=pubnubs type=application/x-shockwave-flash width=1 height=1 data=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=movie value=https://dh15atwfs066y.cloudfront.net/pubnub.swf /><param name=allowscriptaccess value=always /></object>";var M=t("pubnubs")||{};h("load",
+window,function(){setTimeout(L,0)});PUBNUB.rdx=function(a,b){if(!b)return p[a].onerror();p[a].responseText=unescape(b);p[a].onload()};p.id=A;window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);typeof module!=="undefined"&&(module.f=PUBNUB)&&L()}();
(function(){
"use strict";var sjcl=window['sjcl']={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
sjcl.cipher.aes=function(a){this.h[0][0][0]||this.w();var b,c,d,e,f=this.h[0][4],g=this.h[1];b=a.length;var h=1;if(b!==4&&b!==6&&b!==8)throw new sjcl.exception.invalid("invalid aes key size");this.a=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(a%b===0||b===8&&a%b===4){c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255];if(a%b===0){c=c<<8^c>>>24^h<<24;h=h<<1^(h>>7)*283}}d[a]=d[a-b]^c}for(b=0;a;b++,a--){c=d[b&3?a:a-4];e[b]=a<=4||b<4?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^
BIN  socket.io/socket.io.min.js.gz
View
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.