From 7c6722da8487a4cf7d3ffb55b69b39124ac35643 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sat, 11 Jun 2016 18:16:10 -0300 Subject: [PATCH] Added minified version 0.1.3 --- jquery.sse.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.sse.min.js b/jquery.sse.min.js index 747a8b2..16f65c4 100644 --- a/jquery.sse.min.js +++ b/jquery.sse.min.js @@ -1 +1 @@ -!function(n){function t(n){n.type="event",n.instance=new EventSource(n._url),n.instance.successCount=0,n.instance.onmessage=n._settings.onMessage,n.instance.onopen=function(t){0===n.instance.successCount++&&n._settings.onOpen(t)},n.instance.onerror=function(){event.target.readyState===EventSource.CLOSED&&n._settings.onError(event)};for(var t in n._settings.events)n.instance.addEventListener(t,n._settings.events[t],!1)}function e(n){n.type="ajax",n.instance={successCount:0,id:null,retry:3e3,data:"",event:""},s(n)}function s(t){t.instance&&n.ajax({url:t._url,method:"GET",headers:{"Last-Event-ID":t.instance.id},success:function(n,e,i){if(t.instance){0===t.instance.successCount++&&t._settings.onOpen();var a=n.split("\n");t.instance.data="";var r=0;for(var c in a){var o=a[c].indexOf(":"),u=[a[c].substr(0,o),a[c].substr(o+1)];switch(u[0]){case"":u[1]||1!==r++||(eventMessage={data:t.instance.data,lastEventId:t.instance.id,origin:"http://"+i.getResponseHeader("Host"),returnValue:!0},t.instance.event&&t._settings.events[t.instance.event]?t._settings.events[t.instance.event](eventMessage):t._settings.onMessage(eventMessage),t.instance.data="",t.instance.event="",r=0);break;case"retry":r=0,t.instance.retry=parseInt(u[1].trim());break;case"id":r=0,t.instance.id=u[1].trim();break;case"event":r=0,t.instance.event=u[1].trim();break;case"data":r=0,t.instance.data+=(""!==t.instance.data?"\n":"")+u[1].trim();break;default:r=0}}setTimeout(function(){s(t)},t.instance.retry)}},error:t._settings.onError})}n.extend({SSE:function(s,i){var a={instance:null,type:null},r={onOpen:function(){},onEnd:function(){},onError:function(){},onMessage:function(){},options:{},events:{}};return n.extend(r,i),a._url=s,a._settings=r,a._start=a.start,a.start=function(){return this.instance?!1:(!window.EventSource||this._settings.options.forceAjax?e(this):t(this),!0)},a.stop=function(){return this.instance?(!window.EventSource||this._settings.options.forceAjax||this.instance.close(),this._settings.onEnd(),this.instance=null,this.type=null,!0):!1},a}})}(jQuery); \ No newline at end of file +!function(e){function n(e){e.type="event",e.instance=new EventSource(e._url),e.instance.successCount=0,e.instance.onmessage=e._settings.onMessage,e.instance.onopen=function(n){0===e.instance.successCount++&&e._settings.onOpen(n)},e.instance.onerror=function(n){event.target.readyState===EventSource.CLOSED&&e._settings.onError(event)};for(var n in e._settings.events)e.instance.addEventListener(n,e._settings.events[n],!1)}function t(e){e.type="ajax",e.instance={successCount:0,id:null,retry:3e3,data:"",event:""},s(e)}function s(n){if(n.instance){var t={"Last-Event-ID":n.instance.id};e.extend(t,n._settings.headers),e.ajax({url:n._url,method:"GET",headers:t,success:function(e,t,i){if(n.instance){0===n.instance.successCount++&&n._settings.onOpen();var a=e.split("\n");n.instance.data="";var r=0;for(var c in a){var o=a[c].indexOf(":"),u=[a[c].substr(0,o),a[c].substr(o+1)];switch(u[0]){case"":u[1]||1!==r++||(eventMessage={data:n.instance.data,lastEventId:n.instance.id,origin:"http://"+i.getResponseHeader("Host"),returnValue:!0},n.instance.event&&n._settings.events[n.instance.event]?n._settings.events[n.instance.event](eventMessage):n._settings.onMessage(eventMessage),n.instance.data="",n.instance.event="",r=0);break;case"retry":r=0,n.instance.retry=parseInt(u[1].trim());break;case"id":r=0,n.instance.id=u[1].trim();break;case"event":r=0,n.instance.event=u[1].trim();break;case"data":r=0,n.instance.data+=(""!==n.instance.data?"\n":"")+u[1].trim();break;default:r=0}}setTimeout(function(){s(n)},n.instance.retry)}},error:n._settings.onError})}}e.extend({SSE:function(s,i){var a={instance:null,type:null},r={onOpen:function(e){},onEnd:function(e){},onError:function(e){},onMessage:function(e){},options:{},headers:{},events:{}};return e.extend(r,i),a._url=s,a._settings=r,a._start=a.start,a.start=function(){return this.instance?!1:(!window.EventSource||this._settings.options.forceAjax||Object.keys(this._settings.headers).length>0?t(this):n(this),!0)},a.stop=function(){return this.instance?(!window.EventSource||this._settings.options.forceAjax||Object.keys(this._settings.headers).length>0||this.instance.close(),this._settings.onEnd(),this.instance=null,this.type=null,!0):!1},a}})}(jQuery);