fix potential problem when using multiply eventsource's

This commit is contained in:
Robin Appelman 2012-03-31 16:10:29 +02:00
parent 71b70bb05f
commit ad495a9218
1 changed files with 7 additions and 3 deletions

View File

@ -33,8 +33,12 @@
*/
OC.EventSource=function(src,data){
var dataStr='';
for(name in data){
dataStr+=name+'='+encodeURIComponent(data[name])+'&';
this.typelessListeners=[];
this.listeners={};
if(data){
for(name in data){
dataStr+=name+'='+encodeURIComponent(data[name])+'&';
}
}
if(!this.useFallBack && typeof EventSource !='undefined'){
this.source=new EventSource(src+'?'+dataStr);
@ -42,7 +46,7 @@ OC.EventSource=function(src,data){
for(var i=0;i<this.typelessListeners.length;i++){
this.typelessListeners[i](JSON.parse(e.data));
}
}
}.bind(this);
}else{
iframeId='oc_eventsource_iframe_'+OC.EventSource.iframeCount;
OC.EventSource.fallBackSources[OC.EventSource.iframeCount]=this;