Skip to content

Instantly share code, notes, and snippets.

@odoe
Created July 20, 2011 16:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odoe/1095296 to your computer and use it in GitHub Desktop.
Save odoe/1095296 to your computer and use it in GitHub Desktop.
JavaScript method to open Hummingbird/OpenText eDocs files via Desktop Explorer
// This script is used to open files and folders
// in Hummingbird/OpenText eDocs Document Management System.
// Not the most elegant method, but the native API does not seem
// recognize how to open folders in the DMS, so I had to get old
// school and use ActiveX. Of course, this script will only work
// with Internet Explorer, so you may have to adjust security settings.
// Note: I think I can use the API to define a launch method, such as ACROBAT,
// MS WORD or even FOLDER, but I don't know how to use the API to determine which method
// to use, so ActiveX tom-foolery it is.
var currtime = Math.abs(new Date().getTime());
function openDMS(docid, tmppath){
// use a timestamp to keep .DRF files unique to this session.
var docname = tmppath + currtime.toString() + ".DRF";
createReference(docname, docid);
}
function createReference(docname, docid) {
try {
// create a temporary .DRF file
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CreateTextFile(docname, true, true);
var f = fso.GetFile(docname);
var ts = f.OpenAsTextStream(2, -2);
ts.WriteLine("Document;DMS;" + docid + ";R");
ts.Close();
delete fso;
delete f;
delete ts;
openDocument(docname);
} catch(e) {
alert(e.message)
}
}
function openDocument(doc) {
window.onunload = function () {
// when the page is closed, delete the temporary DRF file.
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.DeleteFile(doc);
delete fso;
}
// open the DRF via the Shell
var oShell = new ActiveXObject("WScript.Shell");
oShell.Run(doc + " open");
delete oShell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment