From e0887aca95abf7cda633573d66abea6cbc7ca73d Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Mon, 19 May 2014 10:08:55 +0200 Subject: Disable comparison function if cookies are disabled in the browser. --- web/public/js/taginfo.js | 10 ++++++++++ web/views/key.erb | 12 ++++++++---- web/views/tag.erb | 12 ++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) (limited to 'web') diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js index c800f2f..0604e03 100644 --- a/web/public/js/taginfo.js +++ b/web/public/js/taginfo.js @@ -582,6 +582,16 @@ function open_help() { /* ============================ */ +function cookies_enabled() { + var cookieEnabled = (navigator.cookieEnabled) ? true : false; + + if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) { + document.cookie="testcookie"; + cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false; + } + return (cookieEnabled); +} + function get_comparison_list() { return jQuery.cookie('taginfo_comparison_list') || []; } diff --git a/web/views/key.erb b/web/views/key.erb index de1dc83..316529c 100644 --- a/web/views/key.erb +++ b/web/views/key.erb @@ -122,10 +122,14 @@ function page_init2() { key = #{ @key.to_json }; jQuery('h1').html(fmt_key(key)); - comparison_list_update(key); - jQuery('#list').bind('change', function() { - comparison_list_change(key); - }); + if (cookies_enabled()) { + comparison_list_update(key); + jQuery('#list').bind('change', function() { + comparison_list_change(key); + }); + } else { + jQuery('#list-form').html('Enable cookies for comparison function!'); + } jQuery('#level0_button').bind('click', function() { return level0_editor('#{ TaginfoConfig.get('level0.overpass_url_prefix') }', '#{ TaginfoConfig.get('level0.level0_url_prefix') }', filter, key, undefined); diff --git a/web/views/tag.erb b/web/views/tag.erb index f80d5ce..391d193 100644 --- a/web/views/tag.erb +++ b/web/views/tag.erb @@ -121,10 +121,14 @@ function page_init2() { up = function() { window.location = url_for_key(key); }; jQuery('h1').html(link_to_key(key) + '=' + fmt_value(value)); - comparison_list_update(key, value); - jQuery('#list').bind('change', function() { - comparison_list_change(key, value); - }); + if (cookies_enabled()) { + comparison_list_update(key, value); + jQuery('#list').bind('change', function() { + comparison_list_change(key, value); + }); + } else { + jQuery('#list-form').html('Enable cookies for comparison function!'); + } jQuery('span#keylink').html(link_to_key(key)); jQuery('span#relationlink').html(link_to_rtype(value)); -- cgit v1.2.3