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

static ITHit.WebDAV.Client.DocManager.MsOfficeEditExtensions :ITHit.WebDAV.Client.MsOfficeEditExtensions

MsOfficeEditExtensions
Collection of extensions of files which are opened with Microsoft Office.
Examples

static ITHit.WebDAV.Client.DocManager.ProtocolTimeoutMs :number

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

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

DavProtocolEditDocument

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.<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>

static ITHit.WebDAV.Client.DocManager.EditDocument(sDocumentUrl, sMountUrl, errorCallback)

EditDocument

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>

static ITHit.WebDAV.Client.DocManager.GetProtocolInstallFileNames() → {Array.<string>}

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

static ITHit.WebDAV.Client.DocManager.GetProtocolInstallUri() → {string}

GetProtocolInstallUri
Gets Uri of the protocol installer depending on OS.
Returns:
string Uri of the protocol installer.

static ITHit.WebDAV.Client.DocManager.GSuiteEditDocument(sDocumentUrl, oContainerDomElement, errorCallback)

GSuiteEditDocument

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.

static ITHit.WebDAV.Client.DocManager.GSuitePreviewDocument(sDocumentUrl, oContainerDomElement, errorCallback)

GSuitePreviewDocument

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.

static ITHit.WebDAV.Client.DocManager.IsDavProtocolSupported() → {boolean}

IsDavProtocolSupported
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.

static ITHit.WebDAV.Client.DocManager.IsGSuiteDocument(sDocumentUrl) → {boolean}

IsGSuiteDocument
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.

static ITHit.WebDAV.Client.DocManager.IsMicrosoftOfficeDocument(sDocumentUrl) → {boolean}

IsMicrosoftOfficeDocument
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.

static ITHit.WebDAV.Client.DocManager.MicrosoftOfficeEditDocument(sDocumentUrl)

MicrosoftOfficeEditDocument
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.

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

OpenFolderInOsFileManager

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.