home *** CD-ROM | disk | FTP | other *** search
/ Datatid 2000 #1 / Datatid-2000-01.iso / Internet / hotmetal / HM6EV.EXE / data1.cab / Programming_Samples / Scripts / Last_Modified_Date / macros.txt < prev   
Encoding:
Text File  |  1999-10-15  |  1.3 KB  |  42 lines

  1. <MACRO name="On_Application_Open" lang="JScript"><![CDATA[
  2.   // Some useful constants
  3.   var viewWYSIWYG = 0;
  4.   var viewTagsOn = 1;
  5.   var viewSource = 2;
  6.  
  7.   // InsertLastModifiedDate - inserts date just before document is saved
  8.   function InsertLastModifiedDate() {
  9.  
  10.     // Check what view we're in because we need the DOM
  11.     var viewType = ActiveDocument.ViewType;
  12.     if (viewType != viewWYSIWYG && viewType != viewTagsOn) return;
  13.     
  14.     // Look for SPAN tags with the special ID
  15.     var rng = ActiveDocument.Range;
  16.     var magicID = "SQ-LastModifiedDate";
  17.     var nodeList = ActiveDocument.getElementsByTagName("SPAN");
  18.     var i;
  19.     for (i = 0; i < nodeList.length; i++) {
  20.       var node = nodeList.item(i);
  21.       if (node.getAttribute("ID") == magicID) {
  22.  
  23.         // Replace contents of this node with the current date and time
  24.         rng.SelectBeforeNode(node);
  25.         rng.MoveToElement("SPAN");
  26.         rng.SelectContainerContents();
  27.         var d = new Date();
  28.         var timestamp = d.toLocaleString(); // use your favorite date function here
  29.         rng.TypeText(timestamp);
  30.       }
  31.     }
  32.   }
  33. ]]></MACRO> 
  34.  
  35. <MACRO name="On_Before_Document_Save" lang="JScript"><![CDATA[
  36.   InsertLastModifiedDate();
  37. ]]></MACRO> 
  38.  
  39. <MACRO name="On_Before_Document_SaveAs" lang="JScript"><![CDATA[
  40.   InsertLastModifiedDate();
  41. ]]></MACRO> 
  42.