aboutsummaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/eventsource.js15
-rw-r--r--core/js/share.js28
2 files changed, 29 insertions, 14 deletions
diff --git a/core/js/eventsource.js b/core/js/eventsource.js
index e3ad7e3a671..0c2a995f331 100644
--- a/core/js/eventsource.js
+++ b/core/js/eventsource.js
@@ -42,7 +42,11 @@ OC.EventSource=function(src,data){
}
dataStr+='requesttoken='+OC.EventSource.requesttoken;
if(!this.useFallBack && typeof EventSource !='undefined'){
- this.source=new EventSource(src+'?'+dataStr);
+ var joinChar = '&';
+ if(src.indexOf('?') == -1) {
+ joinChar = '?';
+ }
+ this.source=new EventSource(src+joinChar+dataStr);
this.source.onmessage=function(e){
for(var i=0;i<this.typelessListeners.length;i++){
this.typelessListeners[i](JSON.parse(e.data));
@@ -54,7 +58,12 @@ OC.EventSource=function(src,data){
this.iframe=$('<iframe/>');
this.iframe.attr('id',iframeId);
this.iframe.hide();
- this.iframe.attr('src',src+'?fallback=true&fallback_id='+OC.EventSource.iframeCount+'&'+dataStr);
+
+ var joinChar = '&';
+ if(src.indexOf('?') == -1) {
+ joinChar = '?';
+ }
+ this.iframe.attr('src',src+joinChar+'fallback=true&fallback_id='+OC.EventSource.iframeCount+'&'+dataStr);
$('body').append(this.iframe);
this.useFallBack=true;
OC.EventSource.iframeCount++
@@ -90,7 +99,7 @@ OC.EventSource.prototype={
lastLength:0,//for fallback
listen:function(type,callback){
if(callback && callback.call){
-
+
if(type){
if(this.useFallBack){
if(!this.listeners[type]){
diff --git a/core/js/share.js b/core/js/share.js
index 8fcea84af88..0f71ae22419 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -179,7 +179,7 @@ OC.Share={
if (data.shares) {
$.each(data.shares, function(index, share) {
if (share.share_type == OC.Share.SHARE_TYPE_LINK) {
- OC.Share.showLink(itemSource, share.share_with);
+ OC.Share.showLink(share.token, share.share_with, itemSource);
} else {
if (share.collection) {
OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, share.collection);
@@ -323,18 +323,24 @@ OC.Share={
$('#expiration').show();
}
},
- showLink:function(itemSource, password) {
+ showLink:function(token, password, itemSource) {
OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true;
$('#linkCheckbox').attr('checked', true);
- var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file');
- var type = $('tr').filterAttr('data-id', String(itemSource)).data('type');
- if ($('#dir').val() == '/') {
- var file = $('#dir').val() + filename;
+ if (! token) {
+ //fallback to pre token link
+ var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file');
+ var type = $('tr').filterAttr('data-id', String(itemSource)).data('type');
+ if ($('#dir').val() == '/') {
+ var file = $('#dir').val() + filename;
+ } else {
+ var file = $('#dir').val() + '/' + filename;
+ }
+ file = '/'+OC.currentUser+'/files'+file;
+ var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file);
} else {
- var file = $('#dir').val() + '/' + filename;
+ //TODO add path param when showing a link to file in a subfolder of a public link share
+ var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&t='+token;
}
- file = '/'+OC.currentUser+'/files'+file;
- var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file);
$('#linkText').val(link);
$('#linkText').show('blind');
$('#showPassword').show();
@@ -480,8 +486,8 @@ $(document).ready(function() {
var itemSource = $('#dropdown').data('item-source');
if (this.checked) {
// Create a link
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function() {
- OC.Share.showLink(itemSource);
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function(data) {
+ OC.Share.showLink(data.token, null, itemSource);
OC.Share.updateIcon(itemType, itemSource);
});
} else {