home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / I386 / TOUR.JS_ / tour.js
Encoding:
Text File  |  2007-06-26  |  3.1 KB  |  143 lines

  1. var oTour    = new Tour;
  2. function Scene(Title, Idx, Action, Dur, TimeoutID, ShowMeAction, SoundAction)
  3. {
  4.     this.title         = Title;
  5.     this.idx        = Idx;
  6.     this.action        = Action;
  7.     this.dur        = Dur;
  8.     this.timeoutID    = TimeoutID;
  9.     this.showMe        = ShowMeAction;
  10.     this.sound        = SoundAction;
  11.     this.tremaining    = 0;
  12.     this.tstart        = 0;
  13.     this.useremaining  = false;
  14. }
  15. function Tour()
  16. {
  17.     this.curScene     = 0;
  18.     this.nextScene    = false;
  19.     this.setScene    = setScene;
  20.     this.playNextScene = playNextScene;
  21.     this.scenes     = new Array();
  22.     this.addScene     = addScene;
  23.     this.newScene     = newScene;
  24.     this.clearAllRuning = clearAllRuning;
  25.     this.playScene    = playScene;
  26.     this.play        = playTour;
  27.     this.pause        = pauseTour;
  28.     this.start        = startTour;
  29.     this.stop        = stopTour;
  30.     this.reset        = resetTour;
  31.     this.setRemaining  = setRemaining;
  32.     this.setTRemaining = setTRemaining;
  33.     this.length        = this.scenes.length;
  34.     this.clearAllSetRemaining = clearAllSetRemaining;
  35. }
  36. function newTour()
  37. {
  38.     return oTour;
  39. }
  40. function addScene(oScene)
  41. {
  42.     oTour.scenes[oTour.length++] = oScene;
  43. }
  44. function newScene(sTitle, nIdx, sAction, tDur, sSMAction, sSoundAction)
  45. {
  46.     var newScn = new Scene(sTitle, nIdx, sAction, tDur, 0, sSMAction, sSoundAction);
  47.     oTour.addScene(newScn);
  48. }
  49. function getTime()
  50. {
  51. var d = new Date();
  52. return (d.getTime());
  53. }
  54. function playScene()
  55. {
  56.     oTour.clearAllRuning();
  57.     if(oTour.scenes[oTour.curScene]){
  58.         oTour.scenes[oTour.curScene].tstart = getTime();
  59.         if(oTour.scenes[oTour.curScene].tremaining == 0) oTour.scenes[oTour.curScene].tremaining = oTour.scenes[oTour.curScene].dur;
  60.         eval(oTour.scenes[oTour.curScene].action);
  61.         oTour.curScene++;
  62.         
  63.         if (oTour.nextScene)
  64.         {
  65.             oTour.playNextScene();
  66.         }
  67.     }
  68. }
  69. function clearAllRuning()
  70. {
  71.     for(i = 0; i<oTour.length; i++)
  72.     {
  73.         if(oTour.scenes[i].timeoutID)
  74.         {
  75.             clearInterval(oTour.scenes[i].timeoutID)
  76.             oTour.scenes[i].timeoutID = 0;
  77.         }
  78.     }
  79. }
  80. function clearAllSetRemaining()
  81. {
  82.     for(i = 0; i<oTour.length; i++)
  83.     {
  84.         if(oTour.scenes[i].timeoutID)
  85.         {
  86.             clearInterval(oTour.scenes[i].timeoutID)
  87.             oTour.scenes[i].tremaining = oTour.scenes[i].dur;
  88.             oTour.scenes[i].timeoutID = 0;
  89.         }
  90.     }
  91. }
  92. function playNextScene()
  93. {    
  94.     if(oTour.curScene < oTour.length)
  95.     {
  96.         oTour.scenes[oTour.curScene].timeoutID = setInterval("oTour.play()", (oTour.scenes[oTour.curScene - 1].tremaining));
  97.         
  98.     }        
  99.     else
  100.     {
  101.         oTour.nextScene = false;
  102.     }
  103. }
  104. function playTour()
  105. {
  106.         oTour.setRemaining();
  107.         oTour.playScene();
  108. }
  109. function setRemaining()
  110. {
  111.     oTour.scenes[oTour.curScene].tremaining = oTour.scenes[oTour.curScene].dur;
  112. }
  113. function pauseTour()
  114. {
  115.     oTour.clearAllRuning();
  116.     oTour.setTRemaining();
  117.     if (oTour.curScene > 0 ) oTour.curScene--;
  118. }
  119. function setTRemaining()
  120. {
  121.     oTour.scenes[oTour.curScene - 1].tremaining =  oTour.scenes[oTour.curScene - 1].dur - (getTime() - oTour.scenes[oTour.curScene - 1].tstart);
  122. }
  123. function stopTour()
  124. {
  125.     oTour.nextScene = false;
  126.     oTour.clearAllRuning();
  127.     oTour.reset();
  128. }
  129. function resetTour()
  130. {
  131.     oTour.curScene = 0;
  132. }
  133. function setScene(n)
  134. {
  135.     oTour.curScene = n;
  136. }
  137. function startTour()
  138. {
  139.     oTour.reset();
  140.     TourPlayEVENTonclick(0, 0);
  141.     
  142. }
  143.