spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column56


Using JavaScript in HoTMetaL PRO 6.0

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

The Code

<MACRO name="On_Application_Open" lang="JScript"><![CDATA[
  // Some useful constants
  var viewWYSIWYG = 0;
  var viewTagsOn = 1;
  var viewSource = 2;
]]></MACRO> 

<MACRO name="Format Current Document" lang="JScript" id="153" desc="Apply source layout to entire document">
<![CDATA[
   if (ActiveDocument.ViewType == viewSource) {
     ActiveDocument.Layout();
   }
   else {
     Application.Alert("Applying source layout only works in source view.\nSwitch to source view and try again.");
   }
]]></MACRO>

<MACRO name="Format Current Selection" lang="JScript" id="153" desc="Apply source layout to current selection ">
<![CDATA[
   if (ActiveDocument.ViewType == viewSource) {
     Selection.Layout();
   }
   else {
     Application.Alert("Applying source layout only works in source view.\nSwitch to source view and try again.");
   }
]]></MACRO>

<MACRO name="On_Document_Open_Complete" lang="JScript"><![CDATA[
  var name = ActiveDocument.LocalFullName;
  if (Application.ReadableFileExists(name)) {  // if document has never been saved, do nothing
    Application.Run("On_Document_Save");
  }
]]></MACRO> 
 
<MACRO name="On_Document_Activate" lang="JScript" id="44" tooltip="Hide_On_Document_Activate" desc="Runs Macro: Hide_On_Document_Activate"><![CDATA[
  // Do this for local documents only
  if (ActiveDocument.FullName == ActiveDocument.LocalFullName) {
    var name = ActiveDocument.LocalFullName;
    if (Application.ReadableFileExists(name)) {  // if document has never been saved, do nothing
      var fso = new ActiveXObject("Scripting.FileSystemObject");
      var f = fso.GetFile(name);
      var newMod = Date.parse(f.DateLastModified);
      var props = ActiveDocument.CustomDocumentProperties;
      if (props.count != 0) {
        oldMod = props.Item("LastMod").value;
        if (oldMod != newMod) {
          var Yes = 6;
          var No = 7;
          var msg = "The disk version of this document has changed from the\n";
          msg += "version in memory.  Do you want to re-open the document?";
          var ret = Application.MessageBox(msg, 36, "Document Changed");
          if (ret == Yes) {
            ActiveDocument.Reload();
          }
          // Reset the timestamp regardless of the user's response
          // This will prevent the dialog from always showing
          Application.Run("On_Document_Open_Complete");
        }
      }
    }
  }
]]></MACRO>
 
<MACRO name="On_Application_Activate" lang="JScript"><![CDATA[
  Application.Run("On_Document_Activate");
]]></MACRO> 
 
<MACRO name="On_Document_Save" lang="JScript"><![CDATA[
  var fso = new ActiveXObject("Scripting.FileSystemObject");
  var f = fso.GetFile(ActiveDocument.LocalFullName);
  var mod = Date.parse(f.DateLastModified);
  var props = ActiveDocument.CustomDocumentProperties;
  if (props.count != 0) {
    props.Add("LastMod", mod);
  }
]]></MACRO> 
 
<MACRO name="On_Document_SaveAs" lang="JScript"><![CDATA[
  Application.Run("On_Document_Save");
]]></MACRO> 
 
<MACRO name="Save As Template" lang="JScript" id="90"><![CDATA[
  var obj = new ActiveXObject("HMExtras.FileDlg");
  var filter = "Web Page Template (*.htm, *.html)|*.htm;*.html|All Files (*.*)|*.*||";
  if (obj.DisplayFileDlg(0, "File Save As", filter, Application.Path + "\\Template")) {
    ActiveDocument.SaveAs(obj.FullPathName, true); // save and put on recent file list  
  }
]]></MACRO>

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior


Created: January 18, 2000
Revised: January 18, 2000

URL: http://www.webreference.com/js/column56/code1.html