@ -5,6 +5,7 @@ var documentsMain = {
_members : [ ] ,
_members : [ ] ,
isEditormode : false ,
isEditormode : false ,
useUnstable : false ,
useUnstable : false ,
isGuest : false ,
UI : {
UI : {
/* Overlay HTML */
/* Overlay HTML */
@ -89,10 +90,14 @@ var documentsMain = {
"use strict" ;
"use strict" ;
documentsMain . UI . init ( ) ;
documentsMain . UI . init ( ) ;
if ( ! OC . currentUser ) {
documentsMain . isGuest = true ;
var fileId = $ ( "[name='document']" ) . val ( ) ;
} else {
// Does anything indicate that we need to autostart a session?
// Does anything indicate that we need to autostart a session?
var fileId = parent . location . hash . replace ( /\W*/g , '' )
var fileId = parent . location . hash . replace ( /\W*/g , '' ) ;
|| $ ( "[name='document']" ) . val ( )
}
;
if ( $ ( "[name='document']" ) . val ( ) ) {
if ( $ ( "[name='document']" ) . val ( ) ) {
// !Login page mess wih WebODF toolbars
// !Login page mess wih WebODF toolbars
@ -138,7 +143,6 @@ var documentsMain = {
initSession : function ( response ) {
initSession : function ( response ) {
"use strict" ;
"use strict" ;
if ( ! response || ! response . es _id || ! response . status || response . status === 'error' ) {
if ( ! response || ! response . es _id || ! response . status || response . status === 'error' ) {
OC . Notification . show ( t ( 'documents' , 'Failed to load this document. Please check if it can be opened with an external odt editor. This might also mean it has been unshared or deleted recently.' ) ) ;
OC . Notification . show ( t ( 'documents' , 'Failed to load this document. Please check if it can be opened with an external odt editor. This might also mean it has been unshared or deleted recently.' ) ) ;
documentsMain . prepareGrid ( ) ;
documentsMain . prepareGrid ( ) ;
@ -175,8 +179,14 @@ var documentsMain = {
joinSession : function ( fileId ) {
joinSession : function ( fileId ) {
console . log ( 'joining session ' + fileId ) ;
console . log ( 'joining session ' + fileId ) ;
var url ;
if ( documentsMain . isGuest ) {
url = OC . Router . generate ( 'documents_session_joinasguest' ) + '/' + fileId
} else {
url = OC . Router . generate ( 'documents_session_joinasuser' ) + '/' + fileId
}
$ . post (
$ . post (
OC . Router . generate ( 'documents_session_join' ) + '/' + fileId ,
url,
{ } ,
{ } ,
documentsMain . initSession
documentsMain . initSession
) ;
) ;
@ -230,7 +240,12 @@ var documentsMain = {
// successfull shutdown - all is good.
// successfull shutdown - all is good.
// TODO: proper session leaving call to server, either by webodfServerInstance or custom
// TODO: proper session leaving call to server, either by webodfServerInstance or custom
// documentsMain.webodfServerInstance.leaveSession(sessionId, memberId, function() {
// documentsMain.webodfServerInstance.leaveSession(sessionId, memberId, function() {
if ( documentsMain . isGuest ) {
$ ( document . body ) . attr ( 'id' , 'body-login' ) ;
$ ( 'header,footer' ) . show ( ) ;
}
documentsMain . webodfEditorInstance . destroy ( documentsMain . UI . hideEditor ) ;
documentsMain . webodfEditorInstance . destroy ( documentsMain . UI . hideEditor ) ;
// });
// });
} ) ;
} ) ;
} ,
} ,
@ -240,7 +255,7 @@ var documentsMain = {
} ,
} ,
show : function ( ) {
show : function ( ) {
if ( ! OC . currentUser ) {
if ( documentsMain . isGuest ) {
return ;
return ;
}
}