diff options
-rwxr-xr-x | web/ajax.cgi | 10 | ||||
-rwxr-xr-x | web/index.cgi | 44 | ||||
-rw-r--r-- | web/js.js | 32 | ||||
-rwxr-xr-x | web/posters/index.cgi | 12 |
4 files changed, 69 insertions, 29 deletions
diff --git a/web/ajax.cgi b/web/ajax.cgi index b7adb177a..ca558c17a 100755 --- a/web/ajax.cgi +++ b/web/ajax.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: ajax.cgi,v 1.5 2008-10-17 18:55:16 matthew Exp $ +# $Id: ajax.cgi,v 1.6 2008-10-17 20:19:05 matthew Exp $ use strict; use Standard; @@ -15,7 +15,7 @@ use mySociety::Web qw(ent); sub main { my $q = shift; - my @vars = qw(x y sx sy); + my @vars = qw(x y sx sy all_pins); my %input = map { $_ => $q->param($_) || '' } @vars; my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars; @@ -31,7 +31,11 @@ sub main { $sx ||= 0; $sx += 0; $sy ||= 0; $sy += 0; - my ($pins, $on_map, $around_map, $dist) = Page::map_pins($q, $x, $y, $sx, $sy, '6 months'); + my $interval; + unless ($input{all_pins}) { + $interval = '6 months'; + } + my ($pins, $on_map, $around_map, $dist) = Page::map_pins($q, $x, $y, $sx, $sy, $interval); my $list = ''; foreach (@$on_map) { diff --git a/web/index.cgi b/web/index.cgi index 5f36e38aa..00d07cefc 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.220 2008-10-17 18:55:16 matthew Exp $ +# $Id: index.cgi,v 1.221 2008-10-17 20:19:05 matthew Exp $ use strict; use Standard; @@ -564,7 +564,7 @@ left on the site, but <strong>not</strong> reported to the council. You can help us by finding a contact email address for local problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>."; } else { - $out .= "<p>We do not yet have details for the council that covers + $out .= "<p>We do not yet have details for the council that covers this location. If you submit a report here it will be left on the site, but not reported to the council – please still leave your report, so that we can show to the council the activity in their area."; @@ -698,7 +698,7 @@ EOF sub display_location { my ($q, @errors) = @_; - my @vars = qw(pc x y); + my @vars = qw(pc x y all_pins no_pins); my %input = map { $_ => $q->param($_) || '' } @vars; my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars; @@ -721,8 +721,28 @@ sub display_location { return Page::geocode_choice($error, '/') if (ref($error) eq 'ARRAY'); return front_page($q, $error) if ($error); - my ($pins, $on_map, $around_map, $dist) = Page::map_pins($q, $x, $y, $x, $y, '6 months'); - my $out = Page::display_map($q, x => $x, y => $y, type => 1, pins => $pins ); + # Deal with pin hiding/age + my ($hide_link, $hide_text, $all_link, $all_text, $interval); + if ($input{all_pins}) { + $all_link = NewURL($q, -retain=>1, no_pins=>undef, all_pins=>undef); + $all_text = 'Hide stale reports'; + } else { + $all_link = NewURL($q, -retain=>1, no_pins=>undef, all_pins=>1); + $all_text = 'Include stale reports'; + $interval = '6 months'; + } + my ($pins, $on_map, $around_map, $dist) = Page::map_pins($q, $x, $y, $x, $y, $interval); + if ($input{no_pins}) { + $hide_link = NewURL($q, -retain=>1, no_pins=>undef); + $hide_text = 'Show pins'; + $pins = ''; + } else { + $hide_link = NewURL($q, -retain=>1, no_pins=>1); + $hide_text = 'Hide pins'; + } + my $map_links = "<p style='float:right; margin-top:0;'><a id='hide_pins_link' href='$hide_link'>$hide_text</a> | <a id='all_pins_link' href='$all_link'>$all_text</a></p> <input type='hidden' id='all_pins' name='all_pins' value='$input_h{all_pins}'>"; + + my $out = Page::display_map($q, x => $x, y => $y, type => 1, pins => $pins, post => $map_links ); $out .= $q->h1(_('Problems in this area')); my $email_me = _('Email me new local problems'); my $rss_title = _('RSS feed of recent local problems'); @@ -769,24 +789,10 @@ to describe the location of the problem instead.</small>"), $skipurl)); $list .= '</li>'; } if (@$around_map) { - #my $list_start = @$on_map + 1; - #$out .= '<ul id="current_near" start="' . $list_start . '">' . $list . '</ul>'; $out .= '<ul id="current_near">' . $list . '</ul>'; } else { $out .= $q->p(_('No problems found.')); } - #$out .= $q->h2(sprintf(_('Recently fixed problems within %skm'), $dist)); - #$list = ''; - #foreach (@$fixed) { - # $list .= '<li><a href="' . NewURL($q, -retain=>1, id=>$_->{id}, x=>undef, y=>undef) . '">'; - # $list .= $_->{title} . ' <small>(' . int($_->{distance}/100+.5)/10 . 'km)</small>'; - # $list .= '</a></li>'; - #} - #if (@$fixed) { - # $out .= "<ul id='fixed_near'>$list</ul>\n"; - #} else { - # $out .= $q->p(_('No problems have been fixed yet')); - #} $out .= '</div>'; $out .= Page::display_map_end(1); @@ -118,6 +118,31 @@ YAHOO.util.Event.onContentReady('email_alert_box', function() { }); }); +YAHOO.util.Event.addListener('hide_pins_link', 'click', function(e) { + YAHOO.util.Event.preventDefault(e); + if (this.innerHTML == 'Show pins') { + YAHOO.util.Dom.setStyle('pins', 'display', 'block'); + this.innerHTML = 'Hide pins'; + } else { + YAHOO.util.Dom.setStyle('pins', 'display', 'none'); + this.innerHTML = 'Show pins'; + } +}); +YAHOO.util.Event.addListener('all_pins_link', 'click', function(e) { + YAHOO.util.Event.preventDefault(e); + YAHOO.util.Dom.setStyle('pins', 'display', 'block'); + document.getElementById('hide_pins_link').innerHTML = 'Hide pins'; + if (this.innerHTML == 'Include stale reports') { + this.innerHTML = 'Hide stale reports'; + document.getElementById('all_pins').value = '1'; + load_pins(x, y); + } else { + this.innerHTML = 'Include stale reports'; + document.getElementById('all_pins').value = ''; + load_pins(x, y); + } +}); + /* File upload */ /* function doSubmit(e) { @@ -256,9 +281,14 @@ function update_tiles(dx, dy, force) { if (force) return; + load_pins(x, y); +} + +function load_pins(x, y) { if (document.getElementById('formX')) { url = [ '/ajax?sx=', document.getElementById('formX').value, ';sy=', - document.getElementById('formY').value, ';x=', (x+2), ';y=', (y+2) + document.getElementById('formY').value, ';x=', (x+2), ';y=', (y+2), + ';all_pins=', document.getElementById('all_pins').value ].join(''); YAHOO.util.Connect.asyncRequest('GET', url, { success: pins_loaded diff --git a/web/posters/index.cgi b/web/posters/index.cgi index bc14e1de9..12abcf1b9 100755 --- a/web/posters/index.cgi +++ b/web/posters/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.9 2008-10-14 10:28:38 matthew Exp $ +# $Id: index.cgi,v 1.10 2008-10-17 20:19:05 matthew Exp $ use strict; use Standard -db; @@ -32,10 +32,10 @@ sub body { return $q->h1(_('Publicity Material')) . $q->div({style=>'float:left; width:50%'}, '<p>Copy and paste the text below to add this badge to your site:</p>', $badge, - '<textarea onclick="this.select()" cols=37 rows=5>' . ent($badge) . '</textarea>', - '<p><small>(thanks to Lincolnshire Council for the image)</small></p>' - ) . - $q->div({style=>'float:right; width:47%'}, + '<textarea onclick="this.select()" cols=37 rows=5>' . ent($badge) . '</textarea>', + '<p><small>(thanks to Lincolnshire Council for the image)</small></p>' + ) . + $q->div({style=>'float:right; width:47%'}, $q->p(_('Here are some posters and flyers you can use to publicise FixMyStreet:')) . '<img hspace="5" src="poster.png" alt="Example poster">' . $q->h2(_('Posters')) . @@ -58,7 +58,7 @@ sub body { $q->li($q->a({href=>'fixmystreet-flyers-bw-outlined.pdf'}, _('4 x A6, black and white, outlined'))), $q->li($q->a({href=>'fixmystreet-flyers-bw-low-ink.pdf'}, _('4 x A6, black and white, low ink'))) ) - ) + ) ; } |