source: trunk/npemap.org.uk/static/postcodeine/index.html @ 309

Last change on this file since 309 was 309, checked in by Dominic Hargreaves, 15 years ago

Refactor using SSI

File size: 6.1 KB
Line 
1<!--#set var="title" value="Postcode Explorer" -->
2<!--#set var="link" value="/postcodeine" -->
3<!--#set var="shownav" value="yes" -->
4<!--#include virtual="../inc/header-prebody.shtml" -->
5
6<!--
7    index.html:
8    HTML for postcodeine
9
10    Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
11    Email: chris@mysociety.org; WWW: http://www.mysociety.org/
12   
13                According to http://www.mysociety.org/?p=109 this is licenced under
14                the Affero GPL http://www.affero.org/oagpl.html
15
16    # Changed 2006/11/01 David Sheldon to change the path to the CGI
17                # and change the text on the page.
18
19
20-->
21
22<script type="text/javascript">
23<!--
24
25var updateTimerId = false;
26var panTimerId = false;
27
28var xmlhttp1 = false;
29var xmlhttp2 = false;
30
31var current_x = 451;
32var current_y = 600;
33
34var target_x = current_x;
35var target_y = current_y;
36
37function panZoom() {
38    if (Math.abs(current_x - target_x) < 1
39        && Math.abs(current_y - target_y) < 1)
40        return;
41    current_x = Math.round((current_x + target_x) / 2);
42    current_y = Math.round((current_y + target_y) / 2);
43   
44    var x = Math.round(200 - current_x);
45    var y = Math.round(200 - current_y);
46    /* This is the pixel coordinate in the big map where we want the center
47     * of the zoomed region to be. */
48    var style = "position: relative; top: " + y + "; left: " + x + ";";
49   
50    document.getElementById("p1200b").setAttribute("style", style);
51    document.getElementById("p1200").setAttribute("style", style);
52   
53    if (panTimerId) window.clearTimeout(panTimerId);
54    panTimerId = window.setTimeout(panZoom, 50);
55}
56
57function processCoords() {
58    var t;
59    if (xmlhttp1.readyState != 4 || xmlhttp1.status != 200) return;
60    t = xmlhttp1.responseText;
61
62    var cc = t.split(",");
63    x = parseFloat(cc[0]);
64    y = parseFloat(cc[1]);
65    if (!isNaN(x) && !isNaN(y)) {
66        if (x == 0 && y == 0)
67            return;
68        x *= 902;
69        y *= 1200;
70
71        target_x = x;
72        target_y = y;
73
74        if (panTimerId) window.clearTimeout(panTimerId);
75        panTimerId = window.setTimeout(panZoom, 10);
76    }
77}
78
79function processZones() {
80    if (xmlhttp2.readyState != 4 || xmlhttp2.status != 200) return;
81    document.getElementById("zonelist").innerHTML = xmlhttp2.responseText;
82}
83
84function doUpdate() {
85    if (!xmlhttp1) {
86        /* from http://developer.apple.com/internet/webcontent/xmlhttpreq.html */
87        if (window.XMLHttpRequest) {
88            try {
89                xmlhttp1 = new XMLHttpRequest();
90                xmlhttp2 = new XMLHttpRequest();
91            } catch(e) {
92                xmlhttp1 = false;
93                xmlhttp2 = false;
94            }
95        } else if(window.ActiveXObject) {
96            try {
97                xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
98                xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
99            } catch(e) {
100                try {
101                    xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
102                    xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
103                } catch(e) {
104                    xmlhttp1 = false;
105                    xmlhttp2 = false;
106                }
107            }
108        }
109    }
110    var p = document.getElementById("pc").value.toUpperCase();
111    var prefix = "";
112    for (var i = 0; i < p.length; ++i) {
113        var c = p.substr(i, 1);
114        if ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".indexOf(c) != -1)
115            prefix += c;
116    }
117   
118    xmlhttp1.abort();
119    xmlhttp1.onreadystatechange = processCoords;
120    xmlhttp1.open("GET", "../../cgi/postcodeine.fcgi?X" + prefix, true);
121    xmlhttp1.send("");
122
123    xmlhttp2.abort();
124    xmlhttp2.onreadystatechange = processZones;
125    xmlhttp2.open("GET", "../../cgi/postcodeine.fcgi?Z" + prefix, true);
126    xmlhttp2.send("");
127   
128    document.getElementById("p400").src = "../../cgi/postcodeine.fcgi?S" + prefix;
129    document.getElementById("p1200").src = "../../cgi/postcodeine.fcgi?B" + prefix;
130}
131//-->
132</script>
133
134</head>
135<body onload="document.getElementById('pc').focus(); doUpdate();">
136
137<!--#include virtual="../inc/header-postbody.shtml" -->
138
139<div id="content">
140<!-- overview basemap -->
141<div style="position: absolute; left: 0; top: 0; z-index: 4;">
142<img src="basemap-400px.png" alt="" width="301" height="400">
143</div>
144
145<div style="position: absolute; left: 0; top: 0; z-index: 5;">
146<img src="../../cgi/postcodeine.fcgi?S" id="p400" alt="" width="301" height="400">
147</div>
148
149<!-- zoom basemap -->
150<div style="position: absolute; left: 306; top: 0; z-index: 4; width: 400; height: 400; overflow: hidden;">
151<img src="basemap-1200px.png" id="p1200b" alt="" width="902" height="1200" style="position: relative; left: -251; top: -400;">
152</div>
153
154<div style="position: absolute; left: 306; top: 0; z-index: 5; width: 400; height: 400; overflow: hidden;">
155<img src="../../cgi/postcodeine.fcgi?B" id="p1200" alt="" width="902" height="1200" style="position: relative; left: -251; top: -400;">
156</div>
157
158<!-- list of zones -->
159<div id="zonelist" style="position: absolute; left: 706; top: 0; z-index: 5; width: 15em; height: 400; overflow: hidden;">
160</div>
161
162<div id="edit" style="position: absolute; top: 420; max-width: 800px;">
163<h1>Postcodeine - Showing progress - <a href="/">Home</a></h1>
164
165<div style="background: #eee; padding: 1.5em; font-weight: bold;">
166<input type="text" id="pc" name="pc" onkeydown="if (updateTimerId) window.clearTimeout(updateTimerId); updateTimerId = window.setTimeout(doUpdate, 10); return true;" autocomplete="off">
167&#x2190; start typing any postcode in the box
168</div>
169
170<p>The data on this page is updated hourly.  It will be integrated with the rest of the site
171better at some point.</p>
172
173<hr>
174
175<p>Based on original <a href="http://www.mysociety.org/">mySociety</a> code by <a href="http://ex-parrot.com/~chris/">Chris Lightfoot</a>.
176<a href="source.tar.gz">Code</a> | <a href="http://www.mysociety.org/?p=109">Learn more</a>
177</p>
178
179</div>
180
181</div>
182
183<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
184</script>
185<script type="text/javascript">
186_uacct = "UA-732621-2";
187if (typeof urchinTracker == 'function') urchinTracker();
188</script>
189
190<!--#include virtual="../inc/footer.shtml" -->
Note: See TracBrowser for help on using the repository browser.