home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-08-08 | 81.5 KB | 3,169 lines |
-
- var ctfFailure = 0;
- var ctfReloaded = -1;
- var ctfSuccess = 1;
-
-
- var goBase = null;
- var goTreeXSL = null;
- var goListXSL = null;
- var gsDefPath = "C:\\Co-Citer.c-c";
- var gsCurrentPath = "";
-
- //var imgEdit = null;
- //var imgFragmentExpand = null;
- //var imgFramentDelete = null;
-
- var goCurrentFolderUIN = -1;
- var gnSortBy = -1;
- var gnSortDirection = -1;
- var gbFilterByFolder = true;
- var goVisibilityOptions = null;
-
- //var arButtonSortNames = new Array("ctsName", "ctsDate", "ctsText", "ctsComment", "ctsURL");
- var arAttributeNames = new Array("@Name", "@CreationDate", "@Text", "@Comment", "@BaseURL");
- //var arButtonDirNames = new Array( "ctsAscending", "ctsDescending");
- var arDirectionSigns = new Array( "+", "-");
-
- L_Cogitum_Citates = " - Cogitum Co-Citer";
-
- L_Unable_To_Create = "Script was unable to initialize XML control.";
- L_Failed_To_Load_File = "Failed to load file.";
- L_Confirm_Fragment_Deletion = "Are you sure that you want to delete this citation?";
- L_Confirm_Multiple_Fragments_Deletion = "Are you sure that you want to delete selected citations?";
- L_Confirm_Folder_Deletion = "Are you sure that you want to delete this folder?\n\nThis will also delete all citations residing in it.";
- L_Undetermined_Sort = "Undetermined sort criteria.";
- L_Fragment_Not_Found = "Citation not found.";
- L_Folder_Not_Found = "Folder not found.";
- L_Dont_Delete_Root = "Root folder cannot be deleted.";
- L_Dont_Delete_Unsorted = "This is a system folder, which means that it cannot be deleted.";
- L_NODE_ALREADY_EXISTS = "Folder with the same name already exists.\n\nPlease select another name.";
- L_Database_Cannot_Be_Moved = "Currently selected folder is the root folder of the database.\n\nIt cannot be moved.";
- L_SystemFolder_Cannot_Be_Moved = "Currently selected folder is a system folder, which means that it cannot be moved.";
-
- L_Outside_Modification = "The file has been modified by another program.\nIt will be reloaded.";
- L_NO_FRAGMENTS_HTML = "<DIV Class='NoCitates'> There are no citations in this folder.</DIV>";
- L_LOADING_HTML = "<DIV Class='NoCitates'> Loading. Please wait...</DIV>";
-
- L_Failed_To_Lock_File = "Failed to lock the file.";
- L_FAILED_TO_ADD_NODE = "Failed to add folder to database";
-
- L_FailedToGenerateTempFile = "Failed to create temporary file.";
-
- L_Transform_Failed = "Transform failed.\n\nLooks like something is wrong.";
- L_Unable_To_Save_A_File = "Failed to write to a file:\n";
- L_HTML_FAIL_DIAG = "\n\nEither a file could not be created or text cannot be saved in it.";
-
- L_NOTHING_TO_EXPORT = "No exportable fields are visible.\n\nTurn one of them on and try again.";
- L_NOTHING_TO_EXPORT_TO_HTML = "There are no citations to export.\n\nNeither current folder, nor its subfolders contain citations.";
-
- L_OP_FAILED = "Operation failed with the following error:\n\n";
- L_BUSY = "Program is busy servicing a dialog.\n\nClose dialogs you opened and try again.";
-
-
- /*
- function fnInitialize() {
-
- try {
- var qq = new String(cxbiRoot);
- }
- catch (err) {
- alert(">" + err + "<" );
- //if (err == "[object Error]") {
- if (confirm("Reload?")) {
- window.location.reload();
- return;
-
- }
- //};
- };
-
- fnLoadFile();
- };
- */
-
- function fnCreateXMLctl() {
- var someBase = null;
-
- try {
- someBase = new ActiveXObject("Microsoft.XMLDOM");
- }
- catch (err) {
- someBase = null;
- };
- if (someBase == null) {
- return null;
- };
- someBase.async = false;
- return someBase;
- };
-
- function fnLoadFile(sPath, bDoNotAddToRecentFilesList) {
- var ctlTree = fnGetTreeHolder();
- var ctlCitates = fnGetCitatesHolder();
-
- if (goVisibilityOptions == null) {
- goVisibilityOptions = new Object();
- goVisibilityOptions.bShowFieldNames = ! fnGetSetting(ccsVHideFieldNames , 0, true);
- goVisibilityOptions.bShowTitle = fnGetSetting(ccsVShowTitle , 0, true);
- goVisibilityOptions.bShowDate = fnGetSetting(ccsVShowDate , 0, true);
- goVisibilityOptions.bShowText = fnGetSetting(ccsVShowText , 0, true);
- goVisibilityOptions.bShowComment= fnGetSetting(ccsVShowComment , 0, true);
- goVisibilityOptions.bShowURL = fnGetSetting(ccsVShowURL , 0, true);
-
- if ( ( ! goVisibilityOptions.bShowTitle ) &&
- ( ! goVisibilityOptions.bShowDate ) &&
- ( ! goVisibilityOptions.bShowText ) &&
- ( ! goVisibilityOptions.bShowComment ) &&
- ( ! goVisibilityOptions.bShowURL ) ) {
-
- goVisibilityOptions.bShowTitle =
- goVisibilityOptions.bShowDate =
- goVisibilityOptions.bShowText =
- goVisibilityOptions.bShowComment =
- goVisibilityOptions.bShowURL = true;
- };
- };
-
- if (goBase == null) {
- goBase = fnCreateXMLctl();
- goBase.loadXML("");
- }
- else {
- goBase.loadXML("");
- };
-
- ctlTree.innerHTML = "";
- ctlCitates.innerHTML = "";
-
- if (goBase == null) {
- alert(L_Unable_To_Create);
- return;
- };
-
- if (sPath == null) {
- sPath = gsDefPath;
- };
-
- gsCurrentPath = sPath;
-
- try {
- fnGetHelperObject().LockFile(sPath);
- }
- catch (err) {
- alert(L_Failed_To_Lock_File);
- return;
- };
-
- try {
-
-
- if ( ! fnCheckedInitializeFile(goBase, sPath) ) {
- throw (L_Failed_To_Load_File);
- };
-
- if ( ! fnCheckVersion(goBase) ) {
- if ( ! fnConfirmConversion(goBase) ) {
- throw "";
- }
- else {
- if ( ! fnPerformConversion(goBase) ) {
- throw "";
- };
- };
- };
-
- if (bDoNotAddToRecentFilesList == null)
- bDoNotAddToRecentFilesList = false;
-
- if ( ! bDoNotAddToRecentFilesList ) {
- fnSetSetting(ccsStLastFile, sPath);
-
- fnAddHistorySetting(ccsStPreviousFile, sPath);
- };
-
-
- //Ensure that all CogTracker:ctNODE have their UINs
- var oNodesList = goBase.selectNodes("/root/CogTracker:ctDATABASE|//CogTracker:ctNODE|//CogTracker:ctFRAGMENT");
- for (i = 0; i < oNodesList.length; i++) {
- fnGetElementUIN(goBase, oNodesList.item(i));
- };
-
- if (goTreeXSL == null) {
- goTreeXSL = fnCreateXMLctl();
- if (goTreeXSL == null) {
- throw(L_Unable_To_Create);
- };
-
- //goTreeXSL.load("ctTree.xsl");
- goTreeXSL.load(top.document.frames.ctToolBars.document.all.ctTree.XMLDocument);
-
- }
-
- if (goListXSL == null) {
- goListXSL = fnCreateXMLctl();
- if (goListXSL == null) {
- throw(L_Unable_To_Create);
- };
-
- //goListXSL.load("ctList.xsl");
- goListXSL.load(top.document.frames.ctToolBars.document.all.ctList.XMLDocument);
- }
-
-
-
- var ctDATABASE = goBase.selectSingleNode("/root/CogTracker:ctDATABASE");
-
- if (goCurrentFolderUIN == -1) {
- goCurrentFolderUIN = parseInt(ctDATABASE.getAttribute(cxbiAttCurrentNode));
- if (isNaN(goCurrentFolderUIN)) {
- goCurrentFolderUIN = ctDATABASE.getAttribute(cxbiAttUIN);
- ctDATABASE.setAttribute(cxbiAttCurrentNode, goCurrentFolderUIN);
- };
- }
- else {
- ctDATABASE.setAttribute(cxbiAttCurrentNode, goCurrentFolderUIN);
- };
- var ctCurFolder = goBase.selectSingleNode("//*[@UIN='" + goCurrentFolderUIN + "']");
- if (ctCurFolder == null) {
- goCurrentFolderUIN = ctDATABASE.getAttribute(cxbiAttUIN);
- ctDATABASE.setAttribute(cxbiAttCurrentNode, goCurrentFolderUIN);
-
- };
-
- var szHTML = goBase.transformNode(goTreeXSL);
- if (szHTML == null || szHTML == "") {
- throw(L_Transform_Failed);
- };
-
-
- //ctlTree.insertAdjacentHTML("afterBegin", szHTML);
- ctlTree.innerHTML = szHTML;
- //ctlTree.insertAdjacentHTML("afterBegin","<OPTION>");
-
- var sTitle = "";
- if (sPath != null && sPath != "") {
- sTitle = fnGetHelperObject().AbbreviateFileName(sPath);
- };
-
- if (sTitle != null && sTitle != "") {
- document.title = sTitle + L_Cogitum_Citates;
- }
- else {
- document.title = L_Cogitum_Citates;
- };
-
- fnSortBy(-1, -1, //arButtonSortNames[gnSortBy], gnSortDirection,
- false);
-
-
- // no call here -- the event will be fired after tree initialization
- //OnFolderChanged();
-
- fnGetHelperObject().UnlockFile(sPath);
- }
- catch(err) {
- fnGetHelperObject().UnlockFile(sPath);
-
- if (err != null && err != "") {
- if (err.description != null) {
- alert(L_OP_FAILED + err.description);
- }
- else {
- alert(err);
- };
- };
- }
- finally {
- };
-
- //NOTE: This code will be executed even when error occurs
-
- };
-
- function fnGetBrowserObject() {
- //return top.frames.ctToolBars.ctlBrowser;
- return go_ctlBrowser;
- };
-
- function fnOpenFile() {
- var sOldFileName = gsCurrentPath;
- var OLDCurrentFolderUIN = goCurrentFolderUIN;
- var ctlBrowser = fnGetBrowserObject();
-
-
- top.fnGetMainToolbar().all.OpenButton.ct_unstick();
-
- if ( fnBrowseForFile(gsCurrentPath, L_Open_Dialog_Title) ) {
-
- var ctfResult = fnPrepareToChangeDatabase();
- if (ctfResult != ctfFailure) {
- fnSaveChangedDatabase();
- };
-
- goCurrentFolderUIN = -1;
- fnLoadFile(ctlBrowser.FileName);
- }
- else {
- ctlBrowser.FileName = sOldFileName;
- };
-
-
- };
-
- var popupTimeout = -1;
- function fnShowRecentList() {
-
- if (popupTimeout != -1) {
- window.clearTimeout(popupTimeout);
- popupTimeout = -1;
- };
-
-
- var Helper = fnGetHelperObject();
-
- var RecentFiles = fnGetHistorySettings(ccsStPreviousFile);
-
- if (RecentFiles == null || RecentFiles.length == 0) {
-
- top.fnGetMainToolbar().all.ShowPreviousFiles.ct_unstick();
- popupTimeout = window.setTimeout(fnMouseOutOfButton, 500);
-
- return;
- }
-
- Helper.PopupMenuCreate();
-
- for (var i = 0; i < RecentFiles.length; i++) {
- //Helper.PopupMenuAppendItem(RecentFiles[i],
- Helper.PopupMenuAppendPathItem(RecentFiles[i],
- i + 1, true, false);
-
- };
-
- var MenuButton = fnGetMainToolbar().all.OpenButton;
-
-
- var nLeft = 0; var nTop = 0;
-
- nLeft += MenuButton.offsetLeft + 0 +
- MenuButton.document.body.offsetLeft +
- MenuButton.document.parentWindow.screenLeft;
-
- nTop += MenuButton.offsetTop + MenuButton.offsetHeight +
- MenuButton.document.body.offsetTop +
- MenuButton.document.parentWindow.screenTop;
-
-
- var res = Helper.PopupMenuTrack(nLeft, nTop, top.oHTA.applicationName);
-
- Helper.PopupMenuDestroy();
-
- top.fnGetMainToolbar().all.ShowPreviousFiles.ct_unstick();
-
- if ((res > 0) && ( res < RecentFiles.length + 1) ) {
- //fnSaveChangedDatabase();
- var ctfResult = fnPrepareToChangeDatabase();
- if (ctfResult != ctfFailure) {
- fnSaveChangedDatabase();
- };
-
-
- goCurrentFolderUIN = -1;
- if (RecentFiles[res-1] != null && RecentFiles[res-1] != "")
- fnLoadFile(RecentFiles[res-1]);
- };
-
-
- // popupTimeout = window.setTimeout(fnMouseOutOfButton, 500);
-
- };
-
- function fnMouseOutOfButton() {
- if (popupTimeout != -1) {
- window.clearTimeout(popupTimeout);
- popupTimeout = -1;
- };
-
- top.fnGetMainToolbar().all.ShowPreviousFiles.ct_mouseout();
- top.fnGetMainToolbar().all.OpenButton.ct_mouseout();
- };
-
- var nNodes = 0;
- function OnTransformNode() {
- nNodes ++;
- fnGetCitatesHolder().innerText = nNodes.toString();
- document.recalc(true);
- window.status = nNodes.toString();
- return true;
- };
-
- var FolderChangeTimer = -1;
- var GszHTML = "";
- function fnTransferItem(some) {
- if ( some == null ) {
- some = 0;
- };
-
- window.clearTimeout(FolderChangeTimer);
- FolderChangeTimer = -1;
-
-
- var nPos = 0;
-
- for (i = 0; (i < 20) && (nPos > -1); i ++) {
- nPos = GszHTML.indexOf("<HR />", nPos + 1);
- };
-
-
- var ctlCitates = fnGetCitatesHolder();
-
- if (nPos != -1) {
- nPos += 6;
-
-
- //alert(GszHTML.slice(nPos-10, nPos));
- ctlCitates.insertAdjacentHTML("beforeEnd",
- GszHTML.slice(0, nPos));
-
- GszHTML = GszHTML.slice(nPos);
- //alert("'" + GszHTML.slice(0, 10) + "'");
-
- FolderChangeTimer =
- window.setTimeout(fnTransferItem, 200);
- }
- else {
- if (GszHTML != "") {
- ctlCitates.insertAdjacentHTML("beforeEnd",
- GszHTML);
- GszHTML = "";
- };
-
- fnHideWaitCursor();
-
- };
-
-
-
- };
-
- function OnFolderChanged(some) {
-
- var ctlCitates = fnGetCitatesHolder();
-
- if (some == null)
- some = false;
-
-
- ctlCitates.innerHTML = "";
- GszHTML = "";
- if (FolderChangeTimer != -1) {
- window.clearTimeout(FolderChangeTimer);
- FolderChangeTimer = -1;
- };
-
- if (!some)
- fnShowWaitCursor();
- nNodes = 0;
-
- if (goListXSL == null) {
- goListXSL = fnCreateXMLctl();
- if (goListXSL == null) {
- alert(L_Unable_To_Create);
-
- fnHideWaitCursor();
-
- return;
- };
-
- }
- else {
- goListXSL.loadXML("");
- };
-
- //goListXSL.load("ctList.xsl");
- goListXSL.load(top.document.frames.ctToolBars.document.all.ctList.XMLDocument);
-
- try {
- goCurrentFolderUIN = fnGetFolderTreeUIN();
- //ctlTree.all.tags("SELECT")[0].options[ctlTree.all.tags("SELECT")[0].selectedIndex].value;
- }
- catch(err) {
- goCurrentFolderUIN = -1;
- };
- var ctDATABASE = goBase.selectSingleNode("/root/CogTracker:ctDATABASE");
-
- if (goCurrentFolderUIN != -1) {
- ctDATABASE.setAttribute(cxbiAttCurrentNode, goCurrentFolderUIN);
- };
-
- if (gbFilterByFolder) {
- var oFilters = goListXSL.selectNodes("//xsl:template[@match='root']/xsl:apply-templates/@select");
- for (i = 0; i < oFilters.length; i++) {
- oFilters[i].nodeValue = ".//*[@UIN=" + goCurrentFolderUIN + "]";
- };
- }
- else {
- var oFilters = goListXSL.selectNodes("//xsl:template[@match='root']/xsl:apply-templates");
- for (i = 0; i < oFilters.length; i++) {
- oFilters[i].setAttribute("select", "//CogTracker:ctFRAGMENT");
- oFilters[i].setAttribute("order-by",
- arDirectionSigns[gnSortDirection].toString() +
- arAttributeNames[gnSortBy].toString());
- };
- };
-
- var oSorts = goListXSL.selectNodes("//xsl:apply-templates[@select='./CogTracker:ctFRAGMENT']/@order-by");
- for (i = 0; i < oSorts.length; i++) {
- oSorts[i].nodeValue = arDirectionSigns[gnSortDirection].toString() +
- arAttributeNames[gnSortBy].toString();
- };
-
-
- var ssnFieldsParent =
- goListXSL.selectSingleNode("//TABLE[@CLASS='Fragment']/TBODY");
- var ssnTitleAndDate =
- goListXSL.selectSingleNode("//TR[@CLASS='TitleAndDate']");
-
- var ssnFragmentTools = goListXSL.selectSingleNode("//NOBR[@CLASS='FragmentTools']");
- var ssnDate = goListXSL.selectSingleNode("//xsl:if[@test='@CreationDate']");
- var ssnText = goListXSL.selectSingleNode("//TR[@CLASS='Text']");
- var ssnComment = goListXSL.selectSingleNode("//TR[@CLASS='Comment']");
- var ssnBaseURL = goListXSL.selectSingleNode("//TR[@CLASS='BaseURL']");
-
-
- if ( ! goVisibilityOptions.bShowTitle ) {
- var ssnFragmentToolsHolder = null;
- if ( goVisibilityOptions.bShowText) {
- ssnFragmentToolsHolder = ssnText;
- }
- else if (goVisibilityOptions.bShowComment) {
- ssnFragmentToolsHolder = ssnComment;
- }
- else if (goVisibilityOptions.bShowURL) {
- ssnFragmentToolsHolder = ssnBaseURL;
- };
-
- if (ssnFragmentToolsHolder) {
- ssnFieldTitle = ssnFragmentToolsHolder.selectSingleNode(".//TD[@CLASS='FieldTitle']");
- ssnFieldTitle.appendChild(ssnFragmentTools.parentNode.removeChild(ssnFragmentTools));
- };
-
- ssnFieldsParent.removeChild(ssnTitleAndDate);
- }
- else if ( ! goVisibilityOptions.bShowDate ) {
- ssnDate.parentNode.removeChild(ssnDate);
- };
-
- if ( ! goVisibilityOptions.bShowText ) {
- ssnFieldsParent.removeChild(ssnText);
- };
-
- if ( ! goVisibilityOptions.bShowComment ) {
- ssnFieldsParent.removeChild(ssnComment);
- };
-
- if ( ! goVisibilityOptions.bShowURL ) {
- ssnFieldsParent.removeChild(ssnBaseURL);
- };
-
- if ( ! goVisibilityOptions.bShowFieldNames ) {
- ssnFieldsParent.parentNode.setAttribute("COLS", 2);
-
- var ssnColGroup = ssnFieldsParent.parentNode.selectSingleNode("./COLGROUP");
- ssnColGroup.removeChild(ssnColGroup.firstChild);
- ssnColGroup.lastChild.setAttribute("STYLE", "width:98%;");
-
- var allFieldTitles = ssnFieldsParent.selectNodes(
- "//TD[@CLASS='FieldTitle']");
- for (var i = 0; i < allFieldTitles.length; i ++) {
- allFieldTitles[i].parentNode.removeChild(allFieldTitles[i]);
- };
-
- };
-
- /*
- = true;
- */
-
- //goBase.ontransformnode = OnTransformNode;
-
-
- /*
- goListXSL.load("ctList.xsl");
- var ctCurFolder =
- goBase.selectSingleNode("//*[@UIN='" +
- goCurrentFolderUIN + "']");
-
- var ctFragList = ctCurFolder.selectNodes("./CogTracker:ctFRAGMENT");
- var i = 0;
- top.ctTitleBar.document.body.innerText="Loading...";
- ctlCitates.innerHTML = "";
- var startTime = new Date();
- for (i = 0; i < ctFragList.length; i++) {
- var szHTML = ctFragList.item(i).transformNode(goListXSL);
- ctlCitates.insertAdjacentHTML("beforeEnd", szHTML);
- top.ctTitleBar.document.body.innerText="Loading... " + i.toString();
- };
- var endTime = new Date();
- alert (endTime.getTime() - startTime.getTime());
- //alert("Transformed");
- return;
- */
-
- var startTime = new Date();
-
- var szHTML = goBase.transformNode(goListXSL);
- //szHTML = "";
- //goBase.ontransformnode = null;
- /*
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var a = fso.CreateTextFile("C:\\MarkUp.htm", true);
- a.WriteLine(szHTML);
- a.Close();
-
- */
-
- // LINEBREAKS
- szHTML = szHTML.replace(/!BR\/!/g, "<BR/>");
-
- var endTransTime = new Date();
-
- if (szHTML == null) {
- alert(L_Transform_Failed);
- fnHideWaitCursor();
- return;
- };
-
- ctlCitates.document.selection.empty();
-
- if (szHTML == "") {
- szHTML=L_NO_FRAGMENTS_HTML;
- ctlCitates.innerHTML = szHTML;
- fnHideWaitCursor();
- }
- else {
- var i = 0;
- var nPos = 0;
-
- for (i = 0; (i < 10) && (nPos > -1); i ++) {
- nPos = szHTML.indexOf("<HR", nPos + 1);
- };
-
-
- if (nPos != -1) {
- nPos += 5;
- GszHTML = szHTML;
- szHTML = "";
- fnTransferItem(0);
-
- /*
- if (!some) {
- ctlCitates.innerHTML = szHTML.slice(0, nPos);
- szHTML = "";
- FolderChangeTimer =
- window.setTimeout("OnFolderChanged(1)", 50);
- }
- else {
- ctlCitates.insertAdjacentHTML("beforeEnd",
- szHTML.slice(nPos));
- szHTML = "";
- };
- */
- }
- else {
- ctlCitates.innerHTML = szHTML;
- szHTML = "";
- fnHideWaitCursor();
- };
- };
-
- //ctlCitates.innerHTML = szHTML;
-
-
- var endTime = new Date();
- /*
- alert ( "All time:" +
- ( endTime.getTime() - startTime.getTime() ) + "\n" +
- "Tranform time:" +
- ( endTransTime.getTime() - startTime.getTime() ) + "\n" +
- "Apply time:" +
- ( endTime.getTime() - endTransTime.getTime() ) + "\n"
- );
- */
- //FocusHolder.innerHTML = szHTML;
- //FocusHolder.runtimeStyle = "block";
-
- /*
- var oTexts = ctlCitates.all["FragmentText"];
- if (oTexts == null) {
- fnHideWaitCursor();
- return;
- };
- */
- /*
- //<!-- Auto-resize development delayed -->
-
- var oTextRange = document.body.createTextRange();
- for (i = 0; i < oTexts.length; i++) {
- var oBoundingRect = oTexts[i].getBoundingClientRect();
- oTextRange.moveToElementText(oTexts[i]);
- var oClientRects = oTextRange.getClientRects();
-
- //var nMaxWidth = 0;
- var nSumHeight = 0;
- for (j = 0; j < oClientRects.length; j++) {
- // nMaxWidth = Math.max(oClientRects[j].right - oClientRects[j].left, nMaxWidth);
- nSumHeight += oClientRects[j].bottom - oClientRects[j].top;
- };
-
- //alert("Bounding\n Width:" + (oBoundingRect.right - oBoundingRect.left).toString() +
- // "\n Height:" + (oBoundingRect.bottom - oBoundingRect.top).toString() +
- // "\nSummarized\n Width:" + nMaxWidth.toString() +
- // "\n Height:" + nSumHeight.toString());
-
- if (oClientRects.length <= 4) {
- //if (nSumHeight < (oBoundingRect.bottom - oBoundingRect.top) ) {
- oTexts[i].runtimeStyle.height = nSumHeight + 2 + "px";
- oTexts[i].runtimeStyle.overflow = "hidden";
- oTexts[i].parentNode.parentNode.all.ExpandCollapse.runtimeStyle.display = "none";
- }
- else {
- oTexts[i].runtimeStyle.height = "6em";//(oBoundingRect.bottom - oBoundingRect.top);
- oTexts[i].runtimeStyle.overflow = "auto";
- oTexts[i].parentNode.parentNode.all.ExpandCollapse.runtimeStyle.display = "";
- };
- };
- */
-
- if (some)
- fnHideWaitCursor();
- };
-
- function fnStartChange(someNode) {
- var oTextNode = null;
- var arTextNames = new Array("FragmentTitle", "FragmentText", "FragmentComment", "BaseURLText");
-
- for ( i = 0; (i < arTextNames.length) && (oTextNode == null); i++) {
- try {
- oTextNode = someNode.parentNode.parentNode.all[arTextNames[i]];
- }
- catch (err) {
- oTextNode = null;
- };
- };
-
- if (oTextNode == null) {
- alert ("Not found.");
- return;
- }
- var oDateField = oTextNode.parentNode.all["FragmentDate"];
- if (oDateField != null) {
- oDateField.runtimeStyle.display = "none";
- };
-
- var oTextRange = oTextNode.document.body.createTextRange();
- var sText = oTextNode.innerText;
- oTextRange.moveToElementText(oTextNode);
- var oBoundingRect = oTextNode.getBoundingClientRect();
- var oClientRects = oTextRange.getClientRects();
-
- if (oBoundingRect.bottom - oBoundingRect.top - 2 <= 0) {
- // Rectanle may be empty...
- oTextNode.innerText = " ";
- oTextRange.moveToElementText(oTextNode);
- oBoundingRect = oTextNode.getBoundingClientRect();
- oClientRects = oTextRange.getClientRects();
- oTextNode.innerText = sText;
- if (oBoundingRect.bottom - oBoundingRect.top - 2 <= 0) {
- oBoundingRect.bottom += 16;
- };
- };
-
- //alert(oBoundingRect.bottom - oBoundingRect.top);
-
- oTextNode.innerHTML =
- "<TEXTAREA CLASS='RenameEdit' id='RenameEdit' name='RenameEdit'"+
- "STYLE='WIDTH: 100%; HEIGHT:" +
- (oBoundingRect.bottom - oBoundingRect.top - ((oClientRects.length >1) ?(2):(0)) )
- /*oTextNode.offsetHeight*/ + "px; " +
-
- /*( (oClientRects.length > 1) ?
- (*/"overflow: auto;'"/*) :
- ("overflow: hidden;'") ) */+
- // " StdHeight=" +
- // (oBoundingRect.bottom - oBoundingRect.top - 2) +
- " onblur='top.fnEditOnAccept(this);'" +
- " onkeypress='top.fnEditOnKey(this);'" +
- // " onkeyup='fnEditOnChange();'" +
-
- // LINEBREAKS
- " WRAP='hard'" +
-
- " >" +
- // LINEBREAKS
- //fnRemoveWhiteSpaces(sText) +
-
- sText +
- //(oBoundingRect.bottom - oBoundingRect.top).toString() +
- "</TEXTAREA>";
-
- //oTextNode.all.RenameEdit.width = oTextNode.offsetWidth;
- //oTextNode.all.RenameEdit.height = oTextNode.offsetHeight;
- if (oTextNode.currentStyle.overflow == "auto")
- oTextNode.runtimeStyle.overflow = "hidden";
-
- oTextNode.runtimeStyle.marginTop = "0px";
- oTextNode.runtimeStyle.marginBottom = "0px";
- oTextNode.runtimeStyle.paddingTop = "0px";
- oTextNode.runtimeStyle.paddingBottom = "0px";
-
- // LINEBREAKS
- oTextNode.all["RenameEdit"].oldText = sText;
- //oTextNode.all["RenameEdit"].oldText = fnRemoveWhiteSpaces(sText);
-
- oTextNode.all["RenameEdit"].select();
- oTextNode.all["RenameEdit"].focus();
-
- //oTextRange.execCommand("InsertTextArea", false, "RenameEdit");
- //oTextNode.all["RenameEdit"].innerText = sText;
- /*
- if (oTextNode.id != "FragmentText") {
- var nWidth = oTextNode.offsetWidth;
- var nHeight= oTextNode.offsetHeight;
- if (oTextNode.parentNode.all.FragmentDate != null) {
- nWidth -= oTextNode.parentNode.all.FragmentDate.offsetWidth + 5;
- }
- //oTextNode.offsetWidth;
- oTextNode.innerHTML = "<INPUT Class='RenameEdit' id='RenameEdit' name='RenameEdit' TYPE='text' Value='" + oTextNode.innerText + "'></INPUT>";
- oTextNode.all.RenameEdit.width = nWidth;
- oTextNode.all.RenameEdit.Height = nHeight;
- oTextNode.runtimeStyle.marginTop = "0px";
- oTextNode.runtimeStyle.marginBottom = "0px";
- oTextNode.runtimeStyle.paddingTop = "0px";
- oTextNode.runtimeStyle.paddingBottom = "0px";
- }
- else {
- oTextNode.innerHTML =
- "<TEXTAREA CLASS='RenameEdit' STYLE='WIDTH: 100%; HEIGHT:" +
- oTextNode.offsetHeight + "px; overflow: auto;'" + ">" + oTextNode.innerText + "</TEXTAREA>";
- };
- */
- };
-
- function fnApplyFragmentPropertyChangeToBase(someUIN, someAttributeName, someText) {
-
- var ctfResult = fnPrepareToChangeDatabase();
-
- if (ctfResult == ctfFailure)
- return false;
-
-
- var ctFragment = goBase.selectSingleNode(
- "//" +
- ( (gbFilterByFolder) ?
- ( "*[@UIN='" +
- goCurrentFolderUIN.toString() +
- "']/") :
- ("")
- ) +
- "CogTracker:ctFRAGMENT[@UIN='" +
- someUIN.toString() +
- "']");
- if (ctFragment == null) {
- alert(L_Fragment_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return false;
- }
-
- ctFragment.setAttribute(someAttributeName, someText);
-
- fnSaveChangedDatabase();
-
-
- if (ctfResult == ctfReloaded) {
- OnFolderChanged();
- return false;
- };
-
- return true;
- };
-
- function fnEditOnAccept(oTextEdit) {
- //alert("EditOnAccept");
- //var oTextEdit = event.srcElement;
- var oContainerNode = oTextEdit.parentNode;
- var oUIN = oContainerNode.parentNode.parentNode.parentNode.parentNode.UIN;
-
- oTextEdit.onblur="";
-
- var sPropertyName = "";
- switch (oContainerNode.id) {
- case "FragmentTitle":
- sPropertyName = cxbiAttName;
- break;
- case "FragmentText":
- sPropertyName = cxbiAttText;
- break;
- case "FragmentComment":
- sPropertyName = cxbiAttComment;
- break;
- case "BaseURLText":
- sPropertyName = cxbiAttURL;
- break;
- };
-
- var sText = oTextEdit.innerText;
- // LINEBREAKS
- var sDBText = sText.replace(/\r\n/g, "!BR/!")
-
- //var sText = fnRemoveWhiteSpaces(oTextEdit.innerText);
-
- if ( ! fnApplyFragmentPropertyChangeToBase(oUIN, sPropertyName, sDBText)) {
- //oTextEdit.newText = oTextEdit.oldText;
- return;
- }
- else {
- };
-
- oTextEdit.newText = sText;
-
- fnEditRestoreFromEdit(oTextEdit);
- };
- function fnEditOnKey(oTextEdit) {
- var event = oTextEdit.document.parentWindow.event;
-
- if (event.keyCode == 0x0D && ( ! event.shiftKey) ){
- fnEditOnAccept(oTextEdit);
- event.returnValue = false;
- event.cancelBubble = true;
- }
- else if (event.keyCode == 0x1B){
- event.srcElement.newText = event.srcElement.oldText;
- fnEditRestoreFromEdit(oTextEdit);
- event.returnValue = false;
- event.cancelBubble = true;
- }
- // LINEBREAKS
-
- else if (event.keyCode == 0x0A ||
- (event.keyCode == 0x0D && event.shiftKey == true) ){
- //event.shiftKey = false;
- event.keyCode = 0x0D;
- };
-
- };
- /*
- function fnEditOnChange() {
- var oTextEdit = event.srcElement;
-
- var oTextRange = oTextEdit.createTextRange();
- oTextRange.moveToElementText(oTextEdit);
- var oClientRects = oTextRange.getClientRects();
-
- var i = 0;
- var nTotalHeight = 0;
- for (i = 0; i < oClientRects.length; i++) {
- nTotalHeight += oClientRects[i].bottom - oClientRects[i].top;
- };
-
- if (nTotalHeight > oTextEdit.clientHeight) {
- oTextEdit.runtimeStyle.height = nTotalHeight;
- }
- else if (nTotalHeight < oTextEdit.clientHeight) {
- if (nTotalHeight > oTextEdit.StdHeight) {
- oTextEdit.runtimeStyle.height = nTotalHeight;
- }
- else {
- oTextEdit.runtimeStyle.height = oTextEdit.StdHeight;
- };
- };
- };
- */
- function fnEditRestoreFromEdit(oTextEdit) {
- //alert("RestoreFromEdit");
- //var oTextEdit = event.srcElement;
- oTextEdit.onblur="";
- oTextEdit.onchange="";
- //oTextEdit.fire("onblur");
-
- oTextEdit.runtimeStyle.display = "none";
-
- var oTextNode = oTextEdit.parentNode;
-
- fnGetRightToolbar().all.FocusHolder.focus();
-
- if (oTextNode.id != "BaseURLText") {
- oTextNode.innerText = oTextEdit.newText;
- }
- else {
- var sText = oTextEdit.newText;
- oTextNode.innerHTML =
- "<A TARGET='_blank' CLASS='BaseURL' Name='BaseURL' " +
- "id='BaseURL'></A>";
- var oAnchor = oTextNode.all["BaseURL"];
- oAnchor.href = sText;
- oAnchor.innerText = sText;
- };
- oTextNode.runtimeStyle.marginTop = "";
- oTextNode.runtimeStyle.marginBottom = "";
- oTextNode.runtimeStyle.paddingTop = "";
- oTextNode.runtimeStyle.paddingBottom = "";
-
- if (oTextNode.currentStyle.overflow == "hidden")
- oTextNode.runtimeStyle.overflow = "auto";
-
- var oDateField = oTextNode.parentNode.all["FragmentDate"];
- if (oDateField != null) {
- oDateField.runtimeStyle.display = "";
- };
-
- document.body.focus();
-
- //document.all["FocusHolder"].focus();
-
- //oTextNode.focus();
- //oTextEdit.parentElement.parentElement.focus();
- //window.setTimeout("top.fnGetRightToolbar().click();top.document.frames.ctRightFrame.focus();", 10);
-
- };
-
- L_Must_Select_Fragment = "You should select at least one citation to use this command.";
-
- function fnBuildSelectedTablesArray(someSelectionOnlyFlag) {
-
- var oRightDocument = top.fnGetCitatesHolder().document;
-
- document.frames.ctRightFrame.fnExpandSelection();
-
-
- var oRange = oRightDocument.selection.createRange();
- oRightDocument.selection.empty();
-
- var oEmptyRange = oRange.duplicate();
- oEmptyRange.collapse();
-
- var bSelectionExists = ! oEmptyRange.isEqual(oRange);
-
- if (someSelectionOnlyFlag && ! bSelectionExists) {
- alert(L_Must_Select_Fragment);
-
- return null;
- };
-
- var collTables = oRightDocument.getElementsByTagName("TABLE");
- var arrTables = new Array();
- var oTmpArray = new Array(1);
-
- for (var oRunner = new Enumerator(collTables); !oRunner.atEnd();
- oRunner.moveNext()) {
- var oCurrItem = oRunner.item();
-
- if (oCurrItem.className != "Fragment" ||
- oCurrItem.UIN == null ||
- oCurrItem.UIN == "") {
-
- continue;
- };
-
- if ( bSelectionExists ) {
- var oElementRange = oRightDocument.body.createTextRange();
- oElementRange.moveToElementText(oCurrItem);
-
- if ( ! oRange.inRange(oElementRange)) {
-
- continue;
- }
- };
-
- oTmpArray[0] = oCurrItem;
- arrTables = arrTables.concat(oTmpArray);
- };
-
- if (arrTables.length == 0) {
- if (someSelectionOnlyFlag)
- alert(L_Must_Select_Fragment);
-
- return null;
- };
- var oResult = new Object();
- oResult.arrTables = arrTables;
- oResult.oRange = ( (bSelectionExists) ? (oRange) : (null) );
-
- return oResult;
-
- };
-
- function fnExpandCollapseFraments(bExpand) {
- var oResult = fnBuildSelectedTablesArray(false);
-
- if ( ! oResult ) {
- return;
- };
-
- var arrTables = oResult.arrTables;
- var oRange = oResult.oRange;
-
- for (var i = 0; i < arrTables.length; i ++) {
-
- fnPerformExpandCollapse(
- arrTables[i].all["ExpandCollapse"],
- arrTables[i].all["FragmentText"],
- ( (bExpand) ? (cecExpand) : (cecCollapse) ) );
- };
-
- if (oRange)
- oRange.select();
- };
-
- var cecCollapse = 0;
- var cecExpand = 1;
- var cecToggleState = 2;
-
- function fnPerformExpandCollapse(someButtonNode, someFragmentTextNode, someFlag) {
-
- if ( ( someFragmentTextNode.currentStyle.overflow == "auto" &&
- someFlag == cecToggleState) ||
- (someFlag == cecExpand)
- ) {
-
- someFragmentTextNode.runtimeStyle.overflow = "visible";
- someButtonNode.src = "FragmentCollapse.gif";
- someButtonNode.runtimeStyle.display = "inline";
- }
- else if ( ( someFragmentTextNode.currentStyle.overflow == "visible" &&
- someFlag == cecToggleState) ||
- (someFlag == cecCollapse)
- ) {
- someFragmentTextNode.runtimeStyle.overflow = "auto";
- // Alex: this shouldn't be so, but this helps fix the bug
- // with single-line texts disappearing after restoring.
- someFragmentTextNode.parentElement.innerHTML =
- someFragmentTextNode.parentElement.innerHTML;
-
- someButtonNode.src = "FragmentExpand.gif";
- someButtonNode.runtimeStyle.display = "inline";
- }
- else if (someFragmentTextNode.currentStyle.overflow == "hidden") {
- // Development of auto-resize delayed
- // someButtonNode.runtimeStyle.display = "none";
- };
- };
-
- function fnExpandCollapseText(someNode)
- {
- fnPerformExpandCollapse(someNode,
- someNode.parentNode.parentNode.all.FragmentText,
- cecToggleState);
- };
-
- var tmpNewFolderUIN = -1;
- function fnNewFolderToBase(someUIN, someName) {
- var ctfResult = fnPrepareToChangeDatabase();
-
- tmpNewFolderUIN = -1;
-
- if (ctfResult != ctfFailure) {
- var ctSelected = goBase.selectSingleNode(
- "//*[@UIN='" + someUIN.toString() +"']");
- if (ctSelected == null) {
- alert(L_Folder_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
-
- return ctfFailure;
- };
-
-
- var ctElement = goBase.createElement(cxbiNODE);
-
- var NewUIN = fnCreateNewUIN(goBase);
- tmpNewFolderUIN = NewUIN;
- ctElement.setAttribute(cxbiAttUIN, NewUIN);
- ctElement.setAttribute(cxbiAttName, someName);
- ctElement.text = "\n\t";
-
- ctSelected.appendChild(ctElement);
-
- fnSaveChangedDatabase();
-
- /*Make database be reparsed*/
- /*
- var oTmpBase = fnCreateXMLctl();
- goBase.save(oTmpBase);
- goBase.loadXML("");
- oTmpBase.save(goBase);
- */
- var sXML = new String(goBase.xml);
- goBase.loadXML("");
- goBase.loadXML(sXML);
- };
-
- return ctfResult;
- };
-
- function fnNewFolder()
- {
- var bOK = true;
- var sNewName = "";
- do {
- bOK = true;
-
- var NewDialogHeight = "140px";
- var NewDialogWidth = "220px";
- var xPos = document.body.clientLeft +
- document.body.clientWidth/2;
- var yPos = document.body.clientTop +
- document.body.clientHeight/2;
-
- xPos -= parseInt(NewDialogWidth.slice(0,NewDialogWidth.length-2), 10)/2;
- yPos -= parseInt(NewDialogHeight.slice(0,NewDialogHeight.length-2), 10)/2;
- sNewName = showModalDialog("ctNewNode.htm", "folder",
- "help:no; resizable:no; status:no; center:no;" +
- " dialogLeft:" + xPos.toString() + "px;" +
- "dialogTop:" + yPos.toString() + "px;" +
- "dialogHeight:" + NewDialogHeight + ";" +
- "dialogWidth:" + NewDialogWidth + ";");
-
- if (sNewName == "" || sNewName == null)
- return;
- sNewName = fnRemoveWhiteSpaces(sNewName);
-
- if (sNewName == "" || sNewName == null)
- return;
-
- //TEMP: non-hierarchical add..
- var ctNODE = goBase.selectSingleNode(
- "//*[@UIN='" + goCurrentFolderUIN
- //ctlTree.all.tags("SELECT")[0].options(0).value.toString()
- +"']");
- if (ctNODE == null) {
- alert(L_Folder_Not_Found);
- return ctfFailure;
- };
-
- /*
- //TEMP: non-hierarchical add..
- var ctChildNodes = ctNODE.selectNodes("./CogTracker:ctNODE");
- for (i = 0; i < ctChildNodes.length; i++) {
- var sNodeNameUppered = ctChildNodes[i].getAttribute(cxbiAttName);
- sNodeNameUppered = sNodeNameUppered.toUpperCase();
- var sNewNameUppered = sNewName;
- sNewNameUppered = sNewNameUppered.toUpperCase();
-
- if (sNodeNameUppered == sNewNameUppered) {
- alert(L_NODE_ALREADY_EXISTS);
- bOK = false;
- break;
- };
- };
- */
- if ( fnNodeHasChildWithName(ctNODE, sNewName) ) {
- alert(L_NODE_ALREADY_EXISTS);
- bOK = false;
- };
- } while (!bOK);
-
- if (fnNewFolderToBase(/*ctlTree.all.tags("SELECT")[0].options(0).value*/
- //TEMP: non-hierarchical add..
- goCurrentFolderUIN, sNewName) != ctfFailure) {
-
- fnGetTreeHolder().all.FoldersTree.CreateNewNode(goCurrentFolderUIN,
- sNewName, tmpNewFolderUIN);
- /*
- var oSelect = ctlTree.all.tags("SELECT")[0];
- if (oSelect) {
- var oOption = document.createElement("OPTION");
- oSelect.options.add(oOption);
- oOption.innerText = sNewName;
- oOption.value = tmpNewFolderUIN;
-
- oSelect.selectedIndex = oSelect.options.length - 1;
-
- OnFolderChanged();
- };
- */
- };
- };
-
- function fnRenameFolderToBase(someUIN, someName)
- {
- var ctfResult = fnPrepareToChangeDatabase();
-
- if (ctfResult != ctfFailure) {
- var ctSelected = goBase.selectSingleNode(
- "//*[@UIN='" + someUIN.toString() +"']");
- if (ctSelected == null) {
- alert(L_Folder_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
-
- return ctfFailure;
- };
-
-
- ctSelected.setAttribute(cxbiAttName, someName);
-
- fnSaveChangedDatabase();
- };
-
- return ctfResult;
- };
-
- function fnRenameFolder()
- {
- var bOK = true;
- var sNewName = "";
- var sOldName = "";
- {
- //var oSelect = ctlTree.all.tags("SELECT")[0];
- sOldName = //fnRemoveWhiteSpaces(oSelect.options[oSelect.selectedIndex].innerText);
- fnGetTreeHolder().all.FoldersTree.GetCurrentNodeName();
- };
-
- do {
- bOK = true;
-
- var NewDialogHeight = "140px";
- var NewDialogWidth = "220px";
- var xPos = document.body.clientLeft +
- document.body.clientWidth/2;
- var yPos = document.body.clientTop +
- document.body.clientHeight/2;
-
- xPos -= parseInt(NewDialogWidth.slice(0,NewDialogWidth.length-2), 10)/2;
- yPos -= parseInt(NewDialogHeight.slice(0,NewDialogHeight.length-2), 10)/2;
-
- sNewName = showModalDialog("ctRenameNode.htm", sOldName,
- "help:no; resizable:no; status:no; center:no;" +
- " dialogLeft:" + xPos.toString() + "px;" +
- "dialogTop:" + yPos.toString() + "px;" +
- "dialogHeight:" + NewDialogHeight + ";" +
- "dialogWidth:" + NewDialogWidth + ";");
-
- if (sNewName == "" || sNewName == null)
- return;
- sNewName = fnRemoveWhiteSpaces(sNewName);
-
- if (sNewName == "" || sNewName == null || sNewName == sOldName)
- return;
-
- //TEMP: non-hierarchical add..
- var ctNODE = goBase.selectSingleNode(
- "//*[@UIN='" + goCurrentFolderUIN
- /*ctlTree.all.tags("SELECT")[0].options(0).value.toString()*/
- +"']");
- if ( isNaN(parseInt(ctNODE.getAttribute(cxbiAttIsDatabase))) ||
- parseInt(ctNODE.getAttribute(cxbiAttIsDatabase) != true) ) {
-
- if (ctNODE == null || ctNODE.parentNode == null) {
- alert(L_Folder_Not_Found);
- return ctfFailure;
- };
-
- ctNODE = ctNODE.parentNode;
-
-
- //TEMP: non-hierarchical add..
- var ctChildNodes = ctNODE.selectNodes("./CogTracker:ctNODE");
- //"/root/CogTracker:ctDATABASE|//CogTracker:ctNODE");
- for (i = 0; i < ctChildNodes.length; i++) {
- if (ctChildNodes[i].getAttribute(cxbiAttUIN) ==
- goCurrentFolderUIN) {
-
- continue;
- };
-
-
-
-
- var sNodeNameUppered = ctChildNodes[i].getAttribute(cxbiAttName);
- sNodeNameUppered = sNodeNameUppered.toUpperCase();
- var sNewNameUppered = sNewName;
- sNewNameUppered = sNewNameUppered.toUpperCase();
-
- if (sNodeNameUppered == sNewNameUppered) {
- alert(L_NODE_ALREADY_EXISTS);
- bOK = false;
- break;
- };
- };
- };
- } while (!bOK);
-
- if (fnRenameFolderToBase(goCurrentFolderUIN, sNewName) != ctfFailure) {
- fnGetTreeHolder().all.FoldersTree.RenameNode(goCurrentFolderUIN, sNewName);
- /*
- var oSelect = ctlTree.all.tags("SELECT")[0];
- if (oSelect) {
- oSelect.options(oSelect.selectedIndex).innerText =
- sNewName;
- // has been put here to cause listbox redraw.
- OnFolderChanged();
- };
- */
- };
-
- };
-
- function fnDeleteFolderFromBase(someUIN) {
-
- var ctfResult = fnPrepareToChangeDatabase();
-
- if (ctfResult != ctfFailure) {
- var ctNODE = goBase.selectSingleNode(
- "//*[@UIN='" + someUIN.toString() +"']");
- if (ctNODE == null) {
- alert(L_Folder_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
-
-
- return ctfFailure;
- };
-
- if (ctNODE.tagName == "CogTracker:ctDATABASE") {
- alert(L_Dont_Delete_Root);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
-
-
- if (ctNODE.getAttribute(cxbiAttUnsorted) == 1) {
- alert(L_Dont_Delete_Unsorted);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
-
- var ctParent = ctNODE.parentNode;
- ctParent.removeChild(ctNODE);
-
- fnSaveChangedDatabase();
- };
-
- return ctfResult;
- };
-
- function fnDeleteFolder() {
-
-
- if ( ! confirm(L_Confirm_Folder_Deletion) ) {
- return;
- };
-
-
- if (fnDeleteFolderFromBase(goCurrentFolderUIN) != ctfFailure) {
- /*
- var oSelect = ctlTree.all.tags("SELECT")[0];
- if (oSelect) {
- var oFolders = oSelect.options;
- var nSelectedFolder = oSelect.selectedIndex;
- for (i = 0; i < oFolders.length; i++) {
- if ( (oFolders[i].tagName == "OPTION") &&
- (oFolders[i].value == goCurrentFolderUIN) )
- {
- //oFolders.remove(i);
- oFolders[i] = null;
-
- oSelect.selectedIndex =
- ( (nSelectedFolder > 0) ?
- (nSelectedFolder-1) :
- (0));
-
- OnFolderChanged();
- break;
- };
- };
- };
- */
- fnGetTreeHolder().all.FoldersTree.RemoveNode(goCurrentFolderUIN, true);
- };
-
- fnGetCitatesHolder().document.selection.empty();
- };
-
- function fnMoveFolderInBase(someDestUIN, someSrcUIN) {
- var ctfResult = fnPrepareToChangeDatabase();
-
- if (ctfResult != ctfFailure) {
- var ctSrcNode = goBase.selectSingleNode(
- "//CogTracker:ctNODE[@UIN='" +
- someSrcUIN.toString() +"']");
- if (ctSrcNode == null) {
- alert(L_Folder_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
- var ctDestNode = goBase.selectSingleNode(
- "/root/CogTracker:ctDATABASE[@UIN='" +
- someDestUIN.toString() + "'] | " +
- "//CogTracker:ctNODE[@UIN='" +
- someDestUIN.toString() +"']");
- if (ctDestNode == null) {
- alert(L_Folder_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
-
- var ctParent = ctSrcNode.parentNode;
- ctDestNode.appendChild(ctParent.removeChild(ctSrcNode));
-
- fnSaveChangedDatabase();
-
- };
-
- return ctfResult;
- };
-
- function fnMoveFolder() {
-
- var ctlTree = fnGetTreeHolder();
-
- var currentFolder = fnGetTreeHolder().all.FoldersTree.GetCurrentNode();
-
- if (currentFolder == null) {
- alert(L_Folder_Not_Found);
- return;
- };
-
- currentFolder = currentFolder.parentElement;
- if (currentFolder.IsDatabase) {
- alert(L_Database_Cannot_Be_Moved);
- return;
- };
-
- if (currentFolder.IsUnsortedNode) {
- alert(L_SystemFolder_Cannot_Be_Moved);
- return;
- };
-
- var args = new Object();
- args.XMLbase = goBase;
- args.TreeHTML = new String(ctlTree.innerHTML);
- //args.bFragmentMove = false;
- args.nDialogMode = cmtfFolderMove;
- args.sourceFolder = ctlTree.all.FoldersTree.GetCurrentNodeUIN();
-
- var oResult = showModalDialog("ctMoveToFolder.htm", args,
- "help:no; resizable:no; status:no;");
-
- if (oResult == null || oResult.oFolder == null)
- return;
-
- var destinationFolder = oResult.oFolder;
-
-
- if (fnMoveFolderInBase(destinationFolder, args.sourceFolder) !=
- ctfFailure) {
-
- fnGetCitatesHolder().document.selection.empty();
-
- ctlTree.all.FoldersTree.MoveNode(destinationFolder,
- args.sourceFolder);
- };
- };
-
- function fnPrepareToChangeDatabase() {
-
- try {
- fnGetHelperObject().LockFile(gsCurrentPath);
- }
- catch (err) {
- alert(L_Failed_To_Lock_File);
- return ctfFailure;
- };
-
- var bReloaded = false;
-
- { //Check file's stamp
- var oDiskBase = fnCreateXMLctl();
- if (oDiskBase == null) {
- alert(L_Unable_To_Create);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
-
- if (oDiskBase.load(gsCurrentPath)){
-
- if ( ! fnCheckTimeStampsEqual(goBase, oDiskBase) ) {
- alert(L_Outside_Modification);
-
- bReloaded = true;
-
- fnLoadFile(gsCurrentPath);
- };
- };
- };
-
- if (bReloaded) {
- return ctfReloaded;
- };
-
- return ctfSuccess;
- };
-
- function fnSaveChangedDatabase() {
-
- try {
- if (gsCurrentPath) {
- if (goCurrentFolderUIN != -1 &&
- goBase.selectSingleNode("//*[@UIN='" + goCurrentFolderUIN + "']") ) {
-
- var ctDATABASE = goBase.selectSingleNode("/root/CogTracker:ctDATABASE");
- if (ctDATABASE != null) {
- ctDATABASE.setAttribute(cxbiAttCurrentNode, goCurrentFolderUIN);
- };
- };
-
- fnIncrementTimeStamp(goBase);
-
- goBase.save(gsCurrentPath);
-
- fnGetHelperObject().DoSendChangeNotification(gsCurrentPath, -1);
- }
- else {
-
- };
- }
- catch(err) {
- }
- finally {
- fnGetHelperObject().UnlockFile(gsCurrentPath);
- }
- };
-
- function fnDeleteFragmentFromBase(someArrFragmentUINs /*someUIN*/) {
- var ctfResult = fnPrepareToChangeDatabase();
-
- if (ctfResult == ctfFailure) {
- return ctfFailure;
- };
-
- for (var i = 0; i < someArrFragmentUINs.length; i ++) {
- var someUIN = someArrFragmentUINs[i];
-
- var ctFragment = goBase.selectSingleNode(
- "//CogTracker:ctFRAGMENT[@UIN='" +
- someUIN.toString() +"']");
- if (ctFragment == null) {
- alert(L_Fragment_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
-
- var ctParent = ctFragment.parentNode;
- ctParent.removeChild(ctFragment);
- };
-
- fnSaveChangedDatabase();
-
- return ctfResult;
- };
-
- function fnDeleteFragments(someParam) {
-
- var arrFragmentUINs = null;
-
- if (someParam == null) {
- var oResult = fnBuildSelectedTablesArray(true);
-
- if ( ! oResult ) {
- return;
- };
-
- var arrTables = oResult.arrTables;
- // var oRange = oResult.oRange;
-
- arrFragmentUINs = new Array();
- for (var i = 0; i < arrTables.length; i ++) {
- arrFragmentUINs[i] = arrTables[i].UIN;
- };
- //
- }
- else {
- arrFragmentUINs = someParam;
- };
-
- var sPrompt = "";
- if (arrFragmentUINs.length > 1) {
- sPrompt = L_Confirm_Multiple_Fragments_Deletion;
- }
- else {
- sPrompt = L_Confirm_Fragment_Deletion;
- };
-
-
- var ctlCitates = fnGetCitatesHolder();
-
- if (confirm(sPrompt)) {
-
- if (fnDeleteFragmentFromBase(arrFragmentUINs) != ctfFailure) {
- for (var i = 0; i < arrFragmentUINs.length; i ++) {
- //Database, maybe, has been reloaded...
- oFragment = fnGetCitatesHolder().document.all(
- "id" + arrFragmentUINs[i].toString());
-
- if (oFragment) {
- var oSibling = oFragment.nextSibling; // HR
- var oParent = oFragment.parentNode;
- oParent.removeChild(oFragment);
- if (oSibling.tagName == "HR") {
- oParent.removeChild(oSibling);
- }
- };
- };
- };
-
- fnGetCitatesHolder().document.selection.empty();
-
- if (ctlCitates.innerHTML == "") {
- ctlCitates.innerHTML = L_NO_FRAGMENTS_HTML;
- };
- };
-
- };
-
- function fnFragmentDelete(someNode) {
- var oFragment = someNode.parentNode.parentNode.parentNode.parentNode.parentNode;
- var UIN = oFragment.UIN;
-
- var arrFragmentUINs = new Array();
- arrFragmentUINs[0] = UIN;
-
- fnDeleteFragments(arrFragmentUINs);
- /*
- var ctlCitates = fnGetCitatesHolder();
-
- if (confirm(L_Confirm_Fragment_Deletion)) {
- var oFragment = someNode.parentNode.parentNode.parentNode.parentNode.parentNode;
- var UIN = oFragment.UIN;
-
- if (fnDeleteFragmentFromBase(UIN) != ctfFailure) {
- //Database, maybe, has been reloaded...
- oFragment = fnGetCitatesHolder().document.all("id" + UIN.toString());
-
- if (oFragment) {
- var oSibling = oFragment.nextSibling; // HR
- var oParent = oFragment.parentNode;
- oParent.removeChild(oFragment);
- if (oSibling.tagName == "HR") {
- oParent.removeChild(oSibling);
- }
- };
- };
-
- fnGetCitatesHolder().document.selection.empty();
-
- if (ctlCitates.innerHTML == "") {
- ctlCitates.innerHTML = L_NO_FRAGMENTS_HTML;
- };
- };
- */
- };
-
- var arSortFields = new Array( "Sort by &Title", "Sort by &Date", "Sort by Te&xt",
- "Sort by &Comment", "Sort by &URL");
- var arSortDirections = new Array("Sort &Ascending", "Sort D&escending");
-
- function fnSortModeSelect() {
-
- if (gnSortBy == -1)
- gnSortBy = 1;
- if (gnSortDirection == -1)
- gnSortDirection = 0;
-
- var Helper = fnGetHelperObject();
- Helper.PopupMenuCreate();
-
- for (var i = 0; i < arSortFields.length; i++) {
-
- Helper.PopupMenuAppendItem(arSortFields[i],
- i + 1, true, (gnSortBy == i) );
- };
- Helper.PopupMenuAppendSeparator();
-
- for (var j = 0; j < arSortDirections.length; i++, j++) {
- Helper.PopupMenuAppendItem(arSortDirections[j],
- i + 1, true, (gnSortDirection == j) );
- };
-
- var MenuButton = fnGetRightToolbar().all.ctsSortModes;
-
- var nLeft = 0; var nTop = 0;
-
- nLeft += MenuButton.offsetLeft + 0 +
- MenuButton.document.body.offsetLeft +
- MenuButton.document.parentWindow.screenLeft;
-
- nTop += MenuButton.offsetTop + MenuButton.offsetHeight +
- MenuButton.document.body.offsetTop +
- MenuButton.document.parentWindow.screenTop;
-
-
- var res = Helper.PopupMenuTrack(nLeft, nTop, top.oHTA.applicationName);
-
- Helper.PopupMenuDestroy();
-
- MenuButton.ct_unstick();
-
- res --;
-
- if (res < 0) {
- return;
- };
- if (res < arSortFields.length) {
- fnSortBy(res, -1, true);
- }
- else {
- res -= arSortFields.length;
-
- if (res < arSortDirections.length) {
- fnSortBy(-1, res, true);
- };
- };
- };
-
- function fnSortBy(someSort, someDirection, somePerformRefresh) {
-
- if (gnSortBy == -1)
- gnSortBy = 1;
- if (gnSortDirection == -1)
- gnSortDirection = 0;
-
-
- /*
- if (someSort == null || someSort == "") {
- someSort = -1;
- };
-
- if (someDirection == null || someDirection == "") {
- someDirection = -1;
- };
- */
-
- var nSortBy = gnSortBy;
- var nSortDirection = gnSortDirection;
-
- if (someSort >= 0 && someSort < arAttributeNames.length) {
- nSortBy = someSort;
- };
- if (someDirection >= 0 && someDirection < arAttributeNames.length) {
- nSortDirection = someDirection;
- };
- /*
- var RightToolbar = fnGetRightToolbar();
-
- var nSortBy = -1;
- var nSortDirection = -1;
- if (someSort != null && someSort != "") {
- for( i = 0; i < arButtonSortNames.length; i++) {
- //RightToolbar.all[arButtonSortNames[i]].ct_disabled = 0;
- if (arButtonSortNames[i] == someSort) {
- RightToolbar.all[arButtonSortNames[i]].ct_state = 1;
- nSortBy = i;
- }
- else {
- RightToolbar.all[arButtonSortNames[i]].ct_state = 0;
- };
- };
- }
- else {
- for( i = 0; i < arButtonSortNames.length; i++) {
- if (RightToolbar.all[arButtonSortNames[i]].ct_state == 1) {
- nSortBy = i;
- };
- };
- };
-
- if (someDirection != -1) {
- for( i = 0; i < arButtonDirNames.length; i++) {
- //RightToolbar.all[arButtonDirNames[i]].ct_disabled = 0;
- if ( i == someDirection) {
- RightToolbar.all[arButtonDirNames[i]].ct_state = 1;
- nSortDirection = i;
- }
- else {
- RightToolbar.all[arButtonDirNames[i]].ct_state = 0;
- };
- };
- }
- else {
- for( i = 0; i < arButtonDirNames.length; i++) {
- if ( RightToolbar.all[arButtonDirNames[i]].ct_state == 1 ) {
- nSortDirection = i;
- };
- };
- };
- */
- if ( (nSortBy == -1) || (nSortDirection == -1) ) {
- alert(L_Undetermined_Sort);
- return;
- };
-
- gnSortBy = nSortBy;
- gnSortDirection = nSortDirection;
-
- fnSetSetting(ccsSortBy, gnSortBy + 1, true);
- fnSetSetting(ccsSortDirection, gnSortDirection + 1, true);
-
-
- if (somePerformRefresh == null)
- somePerformRefresh = true;
-
- if (somePerformRefresh)
- OnFolderChanged();
- };
-
- function fnToggleFolderFilter() {
- gbFilterByFolder = (!gbFilterByFolder);
-
- fnGetLeftToolbar().all.ctsFolderFilter.ct_state = (!gbFilterByFolder);
-
- OnFolderChanged();
- };
-
- function fnOnTreeSelectionChange() {
- var oTree = fnGetTreeHolder().all.FoldersTree;
- var oCurNode = oTree.GetCurrentNodeUIN();
-
- gbFilterByFolder = true;
- fnGetLeftToolbar().all.ctsFolderFilter.ct_state = (!gbFilterByFolder);
-
-
- OnFolderChanged();
- };
-
- function fnMoveFragmentInBase(someDestUIN, someSrcUIN, someArrFragmentUINs, //someFragmentUIN,
- someMakeCopy) {
- var ctfResult = fnPrepareToChangeDatabase();
-
- if (ctfResult == ctfFailure) {
- return ctfFailure;
- };
-
-
- for (var i = 0; i < someArrFragmentUINs.length; i ++) {
-
- var someFragmentUIN = someArrFragmentUINs[i];
-
- var ctFragment = goBase.selectSingleNode(
- "//CogTracker:ctFRAGMENT[@UIN='" +
- someFragmentUIN.toString() +"']");
- if (ctFragment == null) {
- alert(L_Fragment_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
- var ctDestNode = goBase.selectSingleNode(
- "/root/CogTracker:ctDATABASE[@UIN='" +
- someDestUIN.toString() + "'] | " +
- "//CogTracker:ctNODE[@UIN='" +
- someDestUIN.toString() +"']");
- if (ctDestNode == null) {
- alert(L_Folder_Not_Found);
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- return ctfFailure;
- };
-
- var ctParent = ctFragment.parentNode;
- if (someMakeCopy) {
- var ctNewFragment = ctFragment.cloneNode(false);
- ctNewFragment.setAttribute(cxbiAttUIN,
- fnCreateNewUIN(goBase));
-
- ctDestNode.appendChild(ctNewFragment);
- }
- else {
-
- ctDestNode.appendChild(ctParent.removeChild(ctFragment));
- };
-
- };
-
- fnSaveChangedDatabase();
-
- return ctfResult;
- };
-
- function fnMoveFragments( someParam ) {
-
- var arrFragmentUINs = null;
-
- if (someParam == null) {
- var oResult = fnBuildSelectedTablesArray(true);
-
- if ( ! oResult ) {
- return;
- };
-
- var arrTables = oResult.arrTables;
- // var oRange = oResult.oRange;
-
- arrFragmentUINs = new Array();
- for (var i = 0; i < arrTables.length; i ++) {
- arrFragmentUINs[i] = arrTables[i].UIN;
- };
- //
- }
- else {
- arrFragmentUINs = someParam;
- };
-
-
- // Ask user...
- var ctlTree = fnGetTreeHolder();
- var ctlCitates = fnGetCitatesHolder();
-
- var args = new Object();
- args.XMLbase = goBase;
- args.TreeHTML = new String(ctlTree.innerHTML);
- //args.bFragmentMove = true;
- args.nDialogMode = cmtfFragmentMove;
-
- args.sourceFolder = ctlTree.all.FoldersTree.GetCurrentNodeUIN();
-
- var oResult = showModalDialog("ctMoveToFolder.htm", args,
- "help:no; resizable:no; status:no;");
-
- if (oResult == null || oResult.oFolder == null)
- return;
-
- var destinationFolder = oResult.oFolder;
- var bMakeCopy = oResult.bMakeCopy;
-
- if (fnMoveFragmentInBase(destinationFolder, args.sourceFolder,
- arrFragmentUINs, //UIN,
- bMakeCopy) != ctfFailure) {
-
- if ( ! bMakeCopy ) {
-
- for (var i = 0; i < arrFragmentUINs.length; i ++) {
-
- //Database, maybe, has been reloaded...
- oFragment = fnGetCitatesHolder().document.all("id" +
- arrFragmentUINs[i].toString());
-
- if (oFragment) {
- var oSibling = oFragment.nextSibling; // HR
- var oParent = oFragment.parentNode;
- oParent.removeChild(oFragment);
- if (oSibling.tagName == "HR") {
- oParent.removeChild(oSibling);
- }
- };
- };
-
- };
-
- fnGetCitatesHolder().document.selection.empty();
-
- if (ctlCitates.innerHTML == "") {
- ctlCitates.innerHTML = L_NO_FRAGMENTS_HTML;
- };
- // A node has been duplicated to this folder
- if ( (bMakeCopy && destinationFolder == args.sourceFolder) ||
- ( ! gbFilterByFolder) ) {
- OnFolderChanged();
- };
- };
-
-
- };
-
- function fnFragmentMove(someNode) {
-
- var oFragment = someNode.parentNode.parentNode.parentNode.parentNode.parentNode;
- var UIN = oFragment.UIN;
-
- var arrFragmentUINs = new Array();
- arrFragmentUINs[0] = UIN;
-
- fnMoveFragments(arrFragmentUINs);
-
- /*
- var ctlTree = fnGetTreeHolder();
- var ctlCitates = fnGetCitatesHolder();
-
- var args = new Object();
- args.XMLbase = goBase;
- args.TreeHTML = new String(ctlTree.innerHTML);
- args.bFragmentMove = true;
- args.sourceFolder = ctlTree.all.FoldersTree.GetCurrentNodeUIN();
-
- var oResult = showModalDialog("ctMoveToFolder.htm", args,
- "help:no; resizable:no; status:no;");
-
- if (oResult == null || oResult.oFolder == null)
- return;
-
- var destinationFolder = oResult.oFolder;
- var bMakeCopy = oResult.bMakeCopy;
-
-
- var oFragment = someNode.parentNode.parentNode.parentNode.parentNode.parentNode;
- var UIN = oFragment.UIN;
-
- var arrFragmentUINs = new Array();
- arrFragmentUINs[0] = UIN;
-
- if (fnMoveFragmentInBase(destinationFolder, args.sourceFolder,
- arrFragmentUINs, //UIN,
- bMakeCopy) != ctfFailure) {
-
- if ( ! bMakeCopy ) {
- //Database, maybe, has been reloaded...
- oFragment = fnGetCitatesHolder().document.all("id" +
- UIN.toString());
-
- if (oFragment) {
- var oSibling = oFragment.nextSibling; // HR
- var oParent = oFragment.parentNode;
- oParent.removeChild(oFragment);
- if (oSibling.tagName == "HR") {
- oParent.removeChild(oSibling);
- }
- };
- };
-
- fnGetCitatesHolder().document.selection.empty();
-
- if (ctlCitates.innerHTML == "") {
- ctlCitates.innerHTML = L_NO_FRAGMENTS_HTML;
- };
-
- // A node has been duplicated to this folder
- if (bMakeCopy && destinationFolder == args.sourceFolder) {
- OnFolderChanged();
- };
- };
- */
- };
-
- function fnChangeVisibilityOptions() {
-
- goVisibilityOptions.nMode = cvoDB;
-
- var result = showModalDialog("ctVisibilityOptions.htm",
- goVisibilityOptions,
- "help:no; resizable:no; status:no;");
-
- if ( ! result ) {
- return;
- };
-
- fnSetSetting(ccsVHideFieldNames , ! goVisibilityOptions.bShowFieldNames, true);
- fnSetSetting(ccsVShowTitle , goVisibilityOptions.bShowTitle, true);
- fnSetSetting(ccsVShowDate , goVisibilityOptions.bShowDate, true);
- fnSetSetting(ccsVShowText , goVisibilityOptions.bShowText, true);
- fnSetSetting(ccsVShowComment , goVisibilityOptions.bShowComment, true);
- fnSetSetting(ccsVShowURL , goVisibilityOptions.bShowURL, true);
-
- OnFolderChanged();
- };
-
-
- function fnPrint() {
- var ctlCitates = fnGetCitatesHolder();
- ctlCitates.document.parentWindow.focus();
- ctlCitates.document.parentWindow.print();
- };
-
-
- function fnFind() {
- window.setTimeout( "document.frames.ctRightFrame.focus();" +
- "fnGetHelperObject().DoCauseFind();" , 500);
-
- /*
- var ctlCitates = fnGetCitatesHolder();
- document.frames.ctToolBars.blur();
- document.frames.ctRightFrame.focus();
- //ctlCitates.document.parentWindow.focus();
-
- fnGetHelperObject().DoCauseFind();
- */
- /*
- var WM_KEYDOWN = 0x0100;
- var WM_KEYUP = 0x0101;
- var WM_COMMAND = 0x0111;
- var VK_CONTROL = 0x11;
- var VK_F = 0x46;
-
- var ctlCitates = fnGetCitatesHolder();
- ctlCitates.document.parentWindow.focus();
-
- var Helper = fnGetHelperObject();
-
- */
- /*
- alert(document.frames.ctRightFrame.document.parentWindow);
- Helper.DoIt(document.frames.ctRightFrame.document.parentWindow);
- */
- /*
- Helper.DoPostMessage(WM_COMMAND,
- 0x443,
- //0x10043,
- //0x1091,
- 0,//(VK_CONTROL << 16) | 1,
- top.oHTA.applicationName);
- */
-
- /*
- Helper.DoPostMessage(0xE124,
- 0,
- 0,//(VK_CONTROL << 16) | 1,
- top.oHTA.applicationName);
- */
- /*
- Helper.DoPostMessage(WM_KEYDOWN,
- VK_CONTROL,
- 0x01D0001,//(VK_CONTROL << 16) | 1,
- top.oHTA.applicationName);
- Helper.DoPostMessage(WM_KEYDOWN,
- VK_F,
- 0x0210001,//(VK_F << 16) | 1,
- top.oHTA.applicationName);
- */
-
- /*
- Helper.DoPostMessage(WM_KEYUP,
- VK_F,
- 0xC0210001,//(VK_F << 16) | 0xC000000 | 1,
- top.oHTA.applicationName);
- Helper.DoPostMessage(WM_KEYUP,
- VK_CONTROL,
- 0xC01D0001,//(VK_CONTROL << 16) | 0xC000000 | 1,
- top.oHTA.applicationName);
- */
- //alert("Not ready yet.");
- //ctlCitates.document.parentWindow.fireEvent();
- //ctlCitates.document.execCommand("Find", true, "a");
- };
-
- function fnOnFileChange() {
-
- var sChangedFilePath = fnGetHelperObject().FileChangeFilePath;
- var nChangedFolderID = fnGetHelperObject().FileChangeFolderID;
-
- if (gsCurrentPath.toUpperCase() == sChangedFilePath.toUpperCase()) {
- fnLoadFile(gsCurrentPath);
- };
- };
-
- var cixImport = 1;
- var cixExport = 2;
- var cixSendByMail = 3;
-
- function fnImport() {
- fnPerformImportExport(cixImport);
- };
-
- function fnExport() {
- fnPerformImportExport(cixExport);
- };
-
- function fnPerformImportExport( nMode, someFilePath) {
-
- var bExternalLocked = false;
- var ctlBrowser = fnGetBrowserObject();
- var oldBase = null;
- var tmpBase = null;
-
- switch (nMode) {
- case cixImport:
-
- if ( ! fnBrowseForFile(gsCurrentPath, L_Import_Dialog_Title,
- L_CITATES_EXT, L_CITATES_FILTER, false, true, true) ) {
-
- return false;
- }
- break;
-
- case cixExport:
-
- if ( ! fnBrowseForFile(gsCurrentPath, L_Export_Dialog_Title) ) {
-
- return false;
- }
- break;
- case cixSendByMail:
- ctlBrowser.FileName = someFilePath;
- break;
-
- default:
- alert("Invalid mode selected.");
- return false;
- break;
- };
-
- var externalBase = fnCreateXMLctl();
- if (externalBase == null) {
- alert(L_Unable_To_Create);
- return false;
- };
- externalBase.loadXML("");
-
-
- var bExternalIsInternal = (ctlBrowser.FileName.toUpperCase() ==
- gsCurrentPath.toUpperCase());
- var sExternalPath = ctlBrowser.FileName;
-
-
- if (bExternalIsInternal) {
- goBase.save(externalBase);
- }
- else {
- try {
- fnGetHelperObject().LockFile(ctlBrowser.FileName);
- }
- catch (err) {
-
- alert(L_Failed_To_Lock_File);
-
- return false;
- };
-
-
- try {
- switch (nMode) {
- case cixImport:
- //No Checked initialize, 'coz we do not need this file to work for us.
- if ( ( ! externalBase.load(sExternalPath) ) ||
- ( ! externalBase.selectSingleNode(cxbiRoot) ) ||
- ( ! externalBase.selectSingleNode(cxbiRoot + "/" + cxbiDatabase) ) ) {
-
- throw(L_Failed_To_Load_File);
- };
- break;
-
- case cixExport:
- case cixSendByMail:
- if ( ! fnCheckedInitializeFile(externalBase, sExternalPath) ) {
-
- throw(L_Failed_To_Load_File);
- };
- break;
- };
- }
- catch(err) {
- fnGetHelperObject().UnlockFile(ctlBrowser.FileName);
-
- if (err != null && err != "") {
- if (err.description != null) {
- alert(L_OP_FAILED + err.description);
- }
- else {
- alert(err);
- };
- };
-
- return false;
- };
-
- fnGetHelperObject().UnlockFile(ctlBrowser.FileName);
- };
-
- /**/
- if ( ! fnCheckVersion(externalBase) ) {
- if ( ! fnConfirmConversion(externalBase) ) {
- return false;
- }
- else {
- if ( ! fnPerformConversion(externalBase) ) {
- return false;
- };
- };
- };
-
- //Ensure that all CogTracker:ctNODE have their UINs
- var oNodesList = externalBase.selectNodes(
- "/root/CogTracker:ctDATABASE|//CogTracker:ctNODE|" +
- "//CogTracker:ctFRAGMENT");
-
- for (var i = 0; i < oNodesList.length; i++) {
- fnGetElementUIN(externalBase, oNodesList.item(i));
- };
-
- //Send By Mail does not present a dialog.
-
- var sourceFolder = null;
- var ctlTree = fnGetTreeHolder();
-
- if (nMode != cixSendByMail) {
-
- if (goTreeXSL == null) {
- goTreeXSL = fnCreateXMLctl();
- if (goTreeXSL == null) {
- alert(L_Unable_To_Create);
- return false;
- };
-
- //goTreeXSL.load("ctTree.xsl");
- goTreeXSL.load(top.document.frames.ctToolBars.document.all.ctTree.XMLDocument);
-
-
- }
-
-
- var ctDATABASE =
- externalBase.selectSingleNode("/root/CogTracker:ctDATABASE");
-
- var oCurrentFolderUIN = parseInt(ctDATABASE.getAttribute(cxbiAttCurrentNode));
- if (isNaN(oCurrentFolderUIN)) {
- oCurrentFolderUIN = ctDATABASE.getAttribute(cxbiAttUIN);
- ctDATABASE.setAttribute(cxbiAttCurrentNode, oCurrentFolderUIN);
- };
-
- var ctCurFolder =
- externalBase.selectSingleNode("//*[@UIN='" + oCurrentFolderUIN + "']");
- if (ctCurFolder == null) {
- oCurrentFolderUIN = ctDATABASE.getAttribute(cxbiAttUIN);
- ctDATABASE.setAttribute(cxbiAttCurrentNode, oCurrentFolderUIN);
- };
-
-
- var szHTML = externalBase.transformNode(goTreeXSL);
- if (szHTML == null || szHTML == "") {
- alert(L_Transform_Failed);
- return false;
- };
-
- var args = new Object();
- args.XMLbase = goBase;
- args.TreeHTML = new String(szHTML);
-
- switch (nMode) {
- case cixImport:
- args.nDialogMode = cmtfFolderImport;
- break;
-
- case cixExport:
- args.nDialogMode = cmtfFolderExport;
- break;
- };
-
- ctlTree = fnGetTreeHolder();
-
- args.sourceFolder = null;
- args.internalDB = goBase;
- args.externalDB = externalBase;
- args.internalFolder = ctlTree.all.FoldersTree.GetCurrentNodeUIN();
-
- var oResult = showModalDialog("ctMoveToFolder.htm", args,
- "help:no; resizable:no; status:no;");
-
- if (oResult == null || oResult.oFolder == null)
- return false;
-
- sourceFolder = oResult.oFolder;
-
- /**/
- }
- else {
- ctlTree = fnGetTreeHolder();
- var ctDATABASE =
- externalBase.selectSingleNode("/root/CogTracker:ctDATABASE");
-
- sourceFolder = fnGetElementUIN(goBase, ctDATABASE);
-
- //Remove Unsorted Node
- var ctUNSORTED =
- externalBase.selectSingleNode("/root/CogTracker:ctDATABASE/CogTracker:ctNODE[@IsUnsortedNode]");
- if (ctUNSORTED != null){
- ctUNSORTED.parentNode.removeChild(ctUNSORTED);
- };
- };
-
-
-
- var ctfResult = fnPrepareToChangeDatabase();
- if (ctfResult == ctfFailure) {
- return false;
- };
-
- if ( ! bExternalIsInternal) {
-
- try {
- fnGetHelperObject().LockFile(ctlBrowser.FileName);
- }
- catch (err) {
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- alert(L_Failed_To_Lock_File);
-
- return false;
- };
- bExternalLocked = true;
- };
-
- var bError = false;
-
- try {
- tmpBase = fnCreateXMLctl();
- if (tmpBase == null) {
- throw(L_Unable_To_Create);
- };
- goBase.save(tmpBase);
-
-
- //Just to be sure...
- ctlTree = fnGetTreeHolder();
- var destinationFolder = ctlTree.all.FoldersTree.GetCurrentNodeUIN();
-
- var sourceNode = externalBase.selectSingleNode(
- "/root/CogTracker:ctDATABASE[@UIN='" +
- sourceFolder + "']|//CogTracker:ctNODE[@UIN='" +
- sourceFolder + "']");
- if (sourceNode == null) {
- throw(L_Folder_Not_Found);
- };
-
- var destinationNode = tmpBase.selectSingleNode(
- "/root/CogTracker:ctDATABASE[@UIN='" +
- destinationFolder + "']|//CogTracker:ctNODE[@UIN='" +
- destinationFolder + "']");
- if (destinationNode == null) {
- throw(L_Folder_Not_Found);
- };
-
- switch (nMode) {
- case cixImport:
- if (fnAddNodeData(tmpBase, destinationNode,
- externalBase, sourceNode, true)) {
- oldBase = goBase;
- goBase = tmpBase;
-
- fnSaveChangedDatabase();
-
- if (bExternalLocked)
- fnGetHelperObject().UnlockFile(sExternalPath);
-
- fnLoadFile(gsCurrentPath);
- }
- else {
-
- throw(L_FAILED_TO_ADD_NODE);
- };
- break;
-
- case cixExport:
- case cixSendByMail:
-
- if (fnAddNodeData(externalBase, sourceNode,
- tmpBase, destinationNode, true)) {
-
- if (nMode == cixSendByMail) {
- //Mark added folder as Unsorted Node
- var ctUNSORTED =
- externalBase.selectSingleNode("/root/CogTracker:ctDATABASE/CogTracker:ctNODE");
- if (ctUNSORTED != null){
- ctUNSORTED.setAttribute(cxbiAttUnsorted, "1");
- };
- };
-
- fnIncrementTimeStamp(externalBase);
-
- externalBase.save(sExternalPath);
-
- fnGetHelperObject().DoSendChangeNotification(
- sExternalPath, -1);
-
- if (bExternalLocked) {
- fnGetHelperObject().UnlockFile(sExternalPath);
- }
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- if (bExternalIsInternal) {
- fnLoadFile(gsCurrentPath);
- };
- }
- else {
- throw(L_FAILED_TO_ADD_NODE);
- };
- break;
- };
-
- //TEMP:
- //fnGetHelperObject().UnlockFile(gsCurrentPath);
- }
- catch(err) {
- if (oldBase != null) {
- goBase = oldBase;
- };
-
- fnGetHelperObject().UnlockFile(gsCurrentPath);
-
- if (bExternalLocked)
- fnGetHelperObject().UnlockFile(sExternalPath);
-
- if (err != null && err != "") {
- if (err.description != null) {
- alert(L_OP_FAILED + err.description);
- }
- else {
- alert(err);
- };
- };
-
- bError = true;
-
- };
- //NOTE: this code gets executed even when error occurs. Beware!
-
-
- tmpBase = oldBase = null;
-
- return (!bError);
- };
-
-
- function fnAddNodeData(someDestBase, someDestNode, someSrcBase, someSrcNode,
- bRecursive)
- {
- var ctNewNode = someDestBase.createElement(cxbiNODE);
-
- var NewUIN = fnCreateNewUIN(someDestBase);
- ctNewNode.setAttribute(cxbiAttUIN, NewUIN);
- ctNewNode.setAttribute(cxbiAttName, someSrcNode.getAttribute(cxbiAttName));
- ctNewNode.text = "\n\t";
-
- someDestNode.appendChild(ctNewNode);
-
- var oFragmentsList = someSrcNode.selectNodes("./CogTracker:ctFRAGMENT");
- for (var i = 0; i < oFragmentsList.length; i++) {
- var ctNewFragment = someDestBase.createElement(cxbiFRAGMENT);
-
- var NewUIN = fnCreateNewUIN(someDestBase);
- ctNewFragment.setAttribute(cxbiAttUIN, NewUIN);
-
- ctNewFragment.setAttribute(cxbiAttName,
- oFragmentsList.item(i).getAttribute(cxbiAttName));
- ctNewFragment.setAttribute(cxbiAttComment,
- oFragmentsList.item(i).getAttribute(cxbiAttComment));
- ctNewFragment.setAttribute(cxbiAttText,
- oFragmentsList.item(i).getAttribute(cxbiAttText));
- ctNewFragment.setAttribute(cxbiAttURL,
- oFragmentsList.item(i).getAttribute(cxbiAttURL));
-
- var strDate = oFragmentsList.item(i).getAttribute(cxbiAttDate);
- if (strDate != null)
- ctNewFragment.setAttribute(cxbiAttDate, strDate);
-
- ctNewNode.appendChild(ctNewFragment);
- }
- oFragmentsList = null;
-
- var oNodesList = someSrcNode.selectNodes("./CogTracker:ctNODE");
-
- if (bRecursive) {
- for (var i = 0; i < oNodesList.length; i++) {
- if ( ! fnAddNodeData(someDestBase, ctNewNode, someSrcBase, oNodesList.item(i),
- bRecursive) ) {
-
- return false;
- };
- };
- };
-
- return true;
- };
-
-
- function fnHTMLExport() {
-
- var nCurFolderUIN = fnGetTreeHolder().all.FoldersTree.GetCurrentNodeUIN();
-
- var ctFOLDER = goBase.selectSingleNode(
- "/root/CogTracker:ctDATABASE[@UIN='" + nCurFolderUIN + "']|"+
- "//CogTracker:ctNODE[@UIN='" + nCurFolderUIN + "']");
- if ( ctFOLDER == null) {
- alert(L_Folder_Not_Found);
- return;
- };
-
- var ctFragment = ctFOLDER.selectSingleNode(".//CogTracker:ctFRAGMENT");
- if (ctFragment == null) {
- alert(L_NOTHING_TO_EXPORT_TO_HTML);
- return;
- };
- if ( ! fnBrowseForFile(gsCurrentPath, L_Export_Dialog_Title, L_HTML_EXT, L_HTML_FILTER, true) ) {
-
- return false;
- };
-
- var ctlBrowser = fnGetBrowserObject();
-
- var sFilePath = ctlBrowser.FileName;
-
- var oXMLtoHTML = fnCreateXMLctl();
- if (oXMLtoHTML == null) {
- alert(L_Unable_To_Create);
- return;
- };
-
- //oXMLtoHTML.load("ctHTML.xsl");
- oXMLtoHTML.load(top.document.frames.ctToolBars.document.all.ctHTML.XMLDocument);
-
-
- var oSorts = oXMLtoHTML.selectNodes("//xsl:apply-templates[@select='./CogTracker:ctFRAGMENT']/@order-by");
- for (i = 0; i < oSorts.length; i++) {
- oSorts[i].nodeValue = arDirectionSigns[gnSortDirection].toString() +
- arAttributeNames[gnSortBy].toString();
- };
-
- var ssnFieldsParent =
- oXMLtoHTML.selectSingleNode("//TABLE[@CLASS='Fragment']/TBODY");
- var ssnTitleAndDate =
- oXMLtoHTML.selectSingleNode("//TR[@CLASS='TitleAndDate']");
-
- var ssnText = oXMLtoHTML.selectSingleNode("//TR[@CLASS='Text']");
- var ssnComment = oXMLtoHTML.selectSingleNode("//TR[@CLASS='Comment']");
- var ssnBaseURL = oXMLtoHTML.selectSingleNode("//xsl:if[@expr='fnIsURLEmpty(this)']");
-
- var oVisibilityOptions = new Object();
- oVisibilityOptions.nMode = cvoHTMLExport;
-
- oVisibilityOptions.bShowContents = !fnGetSetting(ccsHTMLVHideContents , 0, true);
- oVisibilityOptions.bShowFieldNames = !fnGetSetting(ccsHTMLVHideFieldNames , 0, true);
- oVisibilityOptions.bShowTitle = !fnGetSetting(ccsHTMLVHideTitle , 0, true);
- oVisibilityOptions.bShowText = !fnGetSetting(ccsHTMLVHideText , 0, true);
- oVisibilityOptions.bShowComment = !fnGetSetting(ccsHTMLVHideComment , 0, true);
- oVisibilityOptions.bShowURL = !fnGetSetting(ccsHTMLVHideURL , 0, true);
-
- if ( ( ! oVisibilityOptions.bShowTitle ) &&
- ( ! oVisibilityOptions.bShowText ) &&
- ( ! oVisibilityOptions.bShowComment ) ) {
-
- oVisibilityOptions.bShowContents =
- oVisibilityOptions.bShowFieldNames =
- oVisibilityOptions.bShowTitle =
- oVisibilityOptions.bShowText =
- oVisibilityOptions.bShowComment =
- oVisibilityOptions.bShowURL = true;
- };
-
-
- var result = showModalDialog("ctVisibilityOptions.htm",
- oVisibilityOptions,
- "help:no; resizable:no; status:no;");
-
- if ( ! result ) {
- return;
- };
-
- if ( ( ! oVisibilityOptions.bShowTitle) &&
- ( ! oVisibilityOptions.bShowText) &&
- ( ! oVisibilityOptions.bShowComment ) ) {
-
- alert(L_NOTHING_TO_EXPORT);
- return;
- };
-
- fnSetSetting(ccsHTMLVHideContents, !oVisibilityOptions.bShowContents, true);
- fnSetSetting(ccsHTMLVHideFieldNames, !oVisibilityOptions.bShowFieldNames, true);
- fnSetSetting(ccsHTMLVHideTitle, !oVisibilityOptions.bShowTitle, true);
- fnSetSetting(ccsHTMLVHideText, !oVisibilityOptions.bShowText, true);
- fnSetSetting(ccsHTMLVHideComment, !oVisibilityOptions.bShowComment, true);
- fnSetSetting(ccsHTMLVHideURL, !oVisibilityOptions.bShowURL, true);
-
- if ( ! oVisibilityOptions.bShowTitle ) {
- if (oVisibilityOptions.bShowURL) {
-
- var ssnBaseURLHolder = null;
- if ( oVisibilityOptions.bShowText) {
- ssnBaseURLHolder = ssnText;
- }
- else if (oVisibilityOptions.bShowComment) {
- ssnBaseURLHolder = ssnComment;
- };
-
- if (ssnBaseURLHolder) {
- var ssnFieldData =
- ssnBaseURLHolder.selectSingleNode(".//TD[@CLASS='FieldData']");
- ssnFieldData.insertBefore(
- ssnBaseURL.parentNode.removeChild(ssnBaseURL),
- ssnFieldData.firstChild);
- };
- };
-
- ssnFieldsParent.removeChild(ssnTitleAndDate);
- }
- else if ( ! oVisibilityOptions.bShowURL) {
- ssnBaseURL.parentNode.removeChild(ssnBaseURL);
- };
-
- if ( ! oVisibilityOptions.bShowText ) {
- ssnFieldsParent.removeChild(ssnText);
- };
-
- if ( ! oVisibilityOptions.bShowComment ) {
- ssnFieldsParent.removeChild(ssnComment);
- };
-
- if ( ! oVisibilityOptions.bShowFieldNames ) {
- ssnFieldsParent.parentNode.setAttribute("COLS", 1);
-
- var allFieldTitles = ssnFieldsParent.selectNodes(
- "//TD[@CLASS='FieldTitle']");
- for (var i = 0; i < allFieldTitles.length; i ++) {
- allFieldTitles[i].parentNode.removeChild(allFieldTitles[i]);
- };
-
- var allFieldDatas = ssnFieldsParent.selectNodes(
- "//TD[@CLASS='FieldData']");
- for (var i = 0; i < allFieldDatas.length; i ++) {
- allFieldDatas[i].setAttribute("WIDTH", "99%");
- };
-
- };
-
- if ( ! oVisibilityOptions.bShowContents ) {
- var ssnContentsSection = oXMLtoHTML.selectSingleNode(
- "//xsl:if[@test='./CogTracker:ctNODE//CogTracker:ctFRAGMENT']");
- if (ssnContentsSection) {
- ssnContentsSection.parentNode.removeChild(ssnContentsSection);
- };
- };
-
- var ssnFilterPoint =
- oXMLtoHTML.selectSingleNode("//xsl:template[@match='root']/xsl:apply-templates/@select");
-
- ssnFilterPoint.nodeValue = "/root/CogTracker:ctDATABASE[@UIN='"
- + goCurrentFolderUIN + "']|//CogTracker:ctNODE[@UIN='"
- + goCurrentFolderUIN + "']";
-
- var ctNode = goBase.selectSingleNode("/root/CogTracker:ctDATABASE[@UIN='"
- + goCurrentFolderUIN + "']|//CogTracker:ctNODE[@UIN='"
- + goCurrentFolderUIN + "']");
-
-
- var sHTML = goBase.transformNode(oXMLtoHTML);
- if (sHTML == null || sHTML == "") {
-
- alert(L_Transform_Failed);
- return;
- };
-
- sHTML = sHTML.replace(/!BR\/!/g, "<BR/>");
- sHTML = fnSpecialRemoveWhiteSpaces(sHTML);
-
- var bUnicode = true;
- try {
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var ts = fso.CreateTextFile(ctlBrowser.FileName, true, bUnicode);
- ts.Write(sHTML);
- ts.Close();
-
- }
- catch (err) {
- alert(L_Unable_To_Save_A_File + ctlBrowser.FileName +
- L_HTML_FAIL_DIAG);
- return;
- };
- };
-
- /*SendByMail-related return codes*/
- var smcmOK = 0;
- var smcmCancel = 1;
- var smcmNoClients = 2;
- var smcmNoDefaultClient = 3;
- var smcmNoDLL = 4;
- var smcmNoInterface = 5;
- var smcmMAPI_E_ATTACHMENT_OPEN_FAILURE = 6;
- var smcmMAPI_E_ATTACHMENT_WRITE_FAILURE = 7;
- var smcmMAPI_E_FAILURE = 8;
- var smcmMAPI_E_INSUFFICIENT_MEMORY = 9;
- var smcmMAPI_E_LOGIN_FAILURE = 10;
- var smcmMAPI_E_USER_ABORT = 11;
- var smcmMAPI_E_UNKNOWN = 12;
- var smcmMAPI_E_ATTACHMENT_NOT_FOUND = 14;
-
- var sbmDefault = 1;
- var sbmSelected = 2;
-
- function fnSendByMail() {
-
- fnPerformSendByMail(sbmDefault);
- };
-
- function fnSelectClientAndSendByMail() {
-
- fnPerformSendByMail(sbmSelected);
- };
-
- var L_UnknownMailClient = "Mail client\n";
- var L_MailClient = " mail client\n";
- var L_ReportedThat = "reported that there was\n\n";
- var L_WhileSending = "\n\nwhile attaching file to a message.";
- var L_NoMailClients = "There are no compatible mail clients found.";
- var L_NoDefaultClient = "There are no default mail client selected.";
-
- var L_NoDLL = "does not define appropriate library\nfor sending files.";
- var L_NoInterface = "does not define appropriate interface\nfor sending files.";
-
- var L_GeneralError = "a general error";
- var L_AttOpenFail = "attachment open failure";
- var L_AttWriteFail = "attachment write failure";
- var L_InsuffisientMem = "insuffisient memory";
- var L_LoginFailure = "login failure";
- var L_UserAbort = "user abort";
- var L_AttNotFound = "attachment not found";
-
-
- function ReportSendByMailError(someCode) {
- var oHelper = fnGetHelperObject();
-
- var sClientName = oHelper.MailClientName;
-
- var sMessage = "";
-
- if (someCode == smcmNoClients) {
- alert(L_NoMailClients);
- return;
- }
- else if (someCode == smcmNoDefaultClient) {
- alert(L_NoDefaultClient);
- return;
- };
-
-
-
- if ( sClientName != "" && sClientName != null) {
- sMessage = sClientName + L_MailClient;
- }
- else {
- sMessage = L_UnknownMailClient;
- };
-
- switch(someCode) {
- case smcmNoDLL:
- sMessage += L_NoDLL;
- break;
-
- case smcmNoInterface:
- sMessage += L_NoInterface;
- break;
-
-
- case smcmCancel:
- case smcmMAPI_E_FAILURE:
- sMessage += L_ReportedThat + L_GeneralError + L_WhileSending;
- break;
-
- case smcmMAPI_E_ATTACHMENT_OPEN_FAILURE:
- sMessage += L_ReportedThat + L_AttOpenFail + L_WhileSending;
- break;
-
- case smcmMAPI_E_ATTACHMENT_WRITE_FAILURE:
- sMessage += L_ReportedThat + L_AttWriteFail + L_WhileSending;
- break;
-
- case smcmMAPI_E_ATTACHMENT_NOT_FOUND:
- sMessage += L_ReportedThat + L_AttNotFound + L_WhileSending;
- break;
- case smcmMAPI_E_FAILURE:
- sMessage += L_ReportedThat + L_GeneralError + L_WhileSending;
- break;
-
- case smcmMAPI_E_INSUFFICIENT_MEMORY:
- sMessage += L_ReportedThat + L_InsuffisientMem + L_WhileSending;
- break;
-
- case smcmMAPI_E_LOGIN_FAILURE:
- sMessage += L_ReportedThat + L_LoginFailure + L_WhileSending;
- break;
-
- case smcmMAPI_E_USER_ABORT:
- sMessage += L_ReportedThat + L_UserAbort + L_WhileSending;
- break;
-
- case smcmMAPI_E_UNKNOWN:
- sMessage += L_ReportedThat + L_GeneralError + L_WhileSending;
- break;
- default:
- sMessage += L_ReportedThat + L_GeneralError + L_WhileSending;
- break;
- };
-
- alert(sMessage);
- };
-
- function fnPerformSendByMail(someMode) {
-
- var oHelper = fnGetHelperObject();
-
- var nResult = 0;
- switch(someMode) {
- case sbmDefault:
- top.fnGetMainToolbar().all.SendByMailButton.ct_unstick();
-
- nResult = oHelper.SetupDefaultMailClient();
-
- if (nResult != smcmOK) {
- ReportSendByMailError(nResult);
- return;
- };
- break;
-
- case sbmSelected:
-
- var MenuButton = fnGetMainToolbar().all.SendByMailButton;
-
-
- var nLeft = 0; var nTop = 0;
-
- nLeft += MenuButton.offsetLeft + 0 +
- MenuButton.document.body.offsetLeft +
- MenuButton.document.parentWindow.screenLeft;
-
- nTop += MenuButton.offsetTop + MenuButton.offsetHeight +
- MenuButton.document.body.offsetTop +
- MenuButton.document.parentWindow.screenTop;
-
- nResult = oHelper.ShowMailClientsMenu(nLeft, nTop, "");
-
- top.fnGetMainToolbar().all.ShowMailClientsButton.ct_unstick();
-
- if (nResult != smcmOK && nResult != smcmCancel) {
- ReportSendByMailError(nResult);
- return;
- };
- if (nResult == smcmCancel) {
- return;
- };
- break;
-
- default:
- return;
- };
-
-
-
- var sPath = gsCurrentPath;
-
- // sPath = "\\sad.qqq\\ewrwer";
- // sPath = "\\";
- // sPath = "\\.qq";
-
- var nFileNameStart = sPath.lastIndexOf("\\");
- if (nFileNameStart == -1) {
- nFileNameStart = 0;
- }
- else {
- nFileNameStart++;
- };
- var nFileNameEnd = sPath.lastIndexOf(".");
- if ( ( nFileNameEnd == -1 ) || ( nFileNameEnd < nFileNameStart) ) {
- nFileNameEnd = sPath.length;// - nFileNameStart + 1;
- }
- else {
- };
-
- var sFileName = sPath.slice(nFileNameStart, nFileNameEnd);
- var sFileExt = sPath.slice(nFileNameEnd + 1);
-
-
-
- var sTempPath = oHelper.GetTempFilePath(sFileName, sFileExt);
- if (sTempPath == null || sTempPath == "" ) {
-
- alert(L_FailedToGenerateTempFile);
- return;
- };
-
-
- //Turned off, because Outlook Express, per ex, does not return until closed.
- // fnShowWaitCursor();
-
- if (fnPerformImportExport(cixSendByMail, sTempPath)) {
-
- nResult = oHelper.SendFileToMailClient(sTempPath, oHelper.MailClientName,
- oHelper.MailClientDLLPath);
- // fnHideWaitCursor();
-
- if (nResult != smcmOK && nResult != smcmMAPI_E_USER_ABORT) {
- ReportSendByMailError(nResult);
-
- return;
- };
- }
- else {
- // fnHideWaitCursor();
- };
-
- };
-
- function fnOnBusy() {
- var sFilePath = fnGetHelperObject().FileOpenFilePath;
- if ( (gsCurrentPath.toUpperCase() != sFilePath.toUpperCase()) &&
- (sFilePath != "") )
- alert(L_BUSY);
- };
-
- function fnOnFileOpenRequest() {
-
- var sFilePath = fnGetHelperObject().FileOpenFilePath;
-
- if ( sFilePath != "" &&
- gsCurrentPath.toUpperCase() != sFilePath.toUpperCase()) {
-
- var ctfResult = fnPrepareToChangeDatabase();
- if (ctfResult != ctfFailure) {
- fnSaveChangedDatabase();
- };
-
- goCurrentFolderUIN = -1;
- if ( (sFilePath.charAt(0) == '"') && (sFilePath.charAt(sFilePath.length - 1) == '"')) {
- sFilePath = sFilePath.substr(1, sFilePath.length - 2);
- }
- fnLoadFile(sFilePath);
- }
-
- };
-
- function fnShowAbout() {
-
- var NewDialogHeight = "386px";
- var NewDialogWidth = "500px";
- /* var xPos = document.body.clientLeft +
- document.body.clientWidth/2;
- var yPos = document.body.clientTop +
- document.body.clientHeight/2;
-
- xPos -= parseInt(NewDialogWidth.slice(0,NewDialogWidth.length-2), 10)/2;
- yPos -= parseInt(NewDialogHeight.slice(0,NewDialogHeight.length-2), 10)/2;
- */
- showModalDialog("ctAbout.htm", top.oHTA.version,
- /* "help:no; resizable:no; status:no; center:no;" +
- " dialogLeft:" + xPos.toString() + "px;" +
- "dialogTop:" + yPos.toString() + "px;" +
- */ "help:no; resizable:no; status:no; center:yes; " +
- "dialogHeight:" + NewDialogHeight + ";" +
- "dialogWidth:" + NewDialogWidth + ";");
- };
-
- function fnShowHelp() {
-
- fnShowTheHelp();
-
- };