").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
7 |
--------------------------------------------------------------------------------
/Server/public/main.js:
--------------------------------------------------------------------------------
1 | var username = prompt("What is your name", "Type you name here");
2 |
3 | $(function() {
4 | var FADE_TIME = 150; // ms
5 | var COLORS = [
6 | '#FF5600', '#339864', '#AA7C39', '#C64300',
7 | '#339900', '#11C164', '#33B039', '#9B5D00',
8 | '#0D58A6', '#094481', '#00AA72', '#006746'
9 | ];
10 |
11 | var $window = $(window);
12 | var $messages = $('.messages'); // Messages area
13 | var $inputMessage = $('.inputMessage'); // Input message input box
14 |
15 | var connected = false;
16 |
17 | var socket = io();
18 |
19 | socket.emit('addUser', username);
20 | $currentInput = $inputMessage.focus();
21 |
22 | // wrap Socket.io in RX
23 | // ref: https://github.com/Reactive-Extensions/RxJS/issues/112
24 | var rxEvent = Rx.Observable.create (function (obs) {
25 | // Handle messages
26 | socket.io.on('packet', function (packet) {
27 | if (packet.data) obs.onNext({
28 | name: packet.data[0],
29 | data: packet.data[1]
30 | });
31 | });
32 | socket.on('error', function (err) { obs.onError(err); });
33 | socket.on('reconnect_error', function (err) { obs.onError(err); });
34 | socket.on('reconnect_failed', function () { obs.onError(new Error('reconnection failed')); });
35 | socket.io.on('close', function () { obs.onCompleted(); });
36 |
37 | // Return way to unsubscribe
38 | return function() {
39 | socket.close();
40 | };
41 | });
42 |
43 | function addParticipantsMessage (data) {
44 | var message = '';
45 | if (data.numUsers === 1) {
46 | message += "there's 1 participant";
47 | } else {
48 | message += "there're " + data.numUsers + " participants";
49 | }
50 | addChatMessage({
51 | username: "System",
52 | message: message
53 | });
54 | }
55 |
56 | function sendMessage () {
57 | var message = $inputMessage.val();
58 | message = cleanInput(message);
59 | if (message && connected) {
60 | $inputMessage.val('');
61 | addChatMessage({
62 | username: username,
63 | message: message
64 | });
65 | socket.emit('newMessage', message);
66 | }
67 | }
68 |
69 | function addChatMessage (data, options) {
70 |
71 | var $usernameDiv = $('
')
72 | .text(data.username)
73 | .css('color', getUsernameColor(data.username));
74 | var $messageBodyDiv = $('
')
75 | .text(data.message);
76 |
77 | var $messageDiv = $('')
78 | .data('username', data.username)
79 | .append($usernameDiv, $messageBodyDiv);
80 |
81 | addMessageElement($messageDiv, options);
82 | }
83 |
84 | function addMessageElement (el, options) {
85 | var $el = $(el);
86 |
87 | // Setup default options
88 | if (!options) {
89 | options = {};
90 | }
91 | if (typeof options.fade === 'undefined') {
92 | options.fade = true;
93 | }
94 | if (typeof options.prepend === 'undefined') {
95 | options.prepend = false;
96 | }
97 |
98 | // Apply options
99 | if (options.fade) {
100 | $el.hide().fadeIn(FADE_TIME);
101 | }
102 | if (options.prepend) {
103 | $messages.prepend($el);
104 | } else {
105 | $messages.append($el);
106 | }
107 | $messages[0].scrollTop = $messages[0].scrollHeight;
108 | }
109 |
110 | // Prevents input from having injected markup
111 | function cleanInput (input) {
112 | return $('').text(input).text();
113 | }
114 |
115 |
116 | // Gets the color of a username through our hash function
117 | function getUsernameColor (username) {
118 | // Compute hash code
119 | var hash = 7;
120 | for (var i = 0; i < username.length; i++) {
121 | hash = username.charCodeAt(i) + (hash << 5) - hash;
122 | }
123 | // Calculate color
124 | var index = Math.abs(hash % COLORS.length);
125 | return COLORS[index];
126 | }
127 |
128 | // Keyboard events
129 |
130 | $window.keydown(function (event) {
131 | // Auto-focus the current input when a key is typed
132 | if (!(event.ctrlKey || event.metaKey || event.altKey)) {
133 | $currentInput.focus();
134 | }
135 | // When the client hits ENTER on their keyboard
136 | if (event.which === 13) {
137 | if (username) {
138 | sendMessage();
139 | } else {
140 | setUsername();
141 | }
142 | }
143 | });
144 |
145 |
146 | // Focus input when clicking on the message input's border
147 | $inputMessage.click(function () {
148 | $inputMessage.focus();
149 | });
150 |
151 | // Socket events
152 |
153 | rxEvent
154 | .filter(function(data) { return data.name === "login"; })
155 | .map(function(data) { return data.data; })
156 | .subscribe(function(loginData){
157 | connected = true;
158 | addChatMessage({username: "System", message: "Welcome"});
159 | addParticipantsMessage(loginData);
160 | });
161 |
162 | rxEvent
163 | .filter(function(data) { return data.name === "newMessage"; })
164 | .map(function(data) { return data.data; })
165 | .subscribe(function(messageData){
166 | addChatMessage(messageData);
167 | });
168 |
169 | rxEvent
170 | .filter(function(data) { return data.name === "userJoined"; })
171 | .map(function(data) { return data.data; })
172 | .subscribe(function(userData) {
173 | addChatMessage({ username: "System", message: userData.username + ' joined' });
174 | addParticipantsMessage(userData);
175 | });
176 |
177 | rxEvent
178 | .filter(function(data) { return data.name === "userLeft"; })
179 | .map(function(data) { return data.data; })
180 | .subscribe(function(userData) {
181 | addChatMessage({ username: "System", message: userData.username + ' left' });
182 | addParticipantsMessage(userData);
183 | });
184 |
185 | });
186 |
--------------------------------------------------------------------------------
/Server/public/rx.min.js:
--------------------------------------------------------------------------------
1 | /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
2 | (function(a){function b(a){return a&&a.Object===Object?a:null}function c(a){for(var b=[],c=0,d=a.length;d>c;c++)b.push(a[c]);return b}function d(a){return function(){try{return a.apply(this,arguments)}catch(b){return la.e=b,la}}}function e(a){throw a}function f(a,b){if(na&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(ra)){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var e=c.join("\n"+ra+"\n");a.stack=g(e)}}function g(a){for(var b=a.split("\n"),c=[],d=0,e=b.length;e>d;d++){var f=b[d];h(f)||i(f)||!f||c.push(f)}return c.join("\n")}function h(a){var b=k(a);if(!b)return!1;var c=b[0],d=b[1];return c===pa&&d>=qa&&$d>=d}function i(a){return-1!==a.indexOf("(module.js:")||-1!==a.indexOf("(node.js:")}function j(){if(na)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=k(c);if(!d)return;return pa=d[0],d[1]}}function k(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function l(b,c,d,e,f,g){var h=eb(b),i=h.length,j=eb(c),k=j.length;if(i!==k&&!e)return!1;for(var l,m=i;m--;)if(l=h[m],!(e?l in c:bb.call(c,l)))return!1;for(var n=e;++m-1&&a%1===0&&db>=a}function p(a){return n(a)&&o(a.length)&&!!_a[cb.call(a)]}function q(a,b){for(var c=-1,d=a.length;++ci))return!1;for(;++hd;d++)c[d]=b();return c}function v(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function w(a,b){b.isDisposed||(b.isDisposed=!0,b.disposable.dispose())}function x(a,b){this.id=a,this.value=b}function y(a){this._s=a,this.isDisposed=!1}function z(a){this._s=a}function A(a){this._s=a,this._l=a.length,this._i=0}function B(a){this._a=a}function C(a){this._a=a,this._l=G(a),this._i=0}function D(a){return"number"==typeof a&&ba.isFinite(a)}function E(b){var c,d=b[ya];if(!d&&"string"==typeof b)return c=new z(b),c[ya]();if(!d&&b.length!==a)return c=new B(b),c[ya]();if(!d)throw new TypeError("Object is not iterable");return b[ya]()}function F(a){var b=+a;return 0===b?b:isNaN(b)?b:0>b?-1:1}function G(a){var b=+a.length;return isNaN(b)?0:0!==b&&D(b)?(b=F(b)*Math.floor(Math.abs(b)),0>=b?0:b>yc?yc:b):b}function H(a,b){return Cb(a)||(a=Ib),new Ac(b,a)}function I(a,b){this.observer=a,this.parent=b}function J(a,b){return a.amb(b)}function K(){return!1}function L(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return b}function K(){return!1}function L(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return b}function K(){return!1}function M(){return[]}function K(){return!1}function M(){return[]}function L(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return b}function N(a){return function(b){return a.subscribe(b)}}function O(a){return a.toArray()}function P(a){return a.length>0}function Q(a){return{"@@iterator":function(){return{next:function(){return{done:!1,value:a}}}}}}function Q(a){return{"@@iterator":function(){return{next:function(){return{done:!1,value:a}}}}}}function R(a,b,c){for(var d=0,e=a.length;e>d;d++)if(c(a[d],b))return d;return-1}function S(a){this.comparer=a,this.set=[]}function T(b,c){return function(d){for(var e=d,f=0;c>f;f++){var g=e[b[f]];if("undefined"==typeof g)return a;e=g}return e}}function U(a){return{"@@transducer/init":function(){return a},"@@transducer/step":function(a,b){return a.onNext(b)},"@@transducer/result":function(a){return a.onCompleted()}}}var V={"function":!0,object:!0},W=V[typeof exports]&&exports&&!exports.nodeType?exports:null,X=V[typeof module]&&module&&!module.nodeType?module:null,Y=b(W&&X&&"object"==typeof global&&global),Z=b(V[typeof self]&&self),$=b(V[typeof window]&&window),_=X&&X.exports===W?W:null,aa=b(V[typeof this]&&this),ba=Y||$!==(aa&&aa.window)&&$||Z||aa||Function("return this")(),ca={internals:{},config:{Promise:ba.Promise},helpers:{}},da=ca.helpers.noop=function(){},ea=ca.helpers.identity=function(a){return a},fa=ca.helpers.defaultNow=Date.now,ga=ca.helpers.defaultComparer=function(a,b){return ib(a,b)},ha=ca.helpers.defaultSubComparer=function(a,b){return a>b?1:b>a?-1:0},ia=(ca.helpers.defaultKeySerializer=function(a){return a.toString()},ca.helpers.defaultError=function(a){throw a}),ja=ca.helpers.isPromise=function(a){return!!a&&"function"!=typeof a.subscribe&&"function"==typeof a.then},ka=ca.helpers.isFunction=function(){var a=function(a){return"function"==typeof a||!1};return a(/x/)&&(a=function(a){return"function"==typeof a&&"[object Function]"==toString.call(a)}),a}(),la={e:{}},ma=ca.internals.tryCatch=function(a){if(!ka(a))throw new TypeError("fn must be a function");return d(a)};ca.config.longStackSupport=!1;var na=!1,oa=ma(function(){throw new Error})();na=!!oa.e&&!!oa.e.stack;var pa,qa=j(),ra="From previous event:",sa=ca.EmptyError=function(){this.message="Sequence contains no elements.",Error.call(this)};sa.prototype=Object.create(Error.prototype),sa.prototype.name="EmptyError";var ta=ca.ObjectDisposedError=function(){this.message="Object has been disposed",Error.call(this)};ta.prototype=Object.create(Error.prototype),ta.prototype.name="ObjectDisposedError";var ua=ca.ArgumentOutOfRangeError=function(){this.message="Argument out of range",Error.call(this)};ua.prototype=Object.create(Error.prototype),ua.prototype.name="ArgumentOutOfRangeError";var va=ca.NotSupportedError=function(a){this.message=a||"This operation is not supported",Error.call(this)};va.prototype=Object.create(Error.prototype),va.prototype.name="NotSupportedError";var wa=ca.NotImplementedError=function(a){this.message=a||"This operation is not implemented",Error.call(this)};wa.prototype=Object.create(Error.prototype),wa.prototype.name="NotImplementedError";var xa=ca.helpers.notImplemented=function(){throw new wa},ya=(ca.helpers.notSupported=function(){throw new va},"function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_");ba.Set&&"function"==typeof(new ba.Set)["@@iterator"]&&(ya="@@iterator");var za=ca.doneEnumerator={done:!0,value:a},Aa=ca.helpers.isIterable=function(b){return b&&b[ya]!==a},Ba=ca.helpers.isArrayLike=function(b){return b&&b.length!==a};ca.helpers.iterator=ya;var Ca=ca.internals.bindCallback=function(a,b,c){if("undefined"==typeof b)return a;switch(c){case 0:return function(){return a.call(b)};case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)}}return function(){return a.apply(b,arguments)}},Da=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Ea=(Da.length,"[object Arguments]"),Fa="[object Array]",Ga="[object Boolean]",Ha="[object Date]",Ia="[object Error]",Ja="[object Function]",Ka="[object Map]",La="[object Number]",Ma="[object Object]",Na="[object RegExp]",Oa="[object Set]",Pa="[object String]",Qa="[object WeakMap]",Ra="[object ArrayBuffer]",Sa="[object Float32Array]",Ta="[object Float64Array]",Ua="[object Int8Array]",Va="[object Int16Array]",Wa="[object Int32Array]",Xa="[object Uint8Array]",Ya="[object Uint8ClampedArray]",Za="[object Uint16Array]",$a="[object Uint32Array]",_a={};_a[Sa]=_a[Ta]=_a[Ua]=_a[Va]=_a[Wa]=_a[Xa]=_a[Ya]=_a[Za]=_a[$a]=!0,_a[Ea]=_a[Fa]=_a[Ra]=_a[Ga]=_a[Ha]=_a[Ia]=_a[Ja]=_a[Ka]=_a[La]=_a[Ma]=_a[Na]=_a[Oa]=_a[Pa]=_a[Qa]=!1;var ab=Object.prototype,bb=ab.hasOwnProperty,cb=ab.toString,db=Math.pow(2,53)-1,eb=Object.keys||function(){var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=c.length;return function(e){if("object"!=typeof e&&("function"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var f,g,h=[];for(f in e)a.call(e,f)&&h.push(f);if(b)for(g=0;d>g;g++)a.call(e,c[g])&&h.push(c[g]);return h}}(),fb=ca.internals.isObject=function(a){var b=typeof a;return!!a&&("object"===b||"function"===b)},gb=function(){try{Object({toString:0}+"")}catch(a){return function(){return!1}}return function(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}}(),hb=Array.isArray||function(a){return n(a)&&o(a.length)&&cb.call(a)===Fa},ib=ca.internals.isEqual=function(a,b){return t(a,b)},jb=({}.hasOwnProperty,Array.prototype.slice,ca.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),kb=ca.internals.addProperties=function(a){for(var b=[],c=1,d=arguments.length;d>c;c++)b.push(arguments[c]);for(var e=0,f=b.length;f>e;e++){var g=b[e];for(var h in g)a[h]=g[h]}},lb=ca.internals.addRef=function(a,b){return new Vd(function(c){return new wb(b.getDisposable(),a.subscribe(c))})},mb=ca.CompositeDisposable=function(){var a,b,c=[];if(Array.isArray(arguments[0]))c=arguments[0];else for(b=arguments.length,c=new Array(b),a=0;b>a;a++)c[a]=arguments[a];this.disposables=c,this.isDisposed=!1,this.length=c.length},nb=mb.prototype;nb.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},nb.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},nb.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=this.disposables.length,b=new Array(a),c=0;a>c;c++)b[c]=this.disposables[c];for(this.disposables=[],this.length=0,c=0;a>c;c++)b[c].dispose()}};var ob=ca.Disposable=function(a){this.isDisposed=!1,this.action=a||da};ob.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var pb=ob.create=function(a){return new ob(a)},qb=ob.empty={dispose:da},rb=ob.isDisposable=function(a){return a&&ka(a.dispose)},sb=ob.checkDisposed=function(a){if(a.isDisposed)throw new ta},tb=ob._fixup=function(a){return rb(a)?a:qb},ub=ca.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null};ub.prototype.getDisposable=function(){return this.current},ub.prototype.setDisposable=function(a){if(this.current)throw new Error("Disposable has already been assigned");var b=this.isDisposed;!b&&(this.current=a),b&&a&&a.dispose()},ub.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null,a&&a.dispose()}};var vb=ca.SerialDisposable=function(){this.isDisposed=!1,this.current=null};vb.prototype.getDisposable=function(){return this.current},vb.prototype.setDisposable=function(a){var b=this.isDisposed;if(!b){var c=this.current;this.current=a}c&&c.dispose(),b&&a&&a.dispose()},vb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()};var wb=ca.BinaryDisposable=function(a,b){this._first=a,this._second=b,this.isDisposed=!1};wb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this._first;this._first=null,a&&a.dispose();var b=this._second;this._second=null,b&&b.dispose()}};var xb=ca.NAryDisposable=function(a){this._disposables=a,this.isDisposed=!1};xb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=0,b=this._disposables.length;b>a;a++)this._disposables[a].dispose();this._disposables.length=0}};var yb=ca.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?qb:new a(this)},b}();v.prototype.dispose=function(){this.scheduler.schedule(this,w)};var zb=ca.internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||ha,this.disposable=new ub};zb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},zb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},zb.prototype.isCancelled=function(){return this.disposable.isDisposed},zb.prototype.invokeCore=function(){return tb(this.action(this.scheduler,this.state))};var Ab=ca.Scheduler=function(){function a(){}a.isScheduler=function(b){return b instanceof a};var b=a.prototype;return b.schedule=function(a,b){throw new wa},b.scheduleFuture=function(b,c,d){var e=c;return e instanceof Date&&(e-=this.now()),e=a.normalize(e),0===e?this.schedule(b,d):this._scheduleFuture(b,e,d)},b._scheduleFuture=function(a,b,c){throw new wa},a.now=fa,a.prototype.now=fa,a.normalize=function(a){return 0>a&&(a=0),a},a}(),Bb=Ab.normalize,Cb=Ab.isScheduler;!function(a){function b(a,b){function c(b){function d(a,b){return g?f.remove(i):h=!0,e(b,c),qb}var g=!1,h=!1,i=a.schedule(b,d);h||(f.add(i),g=!0)}var d=b[0],e=b[1],f=new mb;return e(d,c),f}function c(a,b){function c(b,d){function g(a,b){return h?f.remove(j):i=!0,e(b,c),qb}var h=!1,i=!1,j=a.scheduleFuture(b,d,g);i||(f.add(j),h=!0)}var d=b[0],e=b[1],f=new mb;return e(d,c),f}a.scheduleRecursive=function(a,c){return this.schedule([a,c],b)},a.scheduleRecursiveFuture=function(a,b,d){return this.scheduleFuture([a,d],b,c)}}(Ab.prototype),function(a){a.schedulePeriodic=function(a,b,c){if("undefined"==typeof ba.setInterval)throw new va;b=Bb(b);var d=a,e=ba.setInterval(function(){d=c(d)},b);return pb(function(){ba.clearInterval(e)})}}(Ab.prototype),function(a){a.catchError=a["catch"]=function(a){return new Ob(this,a)}}(Ab.prototype);var Db,Eb,Fb=(ca.internals.SchedulePeriodicRecursive=function(){function a(a){return function(b,c){c(0,a._period);var d=ma(a._action)(a._state);d===la&&(a._cancel.dispose(),e(d.e)),a._state=d}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new ub;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveFuture(0,this._period,a(this))),b},b}(),function(a){function b(){a.call(this)}return jb(b,a),b.prototype.schedule=function(a,b){return tb(b(this,a))},b}(Ab)),Gb=Ab.immediate=new Fb,Hb=function(a){function b(){for(;d.length>0;){var a=d.dequeue();!a.isCancelled()&&a.invoke()}}function c(){a.call(this)}var d;return jb(c,a),c.prototype.schedule=function(a,c){var f=new zb(this,a,c,this.now());if(d)d.enqueue(f);else{d=new Pb(4),d.enqueue(f);var g=ma(b)();d=null,g===la&&e(g.e)}return f.disposable},c.prototype.scheduleRequired=function(){return!d},c}(Ab),Ib=Ab.currentThread=new Hb,Jb=function(){var a,b=da;if(ba.setTimeout)a=ba.setTimeout,b=ba.clearTimeout;else{if(!ba.WScript)throw new va;a=function(a,b){ba.WScript.Sleep(b),a()}}return{setTimeout:a,clearTimeout:b}}(),Kb=Jb.setTimeout,Lb=Jb.clearTimeout;!function(){function a(b){if(f)Kb(function(){a(b)},0);else{var c=d[b];if(c){f=!0;var g=ma(c)();Eb(b),f=!1,g===la&&e(g.e)}}}function b(){if(!ba.postMessage||ba.importScripts)return!1;var a=!1,b=ba.onmessage;return ba.onmessage=function(){a=!0},ba.postMessage("","*"),ba.onmessage=b,a}var c=1,d={},f=!1;Eb=function(a){delete d[a]};var g=new RegExp("^"+String(toString).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),h="function"==typeof(h=Y&&_&&Y.setImmediate)&&!g.test(h)&&h;if(ka(h))Db=function(b){var e=c++;return d[e]=b,h(function(){a(e)}),e};else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))Db=function(b){var e=c++;return d[e]=b,process.nextTick(function(){a(e)}),e};else if(b()){var i="ms.rx.schedule"+Math.random(),j=function(b){"string"==typeof b.data&&b.data.substring(0,i.length)===i&&a(b.data.substring(i.length))};ba.addEventListener("message",j,!1),Db=function(a){var b=c++;return d[b]=a,ba.postMessage(i+b,"*"),b}}else if(ba.MessageChannel){var k=new ba.MessageChannel;k.port1.onmessage=function(b){a(b.data)},Db=function(a){var b=c++;return d[b]=a,k.port2.postMessage(b),b}}else Db="document"in ba&&"onreadystatechange"in ba.document.createElement("script")?function(b){var e=ba.document.createElement("script"),f=c++;return d[f]=b,e.onreadystatechange=function(){a(f),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},ba.document.documentElement.appendChild(e),f}:function(b){var e=c++;return d[e]=b,Kb(function(){a(e)},0),e}}();var Mb=function(a){function b(){a.call(this)}function c(a,b,c,d){return function(){a.setDisposable(ob._fixup(b(c,d)))}}function d(a){this._id=a,this.isDisposed=!1}function e(a){this._id=a,this.isDisposed=!1}function f(a,b,c){return function(){b(a,c)}}return jb(b,a),d.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,Eb(this._id))},e.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,Lb(this._id))},b.prototype.schedule=function(a,b){var e=new ub,f=Db(c(e,b,this,a));return new wb(e,new d(f))},b.prototype._scheduleFuture=function(a,b,d){if(0===b)return this.schedule(a,d);var f=new ub,g=Kb(c(f,d,this,a),b);return new wb(f,new e(g))},b.prototype.scheduleLongRunning=function(a,b){var c=pb(da);return Db(f(a,b,c)),c},b}(Ab),Nb=Ab["default"]=Ab.async=new Mb,Ob=function(a){function b(b,c){this._scheduler=b,this._handler=c,this._recursiveOriginal=null,this._recursiveWrapper=null,a.call(this)}return jb(b,a),b.prototype.schedule=function(a,b){return this._scheduler.schedule(a,this._wrap(b))},b.prototype._scheduleFuture=function(a,b,c){return this._scheduler.schedule(a,b,this._wrap(c))},b.prototype.now=function(){return this._scheduler.now()},b.prototype._clone=function(a){return new b(a,this._handler)},b.prototype._wrap=function(a){var b=this;return function(c,d){var f=ma(a)(b._getRecursiveWrapper(c),d);return f===la?(b._handler(f.e)||e(f.e),qb):tb(f)}},b.prototype._getRecursiveWrapper=function(a){if(this._recursiveOriginal!==a){this._recursiveOriginal=a;var b=this._clone(a);b._recursiveOriginal=a,b._recursiveWrapper=b,this._recursiveWrapper=b}return this._recursiveWrapper},b.prototype.schedulePeriodic=function(a,b,c){var d=this,f=!1,g=new ub;return g.setDisposable(this._scheduler.schedulePeriodic(a,b,function(a){if(f)return null;var b=ma(c)(a);return b===la?(f=!0,d._handler(b.e)||e(b.e),g.dispose(),null):b})),g},b}(Ab);x.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var Pb=ca.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},Qb=Pb.prototype;Qb.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},Qb.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},Qb.heapify=function(a){if(+a||(a=0),!(a>=this.length||0>a)){var b=2*a+1,c=2*a+2,d=a;if(b0))return void(a.isAcquired=!1);c=a.queue.shift();var d=ma(c)();return d===la?(a.queue=[],a.hasFaulted=!0,e(d.e)):void b(a)}return jb(b,a),b.prototype.next=function(a){this.queue.push(c(this.observer,a))},b.prototype.error=function(a){this.queue.push(d(this.observer,a))},b.prototype.completed=function(){this.queue.push(f(this.observer))},b.prototype.ensureActive=function(){var a=!1;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(this,g))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(_b),dc=function(a){function b(b,c,d){a.call(this,b,c),this._cancel=d}return jb(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b.prototype.dispose=function(){a.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},b}(cc),ec=ca.Observable=function(){function a(a,b){return function(c){var d=c.onError;return c.onError=function(b){f(b,a),d.call(c,b)},b.call(a,c)}}function b(){if(ca.config.longStackSupport&&na){var b=this._subscribe,c=ma(e)(new Error).e;this.stack=c.stack.substring(c.stack.indexOf("\n")+1),this._subscribe=a(this,b)}}return $b=b.prototype,b.isObservable=function(a){return a&&ka(a.subscribe)},$b.subscribe=$b.forEach=function(a,b,c){return this._subscribe("object"==typeof a?a:Zb(a,b,c))},$b.subscribeOnNext=function(a,b){return this._subscribe(Zb("undefined"!=typeof b?function(c){a.call(b,c)}:a))},$b.subscribeOnError=function(a,b){return this._subscribe(Zb(null,"undefined"!=typeof b?function(c){a.call(b,c)}:a))},$b.subscribeOnCompleted=function(a,b){return this._subscribe(Zb(null,null,"undefined"!=typeof b?function(){a.call(b)}:a))},b}(),fc=ca.ObservableBase=function(a){function b(a){return a&&ka(a.dispose)?a:ka(a)?pb(a):qb}function c(a,c){var d=c[0],f=c[1],g=ma(f.subscribeCore).call(f,d);g!==la||d.fail(la.e)||e(la.e),d.setDisposable(b(g))}function d(){a.call(this)}return jb(d,a),d.prototype._subscribe=function(a){var b=new Wd(a),d=[b,this];return Ib.scheduleRequired()?Ib.schedule(d,c):c(null,d),b},d.prototype.subscribeCore=xa,d}(ec),gc=ca.FlatMapObservable=function(a){function b(b,c,d,e){this.resultSelector=ka(d)?d:null,this.selector=Ca(ka(c)?c:function(){return c},e,3),this.source=b,a.call(this)}function c(a,b,c,d){this.i=0,this.selector=b,this.resultSelector=c,this.source=d,this.o=a,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this.selector,this.resultSelector,this))},jb(c,_b),c.prototype._wrapResult=function(a,b,c){return this.resultSelector?a.map(function(a,d){return this.resultSelector(b,a,c,d)},this):a},c.prototype.next=function(a){var b=this.i++,c=ma(this.selector)(a,b,this.source);return c===la?this.o.onError(c.e):(ja(c)&&(c=rc(c)),(Ba(c)||Aa(c))&&(c=ec.from(c)),void this.o.onNext(this._wrapResult(c,a,b)))},c.prototype.error=function(a){this.o.onError(a)},c.prototype.completed=function(){this.o.onCompleted()},b}(fc),hc=ca.internals.Enumerable=function(){};y.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this._s.isDisposed=!0)};var ic=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b){if(!a.isDisposed){var c=ma(a.e.next).call(a.e);if(c===la)return a.o.onError(c.e);if(c.done)return a.o.onCompleted();var e=c.value;ja(e)&&(e=rc(e));var f=new ub;a.subscription.setDisposable(f),f.setDisposable(e.subscribe(new d(a,b)))}}function d(a,b){this._state=a,this._recurse=b,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new vb,d={isDisposed:!1,o:a,subscription:b,e:this.sources[ya]()},e=Ib.scheduleRecursive(d,c);return new xb([b,e,new y(d)])},jb(d,_b),d.prototype.next=function(a){this._state.o.onNext(a)},d.prototype.error=function(a){this._state.o.onError(a)},d.prototype.completed=function(){this._recurse(this._state)},b}(fc);hc.prototype.concat=function(){return new ic(this)};var jc=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b){if(!a.isDisposed){var c=ma(a.e.next).call(a.e);if(c===la)return a.o.onError(c.e);if(c.done)return null!==a.lastError?a.o.onError(a.lastError):a.o.onCompleted();var e=c.value;ja(e)&&(e=rc(e));var f=new ub;a.subscription.setDisposable(f),f.setDisposable(e.subscribe(new d(a,b)))}}function d(a,b){this._state=a,this._recurse=b,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new vb,d={isDisposed:!1,e:this.sources[ya](),subscription:b,lastError:null,o:a},e=Ib.scheduleRecursive(d,c);return new xb([b,e,new y(d)])},jb(d,_b),d.prototype.next=function(a){this._state.o.onNext(a)},d.prototype.error=function(a){this._state.lastError=a,this._recurse(this._state)},d.prototype.completed=function(){this._state.o.onCompleted()},b}(fc);hc.prototype.catchError=function(){return new jc(this)};var kc=function(a){function b(a,b){this.v=a,this.c=null==b?-1:b}function c(a){this.v=a.v,this.l=a.c}return jb(b,a),b.prototype[ya]=function(){return new c(this)},c.prototype.next=function(){return 0===this.l?za:(this.l>0&&this.l--,{done:!1,value:this.v})},b}(hc),lc=hc.repeat=function(a,b){return new kc(a,b)},mc=function(a){function b(a,b,c){this.s=a,this.fn=b?Ca(b,c,3):null}function c(a){this.i=-1,this.s=a.s,this.l=this.s.length,this.fn=a.fn}return jb(b,a),b.prototype[ya]=function(){return new c(this)},c.prototype.next=function(){return++this.id?(a.onNext(b[d]),e(d+1)):a.onCompleted()}}return jb(b,a),b.prototype.subscribeCore=function(a){return this._scheduler.scheduleRecursive(0,c(a,this._args))},b}(fc),Bc=ec.fromArray=function(a,b){return Cb(b)||(b=Ib),new Ac(a,b)},Cc=function(a){function b(b,c,d,e,f){this._initialState=b,this._cndFn=c,this._itrFn=d,this._resFn=e,this._s=f,a.call(this)}function c(a,b){if(a.first)a.first=!1;else if(a.newState=ma(a.self._itrFn)(a.newState),a.newState===la)return a.o.onError(a.newState.e);var c=ma(a.self._cndFn)(a.newState);if(c===la)return a.o.onError(c.e);if(c){var d=ma(a.self._resFn)(a.newState);if(d===la)return a.o.onError(d.e);a.o.onNext(d),b(a)}else a.o.onCompleted()}return jb(b,a),b.prototype.subscribeCore=function(a){var b={o:a,self:this,first:!0,newState:this._initialState};return this._s.scheduleRecursive(b,c)},b}(fc);ec.generate=function(a,b,c,d,e){return Cb(e)||(e=Ib),new Cc(a,b,c,d,e)};var Dc=function(a){function b(){a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return qb},b}(fc),Ec=new Dc,Fc=ec.never=function(){return Ec};ec.of=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return new Ac(b,Ib)},ec.ofWithScheduler=function(a){for(var b=arguments.length,c=new Array(b-1),d=1;b>d;d++)c[d-1]=arguments[d];return new Ac(c,a)};var Gc=function(a){function b(b,c){this._o=b,this._keys=Object.keys(b),this._scheduler=c,a.call(this)}function c(a,b,c){return function(d,e){if(dd?(c.onNext(a+d),e(d+1)):c.onCompleted()}}return jb(b,a),b.prototype.subscribeCore=function(a){return this.scheduler.scheduleRecursive(0,c(this.start,this.rangeCount,a))},b}(fc);ec.range=function(a,b,c){return Cb(c)||(c=Ib),new Hc(a,b,c)};var Ic=function(a){function b(b,c,d){this.value=b,this.repeatCount=null==c?-1:c,this.scheduler=d,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new I(a,this);return b.run()},b}(fc);I.prototype.run=function(){function a(a,d){return(-1===a||a>0)&&(b.onNext(c),a>0&&a--),0===a?b.onCompleted():void d(a)}var b=this.observer,c=this.parent.value;return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount,a)},ec.repeat=function(a,b,c){return Cb(c)||(c=Ib),new Ic(a,b,c)};var Jc=function(a){function b(b,c){this._value=b,this._scheduler=c,a.call(this)}function c(a,b){var c=b[0],d=b[1];return d.onNext(c),d.onCompleted(),qb}return jb(b,a),b.prototype.subscribeCore=function(a){var b=[this._value,a];return this._scheduler===Gb?c(null,b):this._scheduler.schedule(b,c)},b}(fc),Kc=(ec["return"]=ec.just=function(a,b){return Cb(b)||(b=Gb),new Jc(a,b)},function(a){function b(b,c){this._error=b,this._scheduler=c,a.call(this)}function c(a,b){var c=b[0],d=b[1];return d.onError(c),qb}return jb(b,a),b.prototype.subscribeCore=function(a){var b=[this._error,a];return this._scheduler===Gb?c(null,b):this._scheduler.schedule(b,c)},b}(fc)),Lc=ec["throw"]=function(a,b){return Cb(b)||(b=Gb),new Kc(a,b)},Mc=function(a){function b(b,c){this._resFn=b,this._obsFn=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=qb,c=ma(this._resFn)();if(c===la)return new wb(Lc(c.e).subscribe(a),b);c&&(b=c);var d=ma(this._obsFn)(c);return d===la?new wb(Lc(d.e).subscribe(a),b):new wb(d.subscribe(a),b)},b}(fc);ec.using=function(a,b){return new Mc(a,b)},$b.amb=function(a){var b=this;return new Vd(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new ub,j=new ub;ja(a)&&(a=rc(a));var k=Zb(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()}),l=Zb(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()});return i.setDisposable(b.subscribe(k)),j.setDisposable(a.subscribe(l)),new wb(i,j)})},ec.amb=function(){var a,b=Fc();if(Array.isArray(arguments[0]))a=arguments[0];else{var c=arguments.length;a=new Array(a);for(var d=0;c>d;d++)a[d]=arguments[d]}for(var d=0,c=a.length;c>d;d++)b=J(b,a[d]);return b};var Nc=function(a){function b(b,c){this.source=b,this._fn=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new ub,c=new vb;return c.setDisposable(b),b.setDisposable(this.source.subscribe(new Oc(a,c,this._fn))),c},b}(fc),Oc=function(a){function b(b,c,d){this._o=b,this._s=c,this._fn=d,a.call(this)}return jb(b,a),b.prototype.next=function(a){this._o.onNext(a)},b.prototype.completed=function(){return this._o.onCompleted()},b.prototype.error=function(a){var b=ma(this._fn)(a);if(b===la)return this._o.onError(b.e);ja(b)&&(b=rc(b));var c=new ub;this._s.setDisposable(c),c.setDisposable(b.subscribe(this._o))},b}(_b);$b["catch"]=function(a){return ka(a)?new Nc(this,a):Pc([this,a])};var Pc=ec["catch"]=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}return nc(a).catchError()};$b.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return Array.isArray(b[0])?b[0].unshift(this):b.unshift(this),Sc.apply(this,b)};var Qc=function(a){function b(b,c){this._params=b,this._cb=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){for(var b=this._params.length,c=new Array(b),d={hasValue:u(b,K),hasValueAll:!1,isDone:u(b,K),values:new Array(b)},e=0;b>e;e++){var f=this._params[e],g=new ub;c[e]=g,ja(f)&&(f=rc(f)),g.setDisposable(f.subscribe(new Rc(a,e,this._cb,d)))}return new xb(c)},b}(fc),Rc=function(a){function b(b,c,d,e){this._o=b,this._i=c,this._cb=d,this._state=e,a.call(this)}function c(a){return function(b,c){return c!==a}}return jb(b,a),b.prototype.next=function(a){if(this._state.values[this._i]=a,this._state.hasValue[this._i]=!0,this._state.hasValueAll||(this._state.hasValueAll=this._state.hasValue.every(ea))){var b=ma(this._cb).apply(null,this._state.values);if(b===la)return this._o.onError(b.e);this._o.onNext(b)}else this._state.isDone.filter(c(this._i)).every(ea)&&this._o.onCompleted()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._state.isDone[this._i]=!0,this._state.isDone.every(ea)&&this._o.onCompleted()},b}(_b),Sc=ec.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=ka(b[a-1])?b.pop():L;return Array.isArray(b[0])&&(b=b[0]),new Qc(b,d)};$b.concat=function(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return a.unshift(this),Vc.apply(null,a)};var Tc=function(a){function b(b,c){this._s=b,this._fn=c,a.call(this)}return jb(b,a),b.prototype.next=function(a){this._s.o.onNext(a)},b.prototype.error=function(a){this._s.o.onError(a)},b.prototype.completed=function(){this._s.i++,this._fn(this._s)},b}(_b),Uc=function(a){function b(b){this._sources=b,a.call(this)}function c(a,b){if(!a.disposable.isDisposed){if(a.i===a.sources.length)return a.o.onCompleted();var c=a.sources[a.i];ja(c)&&(c=rc(c));var d=new ub;a.subscription.setDisposable(d),d.setDisposable(c.subscribe(new Tc(a,b)))}}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new vb,d=pb(da),e={o:a,i:0,subscription:b,disposable:d,sources:this._sources},f=Gb.scheduleRecursive(e,c);return new xb([b,d,f])},b}(fc),Vc=ec.concat=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{a=new Array(arguments.length);for(var b=0,c=arguments.length;c>b;b++)a[b]=arguments[b]}return new Uc(a)};$b.concatAll=function(){return this.merge(1)};var Wc=function(a){function b(b,c){this.source=b,this.maxConcurrent=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new mb;return b.add(this.source.subscribe(new Xc(a,this.maxConcurrent,b))),b},b}(fc),Xc=function(a){function b(b,c,d){this.o=b,this.max=c,this.g=d,this.done=!1,this.q=[],this.activeCount=0,a.call(this)}function c(b,c){this.parent=b,this.sad=c,a.call(this)}return jb(b,a),b.prototype.handleSubscribe=function(a){var b=new ub;this.g.add(b),ja(a)&&(a=rc(a)),b.setDisposable(a.subscribe(new c(this,b)))},b.prototype.next=function(a){this.activeCount0?this.parent.handleSubscribe(this.parent.q.shift()):(this.parent.activeCount--,this.parent.done&&0===this.parent.activeCount&&this.parent.o.onCompleted())},b}(_b);$b.merge=function(a){return"number"!=typeof a?Yc(this,a):new Wc(this,a)};var Yc=ec.merge=function(){var a,b,c=[],d=arguments.length;if(arguments[0])if(Cb(arguments[0]))for(a=arguments[0],b=1;d>b;b++)c.push(arguments[b]);else for(a=Gb,b=0;d>b;b++)c.push(arguments[b]);else for(a=Gb,b=1;d>b;b++)c.push(arguments[b]);return Array.isArray(c[0])&&(c=c[0]),H(a,c).mergeAll()},Zc=ca.CompositeError=function(a){this.innerErrors=a,this.message="This contains multiple errors. Check the innerErrors",Error.call(this)};Zc.prototype=Object.create(Error.prototype),Zc.prototype.name="CompositeError";var $c=function(a){function b(b){this.source=b,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new mb,c=new ub,d={isStopped:!1,errors:[],o:a};return b.add(c),c.setDisposable(this.source.subscribe(new _c(b,d))),b},b}(fc),_c=function(a){function b(b,c){this._group=b,this._state=c,a.call(this)}function c(a,b){0===b.length?a.onCompleted():1===b.length?a.onError(b[0]):a.onError(new Zc(b))}function d(b,c,d){this._inner=b,this._group=c,this._state=d,a.call(this)}return jb(b,a),b.prototype.next=function(a){var b=new ub;this._group.add(b),ja(a)&&(a=rc(a)),b.setDisposable(a.subscribe(new d(b,this._group,this._state)))},b.prototype.error=function(a){this._state.errors.push(a),this._state.isStopped=!0,1===this._group.length&&c(this._state.o,this._state.errors)},b.prototype.completed=function(){this._state.isStopped=!0,1===this._group.length&&c(this._state.o,this._state.errors)},jb(d,a),d.prototype.next=function(a){this._state.o.onNext(a)},d.prototype.error=function(a){this._state.errors.push(a),this._group.remove(this._inner),this._state.isStopped&&1===this._group.length&&c(this._state.o,this._state.errors)},d.prototype.completed=function(){this._group.remove(this._inner),this._state.isStopped&&1===this._group.length&&c(this._state.o,this._state.errors)},b}(_b);ec.mergeDelayError=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}var d=H(null,a);return new $c(d)};var ad=function(a){function b(b){this.source=b,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new mb,c=new ub;return b.add(c),c.setDisposable(this.source.subscribe(new bd(a,b))),b},b}(fc),bd=function(a){function b(b,c){this.o=b,this.g=c,this.done=!1,a.call(this)}function c(b,c){this.parent=b,this.sad=c,a.call(this)}return jb(b,a),b.prototype.next=function(a){var b=new ub;this.g.add(b),ja(a)&&(a=rc(a)),b.setDisposable(a.subscribe(new c(this,b)))},b.prototype.error=function(a){this.o.onError(a)},b.prototype.completed=function(){this.done=!0,1===this.g.length&&this.o.onCompleted()},jb(c,a),c.prototype.next=function(a){this.parent.o.onNext(a)},c.prototype.error=function(a){this.parent.o.onError(a)},c.prototype.completed=function(){this.parent.g.remove(this.sad),this.parent.done&&1===this.parent.g.length&&this.parent.o.onCompleted()},b}(_b);$b.mergeAll=function(){return new ad(this)},$b.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return ed([this,a])};var cd=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b){if(a.posc;c++)a[c]=arguments[c]}return new cd(a)},fd=function(a){function b(b,c){this._s=b,this._o=ja(c)?rc(c):c,this._open=!1,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new ub;b.setDisposable(this._s.subscribe(new gd(a,this))),ja(this._o)&&(this._o=rc(this._o));var c=new ub;return c.setDisposable(this._o.subscribe(new hd(a,this,c))),new wb(b,c)},b}(fc),gd=function(a){function b(b,c){this._o=b,this._p=c,a.call(this)}return jb(b,a),b.prototype.next=function(a){this._p._open&&this._o.onNext(a)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.onCompleted=function(){this._p._open&&this._o.onCompleted()},b}(_b),hd=function(a){function b(b,c,d){this._o=b,this._p=c,this._r=d,a.call(this)}return jb(b,a),b.prototype.next=function(){this._p._open=!0,this._r.dispose()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.onCompleted=function(){this._r.dispose()},b}(_b);$b.skipUntil=function(a){return new fd(this,a)};var id=function(a){function b(b){this.source=b,a.call(this)}function c(a,b){this.o=a,this.inner=b,this.stopped=!1,this.latest=0,this.hasLatest=!1,_b.call(this)}function d(a,b){this.parent=a,this.id=b,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){var b=new vb,d=this.source.subscribe(new c(a,b));return new wb(d,b)},jb(c,_b),c.prototype.next=function(a){var b=new ub,c=++this.latest;this.hasLatest=!0,this.inner.setDisposable(b),ja(a)&&(a=rc(a)),b.setDisposable(a.subscribe(new d(this,c)))},c.prototype.error=function(a){this.o.onError(a)},c.prototype.completed=function(){this.stopped=!0,!this.hasLatest&&this.o.onCompleted()},jb(d,_b),d.prototype.next=function(a){this.parent.latest===this.id&&this.parent.o.onNext(a)},d.prototype.error=function(a){this.parent.latest===this.id&&this.parent.o.onError(a)},d.prototype.completed=function(){this.parent.latest===this.id&&(this.parent.hasLatest=!1,this.parent.stopped&&this.parent.o.onCompleted())},b}(fc);$b["switch"]=$b.switchLatest=function(){return new id(this)};var jd=function(a){function b(b,c){this.source=b,this.other=ja(c)?rc(c):c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return new wb(this.source.subscribe(a),this.other.subscribe(new kd(a)))},b}(fc),kd=function(a){function b(b){this._o=b,a.call(this)}return jb(b,a),b.prototype.next=function(){this._o.onCompleted()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.onCompleted=da,b}(_b);$b.takeUntil=function(a){return new jd(this,a)};var ld=function(a){function b(b,c,d){this._s=b,this._ss=c,this._cb=d,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){for(var b=this._ss.length,c={hasValue:u(b,K),hasValueAll:!1,values:new Array(b)},d=this._ss.length,e=new Array(d+1),f=0;d>f;f++){var g=this._ss[f],h=new ub;ja(g)&&(g=rc(g)),h.setDisposable(g.subscribe(new md(a,f,c))),e[f]=h}var i=new ub;return i.setDisposable(this._s.subscribe(new nd(a,this._cb,c))),e[d]=i,new xb(e)},b}(fc),md=function(a){function b(b,c,d){this._o=b,this._i=c,this._state=d,a.call(this)}return jb(b,a),b.prototype.next=function(a){this._state.values[this._i]=a,this._state.hasValue[this._i]=!0,this._state.hasValueAll=this._state.hasValue.every(ea)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=da,b}(_b),nd=function(a){function b(b,c,d){this._o=b,this._cb=c,this._state=d,a.call(this)}return jb(b,a),b.prototype.next=function(a){var b=[a].concat(this._state.values);if(this._state.hasValueAll){var c=ma(this._cb).apply(null,b);return c===la?this._o.onError(c.e):void this._o.onNext(c)}},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(_b);$b.withLatestFrom=function(){if(0===arguments.length)throw new Error("invalid arguments");for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=ka(b[a-1])?b.pop():L;return Array.isArray(b[0])&&(b=b[0]),new ld(this,b,d)};var od=function(a){function b(b,c){this._s=b,this._cb=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){for(var b=this._s.length,c=new Array(b),d=u(b,K),e=u(b,M),f=0;b>f;f++){var g=this._s[f],h=new ub;c[f]=h,ja(g)&&(g=rc(g)),h.setDisposable(g.subscribe(new pd(a,f,this,e,d)))}return new xb(c)},b}(fc),pd=function(a){function b(b,c,d,e,f){this._o=b,this._i=c,this._p=d,this._q=e,this._d=f,a.call(this)}function c(a){return a.length>0}function d(a){return a.shift()}function e(a){return function(b,c){return c!==a}}return jb(b,a),b.prototype.next=function(a){if(this._q[this._i].push(a),this._q.every(c)){var b=this._q.map(d),f=ma(this._p._cb).apply(null,b);if(f===la)return this._o.onError(f.e);this._o.onNext(f)}else this._d.filter(e(this._i)).every(ea)&&this._o.onCompleted()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._d[this._i]=!0,this._d.every(ea)&&this._o.onCompleted()},b}(_b);$b.zip=function(){if(0===arguments.length)throw new Error("invalid arguments");for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=ka(b[a-1])?b.pop():L;Array.isArray(b[0])&&(b=b[0]);var e=this;return b.unshift(e),new od(b,d)},ec.zip=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];Array.isArray(b[0])&&(b=ka(b[1])?b[0].concat(b[1]):b[0]);var d=b.shift();return d.zip.apply(d,b)};var qd=function(a){function b(b,c){this.sources=b,this._cb=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){for(var b=this.sources,c=b.length,d=new Array(c),e={q:u(c,M),done:u(c,K),cb:this._cb,o:a},f=0;c>f;f++)!function(a){var c=b[a],f=new ub;(Ba(c)||Aa(c))&&(c=zc(c)),d[a]=f,f.setDisposable(c.subscribe(new rd(e,a)))}(f);return new xb(d)},b}(fc),rd=function(a){function b(b,c){this._s=b,this._i=c,a.call(this)}function c(a){return a.length>0}function d(a){return a.shift()}function e(a){return function(b,c){return c!==a}}return jb(b,a),b.prototype.next=function(a){if(this._s.q[this._i].push(a),this._s.q.every(c)){var b=this._s.q.map(d),f=ma(this._s.cb).apply(null,b);if(f===la)return this._s.o.onError(f.e);this._s.o.onNext(f)}else this._s.done.filter(e(this._i)).every(ea)&&this._s.o.onCompleted()},b.prototype.error=function(a){this._s.o.onError(a)},b.prototype.completed=function(){this._s.done[this._i]=!0,this._s.done.every(ea)&&this._s.o.onCompleted()},b}(_b);$b.zipIterable=function(){if(0===arguments.length)throw new Error("invalid arguments");for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=ka(b[a-1])?b.pop():L,e=this;return b.unshift(e),new qd(b,d)},$b.asObservable=function(){return new Vd(N(this),this)},$b.bufferWithCount=$b.bufferCount=function(a,b){return"number"!=typeof b&&(b=a),this.windowWithCount(a,b).flatMap(O).filter(P)};var sd=function(a){function b(b){this.source=b,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new td(a))},b}(fc),td=function(a){function b(b){this._o=b,a.call(this)}return jb(b,a),b.prototype.next=function(a){a.accept(this._o)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(_b);$b.dematerialize=function(){return new sd(this)};var ud=function(a){function b(b,c,d){this.source=b,this.keyFn=c,this.comparer=d,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new vd(a,this.keyFn,this.comparer))},b}(fc),vd=function(a){function b(b,c,d){this.o=b,this.keyFn=c,this.comparer=d,this.hasCurrentKey=!1,this.currentKey=null,a.call(this)}return jb(b,a),b.prototype.next=function(a){var b,c=a;return ka(this.keyFn)&&(c=ma(this.keyFn)(a),c===la)?this.o.onError(c.e):this.hasCurrentKey&&(b=ma(this.comparer)(this.currentKey,c),b===la)?this.o.onError(b.e):void(this.hasCurrentKey&&b||(this.hasCurrentKey=!0,this.currentKey=c,this.o.onNext(a)))},b.prototype.error=function(a){this.o.onError(a)},b.prototype.completed=function(){this.o.onCompleted()},b}(_b);$b.distinctUntilChanged=function(a,b){return b||(b=ga),new ud(this,a,b)};var wd=function(a){function b(b,c,d,e){this.source=b,this._oN=c,this._oE=d,this._oC=e,a.call(this)}function c(a,b){this.o=a,this.t=!b._oN||ka(b._oN)?Zb(b._oN||da,b._oE||da,b._oC||da):b._oN,this.isStopped=!1,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this))},jb(c,_b),c.prototype.next=function(a){var b=ma(this.t.onNext).call(this.t,a);b===la&&this.o.onError(b.e),this.o.onNext(a)},c.prototype.error=function(a){var b=ma(this.t.onError).call(this.t,a);return b===la?this.o.onError(b.e):void this.o.onError(a)},c.prototype.completed=function(){var a=ma(this.t.onCompleted).call(this.t);return a===la?this.o.onError(a.e):void this.o.onCompleted()},b}(fc);$b["do"]=$b.tap=$b.doAction=function(a,b,c){return new wd(this,a,b,c)},$b.doOnNext=$b.tapOnNext=function(a,b){return this.tap("undefined"!=typeof b?function(c){a.call(b,c)}:a)},$b.doOnError=$b.tapOnError=function(a,b){return this.tap(da,"undefined"!=typeof b?function(c){a.call(b,c)}:a)},$b.doOnCompleted=$b.tapOnCompleted=function(a,b){return this.tap(da,null,"undefined"!=typeof b?function(){a.call(b)}:a)};var xd=function(a){function b(b,c,d){this.source=b,this._fn=Ca(c,d,0),a.call(this)}function c(a,b){this.isDisposed=!1,this._s=a,this._fn=b}return jb(b,a),b.prototype.subscribeCore=function(a){var b=ma(this.source.subscribe).call(this.source,a);return b===la&&(this._fn(),e(b.e)),new c(b,this._fn)},c.prototype.dispose=function(){if(!this.isDisposed){var a=ma(this._s.dispose).call(this._s);this._fn(),a===la&&e(a.e)}},b}(fc);$b["finally"]=function(a,b){return new xd(this,a,b)};var yd=function(a){function b(b){this.source=b,a.call(this)}function c(a){this.o=a,this.isStopped=!1}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a))},c.prototype.onNext=da,c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},b}(fc);$b.ignoreElements=function(){return new yd(this)};var zd=function(a){function b(b,c){this.source=b,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new Ad(a))},b}(fc),Ad=function(a){function b(b){this._o=b,a.call(this)}return jb(b,a),b.prototype.next=function(a){this._o.onNext(Vb(a))},b.prototype.error=function(a){this._o.onNext(Wb(a)),this._o.onCompleted()},b.prototype.completed=function(){this._o.onNext(Xb()),this._o.onCompleted()},b}(_b);$b.materialize=function(){return new zd(this)},$b.repeat=function(a){return lc(this,a).concat()},$b.retry=function(a){return lc(this,a).catchError()};var Bd=function(a){function b(a){return{isDisposed:!1,dispose:function(){this.isDisposed||(this.isDisposed=!0,a.isDisposed=!0)}}}function c(b,c){this.source=b,this._notifier=c,a.call(this)}return jb(c,a),c.prototype.subscribeCore=function(a){var c,d=new Yd,e=new Yd,f=this._notifier(d),g=f.subscribe(e),h=this.source["@@iterator"](),i={isDisposed:!1},j=new vb,k=Ib.scheduleRecursive(null,function(b,f){if(!i.isDisposed){var g=h.next();if(g.done)return void(c?a.onError(c):a.onCompleted());var k=g.value;ja(k)&&(k=rc(k));var l=new ub,m=new ub;j.setDisposable(new wb(m,l)),l.setDisposable(k.subscribe(function(b){a.onNext(b)},function(b){m.setDisposable(e.subscribe(f,function(b){a.onError(b)},function(){a.onCompleted()})),d.onNext(b),l.dispose()},function(){a.onCompleted()}))}});return new xb([g,j,k,b(i)])},c}(fc);$b.retryWhen=function(a){return new Bd(Q(this),a)};var Cd=function(a){function b(a){return{isDisposed:!1,dispose:function(){this.isDisposed||(this.isDisposed=!0,a.isDisposed=!0)}}}function c(b,c){this.source=b,this._notifier=c,a.call(this)}return jb(c,a),c.prototype.subscribeCore=function(a){var c,d=new Yd,e=new Yd,f=this._notifier(d),g=f.subscribe(e),h=this.source["@@iterator"](),i={isDisposed:!1},j=new vb,k=Ib.scheduleRecursive(null,function(b,f){if(!i.isDisposed){var g=h.next();if(g.done)return void(c?a.onError(c):a.onCompleted());var k=g.value;ja(k)&&(k=rc(k));var l=new ub,m=new ub;j.setDisposable(new wb(m,l)),l.setDisposable(k.subscribe(function(b){a.onNext(b)},function(b){a.onError(b)},function(){m.setDisposable(e.subscribe(f,function(b){a.onError(b)},function(){a.onCompleted()})),d.onNext(null),l.dispose()}))}});return new xb([g,j,k,b(i)])},c}(fc);$b.repeatWhen=function(a){return new Cd(Q(this),a)};var Dd=function(a){function b(b,c,d,e){this.source=b,this.accumulator=c,this.hasSeed=d,this.seed=e,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new Ed(a,this))},b}(fc),Ed=function(a){function b(b,c){this._o=b,this._p=c,this._fn=c.accumulator,this._hs=c.hasSeed,this._s=c.seed,this._ha=!1,this._a=null,this._hv=!1,this._i=0,a.call(this)}return jb(b,a),b.prototype.next=function(a){return!this._hv&&(this._hv=!0),this._ha?this._a=ma(this._fn)(this._a,a,this._i,this._p):(this._a=this._hs?ma(this._fn)(this._s,a,this._i,this._p):a,this._ha=!0),this._a===la?this._o.onError(this._a.e):(this._o.onNext(this._a),void this._i++)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){!this._hv&&this._hs&&this._o.onNext(this._s),this._o.onCompleted()},b}(_b);$b.scan=function(){var a,b=!1,c=arguments[0];return 2===arguments.length&&(b=!0,a=arguments[1]),new Dd(this,c,b,a)};var Fd=function(a){function b(b,c){this.source=b,this._c=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new Gd(a,this._c))},b}(fc),Gd=function(a){function b(b,c){this._o=b,this._c=c,this._q=[],a.call(this)}return jb(b,a),b.prototype.next=function(a){this._q.push(a),this._q.length>this._c&&this._o.onNext(this._q.shift())},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(_b);$b.skipLast=function(a){if(0>a)throw new ua;return new Fd(this,a)},$b.startWith=function(){var a,b=0;arguments.length&&Cb(arguments[0])?(a=arguments[0],b=1):a=Gb;for(var c=[],d=b,e=arguments.length;e>d;d++)c.push(arguments[d]);return Vc.apply(null,[Bc(c,a),this])};var Hd=function(a){function b(b,c){this._o=b,this._c=c,this._q=[],a.call(this)}return jb(b,a),b.prototype.next=function(a){this._q.push(a),this._q.length>this._c&&this._q.shift()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){for(;this._q.length>0;)this._o.onNext(this._q.shift());this._o.onCompleted()},b}(_b);$b.takeLast=function(a){if(0>a)throw new ua;var b=this;return new Vd(function(c){return b.subscribe(new Hd(c,a))},b)};var Id=function(a){function b(b,c){this._o=b,this._c=c,this._q=[],a.call(this)}return jb(b,a),b.prototype.next=function(a){this._q.push(a),this._q.length>this._c&&this._q.shift()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onNext(this._q),this._o.onCompleted()},b}(_b);$b.takeLastBuffer=function(a){if(0>a)throw new ua;var b=this;return new Vd(function(c){return b.subscribe(new Id(c,a))},b)},$b.windowWithCount=$b.windowCount=function(a,b){var c=this;if(+a||(a=0),Math.abs(a)===1/0&&(a=0),0>=a)throw new ua;if(null==b&&(b=a),+b||(b=0),Math.abs(b)===1/0&&(b=0),0>=b)throw new ua;return new Vd(function(d){function e(){var a=new Yd;i.push(a),d.onNext(lb(a,g))}var f=new ub,g=new yb(f),h=0,i=[];return e(),f.setDisposable(c.subscribe(function(c){for(var d=0,f=i.length;f>d;d++)i[d].onNext(c);var g=h-a+1;g>=0&&g%b===0&&i.shift().onCompleted(),++h%b===0&&e()},function(a){for(;i.length>0;)i.shift().onError(a);d.onError(a)},function(){for(;i.length>0;)i.shift().onCompleted();d.onCompleted()})),g},c)},$b.flatMapConcat=$b.concatMap=function(a,b,c){return new gc(this,a,b,c).merge(1)},$b.concatMapObserver=$b.selectConcatObserver=function(a,b,c,d){var e=this,f=Ca(a,d,2),g=Ca(b,d,1),h=Ca(c,d,0);return new Vd(function(a){var b=0;return e.subscribe(function(c){var d;try{d=f(c,b++)}catch(e){return void a.onError(e)}ja(d)&&(d=rc(d)),a.onNext(d)},function(b){var c;try{c=g(b)}catch(d){return void a.onError(d)}ja(c)&&(c=rc(c)),a.onNext(c),a.onCompleted()},function(){var b;try{b=h()}catch(c){return void a.onError(c)}ja(b)&&(b=rc(b)),a.onNext(b),a.onCompleted()})},this).concatAll()};var Jd=function(a){function b(b,c){this._o=b,this._d=c,this._f=!1,a.call(this)}return jb(b,a),b.prototype.next=function(a){this._f=!0,this._o.onNext(a)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){!this._f&&this._o.onNext(this._d),this._o.onCompleted()},b}(_b);$b.defaultIfEmpty=function(b){var c=this;return b===a&&(b=null),new Vd(function(a){return c.subscribe(new Jd(a,b));
4 | },c)},S.prototype.push=function(a){var b=-1===R(this.set,a,this.comparer);return b&&this.set.push(a),b};var Kd=function(a){function b(b,c,d){this.source=b,this._keyFn=c,this._cmpFn=d,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new Ld(a,this._keyFn,this._cmpFn))},b}(fc),Ld=function(a){function b(b,c,d){this._o=b,this._keyFn=c,this._h=new S(d),a.call(this)}return jb(b,a),b.prototype.next=function(a){var b=a;return ka(this._keyFn)&&(b=ma(this._keyFn)(a),b===la)?this._o.onError(b.e):void(this._h.push(b)&&this._o.onNext(a))},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(_b);$b.distinct=function(a,b){return b||(b=ga),new Kd(this,a,b)};var Md=function(a){function b(b,c,d){this.source=b,this.selector=Ca(c,d,3),a.call(this)}function c(a,b){return function(c,d,e){return a.call(this,b.selector(c,d,e),d,e)}}function d(a,b,c){this.o=a,this.selector=b,this.source=c,this.i=0,_b.call(this)}return jb(b,a),b.prototype.internalMap=function(a,d){return new b(this.source,c(a,this),d)},b.prototype.subscribeCore=function(a){return this.source.subscribe(new d(a,this.selector,this))},jb(d,_b),d.prototype.next=function(a){var b=ma(this.selector)(a,this.i++,this.source);return b===la?this.o.onError(b.e):void this.o.onNext(b)},d.prototype.error=function(a){this.o.onError(a)},d.prototype.completed=function(){this.o.onCompleted()},b}(fc);$b.map=$b.select=function(a,b){var c="function"==typeof a?a:function(){return a};return this instanceof Md?this.internalMap(c,b):new Md(this,c,b)},$b.pluck=function(){var a=arguments.length,b=new Array(a);if(0===a)throw new Error("List of properties cannot be empty.");for(var c=0;a>c;c++)b[c]=arguments[c];return this.map(T(b,a))},$b.flatMapObserver=$b.selectManyObserver=function(a,b,c,d){var e=this;return new Vd(function(f){var g=0;return e.subscribe(function(b){var c;try{c=a.call(d,b,g++)}catch(e){return void f.onError(e)}ja(c)&&(c=rc(c)),f.onNext(c)},function(a){var c;try{c=b.call(d,a)}catch(e){return void f.onError(e)}ja(c)&&(c=rc(c)),f.onNext(c),f.onCompleted()},function(){var a;try{a=c.call(d)}catch(b){return void f.onError(b)}ja(a)&&(a=rc(a)),f.onNext(a),f.onCompleted()})},e).mergeAll()},$b.flatMap=$b.selectMany=$b.mergeMap=function(a,b,c){return new gc(this,a,b,c).mergeAll()},$b.flatMapLatest=$b.switchMap=function(a,b,c){return new gc(this,a,b,c).switchLatest()};var Nd=function(a){function b(b,c){this.source=b,this._count=c,a.call(this)}function c(a,b){this._o=a,this._r=b,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this._count))},jb(c,_b),c.prototype.next=function(a){this._r<=0?this._o.onNext(a):this._r--},c.prototype.error=function(a){this._o.onError(a)},c.prototype.completed=function(){this._o.onCompleted()},b}(fc);$b.skip=function(a){if(0>a)throw new ua;return new Nd(this,a)};var Od=function(a){function b(b,c){this.source=b,this._fn=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new Pd(a,this))},b}(fc),Pd=function(a){function b(b,c){this._o=b,this._p=c,this._i=0,this._r=!1,a.call(this)}return jb(b,a),b.prototype.next=function(a){if(!this._r){var b=ma(this._p._fn)(a,this._i++,this._p);if(b===la)return this._o.onError(b.e);this._r=!b}this._r&&this._o.onNext(a)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(_b);$b.skipWhile=function(a,b){var c=Ca(a,b,3);return new Od(this,c)};var Qd=function(a){function b(b,c){this.source=b,this._count=c,a.call(this)}function c(a,b){this._o=a,this._c=b,this._r=b,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this._count))},jb(c,_b),c.prototype.next=function(a){this._r-->0&&(this._o.onNext(a),this._r<=0&&this._o.onCompleted())},c.prototype.error=function(a){this._o.onError(a)},c.prototype.completed=function(){this._o.onCompleted()},b}(fc);$b.take=function(a,b){if(0>a)throw new ua;return 0===a?wc(b):new Qd(this,a)};var Rd=function(a){function b(b,c){this.source=b,this._fn=c,a.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new Sd(a,this))},b}(fc),Sd=function(a){function b(b,c){this._o=b,this._p=c,this._i=0,this._r=!0,a.call(this)}return jb(b,a),b.prototype.next=function(a){return this._r&&(this._r=ma(this._p._fn)(a,this._i++,this._p),this._r===la)?this._o.onError(this._r.e):void(this._r?this._o.onNext(a):this._o.onCompleted())},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(_b);$b.takeWhile=function(a,b){var c=Ca(a,b,3);return new Rd(this,c)};var Td=function(a){function b(b,c,d){this.source=b,this.predicate=Ca(c,d,3),a.call(this)}function c(a,b){return function(c,d,e){return b.predicate(c,d,e)&&a.call(this,c,d,e)}}function d(a,b,c){this.o=a,this.predicate=b,this.source=c,this.i=0,_b.call(this)}return jb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new d(a,this.predicate,this))},b.prototype.internalFilter=function(a,d){return new b(this.source,c(a,this),d)},jb(d,_b),d.prototype.next=function(a){var b=ma(this.predicate)(a,this.i++,this.source);return b===la?this.o.onError(b.e):void(b&&this.o.onNext(a))},d.prototype.error=function(a){this.o.onError(a)},d.prototype.completed=function(){this.o.onCompleted()},b}(fc);$b.filter=$b.where=function(a,b){return this instanceof Td?this.internalFilter(a,b):new Td(this,a,b)};var Ud=function(a){function b(b,c){this._o=b,this._xform=c,a.call(this)}return jb(b,a),b.prototype.next=function(a){var b=ma(this._xform["@@transducer/step"]).call(this._xform,this._o,a);b===la&&this._o.onError(b.e)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._xform["@@transducer/result"](this._o)},b}(_b);$b.transduce=function(a){var b=this;return new Vd(function(c){var d=a(U(c));return b.subscribe(new Ud(c,d))},b)};var Vd=ca.AnonymousObservable=function(a){function b(a){return a&&ka(a.dispose)?a:ka(a)?pb(a):qb}function c(a,c){var d=c[0],f=c[1],g=ma(f.__subscribe).call(f,d);g!==la||d.fail(la.e)||e(la.e),d.setDisposable(b(g))}function d(b,c){this.source=c,this.__subscribe=b,a.call(this)}return jb(d,a),d.prototype._subscribe=function(a){var b=new Wd(a),d=[b,this];return Ib.scheduleRequired()?Ib.schedule(d,c):c(null,d),b},d}(ec),Wd=function(a){function b(b){a.call(this),this.observer=b,this.m=new ub}jb(b,a);var c=b.prototype;return c.next=function(a){var b=ma(this.observer.onNext).call(this.observer,a);b===la&&(this.dispose(),e(b.e))},c.error=function(a){var b=ma(this.observer.onError).call(this.observer,a);this.dispose(),b===la&&e(b.e)},c.completed=function(){var a=ma(this.observer.onCompleted).call(this.observer);this.dispose(),a===la&&e(a.e)},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(_b),Xd=function(a,b){this._s=a,this._o=b};Xd.prototype.dispose=function(){if(!this._s.isDisposed&&null!==this._o){var a=this._s.observers.indexOf(this._o);this._s.observers.splice(a,1),this._o=null}};var Yd=ca.Subject=function(a){function b(){a.call(this),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return jb(b,a),kb(b.prototype,Yb.prototype,{_subscribe:function(a){return sb(this),this.isStopped?this.hasError?(a.onError(this.error),qb):(a.onCompleted(),qb):(this.observers.push(a),new Xd(this,a))},hasObservers:function(){return sb(this),this.observers.length>0},onCompleted:function(){if(sb(this),!this.isStopped){this.isStopped=!0;for(var a=0,b=c(this.observers),d=b.length;d>a;a++)b[a].onCompleted();this.observers.length=0}},onError:function(a){if(sb(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;for(var b=0,d=c(this.observers),e=d.length;e>b;b++)d[b].onError(a);this.observers.length=0}},onNext:function(a){if(sb(this),!this.isStopped)for(var b=0,d=c(this.observers),e=d.length;e>b;b++)d[b].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),b.create=function(a,b){return new Zd(a,b)},b}(ec),Zd=(ca.AsyncSubject=function(a){function b(){a.call(this),this.isDisposed=!1,this.isStopped=!1,this.hasValue=!1,this.observers=[],this.hasError=!1}return jb(b,a),kb(b.prototype,Yb.prototype,{_subscribe:function(a){return sb(this),this.isStopped?(this.hasError?a.onError(this.error):this.hasValue?(a.onNext(this.value),a.onCompleted()):a.onCompleted(),qb):(this.observers.push(a),new Xd(this,a))},hasObservers:function(){return sb(this),this.observers.length>0},onCompleted:function(){var a,b;if(sb(this),!this.isStopped){this.isStopped=!0;var d=c(this.observers),b=d.length;if(this.hasValue)for(a=0;b>a;a++){var e=d[a];e.onNext(this.value),e.onCompleted()}else for(a=0;b>a;a++)d[a].onCompleted();this.observers.length=0}},onError:function(a){if(sb(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var b=0,d=c(this.observers),e=d.length;e>b;b++)d[b].onError(a);this.observers.length=0}},onNext:function(a){sb(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.error=null,this.value=null}}),b}(ec),ca.AnonymousSubject=function(a){function b(b,c){this.observer=b,this.observable=c,a.call(this)}return jb(b,a),kb(b.prototype,Yb.prototype,{_subscribe:function(a){return this.observable.subscribe(a)},onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),b}(ec));"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ba.Rx=ca,define(function(){return ca})):W&&X?_?(X.exports=ca).Rx=ca:W.Rx=ca:ba.Rx=ca;var $d=j()}).call(this);
5 | //# sourceMappingURL=rx.map
--------------------------------------------------------------------------------
/Server/public/style.css:
--------------------------------------------------------------------------------
1 | /* Fix user-agent */
2 |
3 | * {
4 | box-sizing: border-box;
5 | }
6 |
7 | html {
8 | font-weight: 300;
9 | -webkit-font-smoothing: antialiased;
10 | }
11 |
12 | html, input {
13 | font-family:
14 | "HelveticaNeue-Light",
15 | "Helvetica Neue Light",
16 | "Helvetica Neue",
17 | Helvetica,
18 | Arial,
19 | "Lucida Grande",
20 | sans-serif;
21 | }
22 |
23 | html, body {
24 | height: 100%;
25 | margin: 0;
26 | padding: 0;
27 | }
28 |
29 | ul {
30 | list-style: none;
31 | word-wrap: break-word;
32 | }
33 |
34 | /* Font */
35 |
36 | .messages {
37 | font-size: 150%;
38 | }
39 |
40 | .inputMessage {
41 | font-size: 100%;
42 | }
43 |
44 | .log {
45 | color: gray;
46 | font-size: 70%;
47 | margin: 5px;
48 | text-align: center;
49 | }
50 |
51 | /* Messages */
52 |
53 | #chat {
54 | height: 100%;
55 | margin: 0;
56 | padding: 0;
57 | width: 100%;
58 | }
59 |
60 | .chatArea {
61 | height: 100%;
62 | padding-bottom: 60px;
63 | }
64 |
65 | .messages {
66 | height: 100%;
67 | margin: 0;
68 | overflow-y: scroll;
69 | padding: 10px 20px 10px 20px;
70 | }
71 |
72 | .message.typing .messageBody {
73 | color: gray;
74 | }
75 |
76 | .username {
77 | float: left;
78 | font-weight: 700;
79 | overflow: hidden;
80 | padding-right: 15px;
81 | text-align: right;
82 | }
83 |
84 | /* Input */
85 |
86 | .inputMessage {
87 | border: 10px solid #000;
88 | bottom: 0;
89 | height: 60px;
90 | left: 0;
91 | outline: none;
92 | padding-left: 10px;
93 | position: absolute;
94 | right: 0;
95 | width: 100%;
96 | }
97 |
--------------------------------------------------------------------------------
/iOS/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, "9.0"
2 |
3 | use_frameworks!
4 |
5 | pod 'JSQMessagesViewController'
6 | pod 'RxSwift'
7 | pod 'Socket.IO-Client-Swift', '~> 5.5.0'
8 |
--------------------------------------------------------------------------------
/iOS/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - JSQMessagesViewController (7.2.0):
3 | - JSQSystemSoundPlayer (~> 2.0.1)
4 | - JSQSystemSoundPlayer (2.0.1)
5 | - RxSwift (2.2.0)
6 | - Socket.IO-Client-Swift (5.5.0)
7 |
8 | DEPENDENCIES:
9 | - JSQMessagesViewController
10 | - RxSwift
11 | - Socket.IO-Client-Swift (~> 5.5.0)
12 |
13 | SPEC CHECKSUMS:
14 | JSQMessagesViewController: 73cab48aa92fc2d512f3b6724f3425cc47a19eb5
15 | JSQSystemSoundPlayer: c5850e77a4363ffd374cd851154b9af93264ed8d
16 | RxSwift: b8a749f2204c6c7a5c29b306a9c3bc11d5b87c5b
17 | Socket.IO-Client-Swift: f39dbd4e9b295907bb7fd4b9588b89c00426783d
18 |
19 | COCOAPODS: 0.39.0
20 |
--------------------------------------------------------------------------------
/iOS/RxChat.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | B730D14B709509F76FDA217C /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F449548296BD5ED086D5C7D /* Pods.framework */; };
11 | CB9F8E441C95D31400657FA8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB9F8E431C95D31400657FA8 /* AppDelegate.swift */; };
12 | CB9F8E461C95D31400657FA8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB9F8E451C95D31400657FA8 /* ViewController.swift */; };
13 | CB9F8E491C95D31400657FA8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB9F8E471C95D31400657FA8 /* Main.storyboard */; };
14 | CB9F8E4B1C95D31400657FA8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CB9F8E4A1C95D31400657FA8 /* Assets.xcassets */; };
15 | CB9F8E4E1C95D31400657FA8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB9F8E4C1C95D31400657FA8 /* LaunchScreen.storyboard */; };
16 | CB9F8E5E1C96E79F00657FA8 /* SocketIO+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB9F8E5C1C96B04B00657FA8 /* SocketIO+Rx.swift */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXFileReference section */
20 | 0F449548296BD5ED086D5C7D /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
21 | 203C331E018E52D8BBC8CB3E /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; };
22 | CB9F8E401C95D31400657FA8 /* RxChat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RxChat.app; sourceTree = BUILT_PRODUCTS_DIR; };
23 | CB9F8E431C95D31400657FA8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
24 | CB9F8E451C95D31400657FA8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
25 | CB9F8E481C95D31400657FA8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
26 | CB9F8E4A1C95D31400657FA8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
27 | CB9F8E4D1C95D31400657FA8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
28 | CB9F8E4F1C95D31400657FA8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
29 | CB9F8E5C1C96B04B00657FA8 /* SocketIO+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SocketIO+Rx.swift"; sourceTree = ""; };
30 | FE74438B3D1986B33196CF26 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | CB9F8E3D1C95D31400657FA8 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | B730D14B709509F76FDA217C /* Pods.framework in Frameworks */,
39 | );
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXFrameworksBuildPhase section */
43 |
44 | /* Begin PBXGroup section */
45 | 4C21A93BEDAE9E46F4F20B34 /* Frameworks */ = {
46 | isa = PBXGroup;
47 | children = (
48 | 0F449548296BD5ED086D5C7D /* Pods.framework */,
49 | );
50 | name = Frameworks;
51 | sourceTree = "";
52 | };
53 | A3F28813523A8349C52FBFCB /* Pods */ = {
54 | isa = PBXGroup;
55 | children = (
56 | FE74438B3D1986B33196CF26 /* Pods.debug.xcconfig */,
57 | 203C331E018E52D8BBC8CB3E /* Pods.release.xcconfig */,
58 | );
59 | name = Pods;
60 | sourceTree = "";
61 | };
62 | CB9F8E371C95D31400657FA8 = {
63 | isa = PBXGroup;
64 | children = (
65 | CB9F8E421C95D31400657FA8 /* RxChat */,
66 | CB9F8E411C95D31400657FA8 /* Products */,
67 | A3F28813523A8349C52FBFCB /* Pods */,
68 | 4C21A93BEDAE9E46F4F20B34 /* Frameworks */,
69 | );
70 | sourceTree = "";
71 | };
72 | CB9F8E411C95D31400657FA8 /* Products */ = {
73 | isa = PBXGroup;
74 | children = (
75 | CB9F8E401C95D31400657FA8 /* RxChat.app */,
76 | );
77 | name = Products;
78 | sourceTree = "";
79 | };
80 | CB9F8E421C95D31400657FA8 /* RxChat */ = {
81 | isa = PBXGroup;
82 | children = (
83 | CB9F8E5A1C96B03400657FA8 /* RxSocketIO */,
84 | CB9F8E431C95D31400657FA8 /* AppDelegate.swift */,
85 | CB9F8E451C95D31400657FA8 /* ViewController.swift */,
86 | CB9F8E471C95D31400657FA8 /* Main.storyboard */,
87 | CB9F8E4A1C95D31400657FA8 /* Assets.xcassets */,
88 | CB9F8E4C1C95D31400657FA8 /* LaunchScreen.storyboard */,
89 | CB9F8E4F1C95D31400657FA8 /* Info.plist */,
90 | );
91 | path = RxChat;
92 | sourceTree = "";
93 | };
94 | CB9F8E5A1C96B03400657FA8 /* RxSocketIO */ = {
95 | isa = PBXGroup;
96 | children = (
97 | CB9F8E5C1C96B04B00657FA8 /* SocketIO+Rx.swift */,
98 | );
99 | name = RxSocketIO;
100 | sourceTree = "";
101 | };
102 | /* End PBXGroup section */
103 |
104 | /* Begin PBXNativeTarget section */
105 | CB9F8E3F1C95D31400657FA8 /* RxChat */ = {
106 | isa = PBXNativeTarget;
107 | buildConfigurationList = CB9F8E521C95D31400657FA8 /* Build configuration list for PBXNativeTarget "RxChat" */;
108 | buildPhases = (
109 | 9DC303CEEE62DBDD93725F18 /* Check Pods Manifest.lock */,
110 | CB9F8E3C1C95D31400657FA8 /* Sources */,
111 | CB9F8E3D1C95D31400657FA8 /* Frameworks */,
112 | CB9F8E3E1C95D31400657FA8 /* Resources */,
113 | 465E69064AFCA029FB55E983 /* Embed Pods Frameworks */,
114 | 249298521C2F350F30CA7A68 /* Copy Pods Resources */,
115 | );
116 | buildRules = (
117 | );
118 | dependencies = (
119 | );
120 | name = RxChat;
121 | productName = RxChat;
122 | productReference = CB9F8E401C95D31400657FA8 /* RxChat.app */;
123 | productType = "com.apple.product-type.application";
124 | };
125 | /* End PBXNativeTarget section */
126 |
127 | /* Begin PBXProject section */
128 | CB9F8E381C95D31400657FA8 /* Project object */ = {
129 | isa = PBXProject;
130 | attributes = {
131 | LastSwiftUpdateCheck = 0720;
132 | LastUpgradeCheck = 0720;
133 | ORGANIZATIONNAME = Sideeffects.xyz;
134 | TargetAttributes = {
135 | CB9F8E3F1C95D31400657FA8 = {
136 | CreatedOnToolsVersion = 7.2.1;
137 | };
138 | };
139 | };
140 | buildConfigurationList = CB9F8E3B1C95D31400657FA8 /* Build configuration list for PBXProject "RxChat" */;
141 | compatibilityVersion = "Xcode 3.2";
142 | developmentRegion = English;
143 | hasScannedForEncodings = 0;
144 | knownRegions = (
145 | en,
146 | Base,
147 | );
148 | mainGroup = CB9F8E371C95D31400657FA8;
149 | productRefGroup = CB9F8E411C95D31400657FA8 /* Products */;
150 | projectDirPath = "";
151 | projectRoot = "";
152 | targets = (
153 | CB9F8E3F1C95D31400657FA8 /* RxChat */,
154 | );
155 | };
156 | /* End PBXProject section */
157 |
158 | /* Begin PBXResourcesBuildPhase section */
159 | CB9F8E3E1C95D31400657FA8 /* Resources */ = {
160 | isa = PBXResourcesBuildPhase;
161 | buildActionMask = 2147483647;
162 | files = (
163 | CB9F8E4E1C95D31400657FA8 /* LaunchScreen.storyboard in Resources */,
164 | CB9F8E4B1C95D31400657FA8 /* Assets.xcassets in Resources */,
165 | CB9F8E491C95D31400657FA8 /* Main.storyboard in Resources */,
166 | );
167 | runOnlyForDeploymentPostprocessing = 0;
168 | };
169 | /* End PBXResourcesBuildPhase section */
170 |
171 | /* Begin PBXShellScriptBuildPhase section */
172 | 249298521C2F350F30CA7A68 /* Copy Pods Resources */ = {
173 | isa = PBXShellScriptBuildPhase;
174 | buildActionMask = 2147483647;
175 | files = (
176 | );
177 | inputPaths = (
178 | );
179 | name = "Copy Pods Resources";
180 | outputPaths = (
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | shellPath = /bin/sh;
184 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
185 | showEnvVarsInLog = 0;
186 | };
187 | 465E69064AFCA029FB55E983 /* Embed Pods Frameworks */ = {
188 | isa = PBXShellScriptBuildPhase;
189 | buildActionMask = 2147483647;
190 | files = (
191 | );
192 | inputPaths = (
193 | );
194 | name = "Embed Pods Frameworks";
195 | outputPaths = (
196 | );
197 | runOnlyForDeploymentPostprocessing = 0;
198 | shellPath = /bin/sh;
199 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
200 | showEnvVarsInLog = 0;
201 | };
202 | 9DC303CEEE62DBDD93725F18 /* Check Pods Manifest.lock */ = {
203 | isa = PBXShellScriptBuildPhase;
204 | buildActionMask = 2147483647;
205 | files = (
206 | );
207 | inputPaths = (
208 | );
209 | name = "Check Pods Manifest.lock";
210 | outputPaths = (
211 | );
212 | runOnlyForDeploymentPostprocessing = 0;
213 | shellPath = /bin/sh;
214 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
215 | showEnvVarsInLog = 0;
216 | };
217 | /* End PBXShellScriptBuildPhase section */
218 |
219 | /* Begin PBXSourcesBuildPhase section */
220 | CB9F8E3C1C95D31400657FA8 /* Sources */ = {
221 | isa = PBXSourcesBuildPhase;
222 | buildActionMask = 2147483647;
223 | files = (
224 | CB9F8E5E1C96E79F00657FA8 /* SocketIO+Rx.swift in Sources */,
225 | CB9F8E461C95D31400657FA8 /* ViewController.swift in Sources */,
226 | CB9F8E441C95D31400657FA8 /* AppDelegate.swift in Sources */,
227 | );
228 | runOnlyForDeploymentPostprocessing = 0;
229 | };
230 | /* End PBXSourcesBuildPhase section */
231 |
232 | /* Begin PBXVariantGroup section */
233 | CB9F8E471C95D31400657FA8 /* Main.storyboard */ = {
234 | isa = PBXVariantGroup;
235 | children = (
236 | CB9F8E481C95D31400657FA8 /* Base */,
237 | );
238 | name = Main.storyboard;
239 | sourceTree = "";
240 | };
241 | CB9F8E4C1C95D31400657FA8 /* LaunchScreen.storyboard */ = {
242 | isa = PBXVariantGroup;
243 | children = (
244 | CB9F8E4D1C95D31400657FA8 /* Base */,
245 | );
246 | name = LaunchScreen.storyboard;
247 | sourceTree = "";
248 | };
249 | /* End PBXVariantGroup section */
250 |
251 | /* Begin XCBuildConfiguration section */
252 | CB9F8E501C95D31400657FA8 /* Debug */ = {
253 | isa = XCBuildConfiguration;
254 | buildSettings = {
255 | ALWAYS_SEARCH_USER_PATHS = NO;
256 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
257 | CLANG_CXX_LIBRARY = "libc++";
258 | CLANG_ENABLE_MODULES = YES;
259 | CLANG_ENABLE_OBJC_ARC = YES;
260 | CLANG_WARN_BOOL_CONVERSION = YES;
261 | CLANG_WARN_CONSTANT_CONVERSION = YES;
262 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
263 | CLANG_WARN_EMPTY_BODY = YES;
264 | CLANG_WARN_ENUM_CONVERSION = YES;
265 | CLANG_WARN_INT_CONVERSION = YES;
266 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
267 | CLANG_WARN_UNREACHABLE_CODE = YES;
268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
269 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
270 | COPY_PHASE_STRIP = NO;
271 | DEBUG_INFORMATION_FORMAT = dwarf;
272 | ENABLE_STRICT_OBJC_MSGSEND = YES;
273 | ENABLE_TESTABILITY = YES;
274 | GCC_C_LANGUAGE_STANDARD = gnu99;
275 | GCC_DYNAMIC_NO_PIC = NO;
276 | GCC_NO_COMMON_BLOCKS = YES;
277 | GCC_OPTIMIZATION_LEVEL = 0;
278 | GCC_PREPROCESSOR_DEFINITIONS = (
279 | "DEBUG=1",
280 | "$(inherited)",
281 | );
282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
283 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
284 | GCC_WARN_UNDECLARED_SELECTOR = YES;
285 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
286 | GCC_WARN_UNUSED_FUNCTION = YES;
287 | GCC_WARN_UNUSED_VARIABLE = YES;
288 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
289 | MTL_ENABLE_DEBUG_INFO = YES;
290 | ONLY_ACTIVE_ARCH = YES;
291 | SDKROOT = iphoneos;
292 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
293 | };
294 | name = Debug;
295 | };
296 | CB9F8E511C95D31400657FA8 /* Release */ = {
297 | isa = XCBuildConfiguration;
298 | buildSettings = {
299 | ALWAYS_SEARCH_USER_PATHS = NO;
300 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
301 | CLANG_CXX_LIBRARY = "libc++";
302 | CLANG_ENABLE_MODULES = YES;
303 | CLANG_ENABLE_OBJC_ARC = YES;
304 | CLANG_WARN_BOOL_CONVERSION = YES;
305 | CLANG_WARN_CONSTANT_CONVERSION = YES;
306 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
307 | CLANG_WARN_EMPTY_BODY = YES;
308 | CLANG_WARN_ENUM_CONVERSION = YES;
309 | CLANG_WARN_INT_CONVERSION = YES;
310 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
311 | CLANG_WARN_UNREACHABLE_CODE = YES;
312 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
313 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
314 | COPY_PHASE_STRIP = NO;
315 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
316 | ENABLE_NS_ASSERTIONS = NO;
317 | ENABLE_STRICT_OBJC_MSGSEND = YES;
318 | GCC_C_LANGUAGE_STANDARD = gnu99;
319 | GCC_NO_COMMON_BLOCKS = YES;
320 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
321 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
322 | GCC_WARN_UNDECLARED_SELECTOR = YES;
323 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
324 | GCC_WARN_UNUSED_FUNCTION = YES;
325 | GCC_WARN_UNUSED_VARIABLE = YES;
326 | IPHONEOS_DEPLOYMENT_TARGET = 9.2;
327 | MTL_ENABLE_DEBUG_INFO = NO;
328 | SDKROOT = iphoneos;
329 | VALIDATE_PRODUCT = YES;
330 | };
331 | name = Release;
332 | };
333 | CB9F8E531C95D31400657FA8 /* Debug */ = {
334 | isa = XCBuildConfiguration;
335 | baseConfigurationReference = FE74438B3D1986B33196CF26 /* Pods.debug.xcconfig */;
336 | buildSettings = {
337 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
338 | INFOPLIST_FILE = RxChat/Info.plist;
339 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
340 | PRODUCT_BUNDLE_IDENTIFIER = xyz.sideeffects.RxChat;
341 | PRODUCT_NAME = "$(TARGET_NAME)";
342 | };
343 | name = Debug;
344 | };
345 | CB9F8E541C95D31400657FA8 /* Release */ = {
346 | isa = XCBuildConfiguration;
347 | baseConfigurationReference = 203C331E018E52D8BBC8CB3E /* Pods.release.xcconfig */;
348 | buildSettings = {
349 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
350 | INFOPLIST_FILE = RxChat/Info.plist;
351 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
352 | PRODUCT_BUNDLE_IDENTIFIER = xyz.sideeffects.RxChat;
353 | PRODUCT_NAME = "$(TARGET_NAME)";
354 | };
355 | name = Release;
356 | };
357 | /* End XCBuildConfiguration section */
358 |
359 | /* Begin XCConfigurationList section */
360 | CB9F8E3B1C95D31400657FA8 /* Build configuration list for PBXProject "RxChat" */ = {
361 | isa = XCConfigurationList;
362 | buildConfigurations = (
363 | CB9F8E501C95D31400657FA8 /* Debug */,
364 | CB9F8E511C95D31400657FA8 /* Release */,
365 | );
366 | defaultConfigurationIsVisible = 0;
367 | defaultConfigurationName = Release;
368 | };
369 | CB9F8E521C95D31400657FA8 /* Build configuration list for PBXNativeTarget "RxChat" */ = {
370 | isa = XCConfigurationList;
371 | buildConfigurations = (
372 | CB9F8E531C95D31400657FA8 /* Debug */,
373 | CB9F8E541C95D31400657FA8 /* Release */,
374 | );
375 | defaultConfigurationIsVisible = 0;
376 | defaultConfigurationName = Release;
377 | };
378 | /* End XCConfigurationList section */
379 | };
380 | rootObject = CB9F8E381C95D31400657FA8 /* Project object */;
381 | }
382 |
--------------------------------------------------------------------------------
/iOS/RxChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS/RxChat.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/iOS/RxChat/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // RxChat
4 | //
5 | // Created by Junior B. on 13/03/16.
6 | // Copyright © 2016 Sideeffects.xyz. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(application: UIApplication) {
23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(application: UIApplication) {
28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(application: UIApplication) {
33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(application: UIApplication) {
37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38 | }
39 |
40 | func applicationWillTerminate(application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/iOS/RxChat/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/iOS/RxChat/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOS/RxChat/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/iOS/RxChat/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | NSAppTransportSecurity
40 |
41 | NSAllowsArbitraryLoads
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/iOS/RxChat/SocketIO+Rx.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SocketIO+Rx.swift
3 | // RxChat
4 | //
5 | // Created by Junior B. on 14/03/16.
6 | // Copyright © 2016 Sideeffects.xyz. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import RxSwift
11 | import SocketIOClientSwift
12 |
13 | private var rxKey: UInt8 = 0 // We still need this boilerplate
14 | extension SocketIOClient {
15 |
16 | var rx_event: Observable {
17 | get {
18 | return associatedObject(self, key: &rxKey) {
19 | return Observable.create { observer -> Disposable in
20 |
21 | self.onAny() { event in
22 | observer.onNext(event)
23 | }
24 |
25 | return AnonymousDisposable {
26 | //self.disconnect() //side effect, risky
27 | }
28 | }.shareReplayLatestWhileConnected()
29 | } // Set the initial value of the var
30 | }
31 | set { associateObject(self, key: &rxKey, value: newValue) }
32 | }
33 | }
34 |
35 | //Ref: https://medium.com/@ttikitu/swift-extensions-can-add-stored-properties-92db66bce6cd#.2t442w1hp
36 | func associatedObject(base: AnyObject, key: UnsafePointer, initialiser: () -> ValueType) -> ValueType {
37 | if let associated = objc_getAssociatedObject(base, key) as? ValueType {
38 | return associated
39 | }
40 |
41 | let associated = initialiser()
42 | objc_setAssociatedObject(base, key, associated, .OBJC_ASSOCIATION_RETAIN)
43 |
44 | return associated
45 | }
46 |
47 | func associateObject(base: AnyObject, key: UnsafePointer, value: ValueType) {
48 | objc_setAssociatedObject(base, key, value,.OBJC_ASSOCIATION_RETAIN)
49 | }
--------------------------------------------------------------------------------
/iOS/RxChat/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // RxChat
4 | //
5 | // Created by Junior B. on 13/03/16.
6 | // Copyright © 2016 Sideeffects.xyz. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SocketIOClientSwift
11 | import RxSwift
12 | import JSQMessagesViewController
13 |
14 | class ViewController: JSQMessagesViewController, UIAlertViewDelegate {
15 |
16 | private var user = BehaviorSubject(value: "")
17 | private var messages: [JSQMessage] = []
18 |
19 | private let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8000")!, options: [.Log(true), .ForcePolling(true)])
20 | private let disposeBag = DisposeBag()
21 |
22 | private let incomingBubble = JSQMessagesBubbleImageFactory().incomingMessagesBubbleImageWithColor(UIColor(red: 10/255, green: 180/255, blue: 230/255, alpha: 1.0))
23 | private let outgoingBubble = JSQMessagesBubbleImageFactory().outgoingMessagesBubbleImageWithColor(UIColor.lightGrayColor())
24 |
25 |
26 | override func viewDidLoad() {
27 | super.viewDidLoad()
28 | // Do any additional setup after loading the view, typically from a nib.
29 |
30 | self.setup()
31 |
32 | user
33 | .distinctUntilChanged()
34 | .subscribeNext() { username in
35 | self.senderId = username
36 | self.senderDisplayName = username
37 | self.socket.emit("addUser", withItems:[username])
38 | }.addDisposableTo(disposeBag)
39 |
40 | socket.rx_event
41 | .filter({ $0.event == "connect"})
42 | .map({ _ in return () })
43 | .subscribeNext { _ in
44 | self.title = "RxChat (Connected)"
45 | }.addDisposableTo(disposeBag)
46 |
47 | socket.rx_event
48 | .filter({ $0.event == "login" && $0.items?.count > 0})
49 | .map({ Array($0.items!) })
50 | .subscribeNext { login in
51 | let users = login[0]["numUsers"] ?? 0
52 | let messageContent = "Welcome, users online \(users!)"
53 | let message = JSQMessage(senderId: "System", displayName: "System", text: messageContent)
54 | self.messages += [message]
55 | self.finishReceivingMessage()
56 | }.addDisposableTo(disposeBag)
57 |
58 | socket.rx_event
59 | .filter({ $0.event == "newMessage" && $0.items?.count > 0})
60 | .map({ Array($0.items!) })
61 | .subscribeNext { data in
62 | let username = data[0]["username"] as? String ?? "unknown"
63 | let text = data[0]["message"] as? String ?? "invalid text"
64 | let message = JSQMessage(senderId: username, displayName: username, text: text)
65 | self.messages += [message]
66 | self.finishSendingMessage()
67 | }.addDisposableTo(disposeBag)
68 |
69 | socket.rx_event
70 | .filter({ $0.event == "userJoined" && $0.items?.count > 0})
71 | .map({ $0.items![0]["username"].map({ "User joined: \($0)"})})
72 | .subscribeNext { text in
73 | let message = JSQMessage(senderId: "System", displayName: "System", text: text)
74 | self.messages += [message]
75 | self.finishReceivingMessage()
76 | }.addDisposableTo(disposeBag)
77 |
78 | socket.rx_event
79 | .filter({ $0.event == "userLeft" && $0.items?.count > 0})
80 | .map({ $0.items![0]["username"].map({ "User left: \($0)"})})
81 | .subscribeNext { text in
82 | let message = JSQMessage(senderId: "System", displayName: "System", text: text)
83 | self.messages += [message]
84 | self.finishReceivingMessage()
85 | }.addDisposableTo(disposeBag)
86 |
87 | }
88 |
89 | override func viewDidAppear(animated: Bool) {
90 | super.viewDidAppear(animated)
91 |
92 | displayUsernameAlert()
93 | socket.connect()
94 | }
95 |
96 | override func didReceiveMemoryWarning() {
97 | super.didReceiveMemoryWarning()
98 | // Dispose of any resources that can be recreated.
99 | }
100 |
101 | // MARK: Convenience
102 |
103 | func reloadMessagesView() {
104 | self.collectionView?.reloadData()
105 | }
106 |
107 | // JSQMessagesCollectionViewDataSource
108 |
109 | override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
110 | return self.messages.count
111 | }
112 |
113 | override func collectionView(collectionView: JSQMessagesCollectionView!, messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
114 | let data = self.messages[indexPath.row]
115 | return data
116 | }
117 |
118 | override func collectionView(collectionView: JSQMessagesCollectionView!, didDeleteMessageAtIndexPath indexPath: NSIndexPath!) {
119 | self.messages.removeAtIndex(indexPath.row)
120 | }
121 |
122 | override func collectionView(collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageBubbleImageDataSource! {
123 | let data = messages[indexPath.row]
124 | switch(data.senderId) {
125 | case self.senderId:
126 | return self.outgoingBubble
127 | default:
128 | return self.incomingBubble
129 | }
130 | }
131 |
132 | override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource! {
133 | return nil
134 | }
135 |
136 | // MARK: Toolbar
137 |
138 | override func didPressSendButton(button: UIButton!, withMessageText text: String!, senderId: String!, senderDisplayName: String!, date: NSDate!) {
139 | let message = JSQMessage(senderId: senderId, senderDisplayName: senderDisplayName, date: date, text: text)
140 | self.messages += [message]
141 | self.finishSendingMessage()
142 | self.socket.emit("newMessage", [text])
143 | }
144 |
145 | override func didPressAccessoryButton(sender: UIButton!) {
146 |
147 | }
148 |
149 | // MARK: Alert View
150 | func displayUsernameAlert() {
151 | let alertController = UIAlertController(title: "Login", message: "Please enter your username", preferredStyle: UIAlertControllerStyle.Alert)
152 | alertController.addTextFieldWithConfigurationHandler() { textField in
153 | textField.placeholder = "Username"
154 | }
155 |
156 | let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { _ in
157 | let usernameTextfield = alertController.textFields![0] as UITextField
158 | guard let username = usernameTextfield.text where username != "" else {
159 | self.displayUsernameAlert()
160 | return
161 | }
162 |
163 | self.user.onNext(username)
164 | }
165 |
166 | alertController.addAction(okAction)
167 |
168 | presentViewController(alertController, animated: true, completion: nil)
169 | }
170 |
171 |
172 | func setup() {
173 | self.senderId = ""
174 | self.senderDisplayName = ""
175 | }
176 |
177 |
178 | }
179 |
180 |
--------------------------------------------------------------------------------