aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2006-09-28 11:10:57 +0000
committermatthew <matthew>2006-09-28 11:10:57 +0000
commit4a7c2e625003b958871338d729623a626eb1a07f (patch)
treea3fcabdc457c9a7d92f4e4ae0d7f0597adce7947
parent9475220c2f73e604e77e18c9e5f268ed78560a35 (diff)
Form state is remembered when clicking the Back button. So can't rely on
that for drawing the correct bit of the map...
-rwxr-xr-xweb/index.cgi5
-rw-r--r--web/js2.js13
2 files changed, 10 insertions, 8 deletions
diff --git a/web/index.cgi b/web/index.cgi
index c918d0843..ec831e128 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: index.cgi,v 1.32 2006-09-28 11:06:43 matthew Exp $
+# $Id: index.cgi,v 1.33 2006-09-28 11:10:57 matthew Exp $
# TODO
# Nothing is done about the update checkboxes - not stored anywhere on anything!
@@ -534,6 +534,9 @@ sub display_map {
if ($type) {
my $pc_enc = ent($q->param('pc'));
$out .= <<EOF;
+<script type="text/javascript">
+x = $x - 2; y = $y - 2;
+</script>
<form action="./" method="get" id="mapForm">
<input type="hidden" name="map" value="1">
<input type="hidden" name="x" value="$x">
diff --git a/web/js2.js b/web/js2.js
index ccc89b687..e3d7a2a20 100644
--- a/web/js2.js
+++ b/web/js2.js
@@ -13,7 +13,6 @@
window.onload = onLoad;
// I love the global
-var x, y;
var tile_x, tile_y;
var tilewidth = 254;
var tileheight = 254;
@@ -34,8 +33,12 @@ function onLoad() {
}
var form = document.getElementById('mapForm');
- x = parseInt(form.x.value, 10) - 2; /* Bottom left corner X,Y */
- y = parseInt(form.y.value, 10) - 2;
+ form.onsubmit = function() {
+ this.x.value = x + 2;
+ this.y.value = y + 2;
+ return true;
+ }
+
tile_x = 0;
tile_y = 0;
var url = '/tilma/tileserver/10k-full-london/' + x + '-' + (x+5) + ',' + y + '-' + (y+5) + '/JSON?';
@@ -107,10 +110,6 @@ function update_tiles(dx, dy) {
y -= vertical;
tile_y = mod((tile_y + vertical), 6);
- var form = document.getElementById('mapForm');
- form.x.value = x + 2;
- form.y.value = y + 2;
-
var url = '/tilma/tileserver/10k-full-london/' + x + '-' + (x+5) + ',' + y + '-' + (y+5) + '/JSON';
var req = YAHOO.util.Connect.asyncRequest('GET', url, urls_loaded, null);
}