-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
139 lines (109 loc) · 5.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Airplane Hub</title>
</head>
<center>
<br><br><br><br>
<h1><strong>Enter URL for Airlines List JSON File</strong> </h1>
<form name="myform" method="POST" id="location">
<input type="text" name="URL" maxlength="100" size="30" />
<br><br>
<input type="button" name="submit" value="Submit Query" onClick="viewJSON(this.form)" />
</form>
</center>
<body>
<script>
function generateHTML(info){
var output='<thead>'+'<tr>';
var HeadLine = info.Mainline.Table.Header.Data;
var ErrorControl = jsonObj.Mainline.Table.Row;
if(ErrorControl==null || ErrorControl == "")
{
alert("No data!");
return;
}
for(var i = 0; i <= info.Mainline.Table.Header.Data.length-1; i++){
//HeadLine[i]=info.Mainline.Table.Header.Data[i];
output +='<th>'+info.Mainline.Table.Header.Data[i]+'</th>'
}
output = output +'</tr>'+'</thead>';
output = output+'<tbody>';//Body starts!
for(var i = 0; i <= info.Mainline.Table.Row.length-1; i++){
var k=0;
//AirLine
output +='<tr>'+'<td>'+info.Mainline.Table.Row[i][HeadLine[k]]+'</td>';
k=k+1;
//IATA
output +='<td>'+info.Mainline.Table.Row[i][HeadLine[k]]+'</td>';
k=k+1;
//Hub
output +='<td><a style="padding-top:10px;padding-bottom:10px;padding-left:15px;padding-right:15px;">'
for(var j = 0; j<=info.Mainline.Table.Row[i][HeadLine[k]].Hub.length-1;j++)
{
if(j===0){
output += '<li><strong>'+info.Mainline.Table.Row[i][HeadLine[k]].Hub[j]+'</strong></li>';
}
else{
output += '<li>'+info.Mainline.Table.Row[i][HeadLine[k]].Hub[j]+'</li>';
}
}
output +='</a></td>';
k=k+1;
//Notes
output +='<td>'+info.Mainline.Table.Row[i][HeadLine[k]]+'</td>';
k=k+1;
//HomePage
output +='<td><a href="'+info.Mainline.Table.Row[i][HeadLine[k]]+'">'+info.Mainline.Table.Row[i][HeadLine[k]]+' </a></td>';
k=k+1;
//Plane
output +='<td> <img src="'+info.Mainline.Table.Row[i][HeadLine[k]]+'"height="100" width="200"/></td>'+'</tr>';
}
output = output +'</tbody>';
var update = document.getElementById('TableData');
var mesg=open();
//mesg.innerHTML = output;
//mesg.document.write(update.innerHTML = output);
mesg.document.write("<table border=1>"+output+"</table>");
}
//end of function generateHTML
function viewJSON(what){
var URL = what.URL.value; //URL=airline.json
if(URL==null || URL == ""){
alert("Empty!Please enter data!");
return;
}
function loadJSON(url) {
if (window.XMLHttpRequest){
request=new XMLHttpRequest();
} else {
request=new ActiveXObject("Microsoft.XMLHTTP");
}
request.open("GET",url,false);
request.send();
if(request.status == 404){
alert("No Files Found! Type again!");
return;
}
jsonObj = JSON.parse(request.responseText);
return jsonObj;
}
jsonObj = loadJSON(URL);
if (window.ActiveXObject){//if IE, simply execute script (due to async prop).
if (jsonObj.parseError.errorCode != 0) {
var myErr = jsonObj.parseError;
generateError(jsonObj);
hWin = window.open("", "Error", "height=300,width=340"); hWin.document.write(html_text);
}
else {
generateHTML(jsonObj);
hWin = window.open("", "Assignment4", "height=800,width=600"); hWin.document.write(html_text);
}
}
else {
generateHTML(jsonObj);
}
}
</script>
</body>
</html>