home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 December / CMCD1203.ISO / Software / Shareware / Programare / toolkit / toolkitsetup.msi / Instal01.cab / _512F417A47084B17A1F025AB604B2E2C < prev    next >
Text File  |  2003-10-22  |  8KB  |  237 lines

  1. //replacement regular expressions
  2. var expUpToPage = /^.*page/i;
  3. var expAOrB = /(a|b)$/i;
  4. var lessonCompleted = false;
  5. var currentLessonPage;
  6. var popupWindowContents = "";
  7. var popupWin = null;
  8. var isNav = (document.all) ? false: true;
  9. var childRef;
  10.  
  11. if(parent.frames.lessonFrame != null)
  12.     childRef = eval("parent.frames.lessonFrame");
  13.  
  14. //Called by User in Lesson Page, used to retrieve the MODULE name to be written to the title area
  15. function txtModuleName()
  16. {
  17.     return objLessonModule.moduleName;
  18. }
  19.  
  20. //Called by User in Lesson Page, used to retrieve the CopyRight statement
  21. function txtCopyRight()
  22. {
  23.     var theReturn = (copyright != "") ? copyright: " ";
  24.     return theReturn;
  25. }
  26.  
  27. //Called by User in Lesson Page, used to retrieve the PAGE name to be written to the subtitle area
  28. function txtTitleLabel()
  29. {
  30.     var pageNum = getPageNum();
  31.     var theReturn;
  32.     if(pageNum <= topPage)
  33.         theReturn = (pageNum < objLessonModule.pages.length) ? objLessonModule.pages[pageNum].pageName: "Registration";
  34.     else
  35.         theReturn = "Registration";
  36.     return theReturn;
  37. }
  38.  
  39. //OBJECT: Lesson Object created by USER in inc_ModuleInfo
  40. function objLesson(txtModuleName)
  41. {
  42.     this.moduleName = txtModuleName;
  43.     this.pages = new Array();
  44.     this.theStatus = "incomplete";
  45.     this.getStatus = checkStatus;
  46.     this.setCurrentPageCompletion = compPage;
  47.     this.addPage = setPage;
  48.     this.isCompleted = false;
  49. }
  50.  
  51. //OBJECT: Lesson Page Object created by USER in inc_ModuleInfo
  52. function objLessonPage(idxNumber, txtPageName)
  53. {
  54.     this.pageNumber = idxNumber;
  55.     this.pageName = txtPageName;
  56.     this.linkPage = "page" + idxNumber;
  57.     this.isCompleted = false;
  58.     return this;
  59. }
  60.  
  61. //Called by objLesson(): addPage() method to create a Page
  62. function setPage(idxIndex, txtPageName)
  63. {
  64.     this.pages[this.pages.length] = new objLessonPage(idxIndex, txtPageName);
  65. }
  66.  
  67. //Called by objLesson(): getStatus(), returns "completed"/"incomplete" depending upon whether or not the Lesson is completed
  68. function checkStatus()
  69. {
  70.     var iterator;
  71.     var theResult = "";
  72.     var theTest = true;
  73.     for(iterator = 0; iterator < this.pages.length; iterator++)
  74.         if(!this.pages[iterator].isCompleted)
  75.             theTest = false;
  76.     this.isCompleted = theTest;
  77.     this.theStatus = (theTest) ? "completed": this.theStatus;
  78.     if(theTest)
  79.         lessonCompleted = true;
  80.     return this.theStatus;
  81. }
  82.  
  83. //Called by objLesson(): setCurrentPageCompletion(), used to set individual page completion to True
  84. function compPage()
  85. {
  86.     var pageNum = getPageNum();
  87.     if(pageNum < this.pages.length)
  88.         this.pages[pageNum].isCompleted = true;
  89.     return true;
  90. }
  91.  
  92. //Called by User in Lesson Page, used to write the "page number of pages" images
  93. function writePageInfo()
  94. {
  95.     var txtPageInfo = " ";
  96.     var currentPage = getPageNum();
  97.     if((currentPage <= topPage)&&(currentPage > 0))
  98.         txtPageInfo = 'Page ' + currentPage + ' of ' + topPage;
  99.     return(txtPageInfo);
  100. }
  101.  
  102. //Called by writeLink(), writeOutlineInfo(), showMenu(), txtTitleLabel(), compPage(), writePageInfo(), used to determine current page number
  103. function getPageNum()
  104. {
  105.     var pageNum;
  106.     if(parent.frames.lessonFrame != null)
  107.         pageNum = (expUpToPage.test(parent.frames.lessonFrame.location.href)) ? parseInt(parent.frames.lessonFrame.location.href.replace(expUpToPage, "")): objLessonModule.pages.length;
  108.     else
  109.         pageNum = 0;
  110.     return pageNum;
  111. }
  112.  
  113. //Called by User in Lesson Page, used to write navigation links
  114. function writeLink(linkDisplay)
  115. {
  116.     var theHREF;
  117.     var pageNum = getPageNum();
  118.     var theDir = linkDisplay.toLowerCase();
  119.     if(theDir == "back")
  120.     {
  121.         if(pageNum > 0)
  122.             theHREF = "<a href=\"./page" + (pageNum - 1) + ".html\" class='titleLink'>Back</a>";
  123.         else
  124.             theHREF = " ";
  125.     }else{
  126.         if(pageNum == topPage)
  127.         {
  128.             theHREF = "<a href=\"./finish.html\" class='pageLink'>Next</a>";
  129.         }else{
  130.             if(pageNum < topPage)
  131.                 theHREF = "<a href=\"./page" + (pageNum + 1) + ".html\" class='pageLink'>Next</a>";
  132.             else
  133.                 theHREF = " ";
  134.         }
  135.     }
  136.     return(theHREF);
  137. }
  138.  
  139. //Called by User in Lesson Page, used to write lesson outline
  140. function writeOutlineInfo()
  141. {
  142.     var theReturn = '';
  143.     var pageNum = getPageNum();
  144.     if(pageNum == 0)
  145.     {
  146.         var thePage;
  147.         var arrReturn = new Array();
  148.         arrReturn[arrReturn.length] = "<b>Contents</b><ul>";
  149.         for(thePage = 0; thePage < objLessonModule.pages.length; thePage++)
  150.             if(thePage == 0)
  151.                 arrReturn[arrReturn.length] = objLessonModule.pages[thePage].pageName;
  152.             else
  153.                 arrReturn[arrReturn.length] = '<a href="page' + thePage + '.html">' + objLessonModule.pages[thePage].pageName + "</a>";
  154.         theReturn = arrReturn.join("<li>") + "</ul>";
  155.     }
  156.     return theReturn;
  157. }
  158.  
  159. //Called by User in Lesson Page, used to create and open Menu popupWindow
  160. function showMenu()
  161. {
  162.     closePopup();
  163.     var pageNum = getPageNum();
  164.     var htmlHeader = "<br clear='all'>\n<table width='90%' border=0 cellpadding=4 cellspacing=0 align='center' class='popupTable'>\n<tr>\n" +
  165.         "<td bgcolor='#336699' class='popupTitle'>\n";
  166.     var htmlTween = "</td>\n</tr>\n<tr>\n<td valign='middle'>\n";
  167.     var arrReturn = new Array();
  168.     var thePage;
  169.     for(thePage = 0; thePage < objLessonModule.pages.length; thePage++)
  170.         arrReturn[arrReturn.length] = "<a href=\"#\" onclick=\"opener.childRef.location.href='page" + thePage + ".html';\">" + objLessonModule.pages[thePage].pageName + "</a>";
  171.     var theMenu = arrReturn.join("<br>") + "<br clear='all'>";
  172.     var htmlFooter = "</td></tr><tr><td align='right'><a href='javascript: window.close();'>Close Window</a> </td>\n</tr>\n</table>";
  173.     var theHeight = 90 + ((topPage + 1) * 14);
  174.     if(theHeight > 600)
  175.         theHeight = 600;
  176.     window.popupWindowContents = htmlHeader + "Contents" + htmlTween + theMenu + htmlFooter;
  177.     window.setTimeout("openPopup(400, " + theHeight + ")", 500);
  178.     return true;
  179. }
  180.  
  181. //Called by <array>.Sort(), used to sort arrays of objects by 'name'
  182. function byName(a, b)
  183. {
  184.     var anew = a.term.toLowerCase();
  185.     var bnew = b.term.toLowerCase();
  186.     if (anew < bnew)
  187.         return -1;
  188.     if (anew > bnew)
  189.         return 1;
  190.     return 0;
  191. }
  192.  
  193. //Called by showMenu(), showActPopup(), showMainGlossary(), showGlossaryPopup(), used to open the popupWindow
  194. function openPopup(widthVal, heightVal)
  195. {
  196.     var x, y, wdt, hgt;
  197.     wdt = (widthVal) ? widthVal: 340;
  198.     hgt = (heightVal) ? heightVal: 300;
  199.     x = ((window.screen.width - wdt) / 2);
  200.     y = ((window.screen.height - hgt) / 2);
  201.     x = (x < 0) ? 0: x;
  202.     y = (y < 0) ? 0: y;
  203.     window.popupWin = window.open('popupWin.html', 'PopupWindow', 'toolbar=no,status=no,menubar=no,resizable=yes,scrollbars=yes,location=no,top=' + y + ',left=' + x + ',width=' + wdt + ',height=' + hgt);
  204.     window.popupWin.focus();
  205.     return true;
  206. }
  207.  
  208. //Called by showMenu(), showActPopup(), showMainGlossary(), showGlossaryPopup(), used to close an open popupWindow
  209. function closePopup()
  210. {
  211.     if(window.DefWin == null)
  212.         if(window.opener)
  213.             if(window.opener != null)
  214.                 if(window.opener.location != null)
  215.                     window.DefWin = window.opener.DefWin;
  216.     if(window.DefWin != null)
  217.         if(window.DefWin.closed)
  218.         {
  219.             window.DefWin = null;
  220.         }else{
  221.             window.DefWin.close();
  222.             window.DefWin = null;
  223.         }
  224.     if(window.DefWin != null)
  225.         window.DefWin = null;
  226.     return true;
  227. }
  228.  
  229. //Called by writeTermHTML(), used to generate a random link name
  230. function getRandom(low, high)
  231. {
  232.     var range = high - low + 1;
  233.     return Math.floor(Math.random() * range) + low;
  234. }
  235.  
  236. //Called by User in frame pages, used to indicate that this script has loaded
  237. var isLessonLoaded = true;