Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

restored console log compatibility layer to provide support to non-co…

…nsole enabled browsers.
  • Loading branch information...
commit bffbc8a99d9c2cf9f45c198acaa3b15fe6314442 1 parent c2fc18f
@stephenlb stephenlb authored
View
8 javascript/3.4/pubnub-3.4.js
@@ -57,8 +57,12 @@ var NOW = 1
/**
* CONSOLE COMPATIBILITY
*/
-window.console||(window.console=window.console||{});
-console.error||(console.error=((window.opera||{}).postError||function(){}));
+window.console || (window.console=window.console||{});
+console.log || (
+ console.log =
+ console.error =
+ ((window.opera||{}).postError||function(){})
+);
/**
* UTILITIES
View
8 javascript/3.4/pubnub-3.4.min.js
@@ -10,10 +10,10 @@ c.addEventListener?c.addEventListener(a,f,!1):c.attachEvent?c.attachEvent("on"+a
function(a){return 0>"-_.!~*'()".indexOf(a)?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")},N=function(a){function c(a,b){V||(V=1,a||la(b),d.onerror=null,clearTimeout(ma),setTimeout(function(){a&&na();var b=s(u),c=b&&b.parentNode;c&&c.removeChild(b)},J))}if(F||G()){a:{var b,e,f=function(){if(!q){q=1;clearTimeout(B);try{e=JSON.parse(b.responseText)}catch(a){return h(1)}l(e)}},j=0,q=0,x=a.timeout||K,B=setTimeout(function(){h(1)},x),i=a.b||n(),l=a.c||n(),h=function(a){j||(j=1,clearTimeout(B),
b&&(b.onerror=b.onload=null,b.abort&&b.abort(),b=null),a&&i())};try{b=G()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest;b.onerror=b.onabort=function(){h(1)};b.onload=b.onloadend=f;b.timeout=x;var g=a.url.join(L);if(a.data){var f=[],m,g=g+"?";for(m in a.data)f.push(m+"="+a.data[m]);g+=f.join(M)}b.open("GET",g,typeof("undefined"===a.g));b.send()}catch(k){h(0);F=0;a=N(a);break a}a=h}return a}var d=E("script"),g=a.a,u=p(),V=0,ma=setTimeout(function(){c(1)},a.timeout||K),na=a.b||n(),la=
a.c||n();window[g]=function(a){c(0,a)};a.g||(d[O]=O);d.onerror=function(){c(1)};d.src=a.url.join(L);if(a.data){g=[];d.src+="?";for(key in a.data)g.push(key+"="+a.data[key]);d.src+=g.join(M)}C(d,"id",u);A().appendChild(d);return c},P=function(a){var c=[];v(a,function(a,e){e.f&&c.push(a)});return c.sort()},S=function(){PUBNUB.time(r);PUBNUB.time(function(){setTimeout(function(){R||(R=1,v(ga,function(a){a()}))},J)})},G=function(){if(!ha.get)return 0;var a={id:G.id++,send:n(),abort:function(){a.id={}},
-open:function(c,b){G[a.id]=a;ha.get(a.id,b)}};return a},aa=1,ea=/{([\w\-]+)}/g,O="async",L="/",M="&",ia=31E4,K=1E4,J=1E3,T="-pnpres",F=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.error||(console.error=(window.opera||{}).postError||n());var U,W=window.localStorage;U={get:function(a){try{return W?W.getItem(a):-1==document.cookie.indexOf(a)?null:((document.cookie||"").match(RegExp(a+"=([^;]+)"))||[])[1]||null}catch(c){}},set:function(a,c){try{if(W)return W.setItem(a,
-c)&&0;document.cookie=a+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}catch(b){}}};var X,Y=Math.floor(20*Math.random());X=function(a){return 0<a.indexOf("pubsub")&&a.replace("pubsub","ps"+(20>++Y?Y:Y=1))||a};var Z={list:{},unbind:function(a){Z.list[a]=[]},bind:function(a,c){(Z.list[a]=Z.list[a]||[]).push(c)},fire:function(a,c){v(Z.list[a]||[],function(a){a(c)})}},$=s("pubnub")||{},R=0,ga=[],qa=function(a){function c(){}function b(){}function e(a){v(P(f),function(b){a(f[b]||{})})}var f={},
-j=0,q=0,x=0,B=0,i=0,l=0,h=a.publish_key||"",g=a.subscribe_key||"",m=a.ssl?"s":"",k=a.uuid||U.get(g+"uuid")||"",d="http"+m+"://"+(a.origin||"pubsub.pubnub.com"),u={history:function(a,b){var b=a.callback||b,c=a.count||a.limit||100,e=a.reverse||"false",f=a.error||n(),i=a.channel,k=a.start,h=a.end,j={},l=H();if(!i)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");j.count=c;j.reverse=e;k&&(j.start=k);h&&(j.end=h);N({a:l,data:j,c:function(a){b(a)},b:f,
-url:[d,"v2","history","sub-key",g,"channel",I(i)]})},time:function(a){var b=H(),c=X(d);N({a:b,url:[c,"time",b],c:function(b){a(b[0])},b:function(){a(0)}})},uuid:function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)});a&&a(b);return b},publish:function(a,b){var b=b||a.callback||n(),c=a.message,e=a.channel,f=H();if(!c)return t("Missing Message");if(!e)return t("Missing Channel");if(!h)return t("Missing Publish Key");
+open:function(c,b){G[a.id]=a;ha.get(a.id,b)}};return a},aa=1,ea=/{([\w\-]+)}/g,O="async",L="/",M="&",ia=31E4,K=1E4,J=1E3,T="-pnpres",F=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.log||(console.log=console.error=(window.opera||{}).postError||n());var U,W=window.localStorage;U={get:function(a){try{return W?W.getItem(a):-1==document.cookie.indexOf(a)?null:((document.cookie||"").match(RegExp(a+"=([^;]+)"))||[])[1]||null}catch(c){}},set:function(a,
+c){try{if(W)return W.setItem(a,c)&&0;document.cookie=a+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}catch(b){}}};var X,Y=Math.floor(20*Math.random());X=function(a){return 0<a.indexOf("pubsub")&&a.replace("pubsub","ps"+(20>++Y?Y:Y=1))||a};var Z={list:{},unbind:function(a){Z.list[a]=[]},bind:function(a,c){(Z.list[a]=Z.list[a]||[]).push(c)},fire:function(a,c){v(Z.list[a]||[],function(a){a(c)})}},$=s("pubnub")||{},R=0,ga=[],qa=function(a){function c(){}function b(){}function e(a){v(P(f),function(b){a(f[b]||
+{})})}var f={},j=0,q=0,x=0,B=0,i=0,l=0,h=a.publish_key||"",g=a.subscribe_key||"",m=a.ssl?"s":"",k=a.uuid||U.get(g+"uuid")||"",d="http"+m+"://"+(a.origin||"pubsub.pubnub.com"),u={history:function(a,b){var b=a.callback||b,c=a.count||a.limit||100,e=a.reverse||"false",f=a.error||n(),i=a.channel,k=a.start,h=a.end,j={},l=H();if(!i)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");j.count=c;j.reverse=e;k&&(j.start=k);h&&(j.end=h);N({a:l,data:j,c:function(a){b(a)},
+b:f,url:[d,"v2","history","sub-key",g,"channel",I(i)]})},time:function(a){var b=H(),c=X(d);N({a:b,url:[c,"time",b],c:function(b){a(b[0])},b:function(){a(0)}})},uuid:function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)});a&&a(b);return b},publish:function(a,b){var b=b||a.callback||n(),c=a.message,e=a.channel,f=H();if(!c)return t("Missing Message");if(!e)return t("Missing Channel");if(!h)return t("Missing Publish Key");
if(!g)return t("Missing Subscribe Key");c=JSON.stringify(c);c=[d,"publish",h,g,0,I(e),f,I(c)];N({a:f,c:function(a){b(a)},b:function(){b([0,"Disconnected"])},url:c,data:{uuid:k}})},unsubscribe:function(a){a=a.channel;a=y((a.join?a.join(","):""+a).split(","),function(a){return a+","+a+T}).join(",");v(a.split(","),function(a){R&&b(a,0);f[a]={}});R&&c()},subscribe:function(a,b){function h(){var a=H(),b=P(f).join(",");b&&(x=N({timeout:ia,a:a,data:{uuid:k},url:[ca,"subscribe",g,I(b),a,l],b:function(){e(function(a){a.d||
(a.d=1,a.i(a.name))});ca=X(d);setTimeout(h,J);u.time(function(a){e(function(b){a&&b.d?(b.d=0,b.j(b.name)):b.error()})})},c:function(a){if(!a)return setTimeout(h,10);e(function(a){a.e||(a.e=1,a.h(a.name))});l=!l&&B?U.get(g)||a[1]:a[1];U.set(g,a[1]);var b,c=(2<a.length?a[2]:"").split(",");b=function(){var a=c.shift()||"";return[(f[a]||{}).a||j,(a||q).split(T)[0]]};v(a[0],function(c){var d=b();if(f[d[1]].f)d[0](c,a,d[1])});setTimeout(h,10)}}))}var m=a.channel,b=(b=b||a.callback)||a.message,ja=a.error||
n(),ka=a.connect||n(),oa=a.reconnect||n(),pa=a.disconnect||n(),Q=a.presence||0,ra=a.restore,ca=X(d);ra&&(B=1);if(!m)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");v((m.join?m.join(","):""+m).split(","),function(a){var c=f[a]||{};f[q=a]={name:a,e:c.e,d:c.d,f:1,a:j=b,h:ka,error:ja,i:pa,j:oa};Q&&(u.subscribe({channel:a+T,callback:Q}),c.f||u.here_now({channel:a,callback:function(b){v("uuids"in b?b.uuids:[],function(c){Q({action:"join",uuid:c,timestamp:r(),
View
BIN  javascript/3.4/pubnub-3.4.min.js.gz
Binary file not shown
View
8 javascript/pubnub-3.4.js
@@ -57,8 +57,12 @@ var NOW = 1
/**
* CONSOLE COMPATIBILITY
*/
-window.console||(window.console=window.console||{});
-console.error||(console.error=((window.opera||{}).postError||function(){}));
+window.console || (window.console=window.console||{});
+console.log || (
+ console.log =
+ console.error =
+ ((window.opera||{}).postError||function(){})
+);
/**
* UTILITIES
View
8 javascript/pubnub-3.4.min.js
@@ -10,10 +10,10 @@ c.addEventListener?c.addEventListener(a,f,!1):c.attachEvent?c.attachEvent("on"+a
function(a){return 0>"-_.!~*'()".indexOf(a)?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")},N=function(a){function c(a,b){V||(V=1,a||la(b),d.onerror=null,clearTimeout(ma),setTimeout(function(){a&&na();var b=s(u),c=b&&b.parentNode;c&&c.removeChild(b)},J))}if(F||G()){a:{var b,e,f=function(){if(!q){q=1;clearTimeout(B);try{e=JSON.parse(b.responseText)}catch(a){return h(1)}l(e)}},j=0,q=0,x=a.timeout||K,B=setTimeout(function(){h(1)},x),i=a.b||n(),l=a.c||n(),h=function(a){j||(j=1,clearTimeout(B),
b&&(b.onerror=b.onload=null,b.abort&&b.abort(),b=null),a&&i())};try{b=G()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest;b.onerror=b.onabort=function(){h(1)};b.onload=b.onloadend=f;b.timeout=x;var g=a.url.join(L);if(a.data){var f=[],m,g=g+"?";for(m in a.data)f.push(m+"="+a.data[m]);g+=f.join(M)}b.open("GET",g,typeof("undefined"===a.g));b.send()}catch(k){h(0);F=0;a=N(a);break a}a=h}return a}var d=E("script"),g=a.a,u=p(),V=0,ma=setTimeout(function(){c(1)},a.timeout||K),na=a.b||n(),la=
a.c||n();window[g]=function(a){c(0,a)};a.g||(d[O]=O);d.onerror=function(){c(1)};d.src=a.url.join(L);if(a.data){g=[];d.src+="?";for(key in a.data)g.push(key+"="+a.data[key]);d.src+=g.join(M)}C(d,"id",u);A().appendChild(d);return c},P=function(a){var c=[];v(a,function(a,e){e.f&&c.push(a)});return c.sort()},S=function(){PUBNUB.time(r);PUBNUB.time(function(){setTimeout(function(){R||(R=1,v(ga,function(a){a()}))},J)})},G=function(){if(!ha.get)return 0;var a={id:G.id++,send:n(),abort:function(){a.id={}},
-open:function(c,b){G[a.id]=a;ha.get(a.id,b)}};return a},aa=1,ea=/{([\w\-]+)}/g,O="async",L="/",M="&",ia=31E4,K=1E4,J=1E3,T="-pnpres",F=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.error||(console.error=(window.opera||{}).postError||n());var U,W=window.localStorage;U={get:function(a){try{return W?W.getItem(a):-1==document.cookie.indexOf(a)?null:((document.cookie||"").match(RegExp(a+"=([^;]+)"))||[])[1]||null}catch(c){}},set:function(a,c){try{if(W)return W.setItem(a,
-c)&&0;document.cookie=a+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}catch(b){}}};var X,Y=Math.floor(20*Math.random());X=function(a){return 0<a.indexOf("pubsub")&&a.replace("pubsub","ps"+(20>++Y?Y:Y=1))||a};var Z={list:{},unbind:function(a){Z.list[a]=[]},bind:function(a,c){(Z.list[a]=Z.list[a]||[]).push(c)},fire:function(a,c){v(Z.list[a]||[],function(a){a(c)})}},$=s("pubnub")||{},R=0,ga=[],qa=function(a){function c(){}function b(){}function e(a){v(P(f),function(b){a(f[b]||{})})}var f={},
-j=0,q=0,x=0,B=0,i=0,l=0,h=a.publish_key||"",g=a.subscribe_key||"",m=a.ssl?"s":"",k=a.uuid||U.get(g+"uuid")||"",d="http"+m+"://"+(a.origin||"pubsub.pubnub.com"),u={history:function(a,b){var b=a.callback||b,c=a.count||a.limit||100,e=a.reverse||"false",f=a.error||n(),i=a.channel,k=a.start,h=a.end,j={},l=H();if(!i)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");j.count=c;j.reverse=e;k&&(j.start=k);h&&(j.end=h);N({a:l,data:j,c:function(a){b(a)},b:f,
-url:[d,"v2","history","sub-key",g,"channel",I(i)]})},time:function(a){var b=H(),c=X(d);N({a:b,url:[c,"time",b],c:function(b){a(b[0])},b:function(){a(0)}})},uuid:function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)});a&&a(b);return b},publish:function(a,b){var b=b||a.callback||n(),c=a.message,e=a.channel,f=H();if(!c)return t("Missing Message");if(!e)return t("Missing Channel");if(!h)return t("Missing Publish Key");
+open:function(c,b){G[a.id]=a;ha.get(a.id,b)}};return a},aa=1,ea=/{([\w\-]+)}/g,O="async",L="/",M="&",ia=31E4,K=1E4,J=1E3,T="-pnpres",F=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.log||(console.log=console.error=(window.opera||{}).postError||n());var U,W=window.localStorage;U={get:function(a){try{return W?W.getItem(a):-1==document.cookie.indexOf(a)?null:((document.cookie||"").match(RegExp(a+"=([^;]+)"))||[])[1]||null}catch(c){}},set:function(a,
+c){try{if(W)return W.setItem(a,c)&&0;document.cookie=a+"="+c+"; expires=Thu, 1 Aug 2030 20:00:00 UTC; path=/"}catch(b){}}};var X,Y=Math.floor(20*Math.random());X=function(a){return 0<a.indexOf("pubsub")&&a.replace("pubsub","ps"+(20>++Y?Y:Y=1))||a};var Z={list:{},unbind:function(a){Z.list[a]=[]},bind:function(a,c){(Z.list[a]=Z.list[a]||[]).push(c)},fire:function(a,c){v(Z.list[a]||[],function(a){a(c)})}},$=s("pubnub")||{},R=0,ga=[],qa=function(a){function c(){}function b(){}function e(a){v(P(f),function(b){a(f[b]||
+{})})}var f={},j=0,q=0,x=0,B=0,i=0,l=0,h=a.publish_key||"",g=a.subscribe_key||"",m=a.ssl?"s":"",k=a.uuid||U.get(g+"uuid")||"",d="http"+m+"://"+(a.origin||"pubsub.pubnub.com"),u={history:function(a,b){var b=a.callback||b,c=a.count||a.limit||100,e=a.reverse||"false",f=a.error||n(),i=a.channel,k=a.start,h=a.end,j={},l=H();if(!i)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");j.count=c;j.reverse=e;k&&(j.start=k);h&&(j.end=h);N({a:l,data:j,c:function(a){b(a)},
+b:f,url:[d,"v2","history","sub-key",g,"channel",I(i)]})},time:function(a){var b=H(),c=X(d);N({a:b,url:[c,"time",b],c:function(b){a(b[0])},b:function(){a(0)}})},uuid:function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0;return("x"==a?b:b&3|8).toString(16)});a&&a(b);return b},publish:function(a,b){var b=b||a.callback||n(),c=a.message,e=a.channel,f=H();if(!c)return t("Missing Message");if(!e)return t("Missing Channel");if(!h)return t("Missing Publish Key");
if(!g)return t("Missing Subscribe Key");c=JSON.stringify(c);c=[d,"publish",h,g,0,I(e),f,I(c)];N({a:f,c:function(a){b(a)},b:function(){b([0,"Disconnected"])},url:c,data:{uuid:k}})},unsubscribe:function(a){a=a.channel;a=y((a.join?a.join(","):""+a).split(","),function(a){return a+","+a+T}).join(",");v(a.split(","),function(a){R&&b(a,0);f[a]={}});R&&c()},subscribe:function(a,b){function h(){var a=H(),b=P(f).join(",");b&&(x=N({timeout:ia,a:a,data:{uuid:k},url:[ca,"subscribe",g,I(b),a,l],b:function(){e(function(a){a.d||
(a.d=1,a.i(a.name))});ca=X(d);setTimeout(h,J);u.time(function(a){e(function(b){a&&b.d?(b.d=0,b.j(b.name)):b.error()})})},c:function(a){if(!a)return setTimeout(h,10);e(function(a){a.e||(a.e=1,a.h(a.name))});l=!l&&B?U.get(g)||a[1]:a[1];U.set(g,a[1]);var b,c=(2<a.length?a[2]:"").split(",");b=function(){var a=c.shift()||"";return[(f[a]||{}).a||j,(a||q).split(T)[0]]};v(a[0],function(c){var d=b();if(f[d[1]].f)d[0](c,a,d[1])});setTimeout(h,10)}}))}var m=a.channel,b=(b=b||a.callback)||a.message,ja=a.error||
n(),ka=a.connect||n(),oa=a.reconnect||n(),pa=a.disconnect||n(),Q=a.presence||0,ra=a.restore,ca=X(d);ra&&(B=1);if(!m)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");v((m.join?m.join(","):""+m).split(","),function(a){var c=f[a]||{};f[q=a]={name:a,e:c.e,d:c.d,f:1,a:j=b,h:ka,error:ja,i:pa,j:oa};Q&&(u.subscribe({channel:a+T,callback:Q}),c.f||u.here_now({channel:a,callback:function(b){v("uuids"in b?b.uuids:[],function(c){Q({action:"join",uuid:c,timestamp:r(),
View
BIN  javascript/pubnub-3.4.min.js.gz
Binary file not shown
View
2  javascript/tests/publish-test.html
@@ -24,7 +24,7 @@
<div id=pubnub></div>
<script src=../json.js></script>
-<script src=../pubnub-3.4.js></script>
+<script src=../pubnub-3.4.min.js></script>
<script>(function(){
// --------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.