home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Full / Serif Page Plus 8 / data1.cab / Help / common / common.chm / w002_script.js < prev    next >
Encoding:
JavaScript  |  2006-08-24  |  8.4 KB  |  278 lines

  1. // MODULE:    
  2. // DESCRIPTION: functions 
  3. // FACILITY:    Serif PagePlus 7
  4. // DATE:    20 October 1999
  5.  
  6.  
  7. var decimalPointDelimiter = ".";
  8. var abspath;
  9. var SaveStudioBarWidth=0;
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. // ---------------------------------------------------------------------------
  19. // FUNCTION:    mOut()
  20. // DESCRIPTION: Changes the apperance of a text object to it's original
  21. //        settings.
  22.  
  23. function mOut() {
  24.     window.event.srcElement.style.color = "black"
  25.     window.event.srcElement.style.textDecoration = "none"
  26. }
  27.  
  28. // ---------------------------------------------------------------------------
  29. // FUNCTION:    mOver()
  30. // DESCRIPTION: Changes the apperance of a text object to a "highlighted"
  31. //        settings.
  32.  
  33. function mOver() {
  34.     window.event.srcElement.style.color = "orange"
  35.     window.event.srcElement.style.textDecoration = "underline"
  36.     window.event.srcElement.style.cursor = "hand"
  37. }
  38.  
  39. // ---------------------------------------------------------------------------
  40. // Returns true if string is empty or whitespace characters only.
  41. function isWhitespace (str)
  42. {   var i;
  43.  
  44.     if (isEmpty(str)) return true;
  45.  
  46.     for (i = 0; i < str.length; i++) {   
  47.         // Check that current character isn't whitespace.
  48.         var c = str.charAt(i);
  49.         if (whitespace.indexOf(c) == -1) return false;
  50.     }
  51.  
  52.     // All characters are whitespace.
  53.     return true;
  54. }
  55.  
  56.  
  57. // ---------------------------------------------------------------------------
  58. // Returns true if character c is a digit (0 -> 9)
  59. function isDigit (c) {   
  60.     return ((c >= "0") && (c <= "9"))
  61. }
  62.  
  63.  
  64.  
  65. // ---------------------------------------------------------------------------
  66. // isFloat (STRING s [, BOOLEAN emptyOK])
  67. // 
  68. // True if string s is an unsigned floating point (real) number. 
  69. //
  70. // Also returns true for unsigned integers. If you wish
  71. // to distinguish between integers and floating point numbers,
  72. // first call isInteger, then call isFloat.
  73.  
  74. function isFloat (s)
  75. {   var i;
  76.     var seenDecimalPoint = false;
  77.  
  78.     //if (isEmpty(s)) 
  79.     //   if (isFloat.arguments.length == 1) return defaultEmptyOK;
  80.     //   else return (isFloat.arguments[1] == true);
  81.  
  82.     if (s == decimalPointDelimiter) return false;
  83.  
  84.     // Search through string's characters one by one
  85.     // until we find a non-numeric character.
  86.     // When we do, return false; if we don't, return true.
  87.  
  88.     for (i = 0; i < s.length; i++)
  89.     {   
  90.         // Check that current character is number.
  91.         var c = s.charAt(i);
  92.  
  93.         if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
  94.         else if (!isDigit(c)) return false;
  95.     }
  96.  
  97.     // All characters are numbers.
  98.     return true;
  99. }
  100.  
  101.  
  102. // ---------------------------------------------------------------------------
  103. // FUNCTION:    Get_TimeDate()
  104. // DESCRIPTION: Gets the current time and date and formats the result into
  105. //        a string based on HH:MM  DD/MM/YEAR
  106.  
  107. function Get_TimeDate() {
  108.     var DateObj   = new Date(); 
  109.     var Day, Month, Year, Minutes, Hours;
  110.  
  111.     Day   = DateObj.getDate();
  112.     Month = DateObj.getMonth();
  113.     Year  = DateObj.getYear();    
  114.  
  115.     Minutes = DateObj.getMinutes();
  116.     Hours   = DateObj.getHours();
  117.  
  118.     if (Minutes < 10) {
  119.     Minutes = "0"+Minutes;
  120.     }
  121.  
  122.     DateString = Hours +":"+ Minutes +"  "+ Day +"/"+ Month +"/"+ Year;        
  123.  
  124.     return DateString;
  125. }
  126.  
  127. // -------------------------------------------------------------------------------------------------------
  128. // FUNCTION:    get_absolute_path()
  129. // DESCRIPTION: Retrieves an absolute path to the folder where the current file is located.
  130. // AUTHOR:    Rob Nicholls
  131. // CHANGES:    Global variable: abspath
  132. // -------------------------------------------------------------------------------------------------------
  133. function get_absolute_path() {
  134.     var temp, strEnd, strStart;
  135.  
  136.     temp        = this.location.pathname;
  137.     strEnd        = temp.length;
  138.     strStart    = temp.lastIndexOf("\\");
  139.     abspath        = temp.substring(1,((temp.length)-(strEnd-strStart)));
  140.     return;
  141. }
  142.  
  143. // -------------------------------------------------------------------------------------------------------
  144. // FUNCTION:    change_current_chm()
  145. // DESCRIPTION: Change the current URL in the browser window to the specified file, based on the value
  146. //              of "abspath". i.e. result will be "abspath"\"Page".
  147. // CHANGES:    this.location
  148. // AUTHOR:    Rob Nicholls
  149. // -------------------------------------------------------------------------------------------------------
  150. function change_current_chm( Page ) {
  151.     var temp;
  152.  
  153.     temp        = abspath +"\\"+ Page;
  154.     this.location    = temp;
  155.     return;
  156. }
  157.  
  158.  
  159. // -------------------------------------------------------------------------------------------------------
  160. // FUNCTION:    CHMStringReference( grafix )
  161. // DESCRIPTION: Returns a concatanated string to a .chm and grafix in the common folder
  162. // CHANGES:    none
  163. // RETURN VAL:    formatted absolute path and filename.
  164. // AUTHOR:    Rob Nicholls
  165. // -------------------------------------------------------------------------------------------------------
  166. function CHMStringReference( grafix ) {
  167.     //var CommonCHM = "C:/Program Files/Serif/pageplus/7.0/help/common";
  168.     var CommonCHM = theApplication.CHMDirectory;
  169.  
  170.     return "mk:@MSITStore:" + CommonCHM + "grafix.chm::" + grafix;
  171. }
  172.  
  173. // -------------------------------------------------------------------------------------------------------
  174. // FUNCTION:    CHMStringReference( grafix )
  175. // DESCRIPTION: Returns a concatanated string to a .chm and grafix in the common folder
  176. // CHANGES:    none
  177. // RETURN VAL:    formatted absolute path and filename.
  178. // AUTHOR:    Rob Nicholls
  179. // -------------------------------------------------------------------------------------------------------
  180. function CHMPageReference( page ) {
  181.     //var CommonCHM = "C:/Program Files/Serif/pageplus/7.0/help/common";
  182.     var CommonCHM = theApplication.CHMDirectory;
  183.  
  184.     return "mk:@MSITStore:" +CommonCHM +"common.chm::/" +page;
  185. }
  186.  
  187.  
  188. // -------------------------------------------------------------------------------------------------------
  189. // FUNCTION:    HideToolbarsAndTabs( void )
  190. // DESCRIPTION: Hides all the toolbars and tabs, except the wizard tab, within the current window
  191. // CHANGES:    Toolbars.visible state (boolean)
  192. // RETURN VAL:    none.
  193. // AUTHOR:    Rob Nicholls
  194. // -------------------------------------------------------------------------------------------------------
  195. function HideToolbarsAndTabs() {
  196.  
  197.     var WToolbars,WToolbars2;
  198.     var ToolbarCount, c;
  199.  
  200.     // Hide the standard tabs
  201.     //theWindow.RulersVisible     = 0;
  202.     //theWindow.StatusBarVisible    = 0;
  203.     //theWindow.MenuVisible         = 0;
  204.     //theWindow.ChangeBarVisible    = 0;
  205.  
  206.     // see how many toolbars are in the window
  207.     //WToolbars    = theWindow.Toolbars;
  208.     //ToolbarCount    = WToolbars.Count();
  209.  
  210.     // Then hide them all
  211.     //for(c=0; c<(ToolbarCount+1); c++) {        
  212.     //    WToolbars.Item(c).visible = 0;
  213.     //}
  214.  
  215.     // Hide all other elements of the studio bar
  216.     WToolbars2            = theWindow.StudioBar;
  217.     WToolbars2.Width        = 175;
  218.  
  219.     //WToolbars2.GraphicsVisible    = 0;
  220.     //WToolbars2.SchemesVisible    = 0;
  221.     //WToolbars2.PortfolioVisible    = 0;
  222.     //WToolbars2.GalleryVisible    = 0;
  223.  
  224.     // Set to Wizard mode
  225.     //theWindow.WizardMode = TRUE;
  226.  
  227.     
  228.     return;
  229. }
  230.  
  231. // -------------------------------------------------------------------------------------------------------
  232. // FUNCTION:    ShowToolbarsAndTabs( void )
  233. // DESCRIPTION: Shows all the toolbars and tabs, except the wizard tab, within the current window
  234. // CHANGES:    Toolbars.visible state (boolean)
  235. // RETURN VAL:    none.
  236. // AUTHOR:    Rob Nicholls
  237. // -------------------------------------------------------------------------------------------------------
  238. function ShowToolbarsAndTabs() {
  239.  
  240.     var WToolbars;
  241.     var ToolbarCount, c;
  242.  
  243.     // Show the standard tabs
  244.     //theWindow.RulersVisible     = 1;
  245.     //theWindow.StatusBarVisible    = 1;
  246.     //theWindow.MenuVisible         = 1;
  247.     //theWindow.ChangeBarVisible    = 1;
  248.  
  249.     // see how many toolbars are in the window
  250.     //WToolbars    = theWindow.Toolbars;
  251.     //ToolbarCount    = WToolbars.Count();
  252.  
  253.     // Then show them all
  254.     //for(c=0; c<(ToolbarCount+1); c++) {        
  255.     //    WToolbars.Item(c).visible = 1;
  256.     //}
  257.  
  258.     // Show all other elements of the studio bar
  259.     //WToolbars2    = theWindow.StudioBar;
  260.  
  261.     //alert("Setting Studio bar to = "+SaveStudioBarWidth);
  262.     //WToolbars2.Width        = SaveStudioBarWidth;
  263.  
  264.     //WToolbars2.GraphicsVisible    = 1;
  265.     //WToolbars2.SchemesVisible    = 1;
  266.     //WToolbars2.PortfolioVisible    = 1;
  267.     //WToolbars2.GalleryVisible    = 1;
  268.  
  269.     // Set to normal publication mode
  270.     //theWindow.WizardMode = FALSE;
  271.  
  272.  
  273.     return;
  274. }
  275.  
  276.  
  277.  
  278.