diff --git a/lib/DDG/Spice/Cryptocurrency.pm b/lib/DDG/Spice/Cryptocurrency.pm index f6f53a9019..34f24e072c 100644 --- a/lib/DDG/Spice/Cryptocurrency.pm +++ b/lib/DDG/Spice/Cryptocurrency.pm @@ -96,6 +96,14 @@ spice wrap_jsonp_callback => 1; spice is_cached => 0; spice proxy_cache_valid => "200 1m"; +spice alt_to => { + cryptonator => { + from => '([^/]+)/([^/]*)', + to => 'https://api.cryptonator.com/api/full/$1-$2', + wrap_jsonp_callback => 0, + } +}; + # This function converts things like "us dollars" to the standard "usd". sub getCode { my $input = shift; diff --git a/share/spice/cryptocurrency/cryptocurrency.js b/share/spice/cryptocurrency/cryptocurrency.js index 00e82ae7e9..d6700ad7fb 100644 --- a/share/spice/cryptocurrency/cryptocurrency.js +++ b/share/spice/cryptocurrency/cryptocurrency.js @@ -101,12 +101,14 @@ Converter.fromCurrency = from; } - var endpoint = "https://api.cryptonator.com/api/full/" + from + "-" + to; - $.get(endpoint, function(payload) { - Converter.rate = parseFloat(payload.ticker.price); + var endpoint = "/js/spice/cryptonator/" + from + "/" + to; + + $.getJSON(endpoint, function(payload) { + var response = payload; + Converter.rate = parseFloat(response.ticker.price); Converter.calculateRate(); Converter.updateMoreAtLink(to, from); - Converter.updateChangeRate(payload.ticker.change); + Converter.updateChangeRate(response.ticker.change); }); },