aboutsummaryrefslogtreecommitdiffstats
path: root/web/cobrands/fixmystreet.com/js.js
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-03-31 13:53:00 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-03-31 13:53:00 +0100
commit6702f44f92e9c74fe6d2dd1c69c5418a15af178c (patch)
treeeb6c54b26fee9e15ed31e476f4ceadce256c908e /web/cobrands/fixmystreet.com/js.js
parentca306d7bbb0bf0baa8d800ea1482b1faa3431022 (diff)
[fixmystreet.com] Move country lookup client side.
There's no need for the IP->country lookup, only used in JavaScript to display a banner, to require a call to the FixMyStreet server.
Diffstat (limited to 'web/cobrands/fixmystreet.com/js.js')
-rw-r--r--web/cobrands/fixmystreet.com/js.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/web/cobrands/fixmystreet.com/js.js b/web/cobrands/fixmystreet.com/js.js
index 3abba8e33..9dbd11f2c 100644
--- a/web/cobrands/fixmystreet.com/js.js
+++ b/web/cobrands/fixmystreet.com/js.js
@@ -1,3 +1,29 @@
jQuery.validator.addMethod('validName', function(value, element) {
var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i;
return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); }, translation_strings.category );
+
+$(function(){
+
+ /* Front page banner for other countries */
+
+ $('.top_banner__close').live('click', function() {
+ $('.top_banner--country').hide();
+ $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'});
+ });
+
+ if ( $('body.frontpage').length ) {
+ if (!$.cookie('has_seen_country_message')) {
+ $.ajax({
+ url: 'https://gaze.mysociety.org/gaze-rest?f=get_country_from_ip',
+ success: function(data) {
+ if ( data && data != 'GB\n' ) {
+ var banner = '<div class="top_banner top_banner--country"><a href="#" class="top_banner__close">Close</a> <p>This site is for reporting <strong>problems in the UK</strong>. There are FixMyStreet sites <a href="http://www.fixmystreet.org/sites/">all over the world</a>, or you could set up your own using the <a href="http://www.fixmystreet.org/">FixMyStreet Platform</a>.</p></div>';
+ $('body').prepend(banner);
+ $('.top_banner--country').slideDown('slow');
+ }
+ }
+ });
+ }
+ }
+
+});