Updated pubnub to 3.4.6

This commit is contained in:
Drew Freyling
2013-05-21 13:28:56 +10:00
parent 1c0927e30e
commit aa90a49abe
3 changed files with 1440 additions and 1 deletions
File diff suppressed because it is too large Load Diff
+31
View File
@@ -0,0 +1,31 @@
// Version: 3.4.6
(function(){
var m=null,q=!1;function s(){return function(){}}
window.JSON&&window.JSON.stringify||function(){function a(){try{return this.valueOf()}catch(a){return m}}function c(a){d.lastIndex=0;return d.test(a)?'"'+a.replace(d,function(a){var b=u[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function b(d,F){var i,k,j,l,h,r=e,g=F[d];g&&"object"===typeof g&&(g=a.call(g));"function"===typeof f&&(g=f.call(F,d,g));switch(typeof g){case "string":return c(g);case "number":return isFinite(g)?String(g):"null";case "boolean":case "null":return String(g);
case "object":if(!g)return"null";e+=p;h=[];if("[object Array]"===Object.prototype.toString.apply(g)){l=g.length;for(i=0;i<l;i+=1)h[i]=b(i,g)||"null";j=0===h.length?"[]":e?"[\n"+e+h.join(",\n"+e)+"\n"+r+"]":"["+h.join(",")+"]";e=r;return j}if(f&&"object"===typeof f){l=f.length;for(i=0;i<l;i+=1)k=f[i],"string"===typeof k&&(j=b(k,g))&&h.push(c(k)+(e?": ":":")+j)}else for(k in g)Object.hasOwnProperty.call(g,k)&&(j=b(k,g))&&h.push(c(k)+(e?": ":":")+j);j=0===h.length?"{}":e?"{\n"+e+h.join(",\n"+e)+"\n"+
r+"}":"{"+h.join(",")+"}";e=r;return j}}window.JSON||(window.JSON={});var d=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,p,u={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},f;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,c,d){var k;p=e="";if("number"===typeof d)for(k=0;k<d;k+=1)p+=" ";else"string"===typeof d&&(p=d);if((f=c)&&"function"!==typeof c&&("object"!==typeof c||"number"!==
typeof c.length))throw Error("JSON.stringify");return b("",{"":a})});"function"!==typeof JSON.parse&&(JSON.parse=function(a){return eval("("+a+")")})}();var aa=1,v=q,ba=[],y=1E3,da="/",ea="&",fa=/{([\w\-]+)}/g;function B(){return"x"+ ++aa+""+ +new Date}function C(){return+new Date}var E,G=Math.floor(20*Math.random());E=function(a,c){return 0<a.indexOf("pubsub.")&&a.replace("pubsub","ps"+(c?ga().split("-")[0]:20>++G?G:G=1))||a};
function ha(a,c){var b=a.join(da),d=[];if(!c)return b;K(c,function(a,b){d.push(a+"="+L(b))});return b+="?"+d.join(ea)}function ia(a,c){function b(){e+c>C()?(clearTimeout(d),d=setTimeout(b,c)):(e=C(),a())}var d,e=0;return b}function ja(a,c){var b=[];K(a||[],function(a){c(a)&&b.push(a)});return b}function ka(a,c){return a.replace(fa,function(a,d){return c[d]||a})}
function ga(a){var c="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var c=16*Math.random()|0;return("x"==a?c:c&3|8).toString(16)});a&&a(c);return c}function K(a,c){if(a&&c)if("undefined"!=typeof a[0])for(var b=0,d=a.length;b<d;)c.call(a[b],a[b],b++);else for(b in a)a.hasOwnProperty&&a.hasOwnProperty(b)&&c.call(a[b],b,a[b])}function O(a,c){var b=[];K(a||[],function(a,e){b.push(c(a,e))});return b}
function L(a){return O(encodeURIComponent(a).split(""),function(a){return 0>"-_.!~*'()".indexOf(a)?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")}function la(a){var c=[];K(a,function(a,d){d.g&&c.push(a)});return c.sort()}function P(){setTimeout(function(){v||(v=1,K(ba,function(a){a()}))},y)}
if(!window.PUBNUB){var Q=function(a){return document.getElementById(a)},ma=function(a){console.error(a)},na=function(a,c){var b=[];K(a.split(/\s+/),function(a){K((c||document).getElementsByTagName(a),function(a){b.push(a)})});return b},S=function(a,c,b){K(a.split(","),function(a){function e(a){a||(a=window.event);b(a)||(a.cancelBubble=!0,a.returnValue=q,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation())}c.addEventListener?c.addEventListener(a,e,q):c.attachEvent?c.attachEvent("on"+
a,e):c["on"+a]=e})},oa=function(){return na("head")[0]},T=function(a,c,b){if(b)a.setAttribute(c,b);else return a&&a.getAttribute&&a.getAttribute(c)},qa=function(a,c){for(var b in c)if(c.hasOwnProperty(b))try{a.style[b]=c[b]+(0<"|width|height|top|left|".indexOf(b)&&"number"==typeof c[b]?"px":"")}catch(d){}},ra=function(a){return document.createElement(a)},sa=function(){return U||W()?0:B()},ua=function(a){function c(a,b){M||(M=1,a||N(b),g.onerror=m,clearTimeout(V),setTimeout(function(){a&&w();var b=
Q(t),c=b&&b.parentNode;c&&c.removeChild(b)},y))}if(U||W()){a:{var b,d,e=function(){if(!u){u=1;clearTimeout(R);try{d=JSON.parse(b.responseText)}catch(a){return l(1)}k(d)}},p=0,u=0,f=a.timeout||1E4,R=setTimeout(function(){l(1)},f),F=a.b||s(),i=a.data||{},k=a.c||s(),j="undefined"===typeof a.h,l=function(a){p||(p=1,clearTimeout(R),b&&(b.onerror=b.onload=m,b.abort&&b.abort(),b=m),a&&F())};try{b=W()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest;b.onerror=b.onabort=function(){l(1)};b.onload=
b.onloadend=e;j&&(b.timeout=f);i.pnsdk=ta;var h=ha(a.url,i);b.open("GET",h,j);b.send()}catch(r){l(0);U=0;a=ua(a);break a}a=l}return a}var g=ra("script"),e=a.a,t=B(),M=0,V=setTimeout(function(){c(1)},a.timeout||1E4),w=a.b||s(),f=a.data||{},N=a.c||s();window[e]=function(a){c(0,a)};a.h||(g[va]=va);g.onerror=function(){c(1)};f.pnsdk=ta;g.src=ha(a.url,f);T(g,"id",t);oa().appendChild(g);return c},wa=function(){return!("onLine"in navigator)?1:navigator.onLine},W=function(){if(!xa||!xa.get)return 0;var a=
{id:W.id++,send:s(),abort:function(){a.id={}},open:function(c,b){W[a.id]=a;xa.get(a.id,b)}};return a},va="async",ta="PubNub-JS-Web/3.4.6",U=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.log||(console.log=console.error=(window.opera||{}).postError||s());var ya,X=window.localStorage;ya={get:function(a){try{return X?X.getItem(a):-1==document.cookie.indexOf(a)?m:((document.cookie||"").match(RegExp(a+"=([^;]+)"))||[])[1]||m}catch(c){}},set:function(a,
c){try{if(X)return X.setItem(a,c)&&0;document.cookie=a+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}catch(b){}}};var Y={list:{},unbind:function(a){Y.list[a]=[]},bind:function(a,c){(Y.list[a]=Y.list[a]||[]).push(c)},fire:function(a,c){K(Y.list[a]||[],function(a){a(c)})}},Z=Q("pubnub")||0,za=function(a){function c(){}function b(){x.time(function(a){if(!a)for(;w.length;)w.shift()();setTimeout(b,i)})}function d(){if(!ca())for(;w.length;)w.shift()();setTimeout(d,y)}function e(a){K(la(z),function(b){(b=
z[b])&&a(b)})}function p(a){a&&(t.i=0);!t.i&&t.length&&(t.i=1,A(t.shift()))}a.jsonp&&(U=0);var u=a.subscribe_key||"";a.uuid||ya.get(u+"uuid");a.xdr=ua;a.db=ya;a.error=ma;a._is_online=wa;a.jsonp_cb=sa;var f,R=+a.windowing||10,F=(+a.timeout||310)*y,i=(+a.keepalive||60)*y,k=a.publish_key||"",j=a.subscribe_key||"",l=a.ssl?"s":"",h="http"+l+"://"+(a.origin||"pubsub.pubnub.com"),r=E(h),g=E(h),t=[],M=0,V=0,w=[],N=0,H=0,z={},A=a.xdr,n=a.error||s(),ca=a._is_online||function(){return 1},D=a.jsonp_cb||function(){return 0},
I=a.db||{get:s(),set:s()},J=a.uuid||I&&I.get(j+"uuid")||"",x={LEAVE:function(a,b){var c={uuid:J},d=E(h),e=D();0<a.indexOf("-pnpres")||("0"!=e&&(c.callback=e),A({h:b||l,timeout:2E3,a:e,data:c,url:[d,"v2","presence","sub_key",j,"channel",L(a),"leave"]}))},history:function(a,b){var b=a.callback||b,c=a.count||a.limit||100,d=a.reverse||"false",e=a.error||s(),f=a.channel,g=a.start,k=a.end,h={},i=D();if(!f)return n("Missing Channel");if(!b)return n("Missing Callback");if(!j)return n("Missing Subscribe Key");
h.stringtoken="true";h.count=c;h.reverse=d;i&&(h.callback=i);g&&(h.start=g);k&&(h.end=k);A({a:i,data:h,c:function(a){b(a)},b:e,url:[r,"v2","history","sub-key",j,"channel",L(f)]})},replay:function(a){var b=b||a.callback||s(),c=a.source,d=a.destination,e=a.stop,f=a.start,g=a.end,h=a.reverse,a=a.limit,i=D(),l={};if(!c)return n("Missing Source Channel");if(!d)return n("Missing Destination Channel");if(!k)return n("Missing Publish Key");if(!j)return n("Missing Subscribe Key");"0"!=i&&(l.callback=i);e&&
(l.stop="all");h&&(l.reverse="true");f&&(l.start=f);g&&(l.end=g);a&&(l.count=a);A({a:i,c:function(a){b(a)},b:function(){b([0,"Disconnected"])},url:[r,"v1","replay",k,j,c,d],data:l})},time:function(a){var b=D();A({a:b,timeout:5*y,url:[r,"time",b],c:function(b){a(b[0])},b:function(){a(0)}})},publish:function(a,b){var b=b||a.callback||s(),c=a.message,d=a.channel,e=D();if(!c)return n("Missing Message");if(!d)return n("Missing Channel");if(!k)return n("Missing Publish Key");if(!j)return n("Missing Subscribe Key");
c=JSON.stringify(c);d=[r,"publish",k,j,0,L(d),e,L(c)];t.push({a:e,timeout:5*y,url:d,data:{uuid:J},c:function(a){b(a);p(1)},b:function(){b([0,"Failed",c]);p(1)}});p()},unsubscribe:function(a){a=a.channel;H=0;N=1;a=O((a.join?a.join(","):""+a).split(","),function(a){return a+","+a+"-pnpres"}).join(",");K(a.split(","),function(a){v&&x.LEAVE(a,0);z[a]=0});v&&c()},subscribe:function(a,b){function d(a){a?setTimeout(c,y):(r=E(h,1),g=E(h,1),setTimeout(function(){x.time(d)},y));e(function(b){if(a&&b.d)return b.d=
0,b.m(b.name);!a&&!b.d&&(b.d=1,b.l(b.name))})}var f=a.channel,b=(b=b||a.callback)||a.message,i=a.connect||s(),k=a.reconnect||s(),l=a.disconnect||s(),p=a.presence||0,t=a.noheresync||0,u=a.backfill||0,ca=a.timeout||F,pa=a.windowing||R;N=a.restore;H=0;if(!f)return n("Missing Channel");if(!b)return n("Missing Callback");if(!j)return n("Missing Subscribe Key");K((f.join?f.join(","):""+f).split(","),function(a){var c=z[a]||{};z[V=a]={name:a,f:c.f,d:c.d,g:1,a:M=b,k:i,l:l,m:k};p&&(x.subscribe({channel:a+
"-pnpres",callback:p}),!c.g&&!t&&x.here_now({channel:a,callback:function(b){K("uuids"in b?b.uuids:[],function(c){p({action:"join",uuid:c,timestamp:C(),occupancy:b.occupancy||1},b,a)})}}))});c=function(){for(;w.length;)w.shift()();var a=D(),b=la(z).join(",");b&&w.push(A({timeout:ca,a:a,b:function(){x.time(d)},data:{uuid:J},url:[g,"subscribe",j,L(b),a,H],c:function(a){if(!a)return setTimeout(c,pa);e(function(a){a.f||(a.f=1,a.k(a.name))});H=!H&&N&&I.get(j)||a[1];u&&(H=1E4,u=0);I.set(j,a[1]);var b,d=
(2<a.length?a[2]:"").split(",");b=function(){var a=d.shift()||"";return[(z[a]||{}).a||M,(a||V).split("-pnpres")[0]]};K(a[0],function(c){var d=b();if(z[d[1]].g)d[0](c,a,d[1])});setTimeout(c,pa)}}))};if(!v)return ba.push(c);c()},here_now:function(a,b){var b=a.callback||b,c=a.error||s(),d=a.channel,e=D(),f=m;if(!d)return n("Missing Channel");if(!b)return n("Missing Callback");if(!j)return n("Missing Subscribe Key");"0"!=e&&(f={},f.callback=e);A({a:e,data:f,c:function(a){b(a)},b:c,url:[r,"v2","presence",
"sub_key",j,"channel",L(d)]})},xdr:A,ready:P,db:I,uuid:ga,map:O,each:K,"each-channel":e,grep:ja,supplant:ka,now:C,unique:B,updater:ia};J||(J=x.uuid());I.set(j+"uuid",J);setTimeout(d,y);setTimeout(b,i);x.time(s());f=x;f.css=qa;f.$=Q;f.create=ra;f.bind=S;f.head=oa;f.search=na;f.attr=T;f.events=Y;f.init=za;S("beforeunload",window,function(){f["each-channel"](function(a){f.LEAVE(a.name,1)});return!0});if(a.notest)return f;S("offline",window,f._reset_offline);S("offline",document,f._reset_offline);return f};
S("load",window,function(){setTimeout(P,0)});var $=Z||{};PUBNUB=za({notest:1,publish_key:T($,"pub-key"),subscribe_key:T($,"sub-key"),ssl:!document.location.href.indexOf("https")||"on"==T($,"ssl"),origin:T($,"origin"),uuid:T($,"uuid")});window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);"undefined"!==typeof module&&(module.exports=PUBNUB)&&P();var xa=Q("pubnubs")||0;if(Z){qa(Z,{position:"absolute",top:-y});if("opera"in window||T(Z,"flash"))Z.innerHTML="<object id=pubnubs data=https://pubnub.a.ssl.fastly.net/pubnub.swf><param name=movie value=https://pubnub.a.ssl.fastly.net/pubnub.swf><param name=allowscriptaccess value=always></object>";
PUBNUB.rdx=function(a,c){if(!c)return W[a].onerror();W[a].responseText=unescape(c);W[a].onload()};W.id=y}}
var Aa=PUBNUB.ws=function(a,c){if(!(this instanceof Aa))return new Aa(a,c);var b=this,a=b.url=a||"";b.protocol=c||"Sec-WebSocket-Protocol";var d=a.split("/"),d={ssl:"wss:"===d[0],origin:d[2],publish_key:d[3],subscribe_key:d[4],channel:d[5]};b.CONNECTING=0;b.OPEN=1;b.CLOSING=2;b.CLOSED=3;b.CLOSE_NORMAL=1E3;b.CLOSE_GOING_AWAY=1001;b.CLOSE_PROTOCOL_ERROR=1002;b.CLOSE_UNSUPPORTED=1003;b.CLOSE_TOO_LARGE=1004;b.CLOSE_NO_STATUS=1005;b.CLOSE_ABNORMAL=1006;b.onclose=b.onerror=b.onmessage=b.onopen=b.onsend=
s();b.binaryType="";b.extensions="";b.bufferedAmount=0;b.trasnmitting=q;b.buffer=[];b.readyState=b.CONNECTING;if(!a)return b.readyState=b.CLOSED,b.onclose({code:b.CLOSE_ABNORMAL,reason:"Missing URL",wasClean:!0}),b;b.e=PUBNUB.init(d);b.e.j=d;b.j=d;b.e.subscribe({restore:q,channel:d.channel,disconnect:b.onerror,reconnect:b.onopen,error:function(){b.onclose({code:b.CLOSE_ABNORMAL,reason:"Missing URL",wasClean:q})},callback:function(a){b.onmessage({data:a})},connect:function(){b.readyState=b.OPEN;b.onopen()}})};
Aa.prototype.send=function(a){var c=this;c.e.publish({channel:c.e.j.channel,message:a,callback:function(a){c.onsend({data:a})}})};
})();
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "pubnub",
"filename": "pubnub.min.js",
"version": "3.4.5",
"version": "3.4.6",
"description": "PubNub, a new kind of Cloud-Hosted Broadcasting Service for Mass Communication.",
"homepage": "http://www.pubnub.com/",
"keywords": [