diff options
-rwxr-xr-x | bin/councils-no-contact | 12 | ||||
-rw-r--r-- | perllib/Page.pm | 20 | ||||
-rw-r--r-- | web/css.css | 2 | ||||
-rwxr-xr-x | web/index.cgi | 14 | ||||
-rw-r--r-- | web/js2.js | 174 |
5 files changed, 103 insertions, 119 deletions
diff --git a/bin/councils-no-contact b/bin/councils-no-contact index 22b2f53e1..22855aaf0 100755 --- a/bin/councils-no-contact +++ b/bin/councils-no-contact @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: councils-no-contact,v 1.1 2006-09-27 13:51:22 matthew Exp $ +# $Id: councils-no-contact,v 1.2 2006-10-07 21:06:31 matthew Exp $ use strict; require 5.8.0; @@ -93,12 +93,12 @@ foreach my $type (@$types) { my $areas_info = mySociety::MaPit::get_voting_areas_info($areas); foreach my $id (keys %$areas_info) { my $area_info = $areas_info->{$id}; - my $name = $area_info->{name}; - foreach my $council (@councils_no_email) { - if ($name =~ /^$council( ((Borough|City|District|County) )*Council)?$/) { + my $name = $area_info->{name}; + foreach my $council (@councils_no_email) { + if ($name =~ /^$council( ((Borough|City|District|County) )*Council)?$/) { push(@out, $id); - } - } + } + } } } diff --git a/perllib/Page.pm b/perllib/Page.pm index 055f9504e..1b323c77d 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.pm,v 1.25 2006-10-06 15:58:28 matthew Exp $ +# $Id: Page.pm,v 1.26 2006-10-07 21:06:31 matthew Exp $ # package Page; @@ -71,15 +71,15 @@ EOF # <script defer type="text/javascript" src="/pngfix.js"></script> # <![endif]--> $html .= <<EOF; - <link type="text/css" rel="stylesheet" href="/yui/logger.css"> - <script type="text/javascript" src="/yui/yahoo-min.js"></script> - <script type="text/javascript" src="/yui/dom-min.js"></script> - <script type="text/javascript" src="/yui/event-min.js"></script> - <script type="text/javascript" src="/yui/animation-min.js"></script> - <script type="text/javascript" src="/yui/dragdrop-min.js"></script> - <script type="text/javascript" src="/yui/logger-min.js"></script> - <script type="text/javascript" src="/js2.js"></script> - <script type="text/javascript" src="/jslib/utils.js"></script> + <link type="text/css" rel="stylesheet" href="/yui/logger.css"> + <script type="text/javascript" src="/yui/yahoo-min.js"></script> + <script type="text/javascript" src="/yui/dom-min.js"></script> + <script type="text/javascript" src="/yui/event-min.js"></script> + <script type="text/javascript" src="/yui/animation-min.js"></script> + <script type="text/javascript" src="/yui/dragdrop-min.js"></script> + <script type="text/javascript" src="/yui/logger-min.js"></script> + <script type="text/javascript" src="/js2.js"></script> + <script type="text/javascript" src="/jslib/utils.js"></script> <title>${title}Neighbourhood Fix-It</title> <style type="text/css">\@import url("/css.css");</style> </head> diff --git a/web/css.css b/web/css.css index caaf3f786..d020150ee 100644 --- a/web/css.css +++ b/web/css.css @@ -4,7 +4,7 @@ body { font-family: "Gill Sans", "Gill Sans MT", Helvetica, Arial, sans-serif; margin: 0; padding: 0; - dcolor: #a9aeb0; + /* color: #a9aeb0; */ } h1 { diff --git a/web/index.cgi b/web/index.cgi index 72cb42a4c..9c2cb3729 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.39 2006-10-07 17:55:10 matthew Exp $ +# $Id: index.cgi,v 1.40 2006-10-07 21:06:32 matthew Exp $ # TODO # Nothing is done about the update checkboxes - not stored anywhere on anything! @@ -261,16 +261,16 @@ EOF $northing = $input_h{northing}; } # XXX: How to do this for not London? - # Needs to return all council types, so passing in an array of types would be good - # And then display choice to user + # Needs to return all council types, so passing in an array of types would be good + # And then display choice to user my $council = mySociety::MaPit::get_voting_area_by_location_en($easting, $northing, 'polygon', 'LBO'); my $areas_info = mySociety::MaPit::get_voting_areas_info($council); - $council = join(', ', map { $areas_info->{$_}->{name} } @$council); + $council = join(', ', map { $areas_info->{$_}->{name} } @$council); my $pins = display_pin($q, $px, $py, 'yellow'); $out .= display_map($q, $input{x}, $input{y}, 1, 0, $pins); $out .= '<h1>Reporting a problem</h1>'; $out .= '<p>You have located the problem at the location marked with a yellow pin on the map, which is within ' - . $council . '. If this is not the correct location, simply click on the map again.</p> + . $council . '. If this is not the correct location, simply click on the map again.</p> <p>Please fill in details of the problem below. Your council won\'t be able to help unless you leave as much detail as you can, so please describe the exact location of the problem (ie. on a wall or the floor), and so on.</p>'; @@ -557,7 +557,7 @@ EOF $out .= <<EOF; <div id="map"><div id="drag"> $img_type id="t2.2" name="tile_$tl" src="$tl_src" style="top:0px; left:0px;">$img_type id="t2.3" name="tile_$tr" src="$tr_src" style="top:0px; left:$imgw;"><br>$img_type id="t3.2" name="tile_$bl" src="$bl_src" style="top:$imgh; left:0px;">$img_type id="t3.3" name="tile_$br" src="$br_src" style="top:$imgh; left:$imgw;"> - $pins + $pins </div></div> EOF $out .= Page::compass($q, $x, $y) if $compass; @@ -591,7 +591,7 @@ sub postcode_check { my @councils; my $types = $mySociety::VotingArea::council_parent_types; foreach my $type (@$types) { - push(@councils, $type) if ($areas->{$type} && !vec($invalid_councils, $areas->{$type}, 1)); + push(@councils, $type) if ($areas->{$type} && !vec($invalid_councils, $areas->{$type}, 1)); } throw Error::Simple("I'm afraid that postcode isn't yet covered by us.\n") unless $areas && @councils; diff --git a/web/js2.js b/web/js2.js index c38646984..06692b0d3 100644 --- a/web/js2.js +++ b/web/js2.js @@ -38,12 +38,12 @@ function onLoad() { if (form) { form.onsubmit = form_submit; - var drag = document.getElementById('drag'); - var inputs = drag.getElementsByTagName('input'); - for (var i=0; i<inputs.length; i++) { - inputs[i].onclick = drag_check; - } - + var drag = document.getElementById('drag'); + var inputs = drag.getElementsByTagName('input'); + for (var i=0; i<inputs.length; i++) { + inputs[i].onclick = drag_check; + } + var url = '/tilma/tileserver/10k-full-london/' + x + '-' + (x+5) + ',' + y + '-' + (y+5) + '/JSON'; var req = mySociety.asyncRequest(url, urls_loaded); @@ -69,15 +69,14 @@ function form_submit() { return true; } -function image_rotate(img, x, y) { - if (x) { +function image_rotate(i, j, x, y) { + var id = 't' + i + '.' + j; + var img = document.getElementById(id); + img.src = '/i/grey.gif'; + if (x) img.style.left = (img.offsetLeft + x*tilewidth) + 'px'; - //img.xx += x; - } - if (y) { + if (y) img.style.top = (img.offsetTop + y*tileheight) + 'px'; - //img.yy += y; - } } var myAnim; @@ -85,13 +84,17 @@ function pan(x, y) { if (!myAnim || !myAnim.isAnimated()) { update_tiles(x, y, true); myAnim = new YAHOO.util.Motion('drag', { points:{by:[x,y]} }, 1, YAHOO.util.Easing.easeBoth); - myAnim.animate(); + myAnim.animate(); } } var drag_x = 0; var drag_y = 0; function update_tiles(dx, dy, noMove) { + if (!dx && !dy) return; + + var old_drag_x = drag_x; + var old_drag_y = drag_y; drag_x += dx; drag_y += dy; @@ -101,35 +104,23 @@ function update_tiles(dx, dy, noMove) { drag.style.top = drag_y + 'px'; } - var horizontal = 0; - var vertical = 0; - for (var i=0; i<6; i++) { - for (var j=0; j<6; j++) { - var id = 't'+i+'.'+j; - var img = document.getElementById(id); - if (drag_x + img.offsetLeft > 762) { - img.src = '/i/grey.gif'; - image_rotate(img, -6, 0); - horizontal--; - } else if (drag_x + img.offsetLeft < -508) { - img.src = '/i/grey.gif'; - image_rotate(img, 6, 0); - horizontal++; - } - if (drag_y + img.offsetTop > 762) { - img.src = '/i/grey.gif'; - image_rotate(img, 0, -6); - vertical--; - } else if (drag_y + img.offsetTop < -508) { - img.src = '/i/grey.gif'; - image_rotate(img, 0, 6); - vertical++; - } - } - } - var horizontal = floor(horizontal/6); - var vertical = floor(vertical/6); + var horizontal = Math.floor(old_drag_x/tilewidth) - Math.floor(drag_x/tilewidth); + var vertical = Math.floor(old_drag_y/tileheight) - Math.floor(drag_y/tileheight); if (!horizontal && !vertical) return; + + for (var j=0; j<horizontal; j++) { + for (var i=0; i<6; i++) { image_rotate(i, mod(j + tile_x, 6), 6, 0); } + } + for (var j=horizontal; j<0; j++) { + for (var i=0; i<6; i++) { image_rotate(i, mod(j + tile_x, 6), -6, 0); } + } + for (var i=0; i<vertical; i++) { + for (var j=0; j<6; j++) { image_rotate(mod(i + tile_y, 6), j, 0, 6); } + } + for (var i=vertical; i<0; i++) { + for (var j=0; j<6; j++) { image_rotate(mod(i + tile_y, 6), j, 0, -6); } + } + x += horizontal; tile_x = mod((tile_x + horizontal), 6); y -= vertical; @@ -148,33 +139,29 @@ function urls_loaded(o) { var ii = (i + tile_y) % 6; for (var j=0; j<6; j++) { var jj = (j + tile_x) % 6; - var id = 't'+ii+'.'+jj; - var xx = x+j; - var yy = y+5-i; - var img = document.getElementById(id); - if (img) { - if (!img.galleryimg) { img.galleryimg = false; } + var id = 't'+ii+'.'+jj; + var xx = x+j; + var yy = y+5-i; + var img = document.getElementById(id); + if (img) { + if (!img.galleryimg) { img.galleryimg = false; } img.src = 'http://tilma.mysociety.org/tileserver/10k-full-london/' + tiles[i][j]; - img.name = 'tile_' + xx + '.' + yy; - //if (!img.xx) img.xx = xx; - //if (!img.yy) img.yy = yy; - continue; - } - img = document.createElement('input'); - img.type = 'image'; + img.name = 'tile_' + xx + '.' + yy; + continue; + } + img = document.createElement('input'); + img.type = 'image'; img.src = 'http://tilma.mysociety.org/tileserver/10k-full-london/' + tiles[i][j]; - img.name = 'tile_' + xx + '.' + yy; - img.id = id; - img.onclick = drag_check; - img.style.position = 'absolute'; - img.style.width = tilewidth + 'px'; - img.style.height = tileheight + 'px'; - img.style.top = ((ii-2)*tileheight) + 'px'; - img.style.left = ((jj-2)*tilewidth) + 'px'; - img.galleryimg = false; - //img.xx = xx; - //img.yy = yy; - img.alt = 'Loading...'; + img.name = 'tile_' + xx + '.' + yy; + img.id = id; + img.onclick = drag_check; + img.style.position = 'absolute'; + img.style.width = tilewidth + 'px'; + img.style.height = tileheight + 'px'; + img.style.top = ((ii-2)*tileheight) + 'px'; + img.style.left = ((jj-2)*tilewidth) + 'px'; + img.galleryimg = false; + img.alt = 'Loading...'; drag.appendChild(img); } } @@ -196,39 +183,37 @@ function mod(m, n) { var last_mouse_pos = {}; var mouse_pos = {}; + function drag_move(e) { if (!e) var e = window.event; - //if (e.stopPropagation) e.stopPropagation(); var point = get_posn(e); + if (point == mouse_pos) return false; in_drag = true; last_mouse_pos = mouse_pos; mouse_pos = point; - YAHOO.log('Updating with '+(mouse_pos.x-last_mouse_pos.x)+','+(mouse_pos.y-last_mouse_pos.y)); - update_tiles(mouse_pos.x-last_mouse_pos.x, mouse_pos.y-last_mouse_pos.y); + var dx = mouse_pos.x-last_mouse_pos.x; + var dy = mouse_pos.y-last_mouse_pos.y; + update_tiles(dx, dy); return false; } function drag_check() { if (in_drag) { in_drag=false; - return false; + return false; } return true; } function drag_start(e) { - YAHOO.log('drag start'); if (!e) var e = window.event; - //if (e.stopPropagation) e.stopPropagation(); - var point = get_posn(e); - mouse_pos = point; + mouse_pos = get_posn(e); setCursor('move'); document.onmousemove = drag_move; document.onmouseup = drag_end; return false; } - function drag_end(e) { if (!e) var e = window.event; if (e.stopPropagation) e.stopPropagation(); @@ -240,7 +225,6 @@ function drag_end(e) { function drag_end_out(e) { if (!e) var e = window.event; - //if (e.stopPropagation) e.stopPropagation(); var relTarg; if (e.relatedTarget) { relTarg = e.relatedTarget; } else if (e.toElement) { relTarg = e.toElement; } @@ -253,26 +237,26 @@ function drag_end_out(e) { return false; } -function get_posn(e) { +/* Called every mousemove, so on first call, overwrite itself with quicker version */ +function get_posn(ev) { var posx, posy; - if (e.pageX || e.pageY) { - posx = e.pageX; - posy = e.pageY; - } else if (e.clientX || e.clientY) { - posx = e.clientX; - if (document.documentElement && document.documentElement.scrollLeft) { - posx += document.documentElement.scrollLeft; - } else { - posx += document.body.scrollLeft; - } - posy = e.clientY; - if (document.documentElement && document.documentElement.scrollTop) { - posy += document.documentElement.scrollTop; - } else { - posy += document.body.scrollTop; - } + if (ev.pageX || ev.pageY) { + get_posn = function(e) { + return { x: e.pageX, y: e.pageY }; + }; + } else if (ev.clientX || ev.clientY) { + get_posn = function(e) { + return { + x: e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft, + y: e.clientY + document.body.scrollTop + document.documentElement.scrollTop + }; + }; + } else { + get_posn = function(e) { + return { x: undef, y: undef }; + }; } - return { x:posx, y:posy }; + return get_posn(ev); } function setCursor(s) { |