summaryrefslogtreecommitdiffstats
path: root/core/js/eventsource.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-01-30 23:26:01 +0100
committerRobin Appelman <icewind@owncloud.com>2012-01-31 16:35:47 +0100
commitfdf3df3de591845df5255b04eabe12e794faa1f1 (patch)
tree1cbf73632c80b1f59d02eb90ae5b21ba6304a15d /core/js/eventsource.js
parent6a1121ab2e91a362ed1e13e18c44fca40761f97a (diff)
downloadnextcloud-server-fdf3df3de591845df5255b04eabe12e794faa1f1.tar.gz
nextcloud-server-fdf3df3de591845df5255b04eabe12e794faa1f1.zip
add option to send get data along with an eventsource request
Diffstat (limited to 'core/js/eventsource.js')
-rw-r--r--core/js/eventsource.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/js/eventsource.js b/core/js/eventsource.js
index 30b942f59e8..dece1a69d04 100644
--- a/core/js/eventsource.js
+++ b/core/js/eventsource.js
@@ -26,9 +26,18 @@
* use server side events with causion, to many open requests can hang the server
*/
-OC.EventSource=function(src){
+/**
+ * create a new event source
+ * @param string src
+ * @param object data to be send as GET
+ */
+OC.EventSource=function(src,data){
+ var dataStr='';
+ for(name in data){
+ dataStr+=name+'='+encodeURIComponent(data[name])+'&';
+ }
if(!this.useFallBack && typeof EventSource !='undefined'){
- this.source=new EventSource(src);
+ this.source=new EventSource(src+'?'+dataStr);
this.source.onmessage=function(e){
for(var i=0;i<this.typelessListeners.length;i++){
this.typelessListeners[i](JSON.parse(e.data));
@@ -40,7 +49,7 @@ OC.EventSource=function(src){
this.iframe=$('<iframe/>');
this.iframe.attr('id',iframeId);
this.iframe.hide();
- this.iframe.attr('src',src+'?fallback=true&fallback_id='+OC.EventSource.iframeCount);
+ this.iframe.attr('src',src+'?fallback=true&fallback_id='+OC.EventSource.iframeCount+'&'+dataStr);
$('body').append(this.iframe);
this.useFallBack=true;
OC.EventSource.iframeCount++