diff --git a/js/documents.js b/js/documents.js index e7900b18..382ed91b 100644 --- a/js/documents.js +++ b/js/documents.js @@ -128,9 +128,189 @@ var documentsMain = { $('#revViewerContainer').prepend($('
')); } - var ocurl = documentsMain._generateDocKey(fileId); // WOPISrc - URL that loolwsd will access (ie. pointing to ownCloud) - var wopiurl = window.location.protocol + '//' + window.location.host + ocurl; + var wopiurl = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: fileId}); + var wopisrc = encodeURIComponent(wopiurl); + + // urlsrc - the URL from discovery xml that we access for the particular + // document; we add various parameters to that. + // The discovery is available at + // https://:9980/hosting/discovery + var urlsrc = documentsMain.urlsrc + + "WOPISrc=" + wopisrc + + "&title=" + encodeURIComponent(title) + + "&lang=" + OC.getLocale().replace('_', '-') + // loleaflet expects a BCP47 language tag syntax + "&permission=readonly"; + + // access_token - must be passed via a form post + var access_token = encodeURIComponent(documentsMain.token); + + // form to post the access token for WOPISrc + var form = '
' + + '
'; + + // iframe that contains the Collabora Online Viewer + var frame = '