Start session first

This commit is contained in:
Victor Dubiniuk 2013-08-07 02:35:46 +03:00 committed by Tobias Hintze
parent 74ef36fdd6
commit 0902ee57b3
2 changed files with 19 additions and 8 deletions

View File

@ -97,7 +97,8 @@ var webodfEditor = (function () {
serverFactory = new ServerFactory(); serverFactory = new ServerFactory();
server = serverFactory.createServer({url: "./office/ajax/otpoll.php"}); server = serverFactory.createServer({url: "./office/ajax/otpoll.php"});
server.getGenesisUrl = function(sid) { server.getGenesisUrl = function(sid) {
return "/owncloud/index.php/apps/files/download/welcome.odt"; // what a dirty hack :)
return window.officeMain.doclocation;
}; };
server.connect(8000, callback); server.connect(8000, callback);
}); });

View File

@ -19,14 +19,12 @@ var officeMain = {
}); });
}); });
}, },
onView: function(dir, file) { onView: function(response) {
"use strict"; "use strict";
if (officeMain.initialized === undefined) {
alert("WebODF Editor not yet initialized...");
return;
}
OC.addScript('office', 'editor/boot_editor').done(function() { OC.addScript('office', 'editor/boot_editor').done(function() {
var doclocation = fileDownloadPath(dir, file); var doclocation = response.genesis_url;
officeMain.doclocation = doclocation;
// fade out files menu and add odf menu // fade out files menu and add odf menu
$('.documentslist').fadeOut('slow').promise().done(function() { $('.documentslist').fadeOut('slow').promise().done(function() {
@ -84,6 +82,18 @@ var officeMain = {
}); });
}); });
}, },
registerSession : function(dir, file){
"use strict";
if (officeMain.initialized === undefined) {
alert("WebODF Editor not yet initialized...");
return;
}
var filepath = fileDownloadPath(dir, file);
$.post(OC.filePath('office', 'ajax', 'session.php'),
{ 'genesis' : filepath },
officeMain.onView
);
},
onClose: function() { onClose: function() {
"use strict"; "use strict";
var bodyelement = document.getElementsByTagName('body')[0]; var bodyelement = document.getElementsByTagName('body')[0];
@ -104,7 +114,7 @@ var officeMain = {
$(document).ready(function() { $(document).ready(function() {
$('.documentslist tr').click(function(event) { $('.documentslist tr').click(function(event) {
event.preventDefault(); event.preventDefault();
officeMain.onView('', $(this).attr('data-file')); officeMain.registerSession('', $(this).attr('data-file'));
}); });
$('#odf_close').live('click', officeMain.onClose); $('#odf_close').live('click', officeMain.onClose);
OC.addScript('office', 'dojo-amalgamation', officeMain.onStartup); OC.addScript('office', 'dojo-amalgamation', officeMain.onStartup);