Permalink
Browse files

fixing build script

  • Loading branch information...
1 parent ea73e28 commit 2e20b5231e65fec9301ad3e4944e9b93d941fa69 geremy cohen committed Dec 10, 2012
View
7 javascript/3.4/build-minify-pubnub
@@ -1,7 +1,10 @@
#!/bin/bash
-googleminify="$1"
-if [ googleminify='' ]; then googleminify="/opt/minify/compiler.jar"; fi
+echo $1
+
+googleminify=$1
+
+if [ -z "$googleminify" ]; then googleminify="/opt/minify/compiler.jar"; fi
echo -e " "
echo -e " USING: $googleminify TO MINIFY..."
View
40 javascript/3.4/pubnub-3.4.min.js
@@ -1,22 +1,22 @@
function n(){return function(){}}
-window.JSON&&window.JSON.stringify||function(){function a(a){b.lastIndex=0;return b.test(a)?'"'+a.replace(b,function(a){var b=j[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(b,j){var i,l,h,g,m=e,k,d=j[b];d&&("object"===typeof d&&"function"===typeof d.toJSON)&&(d=d.toJSON(b));"function"===typeof q&&(d=q.call(j,b,d));switch(typeof d){case "string":return a(d);case "number":return isFinite(d)?String(d):"null";case "boolean":case "null":return String(d);
-case "object":if(!d)return"null";e+=f;k=[];if("[object Array]"===Object.prototype.toString.apply(d)){g=d.length;for(i=0;i<g;i+=1)k[i]=c(i,d)||"null";h=0===k.length?"[]":e?"[\n"+e+k.join(",\n"+e)+"\n"+m+"]":"["+k.join(",")+"]";e=m;return h}if(q&&"object"===typeof q){g=q.length;for(i=0;i<g;i+=1)l=q[i],"string"===typeof l&&(h=c(l,d))&&k.push(a(l)+(e?": ":":")+h)}else for(l in d)Object.hasOwnProperty.call(d,l)&&(h=c(l,d))&&k.push(a(l)+(e?": ":":")+h);h=0===k.length?"{}":e?"{\n"+e+k.join(",\n"+e)+"\n"+
-m+"}":"{"+k.join(",")+"}";e=m;return h}}window.JSON||(window.JSON={});"function"!==typeof String.prototype.toJSON&&(String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var b=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,f,j={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},q;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,
-b,i){var j;f=e="";if("number"===typeof i)for(j=0;j<i;j+=1)f+=" ";else"string"===typeof i&&(f=i);if((q=b)&&"function"!==typeof b&&("object"!==typeof b||"number"!==typeof b.length))throw Error("JSON.stringify");return c("",{"":a})});"function"!==typeof JSON.parse&&(JSON.parse=function(a){return eval("("+a+")")})}();
-if(!window.PUBNUB){var p=function(){return"x"+ ++aa+""+ +new Date},r=function(){return+new Date},ba=function(a,c){function b(){f+c>r()?(clearTimeout(e),e=setTimeout(b,c)):(f=r(),a())}var e,f=0;return b},s=function(a){return document.getElementById(a)},t=function(a){console.error(a)},w=function(a,c){var b=[];v(a.split(/\s+/),function(a){v((c||document).getElementsByTagName(a),function(a){b.push(a)})});return b},v=function(a,c){if(a&&c)if("undefined"!=typeof a[0])for(var b=0,e=a.length;b<e;)c.call(a[b],
-a[b],b++);else for(b in a)a.hasOwnProperty&&a.hasOwnProperty(b)&&c.call(a[b],b,a[b])},y=function(a,c){var b=[];v(a||[],function(a,f){b.push(c(a,f))});return b},da=function(a,c){var b=[];v(a||[],function(a){c(a)&&b.push(a)});return b},fa=function(a,c){return a.replace(ea,function(a,e){return c[e]||a})},z=function(a,c,b){v(a.split(","),function(a){function f(a){a||(a=window.event);b(a)||(a.cancelBubble=!0,a.returnValue=!1,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation())}
-c.addEventListener?c.addEventListener(a,f,!1):c.attachEvent?c.attachEvent("on"+a,f):c["on"+a]=f})},A=function(){return w("head")[0]},C=function(a,c,b){if(b)a.setAttribute(c,b);else return a&&a.getAttribute&&a.getAttribute(c)},D=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(e){}},E=function(a){return document.createElement(a)},H=function(){return F||G()?0:p()},I=function(a){return y(encodeURIComponent(a).split(""),
-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");
-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.j(a.name))});ca=X(d);setTimeout(h,J);u.time(function(a){e(function(b){a&&b.d?(b.d=0,b.k(b.name)):b.error()})})},c:function(a){if(!a)return setTimeout(h,10);e(function(a){a.e||(a.e=1,a.i(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,i:ka,error:ja,j:pa,k:oa};Q&&(u.m({h:a+T,a:Q}),c.f||u.here_now({h:a,a:function(b){v("uuids"in b?b.uuids:[],function(c){Q({action:"join",uuid:c,timestamp:r(),occupancy:b.occupancy||
-1},b,a)})}}))});c=function(){x&&x();clearTimeout(i);i=setTimeout(h,100)};if(!R)return ga.push(c);c()},here_now:function(a,b){var b=a.callback||b,c=a.error||n(),e=a.channel,f=H(),h={};if(!e)return t("Missing Channel");if(!b)return t("Missing Callback");if(!g)return t("Missing Subscribe Key");"0"!=f&&(h.callback=f);N({a:f,data:h,c:function(a){b(a)},b:c,url:[d,"v2","presence","sub_key",g,"channel",I(e)]})},xdr:N,ready:S,db:U,each:v,map:y,grep:da,css:D,$:s,create:E,bind:z,supplant:fa,head:A,search:w,
-attr:C,now:r,unique:p,events:Z,updater:ba,init:qa};k||(k=u.uuid());U.set(g+"uuid",k);b=function(a,b){var c={uuid:k},e=X(d),f=H();0<a.indexOf(T)||("0"!=f&&(c.callback=f),N({g:b||m,timeout:2E3,a:f,data:c,url:[e,"v2","presence","sub_key",g,"channel",I(a),"leave"]}))};z("beforeunload",window,function(){e(function(a){b(a.name,1)});return!0});return u};PUBNUB=qa({publish_key:C($,"pub-key"),subscribe_key:C($,"sub-key"),ssl:!document.location.href.indexOf("https")||"on"==C($,"ssl"),origin:C($,"origin"),uuid:C($,
-"uuid")});D($,{position:"absolute",top:-J});if("opera"in window||C($,"flash"))$.innerHTML="<object id=pubnubs data=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=movie value=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=allowscriptaccess value=always></object>";var ha=s("pubnubs")||{};z("load",window,function(){setTimeout(S,0)});PUBNUB.rdx=function(a,c){if(!c)return G[a].onerror();G[a].responseText=unescape(c);G[a].onload()};G.id=J;window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);
+window.JSON&&window.JSON.stringify||function(){function a(a){b.lastIndex=0;return b.test(a)?'"'+a.replace(b,function(a){var b=j[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(b,j){var i,l,h,g,m=e,k,d=j[b];d&&("object"===typeof d&&"function"===typeof d.toJSON)&&(d=d.toJSON(b));"function"===typeof p&&(d=p.call(j,b,d));switch(typeof d){case "string":return a(d);case "number":return isFinite(d)?String(d):"null";case "boolean":case "null":return String(d);
+case "object":if(!d)return"null";e+=f;k=[];if("[object Array]"===Object.prototype.toString.apply(d)){g=d.length;for(i=0;i<g;i+=1)k[i]=c(i,d)||"null";h=0===k.length?"[]":e?"[\n"+e+k.join(",\n"+e)+"\n"+m+"]":"["+k.join(",")+"]";e=m;return h}if(p&&"object"===typeof p){g=p.length;for(i=0;i<g;i+=1)l=p[i],"string"===typeof l&&(h=c(l,d))&&k.push(a(l)+(e?": ":":")+h)}else for(l in d)Object.hasOwnProperty.call(d,l)&&(h=c(l,d))&&k.push(a(l)+(e?": ":":")+h);h=0===k.length?"{}":e?"{\n"+e+k.join(",\n"+e)+"\n"+
+m+"}":"{"+k.join(",")+"}";e=m;return h}}window.JSON||(window.JSON={});"function"!==typeof String.prototype.toJSON&&(String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var b=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,f,j={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},p;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,
+b,i){var j;f=e="";if(typeof i==="number")for(j=0;j<i;j=j+1)f=f+" ";else typeof i==="string"&&(f=i);if((p=b)&&typeof b!=="function"&&(typeof b!=="object"||typeof b.length!=="number"))throw Error("JSON.stringify");return c("",{"":a})});"function"!==typeof JSON.parse&&(JSON.parse=function(a){return eval("("+a+")")})}();
+if(!window.PUBNUB){var o=function(){return"x"+ ++aa+""+ +new Date},q=function(){return+new Date},ca=function(a,c){function b(){f+c>q()?(clearTimeout(e),e=setTimeout(b,c)):(f=q(),a())}var e,f=0;return b},r=function(a){return document.getElementById(a)},s=function(a){console.error(a)},v=function(a,c){var b=[];u(a.split(/\s+/),function(a){u((c||document).getElementsByTagName(a),function(a){b.push(a)})});return b},u=function(a,c){if(a&&c)if("undefined"!=typeof a[0])for(var b=0,e=a.length;b<e;)c.call(a[b],
+a[b],b++);else for(b in a)a.hasOwnProperty&&a.hasOwnProperty(b)&&c.call(a[b],b,a[b])},x=function(a,c){var b=[];u(a||[],function(a,f){b.push(c(a,f))});return b},da=function(a,c){var b=[];u(a||[],function(a){c(a)&&b.push(a)});return b},fa=function(a,c){return a.replace(ea,function(a,e){return c[e]||a})},y=function(a,c,b){u(a.split(","),function(a){function f(a){a||(a=window.event);b(a)||(a.cancelBubble=!0,a.returnValue=!1,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation())}
+c.addEventListener?c.addEventListener(a,f,!1):c.attachEvent?c.attachEvent("on"+a,f):c["on"+a]=f})},z=function(){return v("head")[0]},B=function(a,c,b){if(b)a.setAttribute(c,b);else return a&&a.getAttribute&&a.getAttribute(c)},C=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(e){}},D=function(a){return document.createElement(a)},G=function(){return E||F()?0:o()},H=function(a){return x(encodeURIComponent(a).split(""),
+function(a){return 0>"-_.!~*'()".indexOf(a)?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")},M=function(a){function c(a,b){U||(U=1,a||ka(b),d.onerror=null,clearTimeout(la),setTimeout(function(){a&&ma();var b=r(t),c=b&&b.parentNode;c&&c.removeChild(b)},I))}if(E||F()){a:{var b,e,f=function(){if(!p){p=1;clearTimeout(A);try{e=JSON.parse(b.responseText)}catch(a){return h(1)}l(e)}},j=0,p=0,w=a.timeout||J,A=setTimeout(function(){h(1)},w),i=a.b||n(),l=a.c||n(),h=function(a){j||(j=1,clearTimeout(A),
+b&&(b.onerror=b.onload=null,b.abort&&b.abort(),b=null),a&&i())};try{b=F()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest;b.onerror=b.onabort=function(){h(1)};b.onload=b.onloadend=f;b.timeout=w;var g=a.url.join(K);if(a.data){var f=[],m,g=g+"?";for(m in a.data)f.push(m+"="+a.data[m]);g+=f.join(L)}b.open("GET",g,typeof("undefined"===a.g));b.send()}catch(k){h(0);E=0;a=M(a);break a}a=h}return a}var d=D("script"),g=a.a,t=o(),U=0,la=setTimeout(function(){c(1)},a.timeout||J),ma=a.b||n(),ka=
+a.c||n();window[g]=function(a){c(0,a)};a.g||(d[N]=N);d.onerror=function(){c(1)};d.src=a.url.join(K);if(a.data){g=[];d.src+="?";for(key in a.data)g.push(key+"="+a.data[key]);d.src+=g.join(L)}B(d,"id",t);z().appendChild(d);return c},O=function(a){var c=[];u(a,function(a,e){e.f&&c.push(a)});return c.sort()},S=function(){PUBNUB.time(q);PUBNUB.time(function(){setTimeout(function(){Q||(Q=1,u(R,function(a){a()}))},I)})},F=function(){if(!ga.get)return 0;var a={id:F.id++,send:n(),abort:function(){a.id={}},
+open:function(c,b){F[a.id]=a;ga.get(a.id,b)}};return a},aa=1,ea=/{([\w\-]+)}/g,N="async",K="/",L="&",ha=31E4,J=1E4,I=1E3,T="-pnpres",E=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.error||(console.error=(window.opera||{}).postError||n());var V,W=window.localStorage;V={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){u(Z.list[a]||[],function(a){a(c)})}},$=r("pubnub")||{},Q=0,R=[],pa=function(a){function c(){}function b(){}function e(a){u(O(f),function(b){a(f[b]||{})})}var f={},
+j=0,p=0,w=0,A=0,i=0,l=0,h=a.publish_key||"",g=a.subscribe_key||"",m=a.ssl?"s":"",k=a.uuid||V.get(g+"uuid")||"",d="http"+m+"://"+(a.origin||"pubsub.pubnub.com"),t={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=G();if(!i)return s("Missing Channel");if(!b)return s("Missing Callback");if(!g)return s("Missing Subscribe Key");j.count=c;j.reverse=e;k&&(j.start=k);h&&(j.end=h);M({a:l,data:j,c:function(a){b(a)},b:f,
+url:[d,"v2","history","sub-key",g,"channel",H(i)]})},time:function(a){var b=G(),c=X(d);M({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=G();if(!c)return s("Missing Message");if(!e)return s("Missing Channel");if(!h)return s("Missing Publish Key");
+if(!g)return s("Missing Subscribe Key");c=JSON.stringify(c);c=[d,"publish",h,g,0,H(e),f,H(c)];M({a:f,c:function(a){b(a)},b:function(){b([0,"Disconnected"])},url:c,data:{uuid:k}})},unsubscribe:function(a){a=a.channel;a=x((a.join?a.join(","):""+a).split(","),function(a){return a+","+a+T}).join(",");u(a.split(","),function(a){Q&&b(a,0);f[a]={}});Q&&c()},subscribe:function(a,b){function h(){var a=G(),b=O(f).join(",");b&&(w=M({timeout:ha,a:a,data:{uuid:k},url:[ba,"subscribe",g,H(b),a,l],b:function(){e(function(a){a.d||
+(a.d=1,a.j(a.name))});ba=X(d);setTimeout(h,I);t.time(function(a){e(function(b){a&&b.d?(b.d=0,b.k(b.name)):b.error()})})},c:function(a){if(!a)return setTimeout(h,10);e(function(a){a.e||(a.e=1,a.i(a.name))});l=!l&&A?V.get(g)||a[1]:a[1];V.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||p).split(T)[0]]};u(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,ia=a.error||
+n(),ja=a.connect||n(),na=a.reconnect||n(),oa=a.disconnect||n(),P=a.presence||0,qa=a.restore,ba=X(d);qa&&(A=1);if(!m)return s("Missing Channel");if(!b)return s("Missing Callback");if(!g)return s("Missing Subscribe Key");u((m.join?m.join(","):""+m).split(","),function(a){var c=f[a]||{};f[p=a]={name:a,e:c.e,d:c.d,f:1,a:j=b,i:ja,error:ia,j:oa,k:na};P&&(t.m({h:a+T,a:P}),c.f||t.here_now({h:a,a:function(b){u("uuids"in b?b.uuids:[],function(c){P({action:"join",uuid:c,timestamp:q(),occupancy:b.occupancy||
+1},b,a)})}}))});c=function(){w&&w();clearTimeout(i);i=setTimeout(h,100)};if(!Q)return R.push(c);c()},here_now:function(a,b){var b=a.callback||b,c=a.error||n(),e=a.channel,f=G(),h={};if(!e)return s("Missing Channel");if(!b)return s("Missing Callback");if(!g)return s("Missing Subscribe Key");"0"!=f&&(h.callback=f);M({a:f,data:h,c:function(a){b(a)},b:c,url:[d,"v2","presence","sub_key",g,"channel",H(e)]})},xdr:M,ready:S,db:V,each:u,map:x,grep:da,css:C,$:r,create:D,bind:y,supplant:fa,head:z,search:v,attr:B,
+now:q,unique:o,events:Z,updater:ca,init:pa};k||(k=t.uuid());V.set(g+"uuid",k);b=function(a,b){var c={uuid:k},e=X(d),f=G();0<a.indexOf(T)||("0"!=f&&(c.callback=f),M({g:b||m,timeout:2E3,a:f,data:c,url:[e,"v2","presence","sub_key",g,"channel",H(a),"leave"]}))};y("beforeunload",window,function(){e(function(a){b(a.name,1)});return!0});return t};PUBNUB=pa({publish_key:B($,"pub-key"),subscribe_key:B($,"sub-key"),ssl:!document.location.href.indexOf("https")||"on"==B($,"ssl"),origin:B($,"origin"),uuid:B($,
+"uuid")});C($,{position:"absolute",top:-I});if("opera"in window||B($,"flash"))$.innerHTML="<object id=pubnubs data=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=movie value=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=allowscriptaccess value=always></object>";var ga=r("pubnubs")||{};y("load",window,function(){setTimeout(S,0)});PUBNUB.rdx=function(a,c){if(!c)return F[a].onerror();F[a].responseText=unescape(c);F[a].onload()};F.id=I;window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);
"undefined"!==typeof module&&(module.l=PUBNUB)&&S()};
View
BIN javascript/3.4/pubnub-3.4.min.js.gz
Binary file not shown.
View
21 javascript/build-minify-pubnub
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+echo $1
+
+googleminify=$1
+
+if [ -z "$googleminify" ]; then googleminify="/opt/minify/compiler.jar"; fi
+
+echo -e " "
+echo -e " USING: $googleminify TO MINIFY..."
+echo -e " COMPILING PUBNUB JAVASCRIPT API..."
+
+cat ./json.js ./pubnub-3.4.js > ./pubnub.tmp
+java -jar $googleminify --js=./pubnub.tmp --compilation_level=ADVANCED_OPTIMIZATIONS > ./pubnub-3.4.min.js
+
+echo -e " >>COMPRESSING<< PUBNUB JAVASCRIPT API..."
+cat ./pubnub-3.4.min.js | gzip -c9 > ./pubnub-3.4.min.js.gz
+
+rm ./pubnub.tmp
+echo -e " "
+echo -e " DONE!\n"
View
BIN javascript/comet.swf
Binary file not shown.
View
4 javascript/crossdomain.xml
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<cross-domain-policy>
- <allow-access-from domain="*" secure="false" />
-</cross-domain-policy>
View
155 javascript/json.js
@@ -0,0 +1,155 @@
+/* =-====================================================================-= */
+/* =-====================================================================-= */
+/* =-========================= JSON =============================-= */
+/* =-====================================================================-= */
+/* =-====================================================================-= */
+
+(window['JSON'] && window['JSON']['stringify']) || (function () {
+ window['JSON'] || (window['JSON'] = {});
+
+ if (typeof String.prototype.toJSON !== 'function') {
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+ function quote(string) {
+ escapable.lastIndex = 0;
+ return escapable.test(string) ?
+ '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' :
+ '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+ return String(value);
+
+ case 'object':
+
+ if (!value) {
+ return 'null';
+ }
+
+ gap += indent;
+ partial = [];
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+ v = partial.length === 0 ? '[]' :
+ gap ? '[\n' + gap +
+ partial.join(',\n' + gap) + '\n' +
+ mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ k = rep[i];
+ if (typeof k === 'string') {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+ for (k in value) {
+ if (Object.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+ v = partial.length === 0 ? '{}' :
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
+ mind + '}' : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+ if (typeof JSON['stringify'] !== 'function') {
+ JSON['stringify'] = function (value, replacer, space) {
+ var i;
+ gap = '';
+ indent = '';
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+ return str('', {'': value});
+ };
+ }
+
+ if (typeof JSON['parse'] !== 'function') {
+ // JSON is parsed on the server for security.
+ JSON['parse'] = function (text) {return eval('('+text+')')};
+ }
+}());
View
BIN javascript/pubnub-3.3.1.min.js
Binary file not shown.
View
639 javascript/pubnub-3.3.1.js → javascript/pubnub-3.4.js
@@ -32,180 +32,39 @@ THE SOFTWARE.
/* =-====================================================================-= */
/* =-====================================================================-= */
-/* =-========================= JSON =============================-= */
-/* =-====================================================================-= */
-/* =-====================================================================-= */
-
-(window['JSON'] && window['JSON']['stringify']) || (function () {
- window['JSON'] || (window['JSON'] = {});
-
- if (typeof String.prototype.toJSON !== 'function') {
- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
- }
-
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
- gap,
- indent,
- meta = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- },
- rep;
-
- function quote(string) {
- escapable.lastIndex = 0;
- return escapable.test(string) ?
- '"' + string.replace(escapable, function (a) {
- var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- }) + '"' :
- '"' + string + '"';
- }
-
-
- function str(key, holder) {
- var i, // The loop counter.
- k, // The member key.
- v, // The member value.
- length,
- mind = gap,
- partial,
- value = holder[key];
-
- if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
- value = value.toJSON(key);
- }
-
- if (typeof rep === 'function') {
- value = rep.call(holder, key, value);
- }
-
- switch (typeof value) {
- case 'string':
- return quote(value);
-
- case 'number':
- return isFinite(value) ? String(value) : 'null';
-
- case 'boolean':
- case 'null':
- return String(value);
-
- case 'object':
-
- if (!value) {
- return 'null';
- }
-
- gap += indent;
- partial = [];
-
- if (Object.prototype.toString.apply(value) === '[object Array]') {
-
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
-
- v = partial.length === 0 ? '[]' :
- gap ? '[\n' + gap +
- partial.join(',\n' + gap) + '\n' +
- mind + ']' :
- '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- k = rep[i];
- if (typeof k === 'string') {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- } else {
- for (k in value) {
- if (Object.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
- }
- }
- }
- }
-
- v = partial.length === 0 ? '{}' :
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
- mind + '}' : '{' + partial.join(',') + '}';
- gap = mind;
- return v;
- }
- }
-
- if (typeof JSON['stringify'] !== 'function') {
- JSON['stringify'] = function (value, replacer, space) {
- var i;
- gap = '';
- indent = '';
-
- if (typeof space === 'number') {
- for (i = 0; i < space; i += 1) {
- indent += ' ';
- }
- } else if (typeof space === 'string') {
- indent = space;
- }
- rep = replacer;
- if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
- throw new Error('JSON.stringify');
- }
- return str('', {'': value});
- };
- }
-
- if (typeof JSON['parse'] !== 'function') {
- // JSON is parsed on the server for security.
- JSON['parse'] = function (text) {return eval('('+text+')')};
- }
-}());
-
-
-/* =-====================================================================-= */
-/* =-====================================================================-= */
-/* =-======================= DOM UTIL ===========================-= */
+/* =-========================= UTIL =============================-= */
/* =-====================================================================-= */
/* =-====================================================================-= */
window['PUBNUB'] || (function() {
/**
+ * UTIL LOCALS
+ */
+var NOW = 1
+, SWF = 'https://dh15atwfs066y.cloudfront.net/pubnub.swf'
+, REPL = /{([\w\-]+)}/g
+, ASYNC = 'async'
+, URLBIT = '/'
+, PARAMSBIT = '&'
+, SUB_TIMEOUT = 310000
+, DEF_TIMEOUT = 10000
+, SECOND = 1000
+, PRESENCE_SUFFIX = '-pnpres'
+, UA = navigator.userAgent
+, XORIGN = UA.indexOf('MSIE 6') == -1;
+
+/**
* CONSOLE COMPATIBILITY
*/
window.console||(window.console=window.console||{});
-console.log||(console.log=((window.opera||{}).postError||function(){}));
+console.error||(console.error=((window.opera||{}).postError||function(){}));
/**
* UTILITIES
*/
function unique() { return'x'+ ++NOW+''+(+new Date) }
-function rnow() { return+new Date }
+function rnow() { return+new Date }
/**
* LOCAL STORAGE OR COOKIE
@@ -233,38 +92,24 @@ var db = (function(){
})();
/**
- * UTIL LOCALS
- */
-var NOW = 1
-, SWF = 'https://dh15atwfs066y.cloudfront.net/pubnub.swf'
-, REPL = /{([\w\-]+)}/g
-, ASYNC = 'async'
-, URLBIT = '/'
-, PARAMSBIT = '&'
-, XHRTME = 310000
-, SECOND = 1000
-, PRESENCE_SUFFIX = '-pnpres'
-, UA = navigator.userAgent
-, XORIGN = UA.indexOf('MSIE 6') == -1;
-
-/**
* NEXTORIGIN
* ==========
* var next_origin = nextorigin();
*/
var nextorigin = (function() {
- var ori = Math.floor(Math.random() * 9) + 1;
+ var max = 20
+ , ori = Math.floor(Math.random() * max);
return function(origin) {
return origin.indexOf('pubsub') > 0
&& origin.replace(
- 'pubsub', 'ps' + (++ori < 10 ? ori : ori=1)
+ 'pubsub', 'ps' + (++ori < max? ori : ori=1)
) || origin;
}
})();
/**
* UPDATER
- * ======
+ * =======
* var timestamp = unique();
*/
function updater( fun, rate ) {
@@ -292,11 +137,11 @@ function updater( fun, rate ) {
function $(id) { return document.getElementById(id) }
/**
- * LOG
- * ===
- * log('message');
+ * ERROR
+ * =====
+ * error('message');
*/
-function log(message) { console['log'](message) }
+function error(message) { console['error'](message) }
/**
* SEARCH
@@ -316,7 +161,7 @@ function search( elements, start ) {
/**
* EACH
* ====
- * each( [1,2,3], function(item) { console.log(item) } )
+ * each( [1,2,3], function(item) { } )
*/
function each( o, f ) {
if ( !o || !f ) return;
@@ -368,7 +213,7 @@ function supplant( str, values ) {
* BIND
* ====
* bind( 'keydown', search('a')[0], function(element) {
- * console.log( element, '1st anchor' )
+ * ...
* } );
*/
function bind( type, el, fun ) {
@@ -508,7 +353,8 @@ function xdr( setup ) {
, callback = setup.callback
, id = unique()
, finished = 0
- , timer = timeout( function(){done(1)}, XHRTME )
+ , xhrtme = setup.timeout || DEF_TIMEOUT
+ , timer = timeout( function(){done(1)}, xhrtme )
, fail = setup.fail || function(){}
, success = setup.success || function(){}
@@ -579,7 +425,8 @@ function ajax( setup ) {
}
, complete = 0
, loaded = 0
- , timer = timeout( function(){done(1)}, XHRTME )
+ , xhrtme = setup.timeout || DEF_TIMEOUT
+ , timer = timeout( function(){done(1)}, xhrtme )
, fail = setup.fail || function(){}
, success = setup.success || function(){}
, done = function(failed) {
@@ -606,20 +453,18 @@ function ajax( setup ) {
xhr.onerror = xhr.onabort = function(){ done(1) };
xhr.onload = xhr.onloadend = finished;
- xhr.timeout = XHRTME;
+ xhr.timeout = xhrtme;
var url = setup.url.join(URLBIT);
if (setup.data) {
var params = [];
var key;
url += "?";
- for (key in setup.data) {
- params.push(key+"="+setup.data[key]);
- }
+ for (key in setup.data) params.push(key+"="+setup.data[key]);
url += params.join(PARAMSBIT);
}
- xhr.open( 'GET', url, typeof setup.blocking == 'undefined' );
+ xhr.open( 'GET', url, (typeof(setup.blocking === 'undefined')) );
xhr.send();
}
catch(eee) {
@@ -632,6 +477,18 @@ function ajax( setup ) {
return done;
}
+/**
+ * Generate Subscription Channel List
+ * ==================================
+ * generate_channel_list(channels_object);
+ */
+function generate_channel_list(channels) {
+ var list = [];
+ each( channels, function( channel, status ) {
+ if (status.subscribed) list.push(channel);
+ } );
+ return list.sort();
+}
/* =-====================================================================-= */
/* =-====================================================================-= */
@@ -644,65 +501,42 @@ var PDIV = $('pubnub') || {}
, READY_BUFFER = []
, CREATE_PUBNUB = function(setup) {
var CHANNELS = {}
+ , SUB_CALLBACK = 0
+ , SUB_CHANNEL = 0
+ , SUB_RECEIVER = 0
+ , SUB_RESTORE = 0
+ , SUB_BUFF_WAIT = 0
+ , TIMETOKEN = 0
, PUBLISH_KEY = setup['publish_key'] || ''
, SUBSCRIBE_KEY = setup['subscribe_key'] || ''
, SSL = setup['ssl'] ? 's' : ''
, UUID = setup['uuid'] || db.get(SUBSCRIBE_KEY+'uuid') || ''
, ORIGIN = 'http'+SSL+'://'+(setup['origin']||'pubsub.pubnub.com')
, LEAVE = function(){}
+ , CONNECT = function(){}
, SELF = {
/*
PUBNUB.history({
channel : 'my_chat_channel',
limit : 100,
- callback : function(messages) { console.log(messages) }
+ callback : function(history) { }
});
*/
'history' : function( args, callback ) {
var callback = args['callback'] || callback
- , limit = args['limit'] || 100
- , channel = args['channel']
- , jsonp = jsonp_cb();
-
- // Make sure we have a Channel
- if (!channel) return log('Missing Channel');
- if (!callback) return log('Missing Callback');
- if (!SUBSCRIBE_KEY) return log('Missing Subscribe Key');
-
- // Send Message
- xdr({
- success : function(response) { callback(response) },
- fail : function(response) { log(response) },
- callback : jsonp,
- url : [
- ORIGIN, 'history',
- SUBSCRIBE_KEY, encode(channel),
- jsonp, limit
- ]
- });
- },
-
- /*
- PUBNUB.detailedHistory({
- channel : 'my_chat_channel',
- count : 100,
- callback : function(messages) { console.log(messages) }
- });
- */
- 'detailedHistory' : function( args, callback ) {
- var callback = args['callback'] || callback
- , count = args['count'] || 100
+ , count = args['count'] || args['limit'] || 100
, reverse = args['reverse'] || "false"
+ , err = args['error'] || function(){}
, channel = args['channel']
, start = args['start']
, end = args['end']
, params = {}
, jsonp = jsonp_cb();
// Make sure we have a Channel
- if (!channel) return log('Missing Channel');
- if (!callback) return log('Missing Callback');
- if (!SUBSCRIBE_KEY) return log('Missing Subscribe Key');
+ if (!channel) return error('Missing Channel');
+ if (!callback) return error('Missing Callback');
+ if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
params["count"] = count;
params["reverse"] = reverse;
@@ -715,32 +549,35 @@ var PDIV = $('pubnub') || {}
callback : jsonp,
data : params,
success : function(response) { callback(response) },
- fail : function(response) { log(response) },
+ fail : err,
url : [
- ORIGIN, 'v2', 'history',
- 'sub-key', SUBSCRIBE_KEY, 'channel', encode(channel)
+ ORIGIN, 'v2', 'history', 'sub-key',
+ SUBSCRIBE_KEY, 'channel', encode(channel)
]
});
},
/*
- PUBNUB.time(function(time){ console.log(time) });
+ PUBNUB.time(function(time){ });
*/
'time' : function(callback) {
- var jsonp = jsonp_cb();
+ var jsonp = jsonp_cb()
+ , origin = nextorigin(ORIGIN);
+
xdr({
callback : jsonp,
- url : [ORIGIN, 'time', jsonp],
+ url : [origin, 'time', jsonp],
success : function(response) { callback(response[0]) },
fail : function() { callback(0) }
});
},
/*
- PUBNUB.uuid(function(uuid) { console.log(uuid) });
+ PUBNUB.uuid(function(uuid) { });
*/
'uuid' : function(callback) {
- var u = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var u = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
+ function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
@@ -761,10 +598,10 @@ var PDIV = $('pubnub') || {}
, jsonp = jsonp_cb()
, url;
- if (!message) return log('Missing Message');
- if (!channel) return log('Missing Channel');
- if (!PUBLISH_KEY) return log('Missing Publish Key');
- if (!SUBSCRIBE_KEY) return log('Missing Subscribe Key');
+ if (!message) return error('Missing Message');
+ if (!channel) return error('Missing Channel');
+ if (!PUBLISH_KEY) return error('Missing Publish Key');
+ if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
// If trying to send Object
message = JSON['stringify'](message);
@@ -783,198 +620,227 @@ var PDIV = $('pubnub') || {}
success : function(response) { callback(response) },
fail : function() { callback([ 0, 'Disconnected' ]) },
url : url,
- data : { uuid: UUID }
+ data : { 'uuid' : UUID }
});
},
+
/*
PUBNUB.unsubscribe({ channel : 'my_chat' });
*/
'unsubscribe' : function(args) {
- // Unsubscribe from both the Channel and the Presence Channel
- unsubscribe(args['channel']);
- unsubscribe(args['channel'] + PRESENCE_SUFFIX);
-
- // Announce Leave
- LEAVE(args['channel']);
-
- function unsubscribe(channel) {
- // Leave if there never was a channel.
- if (!(channel in CHANNELS)) return;
-
- // Disable Channel
- CHANNELS[channel].connected = 0;
-
- // Abort and Remove Script
- CHANNELS[channel].done &&
- CHANNELS[channel].done(0);
- }
+ var channel = args['channel'];
+
+ // Prepare Channel(s)
+ channel = map( (
+ channel.join ? channel.join(',') : ''+channel
+ ).split(','), function(channel) {
+ return channel + ',' + channel + PRESENCE_SUFFIX;
+ } ).join(',');
+
+ // Iterate over Channels
+ each( channel.split(','), function(channel) {
+ if (READY) LEAVE( channel, 0 );
+ CHANNELS[channel] = {};
+ } );
+
+ // ReOpen Connection if Any Channels Left
+ if (READY) CONNECT();
},
/*
PUBNUB.subscribe({
channel : 'my_chat'
- callback : function(message) { console.log(message) }
+ callback : function(message) { }
});
*/
'subscribe' : function( args, callback ) {
var channel = args['channel']
- , callback = callback || args['callback']
- , subscribe_key = args['subscribe_key'] || SUBSCRIBE_KEY
+ , callback = callback || args['callback']
+ , callback = callback || args['message']
+ , err = args['error'] || function(){}
+ , connect = args['connect'] || function(){}
+ , reconnect = args['reconnect'] || function(){}
+ , disconnect = args['disconnect'] || function(){}
+ , presence = args['presence'] || 0
, restore = args['restore']
- , timetoken = 0
- , error = args['error'] || function(){}
- , connect = args['connect'] || function(){}
- , reconnect = args['reconnect'] || function(){}
- , disconnect = args['disconnect'] || function(){}
- , presence = args['presence'] || function(){}
- , disconnected = 0
- , connected = 0
, origin = nextorigin(ORIGIN);
- // Reduce Status Flicker
- if (!READY) return READY_BUFFER.push([ args, callback, SELF ]);
+ // Restore Enabled?
+ if (restore) SUB_RESTORE = 1;
// Make sure we have a Channel
- if (!channel) return log('Missing Channel');
- if (!callback) return log('Missing Callback');
- if (!SUBSCRIBE_KEY) return log('Missing Subscribe Key');
-
- if (!(channel in CHANNELS)) CHANNELS[channel] = {};
+ if (!channel) return error('Missing Channel');
+ if (!callback) return error('Missing Callback');
+ if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
+
+ // Setup Channel(s)
+ each( (channel.join ? channel.join(',') : ''+channel).split(','),
+ function(channel) {
+ var settings = CHANNELS[channel] || {};
+
+ // Store Channel State
+ CHANNELS[SUB_CHANNEL = channel] = {
+ name : channel,
+ connected : settings.connected,
+ disconnected : settings.disconnected,
+ subscribed : 1,
+ callback : SUB_CALLBACK = callback,
+ connect : connect,
+ error : err,
+ disconnect : disconnect,
+ reconnect : reconnect
+ };
+
+ // Presence Enabled?
+ if (!presence) return;
+
+ // Subscribe Presence Channel
+ SELF.subscribe({
+ channel : channel + PRESENCE_SUFFIX,
+ callback : presence
+ });
- // Make sure we have a Channel
- if (CHANNELS[channel].connected) return log('Already Connected');
- CHANNELS[channel].connected = 1;
+ // Presence Subscribed?
+ if (settings.subscribed) return;
+
+ // See Who's Here Now
+ SELF['here_now']({
+ channel : channel,
+ callback : function(here) {
+ each( 'uuids' in here ? here['uuids'] : [],
+ function(uuid) { presence( {
+ 'action' : 'join',
+ 'uuid' : uuid,
+ 'timestamp' : rnow(),
+ 'occupancy' : here['occupancy'] || 1
+ }, here, channel ); } );
+ }
+ });
+ } );
- // Recurse Subscribe
+ // Evented Subscribe
function _connect() {
- var jsonp = jsonp_cb();
+ var jsonp = jsonp_cb()
+ , channels = generate_channel_list(CHANNELS).join(',');
// Stop Connection
- if (!CHANNELS[channel].connected) return;
+ if (!channels) return;
// Connect to PubNub Subscribe Servers
- CHANNELS[channel].done = xdr({
+ SUB_RECEIVER = xdr({
+ timeout : SUB_TIMEOUT,
callback : jsonp,
- data : { uuid: UUID },
+ data : { 'uuid' : UUID },
url : [
origin, 'subscribe',
- subscribe_key, encode(channel),
- jsonp, timetoken
+ SUBSCRIBE_KEY, encode(channels),
+ jsonp, TIMETOKEN
],
fail : function() {
// Disconnect
- if (!disconnected) {
- disconnected = 1;
- disconnect();
- leave();
- }
+ each_channel(function(channel){
+ if (channel.disconnected) return;
+ channel.disconnected = 1;
+ channel.disconnect(channel.name);
+ });
+
+ // New Origin on Failed Connection
+ origin = nextorigin(ORIGIN);
+
+ // Reconnect
timeout( _connect, SECOND );
SELF['time'](function(success){
- // Reconnect
- if (success && disconnected) {
- disconnected = 0;
- reconnect();
- }
- else {
- error();
- }
+ each_channel(function(channel){
+ if (success && channel.disconnected){
+ channel.disconnected = 0;
+ channel.reconnect(channel.name);
+ }
+ else channel.error();
+ });
});
},
success : function(messages) {
- if (!CHANNELS[channel].connected) return;
+ if (!messages) return timeout( _connect, 10 );
// Connect
- if (!connected) {
- connected = 1;
- connect();
- }
-
- // Reconnect
- if (disconnected) {
- disconnected = 0;
- reconnect();
- }
+ each_channel(function(channel){
+ if (channel.connected) return;
+ channel.connected = 1;
+ channel.connect(channel.name);
+ });
// Restore Previous Connection Point if Needed
- // Also Update Timetoken
- restore = db.set(
- SUBSCRIBE_KEY + channel,
- timetoken = restore && db.get(
- subscribe_key + channel
- ) || messages[1]
- );
+ if (!TIMETOKEN && SUB_RESTORE)
+ TIMETOKEN = db.get(SUBSCRIBE_KEY) || messages[1];
+ else TIMETOKEN = messages[1];
+
+ // Update Saved Timetoken
+ db.set( SUBSCRIBE_KEY, messages[1] );
+
+ // Route Channel <---> Callback for Message
+ var next_callback = (function() {
+ var channels = (messages.length>2?messages[2]:'')
+ , list = channels.split(',');
+
+ return function() {
+ var channel = list.shift()||'';
+ return [
+ (CHANNELS[channel]||{})
+ .callback||SUB_CALLBACK,
+ (channel||SUB_CHANNEL)
+ .split(PRESENCE_SUFFIX)[0]
+ ];
+ };
+ })();
each( messages[0], function(msg) {
- callback( msg, messages );
+ var next = next_callback();
+ if (!CHANNELS[next[1]].subscribed) return;
+ next[0]( msg, messages, next[1] );
} );
timeout( _connect, 10 );
}
});
}
- // Announce Leave Event
- function leave(chan) {
- var data = { uuid : UUID }
- , jsonp = jsonp_cb()
- , chann = chan || channel;
+ CONNECT = function() {
+ // Close Previous Subscribe Connection
+ SUB_RECEIVER && SUB_RECEIVER();
- if (jsonp != '0') data['callback'] = jsonp;
-
- xdr({
- blocking : 1,
- callback : jsonp,
- data : data,
- url : [
- origin, 'v2', 'presence',
- 'sub_key', SUBSCRIBE_KEY,
- 'channel', encode(channel),
- 'leave'
- ]
- });
+ // Begin Recursive Subscribe
+ clearTimeout(SUB_BUFF_WAIT);
+ SUB_BUFF_WAIT = timeout( _connect, 100 );
+ };
- return true;
- }
-
- LEAVE = leave;
-
- // onBeforeUnload
- bind( 'beforeunload', window, leave );
-
- // Presence Subscribe
- if (args['presence']) SELF.subscribe({
- channel : args['channel'] + PRESENCE_SUFFIX,
- callback : presence,
- restore : args['restore'],
- disconnect : leave
- });
+ // Reduce Status Flicker
+ if (!READY) return READY_BUFFER.push(CONNECT);
- // Begin Recursive Subscribe
- _connect();
+ // Connect Now
+ CONNECT();
},
'here_now' : function( args, callback ) {
var callback = args['callback'] || callback
+ , err = args['error'] || function(){}
, channel = args['channel']
, jsonp = jsonp_cb()
- , data = {}
- , origin = nextorigin(ORIGIN);
+ , data = {};
// Make sure we have a Channel
- if (!channel) return log('Missing Channel');
- if (!callback) return log('Missing Callback');
- if (!SUBSCRIBE_KEY) return log('Missing Subscribe Key');
+ if (!channel) return error('Missing Channel');
+ if (!callback) return error('Missing Callback');
+ if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
if (jsonp != '0') data['callback'] = jsonp;
- // Send Message
xdr({
callback : jsonp,
data : data,
success : function(response) { callback(response) },
- fail : function(response) { log(response) },
+ fail : err,
url : [
- origin, 'v2', 'presence',
+ ORIGIN, 'v2', 'presence',
'sub_key', SUBSCRIBE_KEY,
'channel', encode(channel)
]
@@ -1002,18 +868,54 @@ var PDIV = $('pubnub') || {}
'updater' : updater,
'init' : CREATE_PUBNUB
};
-
- if (!UUID) UUID = SELF.uuid();
+
+ function each_channel(callback) {
+ each( generate_channel_list(CHANNELS), function(channel) {
+ callback(CHANNELS[channel]||{});
+ } );
+ }
+
+ if (!UUID) UUID = SELF['uuid']();
db.set( SUBSCRIBE_KEY + 'uuid', UUID );
-
+
+ // Announce Leave Event
+ LEAVE = function( channel, blocking ) {
+ var data = { 'uuid' : UUID }
+ , origin = nextorigin(ORIGIN)
+ , jsonp = jsonp_cb();
+
+ // Prevent Leaving a Presence Channel
+ if (channel.indexOf(PRESENCE_SUFFIX) > 0) return;
+
+ if (jsonp != '0') data['callback'] = jsonp;
+
+ xdr({
+ blocking : blocking || SSL,
+ timeout : 2000,
+ callback : jsonp,
+ data : data,
+ url : [
+ origin, 'v2', 'presence', 'sub_key',
+ SUBSCRIBE_KEY, 'channel', encode(channel), 'leave'
+ ]
+ });
+ };
+
+ // Add Leave Functions
+ bind( 'beforeunload', window, function() {
+ each_channel(function(ch){ LEAVE( ch.name, 1 ) });
+ return true;
+ } );
+
return SELF;
};
// CREATE A PUBNUB GLOBAL OBJECT
PUBNUB = CREATE_PUBNUB({
'publish_key' : attr( PDIV, 'pub-key' ),
'subscribe_key' : attr( PDIV, 'sub-key' ),
- 'ssl' : !document.location.href.indexOf('https') || attr( PDIV, 'ssl' ) == 'on',
+ 'ssl' : !document.location.href.indexOf('https') ||
+ attr( PDIV, 'ssl' ) == 'on',
'origin' : attr( PDIV, 'origin' ),
'uuid' : attr( PDIV, 'uuid' )
});
@@ -1033,14 +935,11 @@ function ready() { PUBNUB['time'](rnow);
PUBNUB['time'](function(t){ timeout( function() {
if (READY) return;
READY = 1;
- each( READY_BUFFER, function(sub) {
- sub[2]['subscribe']( sub[0], sub[1] )
- } );
+ each( READY_BUFFER, function(connect) { connect() } );
}, SECOND ); }); }
// Bind for PUBNUB Readiness to Subscribe
-if (document.readyState === "complete") { ready(); }
-else bind( 'load', window, function(){ timeout( ready, 0 ) } );
+bind( 'load', window, function(){ timeout( ready, 0 ) } );
// Create Interface for Opera Flash
PUBNUB['rdx'] = function( id, data ) {
View
22 javascript/pubnub-3.4.min.js
@@ -0,0 +1,22 @@
+function n(){return function(){}}
+window.JSON&&window.JSON.stringify||function(){function a(a){b.lastIndex=0;return b.test(a)?'"'+a.replace(b,function(a){var b=j[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(b,j){var i,l,h,g,m=e,k,d=j[b];d&&("object"===typeof d&&"function"===typeof d.toJSON)&&(d=d.toJSON(b));"function"===typeof p&&(d=p.call(j,b,d));switch(typeof d){case "string":return a(d);case "number":return isFinite(d)?String(d):"null";case "boolean":case "null":return String(d);
+case "object":if(!d)return"null";e+=f;k=[];if("[object Array]"===Object.prototype.toString.apply(d)){g=d.length;for(i=0;i<g;i+=1)k[i]=c(i,d)||"null";h=0===k.length?"[]":e?"[\n"+e+k.join(",\n"+e)+"\n"+m+"]":"["+k.join(",")+"]";e=m;return h}if(p&&"object"===typeof p){g=p.length;for(i=0;i<g;i+=1)l=p[i],"string"===typeof l&&(h=c(l,d))&&k.push(a(l)+(e?": ":":")+h)}else for(l in d)Object.hasOwnProperty.call(d,l)&&(h=c(l,d))&&k.push(a(l)+(e?": ":":")+h);h=0===k.length?"{}":e?"{\n"+e+k.join(",\n"+e)+"\n"+
+m+"}":"{"+k.join(",")+"}";e=m;return h}}window.JSON||(window.JSON={});"function"!==typeof String.prototype.toJSON&&(String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var b=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,f,j={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},p;"function"!==typeof JSON.stringify&&(JSON.stringify=function(a,
+b,i){var j;f=e="";if(typeof i==="number")for(j=0;j<i;j=j+1)f=f+" ";else typeof i==="string"&&(f=i);if((p=b)&&typeof b!=="function"&&(typeof b!=="object"||typeof b.length!=="number"))throw Error("JSON.stringify");return c("",{"":a})});"function"!==typeof JSON.parse&&(JSON.parse=function(a){return eval("("+a+")")})}();
+if(!window.PUBNUB){var o=function(){return"x"+ ++aa+""+ +new Date},q=function(){return+new Date},ca=function(a,c){function b(){f+c>q()?(clearTimeout(e),e=setTimeout(b,c)):(f=q(),a())}var e,f=0;return b},r=function(a){return document.getElementById(a)},s=function(a){console.error(a)},v=function(a,c){var b=[];u(a.split(/\s+/),function(a){u((c||document).getElementsByTagName(a),function(a){b.push(a)})});return b},u=function(a,c){if(a&&c)if("undefined"!=typeof a[0])for(var b=0,e=a.length;b<e;)c.call(a[b],
+a[b],b++);else for(b in a)a.hasOwnProperty&&a.hasOwnProperty(b)&&c.call(a[b],b,a[b])},x=function(a,c){var b=[];u(a||[],function(a,f){b.push(c(a,f))});return b},da=function(a,c){var b=[];u(a||[],function(a){c(a)&&b.push(a)});return b},fa=function(a,c){return a.replace(ea,function(a,e){return c[e]||a})},y=function(a,c,b){u(a.split(","),function(a){function f(a){a||(a=window.event);b(a)||(a.cancelBubble=!0,a.returnValue=!1,a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation())}
+c.addEventListener?c.addEventListener(a,f,!1):c.attachEvent?c.attachEvent("on"+a,f):c["on"+a]=f})},z=function(){return v("head")[0]},B=function(a,c,b){if(b)a.setAttribute(c,b);else return a&&a.getAttribute&&a.getAttribute(c)},C=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(e){}},D=function(a){return document.createElement(a)},G=function(){return E||F()?0:o()},H=function(a){return x(encodeURIComponent(a).split(""),
+function(a){return 0>"-_.!~*'()".indexOf(a)?a:"%"+a.charCodeAt(0).toString(16).toUpperCase()}).join("")},M=function(a){function c(a,b){U||(U=1,a||ka(b),d.onerror=null,clearTimeout(la),setTimeout(function(){a&&ma();var b=r(t),c=b&&b.parentNode;c&&c.removeChild(b)},I))}if(E||F()){a:{var b,e,f=function(){if(!p){p=1;clearTimeout(A);try{e=JSON.parse(b.responseText)}catch(a){return h(1)}l(e)}},j=0,p=0,w=a.timeout||J,A=setTimeout(function(){h(1)},w),i=a.b||n(),l=a.c||n(),h=function(a){j||(j=1,clearTimeout(A),
+b&&(b.onerror=b.onload=null,b.abort&&b.abort(),b=null),a&&i())};try{b=F()||window.XDomainRequest&&new XDomainRequest||new XMLHttpRequest;b.onerror=b.onabort=function(){h(1)};b.onload=b.onloadend=f;b.timeout=w;var g=a.url.join(K);if(a.data){var f=[],m,g=g+"?";for(m in a.data)f.push(m+"="+a.data[m]);g+=f.join(L)}b.open("GET",g,typeof("undefined"===a.g));b.send()}catch(k){h(0);E=0;a=M(a);break a}a=h}return a}var d=D("script"),g=a.a,t=o(),U=0,la=setTimeout(function(){c(1)},a.timeout||J),ma=a.b||n(),ka=
+a.c||n();window[g]=function(a){c(0,a)};a.g||(d[N]=N);d.onerror=function(){c(1)};d.src=a.url.join(K);if(a.data){g=[];d.src+="?";for(key in a.data)g.push(key+"="+a.data[key]);d.src+=g.join(L)}B(d,"id",t);z().appendChild(d);return c},O=function(a){var c=[];u(a,function(a,e){e.f&&c.push(a)});return c.sort()},S=function(){PUBNUB.time(q);PUBNUB.time(function(){setTimeout(function(){Q||(Q=1,u(R,function(a){a()}))},I)})},F=function(){if(!ga.get)return 0;var a={id:F.id++,send:n(),abort:function(){a.id={}},
+open:function(c,b){F[a.id]=a;ga.get(a.id,b)}};return a},aa=1,ea=/{([\w\-]+)}/g,N="async",K="/",L="&",ha=31E4,J=1E4,I=1E3,T="-pnpres",E=-1==navigator.userAgent.indexOf("MSIE 6");window.console||(window.console=window.console||{});console.error||(console.error=(window.opera||{}).postError||n());var V,W=window.localStorage;V={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){u(Z.list[a]||[],function(a){a(c)})}},$=r("pubnub")||{},Q=0,R=[],pa=function(a){function c(){}function b(){}function e(a){u(O(f),function(b){a(f[b]||{})})}var f={},
+j=0,p=0,w=0,A=0,i=0,l=0,h=a.publish_key||"",g=a.subscribe_key||"",m=a.ssl?"s":"",k=a.uuid||V.get(g+"uuid")||"",d="http"+m+"://"+(a.origin||"pubsub.pubnub.com"),t={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=G();if(!i)return s("Missing Channel");if(!b)return s("Missing Callback");if(!g)return s("Missing Subscribe Key");j.count=c;j.reverse=e;k&&(j.start=k);h&&(j.end=h);M({a:l,data:j,c:function(a){b(a)},b:f,
+url:[d,"v2","history","sub-key",g,"channel",H(i)]})},time:function(a){var b=G(),c=X(d);M({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=G();if(!c)return s("Missing Message");if(!e)return s("Missing Channel");if(!h)return s("Missing Publish Key");
+if(!g)return s("Missing Subscribe Key");c=JSON.stringify(c);c=[d,"publish",h,g,0,H(e),f,H(c)];M({a:f,c:function(a){b(a)},b:function(){b([0,"Disconnected"])},url:c,data:{uuid:k}})},unsubscribe:function(a){a=a.channel;a=x((a.join?a.join(","):""+a).split(","),function(a){return a+","+a+T}).join(",");u(a.split(","),function(a){Q&&b(a,0);f[a]={}});Q&&c()},subscribe:function(a,b){function h(){var a=G(),b=O(f).join(",");b&&(w=M({timeout:ha,a:a,data:{uuid:k},url:[ba,"subscribe",g,H(b),a,l],b:function(){e(function(a){a.d||
+(a.d=1,a.j(a.name))});ba=X(d);setTimeout(h,I);t.time(function(a){e(function(b){a&&b.d?(b.d=0,b.k(b.name)):b.error()})})},c:function(a){if(!a)return setTimeout(h,10);e(function(a){a.e||(a.e=1,a.i(a.name))});l=!l&&A?V.get(g)||a[1]:a[1];V.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||p).split(T)[0]]};u(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,ia=a.error||
+n(),ja=a.connect||n(),na=a.reconnect||n(),oa=a.disconnect||n(),P=a.presence||0,qa=a.restore,ba=X(d);qa&&(A=1);if(!m)return s("Missing Channel");if(!b)return s("Missing Callback");if(!g)return s("Missing Subscribe Key");u((m.join?m.join(","):""+m).split(","),function(a){var c=f[a]||{};f[p=a]={name:a,e:c.e,d:c.d,f:1,a:j=b,i:ja,error:ia,j:oa,k:na};P&&(t.m({h:a+T,a:P}),c.f||t.here_now({h:a,a:function(b){u("uuids"in b?b.uuids:[],function(c){P({action:"join",uuid:c,timestamp:q(),occupancy:b.occupancy||
+1},b,a)})}}))});c=function(){w&&w();clearTimeout(i);i=setTimeout(h,100)};if(!Q)return R.push(c);c()},here_now:function(a,b){var b=a.callback||b,c=a.error||n(),e=a.channel,f=G(),h={};if(!e)return s("Missing Channel");if(!b)return s("Missing Callback");if(!g)return s("Missing Subscribe Key");"0"!=f&&(h.callback=f);M({a:f,data:h,c:function(a){b(a)},b:c,url:[d,"v2","presence","sub_key",g,"channel",H(e)]})},xdr:M,ready:S,db:V,each:u,map:x,grep:da,css:C,$:r,create:D,bind:y,supplant:fa,head:z,search:v,attr:B,
+now:q,unique:o,events:Z,updater:ca,init:pa};k||(k=t.uuid());V.set(g+"uuid",k);b=function(a,b){var c={uuid:k},e=X(d),f=G();0<a.indexOf(T)||("0"!=f&&(c.callback=f),M({g:b||m,timeout:2E3,a:f,data:c,url:[e,"v2","presence","sub_key",g,"channel",H(a),"leave"]}))};y("beforeunload",window,function(){e(function(a){b(a.name,1)});return!0});return t};PUBNUB=pa({publish_key:B($,"pub-key"),subscribe_key:B($,"sub-key"),ssl:!document.location.href.indexOf("https")||"on"==B($,"ssl"),origin:B($,"origin"),uuid:B($,
+"uuid")});C($,{position:"absolute",top:-I});if("opera"in window||B($,"flash"))$.innerHTML="<object id=pubnubs data=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=movie value=https://dh15atwfs066y.cloudfront.net/pubnub.swf><param name=allowscriptaccess value=always></object>";var ga=r("pubnubs")||{};y("load",window,function(){setTimeout(S,0)});PUBNUB.rdx=function(a,c){if(!c)return F[a].onerror();F[a].responseText=unescape(c);F[a].onload()};F.id=I;window.jQuery&&(window.jQuery.PUBNUB=PUBNUB);
+"undefined"!==typeof module&&(module.l=PUBNUB)&&S()};
View
BIN javascript/pubnub-3.4.min.js.gz
Binary file not shown.
View
47 javascript/pubnub.as
@@ -1,47 +0,0 @@
-package {
- import flash.external.ExternalInterface;
- import flash.display.Sprite;
- import flash.net.URLLoader;
- import flash.net.URLRequest;
- import flash.events.Event;
- import flash.events.IOErrorEvent;
- import flash.events.SecurityErrorEvent;
- import flash.system.Security;
- import flash.utils.setTimeout;
-
- public class pubnub extends Sprite {
-
- Security.allowDomain("*");
- Security.allowInsecureDomain("*");
-
- ExternalInterface.addCallback( "get", function(
- id:Number,
- url:String
- ):void {
- function handler(e:Event):void {
- var loader:URLLoader = URLLoader(e.target)
- , data:String = loader.data
- , timeout:int = 1;
-
- if (e.type == 'securityError') {
- data = '[1,"S"]';
- timeout = 1000;
- }
-
- setTimeout( function delayed():void {
- ExternalInterface.call( "PUBNUB.rdx", id, escape(data) );
- loader.close();
- }, timeout );
- }
-
- var loader:URLLoader = new URLLoader();
-
- loader.addEventListener( Event.COMPLETE, handler );
- loader.addEventListener( IOErrorEvent.IO_ERROR, handler );
- loader.addEventListener(
- SecurityErrorEvent.SECURITY_ERROR, handler
- );
- loader.load(new URLRequest(url));
- });
- }
-}
View
BIN javascript/pubnub.swf
Binary file not shown.

0 comments on commit 2e20b52

Please sign in to comment.