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.

Members

staticITHit.WebDAV.Client.DocManager.MsOfficeEditExtensionsITHit.WebDAV.Client.MsOfficeEditExtensions

Collection of extensions of files which are opened with Microsoft Office.
Example
var sDocumentUrl = 'http://localhost:87654/myfile.rtf';
var sMountPoint = 'http://localhost:87654/';

ITHit.WebDAV.Client.DocManager.MsOfficeEditExtensions.Word.push("rtf");

// Now .rtf files are opened with Microsoft Word.
ITHit.WebDAV.Client.DocManager.EditDocument(sDocumentUrl, sMountPoint, fProtocolInstallCallback);

// or call
// ITHit.WebDAV.Client.DocManager.MicrosoftOfficeEditDocument(sDocumentUrl, fProtocolInstallCallback);

staticITHit.WebDAV.Client.DocManager.ProtocolTimeoutMsITHit.WebDAV.Client.ProtocolTimeoutMs

Timeout in milliseconds to call error callback if application associated with the extension did not start. Default is 3000ms. Used in Chrome / Internet Explorer / Safari if protocol application is not installed AND web browser protocol warning dialog is disabled AND EditDocument() / MicrosoftOfficeEditDocument() function is called (in case of Basic/Digest/Anonymous authentication). NOT used in Firefox / Edge OR if DavProtocolEditDocument() is called OR if web browser protocol warning dialog is enabled.

Methods

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

Opens document for editing or printing 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 Array 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. Indicates cookies authentication. Supported options are:
  • 'Current' - Copies cookies from web browser in which this script is running.
  • 'None' - do not search or copy any cookies.
Default is 'None'.
sCookieNames string optional v3 Beta and later only. Coma separated list of cookie names to search for. Microsoft Office requires persistent cookie (with expiration date), it does not support session 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:
  • null - Chooses an appropriate verb to open a document in the associated application.
  • 'Edit' - Opens a document for editing.
  • 'Open' - Opens a document in the associated application. Not applicable for some applications.
  • 'OpenWith' - Show system 'Open With' dialog to select application to be used to open a document. This option is supported on Windows only.
  • 'Print' - Prints a document. The application that prints a document is running in a minimized state and automatically closes if printing is successful. If printing fails, the application remains open. To print multiple documents, pass a list of documents as a first parameter. This option is supported on Windows only.
Default is null.
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
            errorCallback,                            // Function to call if protocol app is not installed
            null,                                     // Reserved
            'Current',                                // Which browser to copy cookies from: 'Current', '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', 'Print'
        );
    }

    function errorCallback() {
        var installerFilePath = "/Plugins/" + ITHit.WebDAV.Client.DocManager.GetProtocolInstallFileNames()[0];

        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. This callback is executed for non-Microsoft Office documents only. 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/", errorCallback);
    }

    function errorCallback() {
        var installerFilePath = "/Plugins/" + ITHit.WebDAV.Client.DocManager.GetProtocolInstallFileNames()[0];

        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.GetProtocolInstallFileNames(){Array}

Gets file names of the protocol installer depending on OS.
Returns:
Array An array with file names of the protocol installer.

staticITHit.WebDAV.Client.DocManager.GSuiteEditDocument(sDocumentUrl, oContainerDomElement, errorCallback)

Edit MS Office document with G Suite Online Editor.

Name Type Description
sDocumentUrl string URL of the document to open for editing from server. Must be a full URL including the domain name.
oContainerDomElement DOM HTML DOM element where the G Suite online editor will be loaded. If this parameter is omitted or null is passed the editor will be created in a new tab/window.
errorCallback function optional Function to call if document opening failed.

staticITHit.WebDAV.Client.DocManager.GSuitePreviewDocument(sDocumentUrl, oContainerDomElement, errorCallback)

Preview MS Office document with G Suite Online Tool.

Name Type Description
sDocumentUrl string URL of the document to open for preview. Must be a full URL including the domain name.
oContainerDomElement DOM HTML DOM element where the G Suite preview will be loaded. If this parameter is omitted or null is passed the preview will be created in a new tab/window.
errorCallback function optional Function to call if document opening failed.

staticITHit.WebDAV.Client.DocManager.IsDavProtocolSupported(){boolean}

Returns true if protocol application installer is supported for the OS on which this function is called, false - otherwise.
Returns:
boolean True if protocol application installer is supported for the OS on which this function is called.

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

Extracts extension and returns true if the document can be edited in G Suite editor or document preview generated via G Suite.
Name Type Description
sDocumentUrl string URL of the document.
Returns:
boolean True if URL points to GSuite Editor.

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)

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.

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 parameter 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. Indicates cookies authentication. Allowed values are:
  • 'Current' - Copies cookies from web browser in which this script is running.
  • 'None' - do not search or copy any cookies.
Default is 'None'.
sCookieNames string optional v3 Beta and later only. Coma separated list of cookie names to search for. Microsoft Office requires persistent cookie (with expiration date), it does not support session 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.