Class: DocManager

DocManager Class

Namespace

ITHit.WebDAV.Client

This class provides methods for opening documents for editing directly from server and saving back to server without download and upload steps. This includes editing Microsoft Office documents as well as any other file types and works on Windows, Mac OS X and Linux.

Methods

staticITHit.WebDAV.Client.DocManager.DavProtocolEditDocument(sDocumentUrls, sMountUrl, errorCallback, reserved, sSearchIn, sCookieNames, sLoginUrl, sCommand)

Opens document for editing using davX: protocol and prompts to install the protocol it if not found.

The following functionality is supported in v3 Beta and later only:

This function supports both challenge-response authentication (Basic, Digest, NTLM, Kerberos) and cookies authentication. If 'None' is specified in the sSearchIn parameter the challenge-response authentication is used, otherwise cookies authentication is used.

Name Type Description
sDocumentUrls string Coma separated list of document URLs to be opened for editing from server. All documents must be located under the same mount URL (specified in sMountUrl parameter). Must be a full URL(s) including the domain name.
sMountUrl string optional URL to mount file system to before opening the folder. Usually this is your WebDAV server root folder. If this perameter is not specified file system will be mounted to the folder in which document is located.
errorCallback function optional Function to call if document opening failed. Typically you will request the protocol installation in this callback. If not specified a default message offering protocol installation will be displayed.
reserved string optional Reserved for future use.
sSearchIn string optional v3 Beta and later only. Coma separated list of web browsers to search and copy permanent cookies from. Supported options are:
  • 'Current' - Copies cookies from web browser in which this script is running.
  • 'None' - do not search or copy any cookies.
  • 'All' - search all installed web browsers for cookies specified in 'sCookieNames' parameter.
'All' can be specified only if sCookieNames parameter is specified. Default is 'None'.
sCookieNames string optional v3 Beta and later only. Coma separated list of cookie names to search for. If this parameter is not specified - copies all cookies from a web browser specified in SearchIn parameter. The cookie(s) specified in this parameter must be persistent (has an expiration date), the protocol app can NOT pass non-persistent cookies.
sLoginUrl string optional v3 Beta and later only. Login URL to redirect to in case any cookies specified in sCookieNames parameter are not found.
sCommand string optional v3 Beta and later only. Command to use when opening the document. Supported options are:
  • 'Edit' - edit document command.
  • 'OpenWith' - show system 'Open With' dialog to select application to be used to open a document. This option is supported on Windows and OS X only.
Default is 'Edit'.
Example
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="ITHitWebDAVClient.js" ></script>
</head>
<body>
<script type="text/javascript">
    function edit() {
        ITHit.WebDAV.Client.DocManager.DavProtocolEditDocument(
            'http://localhost:87654/folder/file.ext', // Document URL(s)
            'http://localhost:87654/',                // Mount URL
            protocolInstallMessage,                   // Function to call if protocol app is not installed
            null,                                     // Reserved
            'Current',                                // Which browser to copy cookies from: 'Current', 'All', 'None'
            '.AspNet.ApplicationCookie',              // Cookie(s) to copy.
            '/Account/Login',                         // URL to navigate to if any cookie from the list is not found.
            'Edit'                                    // Command to execute: 'Edit', 'OpenWith'
        );
    }
    
    function protocolInstallMessage(message) {
        var installerFilePath = "/Plugins/" + ITHit.WebDAV.Client.DocManager.GetInstallFileName();

        if (confirm("Opening this type of file requires a protocol installation. Select OK to download the protocol installer.")){
            window.open(installerFilePath);
        }
    }
</script>
<input type="button" value="Edit Document" onclick="edit()" />
</body>
</html>

staticITHit.WebDAV.Client.DocManager.EditDocument(sDocumentUrl, sMountUrl, errorCallback)

Opens document for editing. In case of Microsoft Office documents, it will try to use Microsoft Office protocols first. If Microsoft Office protocols are not found it will use davX: protocol and prompt to install it if not found.

This function supports only challenge-response authentication (Basic, Digest, NTLM, Kerberos). You can also use it to open MS Office documents from servers with MS-OFBA authentication.

This function does NOT support cookies authentication. If your server is using cookies authentication use the DavProtocolEditDocument() function instead.

Name Type Description
sDocumentUrl string URL of the document to open for editing from server. Must be a full URL including the domain name. Unlike DavProtocolEditDocument() function, this function supports only one document URL in this parameter.
sMountUrl string optional URL to mount file system to before opening the folder. Usually this is your WebDAV server root folder. If this perameter is not specified file system will be mounted to the folder in which document is located.
errorCallback function optional Function to call if document opening failed. Typically you will request the protocol installation in this callback. If not specified a default message offering protocol installation will be displayed.
Example
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="ITHitWebDAVClient.js" ></script>
</head>
<body>
<script type="text/javascript">
    function edit() {
        ITHit.WebDAV.Client.DocManager.EditDocument("http://localhost:87654/folder/file.ext", "http://localhost:87654/", protocolInstallMessage);
    }
    
    function protocolInstallMessage(message) {
        var installerFilePath = "/Plugins/" + ITHit.WebDAV.Client.DocManager.GetInstallFileName();

        if (confirm("Opening this type of file requires a protocol installation. Select OK to download the protocol installer.")){
            window.open(installerFilePath);
        }
    }
</script>
<input type="button" value="Edit Document" onclick="edit()" />
</body>
</html>

staticITHit.WebDAV.Client.DocManager.GetInstallFileName(){string}

Gets file name of the protocol installer depending on OS.
Returns:
string File name of the protocol installer.

staticITHit.WebDAV.Client.DocManager.IsMicrosoftOfficeDocument(sDocumentUrl){boolean}

Extracts extension and returns true if URL points to Microsoft Office Document.
Name Type Description
sDocumentUrl string URL of the document.
Returns:
boolean True if URL points to Microsoft Office Document.

staticITHit.WebDAV.Client.DocManager.MicrosoftOfficeEditDocument(sDocumentUrl, errorCallback)

Opens Microsoft Office document using protocol. This method does not offer protocol installation if protocol is not found. Microsoft Office must be installed on a client machine.
Name Type Description
sDocumentUrl string URL of the document to edit. This must be a Microsoft Office document. Must be a full URL including the domain name.
errorCallback function optional Function to call if document opening failed.

staticITHit.WebDAV.Client.DocManager.OpenFolderInOsFileManager(sFolderUrl, sMountUrl, errorCallback, reserved, sSearchIn, sCookieNames, sLoginUrl)

Mounts folder in file system and opens it in default OS file manger. Requests protocol installation if folder opening protocol is not installed.

The following functionality is supported in v3 Beta and later only:

This function supports both challenge-response authentication (Basic, Digest, NTLM, Kerberos) and cookies authentication. If 'None' is specified in the sSearchIn parameter the challenge-response authentication is used, otherwise cookies authentication is used.

Name Type Description
sFolderUrl string URL of the folder to open in OS file manager. Must be a full URL including the domain name.
sMountUrl string optional URL to mount file system to before opening the folder. Usually this is your WebDAV server root folder. If this perameter is not specified file system will be mounted to the folder in which document is located.
errorCallback function optional Function to call if file manager opening has failed. Typically you will request the protocol installation in this callback. If not specified a default message offering protocol installation will be displayed.
reserved string optional Reserved for future use.
sSearchIn string optional v3 Beta and later only. Coma separated list of web browsers to search and copy permanent cookies from. Allowed values are:
  • 'Current' - Copies cookies from web browser in which this script is running.
  • 'None' - do not search or copy any cookies.
  • 'All' - search all installed web browsers for cookies specified in 'sCookieNames' parameter.
'All' can be specified only if sCookieNames parameter is specified. Default is 'None'.
sCookieNames string optional v3 Beta and later only. Coma separated list of cookie names to search for. If this parameter is not specified - copies all cookies from a web browser specified in SearchIn parameter. The cookie(s) specified in this parameter must be persistent (has an expiration date), the protocol app can NOT pass non-persistent cookies.
sLoginUrl string optional v3 Beta and later only. Login URL to redirect to in case any cookies specified in sCookieNames parameter are not found.