Skip to content

Instantly share code, notes, and snippets.

@pdincau
Last active August 29, 2015 14:22

Revisions

  1. pdincau revised this gist May 31, 2015. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -12,5 +12,4 @@
    el.attr('href', el.attr(attributes[code]));
    });
    });
    });
    </script>
    });
  2. pdincau revised this gist May 31, 2015. 1 changed file with 12 additions and 9 deletions.
    21 changes: 12 additions & 9 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,16 @@
    var attributes = {}
    attributes["IT"] = 'data-amazon-it';
    attributes["GB"] = 'data-amazon-gb';
    jQuery(document).ready(function() {
    var attributes = {}
    attributes["IT"] = 'data-amazon-it';
    attributes["GB"] = 'data-amazon-gb';

    var url = "http://freegeoip.net/json/ ";
    jQuery.getJSON(url, function(data) {
    var code = data.country_code;
    var links = jQuery('[data-amazon]');
    jQuery.each(links, function(index, link) {
    var url = "http://freegeoip.net/json/ ";
    jQuery.getJSON(url, function(data) {
    var code = data.country_code;
    var links = jQuery('[data-amazon]');
    jQuery.each(links, function(index, link) {
    var el = jQuery(link);
    el.attr('href', el.attr(attributes[code]));
    });
    });
    });
    });
    </script>
  3. pdincau revised this gist May 31, 2015. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,13 @@
    var attributes = {}
    attributes["IT"] = 'data-amazon-it';
    attributes["GB"] = 'data-amazon-gb';

    var url = "http://freegeoip.net/json/ ";
    jQuery.getJSON(url, function(data) {
    var code = data.country_code;
    var links = jQuery('[data-amazon]');
    jQuery.each(links, function(index, link) {
    var el = jQuery(link);
    if (code == "IT") {
    el.attr('href', el.attr('data-amazon-it'));
    }
    if (code == "GB") {
    el.attr('href', el.attr('data-amazon-gb'));
    }
    el.attr('href', el.attr(attributes[code]));
    });
    });
  4. pdincau created this gist May 30, 2015.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    var url = "http://freegeoip.net/json/ ";
    jQuery.getJSON(url, function(data) {
    var code = data.country_code;
    var links = jQuery('[data-amazon]');
    jQuery.each(links, function(index, link) {
    var el = jQuery(link);
    if (code == "IT") {
    el.attr('href', el.attr('data-amazon-it'));
    }
    if (code == "GB") {
    el.attr('href', el.attr('data-amazon-gb'));
    }
    });
    });