activemq-artemis/examples/jms/stomp-websockets/aerogear-chat/aerogear.min.js

19 lines
68 KiB
JavaScript
Raw Normal View History

/*! AeroGear JavaScript Library - v1.4.0-dev - 2014-01-19
* https://github.com/aerogear/aerogear-js
* JBoss, Home of Professional Open Source
* Copyright Red Hat, Inc., and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(e,t){function r(e,t,r){if(4!==t.length)throw new h.exception.invalid("invalid aes block size");var n=e.c[r],a=t[0]^n[0],i=t[r?3:1]^n[1],s=t[2]^n[2];t=t[r?1:3]^n[3];var o,c,u,f,l=n.length/4-2,d=4,p=[0,0,0,0];o=e.n[r],e=o[0];var g=o[1],m=o[2],y=o[3],b=o[4];for(f=0;l>f;f++)o=e[a>>>24]^g[255&i>>16]^m[255&s>>8]^y[255&t]^n[d],c=e[i>>>24]^g[255&s>>16]^m[255&t>>8]^y[255&a]^n[d+1],u=e[s>>>24]^g[255&t>>16]^m[255&a>>8]^y[255&i]^n[d+2],t=e[t>>>24]^g[255&a>>16]^m[255&i>>8]^y[255&s]^n[d+3],d+=4,a=o,i=c,s=u;for(f=0;4>f;f++)p[r?3&-f:f]=b[a>>>24]<<24^b[255&i>>16]<<16^b[255&s>>8]<<8^b[255&t]^n[d++],o=a,a=i,i=s,s=t,t=o;return p}function n(e,t){var r,n,a,i=t.slice(0),s=e.u,o=e.c,c=s[0],u=s[1],h=s[2],f=s[3],l=s[4],d=s[5],p=s[6],g=s[7];for(r=0;64>r;r++)16>r?n=i[r]:(n=i[15&r+1],a=i[15&r+14],n=i[15&r]=0|(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(a>>>17^a>>>19^a>>>10^a<<15^a<<13)+i[15&r]+i[15&r+9]),n=n+g+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(p^l&(d^p))+o[r],g=p,p=d,d=l,l=0|f+n,f=h,h=u,u=c,c=0|n+(u&h^f&(u^h))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10);s[0]=0|s[0]+c,s[1]=0|s[1]+u,s[2]=0|s[2]+h,s[3]=0|s[3]+f,s[4]=0|s[4]+l,s[5]=0|s[5]+d,s[6]=0|s[6]+p,s[7]=0|s[7]+g}function a(e,t){var r,n=h.random.F[e],a=[];for(r in n)n.hasOwnProperty(r)&&a.push(n[r]);for(r=0;a.length>r;r++)a[r](t)}function i(e){e.c=s(e).concat(s(e)),e.H=new h.cipher.aes(e.c)}function s(e){for(var t=0;4>t&&(e.h[t]=0|e.h[t]+1,!e.h[t]);t++);return e.H.encrypt(e.h)}this.AeroGear={},AeroGear.Core=function(){if(this instanceof AeroGear.Core)throw"Invalid instantiation of base class AeroGear.Core";this.add=function(e){var t,r,n=this[this.collectionName]||{};if(this[this.collectionName]=n,!e)return this;if("string"==typeof e)n[e]=AeroGear[this.lib].adapters[this.type](e,this.config);else if(AeroGear.isArray(e))for(t=0;e.length>t;t++)r=e[t],"string"==typeof r?n[r]=AeroGear[this.lib].adapters[this.type](r,this.config):r.name&&(r.settings=AeroGear.extend(r.settings||{},this.config),r.settings.recordId=r.settings.recordId||r.recordId,n[r.name]=AeroGear[this.lib].adapters[r.type||this.type](r.name,r.settings));else{if(!e.name)return this;e.settings=AeroGear.extend(e.settings||{},this.config),e.settings.recordId=e.settings.recordId||e.recordId,n[e.name]=AeroGear[this.lib].adapters[e.type||this.type](e.name,e.settings)}return this[this.collectionName]=n,this},this.remove=function(e){var t,r,n=this[this.collectionName]||{};if("string"==typeof e)delete n[e];else if(AeroGear.isArray(e))for(t=0;e.length>t;t++)r=e[t],"string"==typeof r?delete n[r]:delete n[r.name];else e&&delete n[e.name];return this[this.collectionName]=n,this}},AeroGear.isArray=function(e){return"[object Array]"==={}.toString.call(e)},AeroGear.extend=function(e,t){var r;for(r in t)e[r]=t[r];return e},function(){function e(e,t,r){var n=t&&r||0,a=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){16>a&&(t[n+a++]=g[e])});16>a;)t[n+a++]=0;return t}function t(e,t){var r=t||0,n=p;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}function r(e,r,n){var a=r&&n||0,i=r||[];e=e||{};var s=null!=e.clockseq?e.clockseq:v,o=null!=e.msecs?e.msecs:(new Date).getTime(),c=null!=e.nsecs?e.nsecs:x+1,u=o-A+(c-x)/1e4;if(0>u&&null==e.clockseq&&(s=16383&s+1),(0>u||o>A)&&null==e.nsecs&&(c=0),c>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");A=o,x=c,v=s,o+=122192928e5;var h=(1e4*(268435455&o)+c)%4294967296;i[a++]=255&h>>>24,i[a++]=255&h>>>16,i[a++]=255&h>>>8,i[a++]=255&h;var f=268435455&1e4*(o/4294967296);i[a++]=255&f>>>8,i[a++]=255&f,i[a++]=16|15&f>>>24,i[a++]=255&f>>>16,i[a++]=128|s>>>8,i[a++]=255&s;for(var l=e.node||b,d=0;6>d;d++)i[a+d]=l[d];return r?r:t(i)}function n(e,r,n){var a=r&&n||0;"string"==typeof e&&(r="binary"==e?new d(16):null,e=null),e=e||{};var i=e.random||(e.rng||l)();if(i[6]=64|15&i[6],i[8]=128|63&i[8],r)for(var s=0;16>s;s++)r[a+s]=i[s];return r||t(i)}var a,i,s,o=this,c=Array(16);if(a=function(){for(var e,e,t=c,r=0,r=0;16>r;r++)0==(3&r)&&(e=4294967296*Math.random()),t[r]=255&e>>>
for(var u in n){r=n[u].trim().split(";");for(var h in r)a=r[h].trim(),0===a.indexOf("<")&&a.lastIndexOf(">")===r[h].length-1?i=a.substr(1,a.length-2).split("?")[1]:0===a.indexOf("rel=")&&(a.indexOf(c.previousIdentifier)>=0?s=c.previousIdentifier:a.indexOf(c.nextIdentifier)>=0&&(s=c.nextIdentifier));s&&(o[s]=i,s=t)}return o},this.headerPageParser=function(e){var t=e.getResponseHeader(c.previousIdentifier),r=e.getResponseHeader(c.nextIdentifier),n={},a={};return c.parameterProvider?(n=c.parameterProvider(e),a[c.previousIdentifier]=n[c.previousIdentifier],a[c.nextIdentifier]=n[c.nextIdentifier]):(a[c.previousIdentifier]=t?t.split("?")[1]:null,a[c.nextIdentifier]=r?r.split("?")[1]:null),a},this.bodyPageParser=function(e){var t={},r={};return c.parameterProvider?(r=c.parameterProvider(e),t[c.previousIdentifier]=r[c.previousIdentifier],t[c.nextIdentifier]=r[c.nextIdentifier]):(t[c.previousIdentifier]=e[c.previousIdentifier],t[c.nextIdentifier]=e[c.nextIdentifier]),t},this.formatJSONError=function(e){if("json"===this.getAjaxSettings().dataType)try{e.responseJSON=JSON.parse(e.responseText)}catch(t){}return e}},AeroGear.Pipeline.adapters.Rest.prototype.read=function(e){var r,n,a,i,s=this,o=this.getRecordId(),c=this.getAjaxSettings(),u=this.getPageConfig();if(e=e?e:{},e.query=e.query?e.query:{},r=e[o]?c.url+"/"+e[o]:c.url,u&&e.paging!==!1){e.paging||(e.paging={offset:e.offsetValue||0,limit:e.limitValue||10}),e.query=e.query||{};for(var h in e.paging)e.query[h]=e.paging[h]}return n=function(r,n,a){var i;u&&e.paging!==!1&&(i=s[u.metadataLocation+"PageParser"]("body"===u.metadataLocation?r:a),["previous","next"].forEach(function(n){r[n]=function(e,r,n){return function(a){return n.paging=!0,n.offsetValue=n.limitValue=t,n.query=r,n.success=a&&a.success?a.success:n.success,n.error=a&&a.error?a.error:n.error,e.read(n)}}(s,i[u[n+"Identifier"]],e)})),e.success&&e.success.apply(this,arguments)},a=function(t){t=s.formatJSONError(t),e.error&&e.error.apply(this,arguments)},i={type:"GET",data:e.query,success:n,error:a,url:r,statusCode:e.statusCode,complete:e.complete,headers:e.headers,timeout:this.getTimeout()},e.jsonp&&(i.dataType="jsonp",i.jsonp=e.jsonp.callback?e.jsonp.callback:"callback",e.jsonp.customCallback&&(i.jsonpCallback=e.jsonp.customCallback)),this.getAuthorizer()?this.getAuthorizer().execute(jQuery.extend({},e,i)):jQuery.ajax(jQuery.extend({},this.getAjaxSettings(),i))},AeroGear.Pipeline.adapters.Rest.prototype.save=function(t,r){var n,a,i,s,o,c,u,h=this,f=this.getRecordId(),l=this.getAjaxSettings();if(t=t||{},r=r||{},n=t[f]?"PUT":"POST",a=t[f]?l.url+"/"+t[f]:l.url,i=function(){r.success&&r.success.apply(this,arguments)},s=function(e){e=h.formatJSONError(e),r.error&&r.error.apply(this,arguments)},o=jQuery.extend({},l,{data:t,type:n,url:a,success:i,error:s,statusCode:r.statusCode,complete:r.complete,headers:r.headers,timeout:this.getTimeout()}),"FormData"in e){c=new FormData;for(u in t)c.append(u,t[u]),(t[u]instanceof File||t[u]instanceof Blob)&&(o.contentType=!1,o.processData=!1);o.contentType===!1&&(o.data=c),o.xhr=function(){var e=jQuery.ajaxSettings.xhr();return e.upload&&e.upload.addEventListener("progress",function(){r.progress&&r.progress.apply(this,arguments)},!1),e}}return"application/json"===o.contentType&&o.data&&"string"!=typeof o.data&&(o.data=JSON.stringify(o.data)),this.getAuthorizer()?this.getAuthorizer().execute(jQuery.extend({},r,o)):jQuery.ajax(jQuery.extend({},this.getAjaxSettings(),o))},AeroGear.Pipeline.adapters.Rest.prototype.remove=function(e,t){var r,n,a,i,s,o=this,c=this.getRecordId(),u=this.getAjaxSettings(),h="";return"string"==typeof e||"number"==typeof e?r=e:e&&e[c]?r=e[c]:e&&!t&&(t=e),t=t||{},h=r?"/"+r:"",n=u.url+h,a=function(){t.success&&t.success.apply(this,arguments)},i=function(e){e=o.formatJSONError(e),t.error&&t.error.apply(this,arguments)},s={type:"DELETE",url:n,success:a,error:i,statusCode:t.statusCode,complete:t.complete,headers:t.headers,timeout:this.getTimeout()},this.getAuthorizer()?this.getAuthorizer().execute(jQuery.extend({},t,s)):jQuery.ajax(jQuery.extend({},this.getAjaxSettings(),s))
t>=0&&r.splice(t,1)},this.getState=function(){return i},this.setState=function(e){i=e},this.getClient=function(){return s},this.setClient=function(e){s=e},!n&&!r.length||t.login||t.password||this.connect({url:a,onConnect:t.onConnect,onConnectError:t.onConnectError})},AeroGear.Notifier.adapters.stompws.prototype.connect=function(e){e=e||{};var t=this,r=new Stomp.client(e.url||this.getConnectURL(),e.protocol||"v11.stomp"),n=function(){var r=t.getChannels().slice(0);t.setState(AeroGear.Notifier.CONNECTED),t.subscribe(r,!0),e.onConnect&&e.onConnect.apply(this,arguments)},a=function(){t.setState(AeroGear.Notifier.DISCONNECTED),e.onConnectError&&e.onConnectError.apply(this,arguments)};r.connect(e.login,e.password,n,a,e.host),this.setClient(r)},AeroGear.Notifier.adapters.stompws.prototype.disconnect=function(e){var t=this,r=this.getClient(),n=function(){t.getState()===AeroGear.Notifier.DISCONNECTING&&(t.setState(AeroGear.Notifier.DISCONNECTED),e&&e.apply(this,arguments))};this.getState()===AeroGear.Notifier.CONNECTED&&(this.setState(AeroGear.Notifier.DISCONNECTING),r.disconnect(n))},AeroGear.Notifier.adapters.stompws.prototype.subscribe=function(e,t){var r=this.getClient();t&&this.unsubscribe(this.getChannels()),e=AeroGear.isArray(e)?e:[e];for(var n=0;e.length>n;n++)e[n].id=r.subscribe(e[n].address,e[n].callback),this.addChannel(e[n])},AeroGear.Notifier.adapters.stompws.prototype.debug=function(e){var t=this.getClient(),r=function(){e&&e.apply(this,arguments)};t&&(t.debug=r)},AeroGear.Notifier.adapters.stompws.prototype.unsubscribe=function(e){var t=this.getClient(),r=this.getChannels();e=AeroGear.isArray(e)?e:[e];for(var n=0;e.length>n;n++)t.unsubscribe(e[n].id||r[this.getChannelIndex(e[n].address)].id),this.removeChannel(e[n])},AeroGear.Notifier.adapters.stompws.prototype.send=function(e,t){var r={},n=this.getClient();t=t||"",t.headers&&(r=t.headers,t=t.body),n.send(e,r,t)},function(r,n){r.UnifiedPushClient=function(a,i,s){if(!a||!i||!s)throw"UnifiedPushClientException";return this instanceof r.UnifiedPushClient?(this.registerWithPushServer=function(t){t=t||{};var o=t.metadata||{};if(!o.deviceToken)throw"UnifiedPushRegistrationException";return o.categories=r.isArray(o.categories)?o.categories:o.categories?[o.categories]:[],n.ajax({contentType:"application/json",dataType:"json",type:"POST",url:s,headers:{Authorization:"Basic "+e.btoa(a+":"+i)},data:JSON.stringify(o),success:t.success,error:t.error,complete:t.complete})},this.unregisterWithPushServer=function(t,r){return r=r||{},n.ajax({contentType:"application/json",dataType:"json",type:"DELETE",url:s+"/"+t,headers:{Authorization:"Basic "+e.btoa(a+":"+i)},success:r.success,error:r.error,complete:r.complete})},t):new r.UnifiedPushClient(a,i,s)}}(AeroGear,jQuery),function(t,r){t.SimplePushClient=function(n){if(!(this instanceof t.SimplePushClient))return new t.SimplePushClient(n);if(this.options=n||{},!navigator.push||!this.options.useNative){if(this.options.useNative)if("WebSocket"in e)this.options.simplePushServerURL="wss://push.services.mozilla.com";else{if(!this.options.simplePushServerURL)throw"SimplePushConfigurationError";this.options.useNative=!1}var a=this,i={onConnect:function(){navigator.push=function(){return{register:function(){var e={onsuccess:function(){}};if(!a.simpleNotifier)throw"SimplePushConnectionError";return a.simpleNotifier.subscribe({requestObject:e,callback:function(e){r(navigator.push).trigger({type:"push",message:e})}}),e},unregister:function(e){a.simpleNotifier.unsubscribe(e)},reconnect:function(){a.simpleNotifier.connect(i)}}}(),navigator.setMessageHandler=function(e,t){r(navigator.push).on(e,function(e){var r=e.message;t.call(this,r)})},a.options.onConnect&&a.options.onConnect()},onClose:function(){a.simpleNotifier.disconnect(a.options.onClose)}};a.simpleNotifier=t.Notifier({name:"agPushNetwork",type:"SimplePush",settings:{connectURL:a.options.simplePushServerURL,useNative:a.options.useNative}}).clients.agPushNetwork,a.simpleNotifier.connect(i)}}}(AeroGear,jQuery),AeroGear.Crypto=function(){if(!e.crypto||!e.crypto.getRandomValues)throw"Your brows
//@ sourceMappingURL=aerogear.js.map