Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

459 lines
11 KiB

  1. // mouse tutorial stuff
  2. function InitSimpleNavMap_MouseTut() {
  3. var mousedir="html\\mouse\\";
  4. g_SimpleNavMap.Add("mouse.htm", mousedir+"mouse_a.htm");
  5. g_SimpleNavMap.Add("mouse_a.htm",mousedir+"mouse_b.htm");
  6. g_SimpleNavMap.Add("mouse_b.htm",mousedir+"mouse_c.htm");
  7. g_SimpleNavMap.Add("mouse_c.htm",mousedir+"mouse_d.htm");
  8. g_SimpleNavMap.Add("mouse_d.htm",mousedir+"mouse_e.htm");
  9. g_SimpleNavMap.Add("mouse_e.htm",mousedir+"mouse_f.htm");
  10. g_SimpleNavMap.Add("mouse_f.htm",mousedir+"mouse_g.htm");
  11. g_SimpleNavMap.Add("mouse_g.htm",mousedir+"mouse_h.htm");
  12. g_SimpleNavMap.Add("mouse_h.htm",mousedir+"mouse_i.htm");
  13. g_SimpleNavMap.Add("mouse_i.htm",mousedir+"mouse_j.htm");
  14. g_SimpleNavMap.Add("mouse_j.htm",mousedir+"mouse_k.htm");
  15. }
  16. var curRewardStr=0;
  17. // need individual defns for localization
  18. var L_RewardStr1_Text="Good job!";
  19. var L_RewardStr2_Text="That's it!";
  20. var L_RewardStr3_Text="You've got it!";
  21. var L_RewardStr4_Text="Excellent!";
  22. var L_RewardStr5_Text="It's that easy!";
  23. var L_RewardStr6_Text="Outstanding!";
  24. var L_RewardStr7_Text="Bravo!";
  25. var L_RewardStr8_Text="Stupendous!";
  26. var RewardStrs = new Array(8);
  27. {
  28. for(var i=1;i<=8;i++) {
  29. eval("RewardStrs["+(i-1).toString()+"]=L_RewardStr"+i.toString()+"_Text;");
  30. }
  31. }
  32. function GetRewardStr(i) {
  33. return RewardStrs[i];
  34. }
  35. var ButTouched = new Array(4);
  36. function MouseTut_LoadMe()
  37. {
  38. InitFrameRef('External');
  39. if (g.btnNext != null)
  40. g_FirstFocusElement = g.btnNext;
  41. else if (g.btnSkip != null)
  42. g_FirstFocusElement = g.btnSkip;
  43. else if (g.btnBack != null)
  44. g_FirstFocusElement = g.btnBack;
  45. if (GetCurrentPageName() == "mouse.htm")
  46. {
  47. InitNewButtons(null, "SimpleNext");
  48. g.btnSkip.onmouseover = HandleNextButtonMouseOver;
  49. g.btnSkip.onmouseout = HandleNextButtonMouseOut;
  50. g.btnSkip.onmousedown = HandleNextButtonMouseDown;
  51. g.btnSkip.className = "newbuttonsNext";
  52. }
  53. else
  54. InitNewButtons("SimpleBack", "SimpleNext");
  55. if (g_FirstFocusElement != null)
  56. g_FirstFocusElement.focus();
  57. else
  58. g.document.body.focus();
  59. }
  60. var g_MouseImgDir="images/";
  61. function HandleButMouseUp() {
  62. if(this.tagName=="IMG") {
  63. if(g.event.button!=1) {
  64. return;
  65. }
  66. var butnumchar=this.id.substr(3,1);
  67. this.src=g_MouseImgDir+"but"+butnumchar+"_up.gif";
  68. }
  69. }
  70. function HandleButMouseDown() {
  71. if(this.tagName=="IMG") {
  72. if(g.event.button!=1) {
  73. return;
  74. }
  75. var butnumchar=this.id.substr(3,1);
  76. this.src=g_MouseImgDir+"but"+butnumchar+"_dwn.gif";
  77. }
  78. }
  79. function HandleButMouseOut() {
  80. if(this.tagName=="IMG") {
  81. var butnumchar=this.id.substr(3,1);
  82. var butnum=parseInt(butnumchar);
  83. this.src=g_MouseImgDir+"but"+butnumchar+"_idl.gif";
  84. eval("g.rtxt"+butnumchar+".style.display='none';");
  85. ButTouched[butnum]=false;
  86. }
  87. }
  88. // for mouse_c/e pages
  89. function HandleButMouseOver() {
  90. if(this.tagName=="IMG") {
  91. var butnumchar=this.id.substr(3,1);
  92. var butnum=parseInt(butnumchar);
  93. if(g.event.button==1) {
  94. this.src=g_MouseImgDir+"but"+butnumchar+"_dwn.gif";
  95. } else {
  96. this.src=g_MouseImgDir+"but"+butnumchar+"_up.gif";
  97. }
  98. if(!ButTouched[butnum]) {
  99. ButTouched[butnum]=true;
  100. eval("g.rtxt"+butnumchar+".innerText=GetRewardStr("+curRewardStr.toString()+");");
  101. eval("g.rtxt"+butnumchar+".style.display='inline';");
  102. curRewardStr=(curRewardStr+1) % RewardStrs.length;
  103. // Call Agent to move the character -- inserted by tandyt
  104. try {
  105. Agent_MouseOver(g.event.srcElement);
  106. }
  107. catch(e) {
  108. }
  109. }
  110. }
  111. }
  112. function HandleDragEvent() {
  113. g.event.cancelBubble=true;
  114. g.event.returnValue=false;
  115. return false;
  116. }
  117. // need to make sure "out" doesnt occur before "up" is this possible to do?
  118. function setToolBarButtonHandlers(but1,PageChar) {
  119. // set handlers for toolbar
  120. if(PageChar=="E") {
  121. but1.onmouseover=HandleButMouseOver_PageE;
  122. but1.onmousedown=HandleButMouseDown_PageE;
  123. but1.onmousemove=HandleButMouseOver_PageE;
  124. but1.onmouseup=HandleButMouseUp_PageE;
  125. } else {
  126. but1.onmouseover=HandleButMouseOver;
  127. but1.onmousedown=HandleButMouseDown;
  128. but1.onmousemove=HandleButMouseOver;
  129. but1.onmouseup=HandleButMouseUp;
  130. }
  131. but1.onmouseout=HandleButMouseOut;
  132. but1.ondragover=HandleDragEvent;
  133. but1.ondragenter=HandleDragEvent;
  134. }
  135. function MouseTut_LoadMe_PageC() {
  136. MouseTut_LoadMe();
  137. for(var i=0;i<ButTouched.length;i++)
  138. ButTouched[i]=false;
  139. setToolBarButtonHandlers(g.but1);
  140. setToolBarButtonHandlers(g.but2);
  141. setToolBarButtonHandlers(g.but3);
  142. setToolBarButtonHandlers(g.but4);
  143. }
  144. function HandleButMouseOver_PageE() {
  145. if(this.tagName=="IMG") {
  146. var butnumchar=this.id.substr(3,1);
  147. var butnum=parseInt(butnumchar);
  148. if(g.event.button==1) {
  149. this.src=g_MouseImgDir+"but"+butnumchar+"_dwn.gif";
  150. } else {
  151. this.src=g_MouseImgDir+"but"+butnumchar+"_up.gif";
  152. }
  153. }
  154. }
  155. function HandleButMouseDown_PageE() {
  156. if(this.tagName=="IMG") {
  157. if(g.event.button!=1) {
  158. return;
  159. }
  160. var butnumchar=this.id.substr(3,1);
  161. var butnum=parseInt(butnumchar);
  162. this.src=g_MouseImgDir+"but"+butnumchar+"_dwn.gif";
  163. if(!ButTouched[butnum]) {
  164. ButTouched[butnum]=true;
  165. eval("g.rtxt"+butnumchar+".innerText=GetRewardStr("+curRewardStr.toString()+");");
  166. eval("g.rtxt"+butnumchar+".style.display='inline';");
  167. curRewardStr=(curRewardStr+1) % RewardStrs.length;
  168. }
  169. }
  170. }
  171. function HandleButMouseUp_PageE() {
  172. if(this.tagName=="IMG") {
  173. if(g.event.button!=1) {
  174. return;
  175. }
  176. var butnumchar=this.id.substr(3,1);
  177. var butnum=parseInt(butnumchar);
  178. this.src=g_MouseImgDir+"but"+butnumchar+"_up.gif";
  179. eval("g.rtxt"+butnumchar+".style.display='none';");
  180. ButTouched[butnum]=false;
  181. }
  182. }
  183. function MouseTut_LoadMe_PageE() {
  184. MouseTut_LoadMe();
  185. for(var i=0;i<ButTouched.length;i++)
  186. ButTouched[i]=false;
  187. setToolBarButtonHandlers(g.but1,"E");
  188. setToolBarButtonHandlers(g.but2,"E");
  189. setToolBarButtonHandlers(g.but3,"E");
  190. setToolBarButtonHandlers(g.but4,"E");
  191. }
  192. var g_MouseTutCityIdx=0;
  193. var g_MouseTutCityStr;
  194. function CityFileName(CityName,IsBlackAndWhite) {
  195. if(IsBlackAndWhite) {
  196. return g_MouseImgDir+CityName.substr(0,7)+"m.jpg";
  197. } else {
  198. return g_MouseImgDir+CityName.substr(0,7)+".jpg";
  199. }
  200. }
  201. function HandleSelCityChange() {
  202. g_MouseTutCityIdx=g.selCity.selectedIndex;
  203. g_MouseTutCityStr=g.selCity.options(g.selCity.selectedIndex).name;
  204. if(g.selCity.selectedIndex==0) {
  205. g.cityImg.style.display="none";
  206. g.noCity.style.display="inline";
  207. } else {
  208. g.cityImg.src=CityFileName(g_MouseTutCityStr,false);
  209. g.noCity.style.display="none";
  210. g.cityImg.style.display="inline";
  211. }
  212. g.btnNext.disabled=(g.selCity.selectedIndex==0);
  213. InitNewButtons("SimpleBack", "SimpleNext");
  214. }
  215. function MouseTut_LoadMe_PageG() {
  216. InitFrameRef('External');
  217. g_FirstFocusElement = g.selCity;
  218. g.selCity.onchange = HandleSelCityChange;
  219. HandleSelCityChange();
  220. g_FirstFocusElement.focus();
  221. }
  222. var g_BW_selected=false;
  223. function MouseTut_LoadMe_PageH() {
  224. InitFrameRef('External');
  225. g.bwsel.checked=g_BW_selected;
  226. g.colorsel.checked=!g_BW_selected;
  227. if(g_MouseTutCityStr==null) {
  228. g_MouseTutCityStr="Verona"; // for debugging scenario where there is no previous page
  229. }
  230. g.cityImg.src=CityFileName(g_MouseTutCityStr,g_BW_selected);
  231. if(g_BW_selected)
  232. g_FirstFocusElement = g.bwsel;
  233. else g_FirstFocusElement = g.colorsel;
  234. InitNewButtons("SimpleBack", "SimpleNext");
  235. g.colorsel.onclick = PageH_radioClicked;
  236. g.bwsel.onclick = PageH_radioClicked;
  237. g_FirstFocusElement.focus();
  238. }
  239. function PageH_radioClicked()
  240. {
  241. try
  242. {
  243. if (g.event == null)
  244. return;
  245. }
  246. catch(e)
  247. {
  248. return;
  249. }
  250. g_BW_selected=g.bwsel.checked;
  251. g.cityImg.src=CityFileName(g_MouseTutCityStr,g_BW_selected);
  252. InitNewButtons("SimpleBack", "SimpleNext");
  253. }
  254. var g_MatSelected=false;
  255. var g_FrameSelected=false;
  256. var g_BorderSelected=false;
  257. function setCityImgBorders() {
  258. if(g_MatSelected) {
  259. g.mat_table.bgColor="sandybrown";
  260. g.mat_table.style.border="thick solid sandybrown"
  261. } else {
  262. g.mat_table.bgColor="";
  263. g.mat_table.style.border="";
  264. }
  265. if(g_FrameSelected) {
  266. g.frametable.bgColor="sienna";
  267. g.frameclrcel.style.border="thick inset sienna"
  268. } else {
  269. g.frametable.bgColor="";
  270. g.frameclrcel.style.border="";
  271. }
  272. if(g_BorderSelected) {
  273. g.cityImg.style.border="thin solid black";
  274. } else {
  275. g.cityImg.style.border="";
  276. }
  277. }
  278. function PageI_chkboxClicked() {
  279. g_MatSelected=g.mattesel.checked;
  280. g_BorderSelected=g.bordersel.checked;
  281. g_FrameSelected=g.framesel.checked;
  282. setCityImgBorders();
  283. InitNewButtons("SimpleBack", "SimpleNext");
  284. }
  285. function MouseTut_LoadMe_PageI() {
  286. InitFrameRef('External');
  287. g.mattesel.checked=g_MatSelected;
  288. g.framesel.checked=g_FrameSelected;
  289. g.bordersel.checked=g_BorderSelected;
  290. if(g_MouseTutCityStr==null) {
  291. // for debugging scenario where there is no previous page
  292. g_MouseTutCityStr="Bulzano";
  293. g_BW_selected=true;
  294. }
  295. g.cityImg.src=CityFileName(g_MouseTutCityStr,g_BW_selected);
  296. setCityImgBorders();
  297. g_FirstFocusElement = g.bordersel;
  298. InitNewButtons("SimpleBack", "SimpleNext");
  299. g.mattesel.onclick=PageI_chkboxClicked;
  300. g.framesel.onclick=PageI_chkboxClicked;
  301. g.bordersel.onclick=PageI_chkboxClicked;
  302. g_FirstFocusElement.focus();
  303. }
  304. var g_CityCaptionStr="";
  305. function HandleCityCaptionChange() {
  306. g_CityCaptionStr =g.caption.value;
  307. }
  308. function MouseTut_LoadMe_PageJ() {
  309. InitFrameRef('External');
  310. if(g_MouseTutCityStr==null) {
  311. // for debugging scenario where there is no previous page
  312. g_MouseTutCityStr="Bulzano";
  313. g_BW_selected=true;
  314. g_MatSelected=true;
  315. g_FrameSelected=true;
  316. g_BorderSelected=true;
  317. }
  318. g.cityImg.src=CityFileName(g_MouseTutCityStr,g_BW_selected);
  319. g.caption.value=g_CityCaptionStr;
  320. setCityImgBorders();
  321. g_FirstFocusElement = g.caption;
  322. InitNewButtons("SimpleBack", "SimpleNext");
  323. g.caption.onchange=HandleCityCaptionChange;
  324. g_FirstFocusElement.focus();
  325. }
  326. function MouseTut_LoadMe_PageK() {
  327. InitFrameRef('External');
  328. if(g_MouseTutCityStr==null) {
  329. // for debugging scenario where there is no previous page
  330. g_MouseTutCityStr="Bulzano";
  331. g_BW_selected=true;
  332. g_MatSelected=true;
  333. g_FrameSelected=true;
  334. g_BorderSelected=true;
  335. var L_CaptionString_Text = "Seattle Seahawks won against the Steelers.";
  336. g_CityCaptionStr = L_CaptionString_Text;
  337. }
  338. var re = new RegExp("^\\s*$");
  339. // if user enters no caption, dont display caption block
  340. if(re.exec(g.caption.value) == null) {
  341. g.captioncell.style.display="inline";
  342. }
  343. //BUGBUG: picture will be center-shifted offscreen if any single word in g_CityCaptionStr
  344. // is longer than screen length
  345. g.cityImg.src=CityFileName(g_MouseTutCityStr,g_BW_selected);
  346. g.caption.innerText=g_CityCaptionStr;
  347. setCityImgBorders();
  348. // g.captioncell.bgColor="linen";
  349. // g.captioncell.style.border="thick sienna";
  350. g_FirstFocusElement = g.btnNext;
  351. InitNewButtons("SimpleBack");
  352. g_FirstFocusElement.focus();
  353. }