Adapt to changes in loolwsd - pass only access_token via form post.
Also limit the amount of stuff that actually needs to be passed, and add comments.
This commit is contained in:
parent
2508e550fc
commit
f2974bd618
@ -154,7 +154,6 @@ var documentsMain = {
|
|||||||
ready :false,
|
ready :false,
|
||||||
fileName: null,
|
fileName: null,
|
||||||
baseName: null,
|
baseName: null,
|
||||||
url: null,
|
|
||||||
canShare : false,
|
canShare : false,
|
||||||
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
|
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
|
||||||
|
|
||||||
@ -191,23 +190,31 @@ var documentsMain = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlsrc = $('li[data-id='+ documentsMain.fileId +']>a').attr('urlsrc');
|
// WOPISrc - URL that loolwsd will access (ie. pointing to ownCloud)
|
||||||
var token = encodeURIComponent(result.token);
|
var wopiurl = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: documentsMain.fileId});
|
||||||
var url = OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: documentsMain.fileId});
|
var wopisrc = encodeURIComponent(wopiurl);
|
||||||
documentsMain.url = window.location.protocol + '//' + window.location.host + url;
|
|
||||||
|
|
||||||
var wopisrc = encodeURIComponent(documentsMain.url);
|
// urlsrc - the URL from discovery.xml that we access for the particular
|
||||||
|
// document; we add various parameters to that
|
||||||
|
var urlsrc = $('li[data-id='+ documentsMain.fileId +']>a').attr('urlsrc') +
|
||||||
|
"WOPISrc=" + wopisrc +
|
||||||
|
"&title=" + encodeURIComponent(title) +
|
||||||
|
"&closebutton=1";
|
||||||
|
|
||||||
|
// access_token - must be passed via a form post
|
||||||
|
var access_token = encodeURIComponent(result.token);
|
||||||
|
|
||||||
|
// form to post the access token for WOPISrc
|
||||||
var form = '<form id="loleafletform" name="loleafletform" target="loleafletframe" action="' + urlsrc + '" method="post">' +
|
var form = '<form id="loleafletform" name="loleafletform" target="loleafletframe" action="' + urlsrc + '" method="post">' +
|
||||||
'<input name="WOPISrc" value="' + wopisrc + '" type="hidden"/>' +
|
'<input name="access_token" value="' + access_token + '" type="hidden"/></form>';
|
||||||
'<input name="title" value="' + title + '" type="hidden"/>' +
|
|
||||||
'<input name="permission" value="view" type="hidden"/>' +
|
// iframe that contains the Collabora Online
|
||||||
'<input name="timestamp" value="" type="hidden"/>' +
|
|
||||||
'<input name="closebutton" value="1" type="hidden"/>' +
|
|
||||||
'<input name="access_token" value="' + token + '" type="hidden"/></form>';
|
|
||||||
var frame = '<iframe id="loleafletframe" name= "loleafletframe" allowfullscreen style="width:100%;height:100%;position:absolute;"/>';
|
var frame = '<iframe id="loleafletframe" name= "loleafletframe" allowfullscreen style="width:100%;height:100%;position:absolute;"/>';
|
||||||
|
|
||||||
$('#mainContainer').append(form);
|
$('#mainContainer').append(form);
|
||||||
$('#mainContainer').append(frame);
|
$('#mainContainer').append(frame);
|
||||||
|
|
||||||
|
// handler for the 'Close' button - we have enabled it via closebutton=1
|
||||||
$('#loleafletframe').load(function(){
|
$('#loleafletframe').load(function(){
|
||||||
documentsMain.overlay.documentOverlay('hide');
|
documentsMain.overlay.documentOverlay('hide');
|
||||||
window.addEventListener('message', function(e){
|
window.addEventListener('message', function(e){
|
||||||
@ -217,6 +224,7 @@ var documentsMain = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// submit that
|
||||||
$('#loleafletform').submit();
|
$('#loleafletform').submit();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user