Advertisement
harryfear

Cookie Consent for Europe (with GeoIP AJAX)

Jul 16th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <style type="text/css">
  2. #catapult-cookie-bar {display:none}
  3. </style>
  4.  
  5. <script>
  6. jQuery(document).ready(function($) {
  7.  
  8. //https://github.com/yellowtree/geoip-detect/wiki/API%3A-AJAX
  9.  
  10. geoip_detect.get_info().then(function(record) {
  11. if (record.error()) {
  12. console.error('WARNING Geodata Error:' + record.error() );
  13. var my_css_class_2 = { display : 'block' };
  14. $("#catapult-cookie-bar").css(my_css_class_2); //show in case
  15.  
  16. }
  17.  
  18. // Debug: Show raw data of record. (Warning: No property in this object is guaranteed to exist.)
  19. //console.log(record.get('continent', 'Null'));
  20.  
  21. if ( record.get('continent', 'Europe') == "Europe" ) {
  22.  
  23. //console.log('Europe!');
  24.  
  25. var my_css_class_2 = { display : 'block' };
  26. $("#catapult-cookie-bar").css(my_css_class_2);
  27. //https://stackoverflow.com/questions/1212500/create-a-css-rule-class-with-jquery-at-runtime
  28.  
  29. } else {
  30.  
  31. //console.log('Not Europe!');
  32.  
  33. //var my_css_class = { display : 'none' };
  34. //$("#catapult-cookie-bar").css(my_css_class);
  35.  
  36. };
  37.  
  38. });
  39.  
  40. });
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement