-
Notifications
You must be signed in to change notification settings - Fork 0
/
rail.php
265 lines (240 loc) · 9.97 KB
/
rail.php
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
include('includes/paths.php');
//center locs
$lat = 54.31652;//52.7; //to be set from xml
$lon = -2.37305;//-2.52; //to be set from xml
if ($_GET['ldb']){
$show_ldb = "true";
}else{
$show_ldb = "false";
}
if ($_GET['marker'] || $_GET['marker'] == "0"){
$marker_id = $_GET['marker'];
$markers = "true";
}else{
$marker_id = 0;
$markers = "false";
}
if ($_GET['lat']){
$zoom = "true";
$lv = $_GET['lat'];
$lnv = $_GET['lon'];
$zl = $_GET['zl'];
}else{
$zoom = "false";
$lv = 1;
$lnv = 1;
$zl = 1;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style23.css" />
<title>BlueGhost UK Weather, with weather.com® & backstage.bbc.co.uk</title>
<script src="http://maps.google.com/maps?file=api&v=1&key=<?php echo $googleKey;?>" type="text/javascript"></script>
<script src="javascript/common_single.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA
var weather = false;
var rail = true;
var traffic = false;
var sidebar = false;
var ldb_visible = <?php echo $show_ldb;?>;
function getPermalink(){
document.location.href = 'http://bbc.blueghost.co.uk/rail.php?' + genPermalink();
}
function createRailMarker(point, html, src, type, start, stp, image) {
var icon = new GIcon();
icon.image = "<?php echo $img_url;?>"+image+".png";
icon.shadow = "<?php echo $img_url;?>weather/trans.png";
icon.iconSize = new GSize(19, 40);
icon.shadowSize = new GSize(1, 1);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
var marker = new GMarker(point,icon);
var info_html = '<div style="width: 200px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:small;"><img style="float:left" src="<?php echo $img_url;?>'+type+'.png" alt="img" />'+html+'</div><strong>Source:'+src+'</strong>';
info_html += '<div>Started @ '+start+'</div><div>End @ '+stp+'</div>';
info_html += '<div class="weather_link"><a href="javascript:zoomOut();">Zoom Out</a>';
GEvent.addListener(marker, "click", function() {
map.centerAndZoom(point, 2);
marker.openInfoWindowHtml(info_html);
});
return marker;
}
function createLDBMarker(point, name, code, id) {
var marker = new GMarker(point, ldbICon);
var request = GXmlHttp.create();
var links ='<div class="weather_link"><a href="http://www.livedepartureboards.co.uk/ldb/summary.aspx?T='+code+'">Live Data from National Rail</a>';
GEvent.addListener(marker, "click", function() {
map.centerAndZoom(point, 5);
loadLDB(marker, name, code);
//if (show_pop_ups)
//marker.openInfoWindowHtml(html);
last_open = id; //refers to rail_markers
});
//alert("Given id = " + id + " , wanted id = " + <?php echo $marker_id;?>);
if ( (first_run) && (id == <?php echo $marker_id;?>) ){
GEvent.trigger(marker, "click");
first_run = false;
}
return marker;
}
function loadLDB(marker, name, code){
var request = GXmlHttp.create();
var url = "<?php echo $site_url;?>includes/rail.php?ldb="+code+"";
var lo = document.getElementById("loading");
lo.innerHTML = "Loading LDBData ...";// from "+url+" ...";
request.open("GET", url , true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200) {
var xmlDoc = request.responseXML;
if (xmlDoc.documentElement){
//alert("loaded");
var data = xmlDoc.documentElement.getElementsByTagName('table');
var divs = xmlDoc.documentElement.getElementsByTagName('div');
var a_d = -1;
for (var i=0; i< divs.length; i++){
if (divs[i].className == "maint_message"){
a_d = i;
i = divs.length;
}
}
var st_title = '<td colspan="7" title="Data Source" class="st_name">'+name+'</td></tr>';
var copy_text = '<td colspan="7" title="Data Source" class="copy_text"><a href="http://www.livedepartureboards.co.uk/ldb/summary.aspx?T='+code+'" target="_blank">Data from National Rail Live Departure Boards</a></td></tr>';
var copy_2 = '<td colspan="7" title="Data Source" class="copy_text"><a href="http://www.atoc.org" target="_blank">© Association of Train Operating Companies 2004</a></td></tr>';
if (a_d != -1){
var a_t = '<tr><td colspan="7" title="Problems" class="alert">'+divs[a_d].innerHTML+'</td></tr>';
marker.openInfoWindowHtml("<table class=\"ldb_tbl\">"+st_title+a_t+data[0].innerHTML+copy_text+copy_2+"</table>");
}else
marker.openInfoWindowHtml("<table class=\"ldb_tbl\">"+st_title+data[0].innerHTML+copy_text+copy_2+"</table>");
lo.innerHTML = "LDB Data Loaded";
}else{
//alert("Function not available in this Web Browser");
lo.innerHTML = "LDB Function not fully supported in this Web Browser";
xmlDoc = request.responseText;
marker.openInfoWindowHtml(xmlDoc);
}
}else{
lo.innerHTML = "ERROR loading LDB Data";
}
}
}
request.send(null);
}
function onLoad(){
if (GBrowserIsCompatible()) {
/*DETECT RES */
if (screen.width == '1280' && screen.height == '800')
widescreen = true;
if (screen.width == '1280' && screen.height == '768')
widescreen = true;
loc = new GPoint(<?php echo $lon;?>,<?php echo $lat;?>);
cen = new GPoint(<?php echo $lon;?>,<?php echo $lat;?>);
map = new GMap(document.getElementById("weather_map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
if (<?php echo $zoom;?>){
var p = new GPoint(<?php echo $lnv;?>,<?php echo $lv;?>);
map.centerAndZoom(p, <?php echo $zl;?>);
}else{
map.centerAndZoom(cen, 11);
}
if (<?php echo $markers;?>)
first_run = true;
setupRail();
reload();
}//end iscompat
}//end onLoad
function setupRail(){
var img = 'bbc_v2.png';
var size_x = 350;
var size_y = 30;
var html = '<div class="weather_link">supported by<br /><a href="http://backstage.bbc.co.uk" target="_blank">backstage.bbc.co.uk</a></div>';
var move = false;
var moveend = true;
var clicker = true;
var reloader= false;
var zoom = true;
placeCopyLogo(wICon, wMarker, img, size_x, size_y, html, move, moveend, clicker, reloader);
if (!ldbICon){
//ldb_marker
ldbICon = new GIcon();
ldbICon.image = "<?php echo $img_url;?>mm_20_green.png";
ldbICon.shadow = "<?php echo $img_url;?>mm_20_shadow.png";
ldbICon.iconSize = new GSize(12, 20);
ldbICon.shadowSize = new GSize(22, 20);
ldbICon.iconAnchor = new GPoint(0, 0);
ldbICon.infoWindowAnchor = new GPoint(-5, -5);
}
reloadRail(); //call only needed here
}
function reload(){
updateDisplay();
}
function reloadRail(){
if (rail_setup){
if (ldb_indicator != -1){
for (var i=0; i< rail_markers.length && i < ldb_indicator; i++)
map.addOverlay(rail_markers[i]);
}else{
for (var i=0; i< rail_markers.length; i++)
map.addOverlay(rail_markers[i]);
}
var lo = document.getElementById("loading");
lo.innerHTML = "Loaded Rail Data";
if (ldb_visible)
doLDB();
}else{
var url = "<?php echo $site_url;?>travel_data/railways.xml";
var status = 'Loading Rail Data ...';
doXMLHTTPRequest(reloadRailXML, url, status);
rail_setup = true;
}
}
function doLDB(){
if (ldb_visible){
if (ldb_loaded){
for (var i=ldb_indicator; i< rail_markers.length ; i++)
map.addOverlay(rail_markers[i]);
var lo = document.getElementById("loading");
lo.innerHTML = "Loaded LDB Data";
}else{
var url = "<?php echo $site_url;?>ldb_data/stations.xml";
var status = 'Loading LDB Data ...';
doXMLHTTPRequest(doLDBXML, url, status);
ldb_loaded = true;
}
}else{
if (ldb_indicator != -1){
for (var i=ldb_indicator; i< rail_markers.length ; i++)
map.removeOverlay(rail_markers[i]);
}
}
}
function goToSidebar(){
document.location.href = 'http://bbc.blueghost.co.uk/rail_sb.php?'+genPermalink();
}
//]]>
</script>
</head>
<body onload="onLoad()" onunload="unLoad()">
<div id="selector">
<div id="wc" class="choiceS" title="Click to Show Weather Overlay" onmouseover="javascript:highlight('wc', 'choiceH');" onmouseout="unhighlight('wc', 'choice');" onclick="javascript:goTo('weather');">Weather</div>
<div id="rc" class="choice" title="Click to Show Rail Overlay" onmouseover="javascript:highlight('rc', 'choiceH');" onmouseout="unhighlight('rc', 'choice');" onclick="javascript:goTo('rail');">Rail</div>
<div id="tc" class="choice" title="Click to Show Road Traffic Overlay" onmouseover="javascript:highlight('tc', 'choiceH');" onmouseout="unhighlight('tc', 'choice');" onclick="javascript:goTo('traffic');">Traffic</div>
<div id="pc" class="choiceP" title="Click to get a Permanant Link to this map view" onmouseover="javascript:highlight('pc', 'choiceHP');" onmouseout="unhighlight('pc', 'choiceP');" onclick="javascript:getPermalink();">Permalink</div>
<div id="rv" class="choiceP" title="Reset the Viewpoint back to the original position" onmouseover="javascript:highlight('rv', 'choiceHP');" onmouseout="unhighlight('rv', 'choiceP');" onclick="javascript:zoomOut();">Reset Viewpoint</div>
<div id="sb" class="choiceP" title="Click to Add a Sidebar to the map" onmouseover="javascript:highlight('sb', 'choiceHP');" onmouseout="unhighlight('sb', 'choiceP');" onclick="javascript:goToSidebar();">Add Sidebar</div>
<div id="hc" class="choiceR" title="Click to see help" onmouseover="javascript:highlight('hc', 'choiceHR');" onmouseout="unhighlight('hc', 'choiceR');" onclick="javascript:openHelp();">Help</div>
<div id="ac" class="choiceR" title="Click to see detail about this site" onmouseover="javascript:highlight('ac', 'choiceHR');" onmouseout="unhighlight('ac', 'choiceR');" onclick="javascript:openAbout();">About</div>
</div>
<div id="sub_selector">
<div id="static">Some Text</div>
<div id="loading">Loading ABC...</div>
</div>
<div id="weather_map"></div>
</body>
</html>