Please
Click here, if you wish to Download Zip file
containing source code for: |
|||
The following listing contains component code for interactive Flight-Image, which has three sections. The sections are shown in different color coded boxes to highlight each of the sections. Although, the Class definition code can be included in this file, I prefer to place the code in external-file and include it in the SVG-file as shown in the 'SECTION-1'. The 'SECTION-2' instantiates and initializes a JavaScript Object for the Flight and 'SECTION-3' contains SVG-Instructions to show the image. This listing contains initialization code at the Top that initializes Global Objects, which can be used by any component in the webpage. This listing also contains test code to test few services of the Flight-component at the Bottom, which calls the service functions of the Flight. |
|||
Source Code Listing for File: Flight_test.svg |
|||
1. <svg width='1000' height='700'
onload='svg_doc_onload_init(evt)'> 2. <script type='text/ecmascript'> 3. <![CDATA[ 4. // Global variables available to all SVG-Components. 5. var SVG_Document = null; // Global
Variable 6. var onload_init_list = new Array(); 7. 8. function svg_doc_onload_init (evt) { 9. SVG_Document =
evt.getTarget().getOwnerDocument() 10. 11. for(var i = 0; i <
onload_init_list.length; i++) 12. (onload_init_list[i])(evt); 13. } 14. ]]> 15. </script> 16.
56. 57. // The following is just code to
test the Features 58. <script type='text/ecmascript'> 59. <![CDATA[ 60. var dir_ang = 10.0; 61. var loc_nx = 70.0; 62. var loc_ny = 90.0; 63. function set_new_lacation(nx, ny,
nd) { 64. 65. if ( nd != 0) 66. dir_ang += nd; 67. else { 68. var tdir = dir_ang*22/(7*180) 69. loc_nx
+= nx*Math.cos(tdir); 70. loc_ny += ny*Math.sin(tdir); 71. } 72.
//alert(' X: '+loc_nx+ ' Y:
'+loc_ny+ ' DIR: '+dir_ang); 73. airline_UNQID.update_location(loc_nx,
loc_ny, dir_ang); 74. } 75. var
emerg_flag = 0; 76.
function
switch_atc_clue_state() { 77. if
(emerg_flag == 0) emerg_flag = 1; 78. else emerg_flag = 0; 79. airline_UNQID.set_emergency_flag(emerg_flag); 80.
} 81. ]]> 82. </script> 83. <!-- Display Buttons and
control the Layers using the buttons. --> 84. <g transform='translate(20 500)'> 85. <g style='visibility:visible;'
onclick='set_new_lacation(10,10,0)'> 86. <rect style='fill:white;stroke:black;' x='0' y='0'
width='20' height='20'/> 87. <text style='fill:black;font-size:16pt' x='25'
y='20'>Move</text> 88. </g> 89. <g style='visibility:visible;'
onclick='set_new_lacation(0,0,10)'> 90. <rect style='fill:red;stroke:black;' x='100' y='0'
width='20' height='20'/> 91. <text style='fill:black;font-size:16pt' x='125'
y='20'>Rotate</text> 92. </g> 93. <g style='visibility:visible;'
onclick='switch_atc_clue_state(1)'> 94. <rect style='fill:green;stroke:black;' x='210' y='0'
width='20' height='20'/> 95. <text style='fill:black;font-size:16pt' x='235' y='20'>
Show Emergency Flag </text> 96. </g> 97. </g> 98. </svg> |
|||
Copy Right © 2009 Raju Chiluvuri. All Rights Reserved. |