Source Code Listing for: Flight_class.js 

 1. function airline_v1_1(FlightNum, flight_data_server_url, unique_id) 
 2. {
 3.  this.update_location = update_location;
 4.  this.highlight = highlight;
 5.  this.show_info = show_info;
 6.  this.info_table_func = null;
 7.  this.change_color = change_color;
 8.  this.set_emergency_flag = set_emergency_flag;
 9.  this.set_info_table_func = set_info_table_func;
10.  this.Flight_num = FlightNum;
11. 
12.  var unq_id = unique_id;
13.  var info_table_func = null;
14.  var data_url = flight_data_server_url + "?FlightNo=" + FlightNum;
15. 
16.      function update_location (nx, ny, dir) {
17.           // Set new location of the Flight
18.           var svgobj = SVG_Document.getElementById('al_loc_' + unq_id);
19.           var trans_str = 'translate(' +nx+ ',' +ny+')';
20.           if (svgobj != null)
21.                svgobj.setAttribute('transform', trans_str);
22. 
23.           // Set new angular direction of the Flight.
24.           var svgobj = SVG_Document.getElementById('al_img_' + unq_id);
25.           var trans_str = 'rotate('+dir+')';
26.           if (svgobj != null)
27.                svgobj.setAttribute('transform', trans_str);
28.      }
29. 
30.      function set_info_table_func (Display_func_name) {
31.           info_table_func = Display_func_name;
32.      }
33. 
34.      function highlight( stat ) {
35.           var svgobj = SVG_Document.getElementById('al_grp_' + unq_id);
36.           if (svgobj != null){
37.                if (stat == 0) { // In case of mouse-over event.
38.                     // Decrees the scale to reduce the size.
39.                     svgobj.setAttribute('transform', 'scale(0.25)');
40.                }
41.                else { // In case of mouse-out event.
42.                     // Increase the scale to magnify the Image size.
43.                     svgobj.setAttribute('transform', 'scale(0.75)');
44.                }
45.           }
46.      } 
47.      // The Ajax function that is called upon arrival of the XML-data
48.      // This is just a companion function for the next Ajax function
49.      function func_to_get_xml_data(data) {
50.           if(data.success)
51.                info_table_func ( data.content );
52.           return;
53.      }
54.      // The following function makes an AJAX call to the server
55.      function show_info ( ) {
56.           // If Function to call the Table for displaying data is set
57.           if(info_table_func != null) 
58.                getURL(data_url, func_to_get_xml_data); //Make Ajax call
50.      } //
Note: In SVG, getURL() is equivalent to XMLHttpRequest()
60. 
61.      // Let me sneak in couple of potential useful service functions.
62.      function set_emergency_flag (state) {
63.           var svgobj = SVG_Document.getElementById('al_clue_' + unq_id);
64.           (svgobj.getStyle()).setProperty('visibility', (state == 1) ? 'visible': 'hidden');
65.      }
66.      // This function may be called to change the color of the Image.
67.      function change_color( new_col ) {
68.           var svgobj = SVG_Document.getElementById('al_img_' + unq_id);
69.           if (svgobj != null)
70.                (svgobj.getStyle()).setProperty ('fill', new_col);
71.      }
72. }