source: trunk/npemap.org.uk/static/distantPostcodes.html @ 212

Last change on this file since 212 was 212, checked in by Nick Burch, 13 years ago

Support displaying outer and outer+1 problem postcodes

File size: 2.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
3<html>
4<head>
5  <title>Distant Postcodes | New Popular Edition Maps</title>
6</head>
7
8<body>
9<h1>Distant Postcodes</h1>
10
11<div id="actions">
12</div>
13
14<br />
15
16<div id="distant">
17</div>
18
19<script type="text/javascript">
20var actions = document.getElementById("actions");
21var distant = document.getElementById("distant");
22
23function addProblem(id,postcode,matchpart,easting,northing,avg_e,avg_n,source_id,source_name) {
24        var disp_source = "NPE Submission";
25        if(source_id == 1) {
26                disp_source = "FreeThePostcode";
27        }
28
29        var div = document.createElement("div");
30        div.appendChild(document.createTextNode(postcode + " (" + id + " - " + disp_source + "), matched from " + matchpart + ", was at "));
31
32        var pl = document.createElement("a");
33        pl.appendChild(document.createTextNode(easting + " " + northing));
34        pl.href = "tiles/map.html#" + Math.round(easting/1000) + "," + Math.round(northing/1000) + ",1";
35        div.appendChild(pl);
36
37        div.appendChild(document.createTextNode(", instead of at "));
38
39        var al = document.createElement("a");
40        al.appendChild(document.createTextNode(avg_e + " " + avg_e));
41        al.href = "tiles/map.html#" + Math.round(avg_e/1000) + "," + Math.round(avg_n/1000) + ",1";
42        div.appendChild(al);
43
44        var e_km = Math.abs(Math.round((easting-avg_e)/1000));
45        var n_km = Math.abs(Math.round((northing-avg_n)/1000));
46        div.appendChild(document.createTextNode(", out by " + e_km + "km and " + n_km + "km"));
47
48        distant.appendChild(div);
49}
50
51// How should we call the script?
52var cgi = "/cgi/get-distant-postcodes.fcgi";
53var oLink = document.createElement("a");
54if(location.href.indexOf("?outer1") > 0) {
55        cgi = cgi + "?outer1=yes";
56        oLink.href = "?";
57        oLink.appendChild(document.createTextNode("Match only by outer parts"));
58} else {
59        oLink.href = "?outer1=yes";
60        oLink.appendChild(document.createTextNode("Match by outer in 1st inner"));
61}
62actions.appendChild(oLink);
63
64// Include the script
65var sc = document.createElement("script");
66sc.type = "text/javascript";
67sc.src = cgi;
68actions.appendChild(sc);
69</script>
70
71</body>
72</html>
Note: See TracBrowser for help on using the repository browser.